box2d 3.0.0
A 2D physics engine for games
 
Loading...
Searching...
No Matches
id.h
1// SPDX-FileCopyrightText: 2023 Erin Catto
2// SPDX-License-Identifier: MIT
3
4#pragma once
5
6#include "api.h"
7
8#include <stdbool.h>
9#include <stdint.h>
10
13
15typedef struct b2WorldId
16{
17 int16_t index;
18 uint16_t revision;
19} b2WorldId;
20
22typedef struct b2BodyId
23{
24 int32_t index;
25 int16_t world;
26 uint16_t revision;
27} b2BodyId;
28
30typedef struct b2ShapeId
31{
32 int32_t index;
33 int16_t world;
34 uint16_t revision;
35} b2ShapeId;
36
38typedef struct b2JointId
39{
40 int32_t index;
41 int16_t world;
42 uint16_t revision;
43} b2JointId;
44
46typedef struct b2ChainId
47{
48 int32_t index;
49 int16_t world;
50 uint16_t revision;
51} b2ChainId;
52
53static const b2WorldId b2_nullWorldId = {-1, 0};
54static const b2BodyId b2_nullBodyId = {-1, -1, 0};
55static const b2ShapeId b2_nullShapeId = {-1, -1, 0};
56static const b2JointId b2_nullJointId = {-1, -1, 0};
57static const b2ChainId b2_nullChainId = {-1, -1, 0};
58
60#define B2_IS_NULL(id) (id.index == -1)
61
63#define B2_NON_NULL(id) (id.index != -1)
64
65// Compare two ids for equality. Doesn't work for b2WorldId.
66#define B2_ID_EQUALS(id1, id2) (id1.index == id2.index && id1.world == id2.world && id1.revision == id2.revision)
67
69BOX2D_API bool b2World_IsValid(b2WorldId id);
70
72BOX2D_API bool b2Body_IsValid(b2BodyId id);
73
75BOX2D_API bool b2Shape_IsValid(b2ShapeId id);
76
78BOX2D_API bool b2Chain_IsValid(b2ChainId id);
79
81BOX2D_API bool b2Joint_IsValid(b2JointId id);
Body identitifier.
Definition id.h:23
References a chain instances.
Definition id.h:47
References a joint instance.
Definition id.h:39
References a shape instance.
Definition id.h:31
World identifier.
Definition id.h:16