box2d-ruby 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +336 -0
- data/examples/contact_events.rb +22 -0
- data/examples/debug_draw.rb +15 -0
- data/examples/falling_ball.rb +19 -0
- data/examples/rugl_debug_draw.rb +68 -0
- data/examples/stagecraft_debug_draw.rb +64 -0
- data/examples/support/box2d_debug_lines.rb +125 -0
- data/ext/box2d/CMakeLists.txt +35 -0
- data/ext/box2d/extconf.rb +42 -0
- data/ext/box2d/native.c +9 -0
- data/ext/box2d/vendor/box2d/LICENSE +21 -0
- data/ext/box2d/vendor/box2d/VERSION +1 -0
- data/ext/box2d/vendor/box2d/include/box2d/base.h +131 -0
- data/ext/box2d/vendor/box2d/include/box2d/box2d.h +1222 -0
- data/ext/box2d/vendor/box2d/include/box2d/collision.h +830 -0
- data/ext/box2d/vendor/box2d/include/box2d/id.h +144 -0
- data/ext/box2d/vendor/box2d/include/box2d/math_functions.h +761 -0
- data/ext/box2d/vendor/box2d/include/box2d/types.h +1457 -0
- data/ext/box2d/vendor/box2d/src/CMakeLists.txt +223 -0
- data/ext/box2d/vendor/box2d/src/aabb.c +132 -0
- data/ext/box2d/vendor/box2d/src/aabb.h +56 -0
- data/ext/box2d/vendor/box2d/src/arena_allocator.c +112 -0
- data/ext/box2d/vendor/box2d/src/arena_allocator.h +48 -0
- data/ext/box2d/vendor/box2d/src/array.c +8 -0
- data/ext/box2d/vendor/box2d/src/array.h +179 -0
- data/ext/box2d/vendor/box2d/src/atomic.h +79 -0
- data/ext/box2d/vendor/box2d/src/bitset.c +67 -0
- data/ext/box2d/vendor/box2d/src/bitset.h +65 -0
- data/ext/box2d/vendor/box2d/src/body.c +1884 -0
- data/ext/box2d/vendor/box2d/src/body.h +194 -0
- data/ext/box2d/vendor/box2d/src/box2d.natvis +41 -0
- data/ext/box2d/vendor/box2d/src/broad_phase.c +524 -0
- data/ext/box2d/vendor/box2d/src/broad_phase.h +83 -0
- data/ext/box2d/vendor/box2d/src/constants.h +54 -0
- data/ext/box2d/vendor/box2d/src/constraint_graph.c +322 -0
- data/ext/box2d/vendor/box2d/src/constraint_graph.h +58 -0
- data/ext/box2d/vendor/box2d/src/contact.c +650 -0
- data/ext/box2d/vendor/box2d/src/contact.h +148 -0
- data/ext/box2d/vendor/box2d/src/contact_solver.c +2120 -0
- data/ext/box2d/vendor/box2d/src/contact_solver.h +54 -0
- data/ext/box2d/vendor/box2d/src/core.c +178 -0
- data/ext/box2d/vendor/box2d/src/core.h +149 -0
- data/ext/box2d/vendor/box2d/src/ctz.h +112 -0
- data/ext/box2d/vendor/box2d/src/distance.c +1415 -0
- data/ext/box2d/vendor/box2d/src/distance_joint.c +556 -0
- data/ext/box2d/vendor/box2d/src/dynamic_tree.c +1989 -0
- data/ext/box2d/vendor/box2d/src/geometry.c +1028 -0
- data/ext/box2d/vendor/box2d/src/hull.c +328 -0
- data/ext/box2d/vendor/box2d/src/id_pool.c +79 -0
- data/ext/box2d/vendor/box2d/src/id_pool.h +35 -0
- data/ext/box2d/vendor/box2d/src/island.c +977 -0
- data/ext/box2d/vendor/box2d/src/island.h +89 -0
- data/ext/box2d/vendor/box2d/src/joint.c +1272 -0
- data/ext/box2d/vendor/box2d/src/joint.h +335 -0
- data/ext/box2d/vendor/box2d/src/manifold.c +1726 -0
- data/ext/box2d/vendor/box2d/src/math_functions.c +159 -0
- data/ext/box2d/vendor/box2d/src/motor_joint.c +283 -0
- data/ext/box2d/vendor/box2d/src/mouse_joint.c +214 -0
- data/ext/box2d/vendor/box2d/src/mover.c +73 -0
- data/ext/box2d/vendor/box2d/src/prismatic_joint.c +656 -0
- data/ext/box2d/vendor/box2d/src/revolute_joint.c +534 -0
- data/ext/box2d/vendor/box2d/src/sensor.c +389 -0
- data/ext/box2d/vendor/box2d/src/sensor.h +36 -0
- data/ext/box2d/vendor/box2d/src/shape.c +1714 -0
- data/ext/box2d/vendor/box2d/src/shape.h +123 -0
- data/ext/box2d/vendor/box2d/src/solver.c +2038 -0
- data/ext/box2d/vendor/box2d/src/solver.h +155 -0
- data/ext/box2d/vendor/box2d/src/solver_set.c +613 -0
- data/ext/box2d/vendor/box2d/src/solver_set.h +57 -0
- data/ext/box2d/vendor/box2d/src/table.c +238 -0
- data/ext/box2d/vendor/box2d/src/table.h +37 -0
- data/ext/box2d/vendor/box2d/src/timer.c +185 -0
- data/ext/box2d/vendor/box2d/src/types.c +151 -0
- data/ext/box2d/vendor/box2d/src/weld_joint.c +310 -0
- data/ext/box2d/vendor/box2d/src/wheel_joint.c +551 -0
- data/ext/box2d/vendor/box2d/src/world.c +3301 -0
- data/ext/box2d/vendor/box2d/src/world.h +192 -0
- data/generator/generate.rb +316 -0
- data/generator/layout_probe.c +507 -0
- data/generator/verify_layouts.rb +32 -0
- data/lib/box2d/body.rb +172 -0
- data/lib/box2d/body_definition.rb +38 -0
- data/lib/box2d/body_shapes.rb +135 -0
- data/lib/box2d/chain.rb +61 -0
- data/lib/box2d/debug_draw.rb +118 -0
- data/lib/box2d/events.rb +103 -0
- data/lib/box2d/fixed_stepper.rb +39 -0
- data/lib/box2d/handle.rb +46 -0
- data/lib/box2d/hit.rb +5 -0
- data/lib/box2d/joint.rb +197 -0
- data/lib/box2d/native.rb +1462 -0
- data/lib/box2d/native_loader.rb +45 -0
- data/lib/box2d/pixel_scale.rb +29 -0
- data/lib/box2d/shape.rb +109 -0
- data/lib/box2d/shape_definition.rb +44 -0
- data/lib/box2d/value_conversion.rb +80 -0
- data/lib/box2d/version.rb +7 -0
- data/lib/box2d/world.rb +135 -0
- data/lib/box2d/world_joints.rb +156 -0
- data/lib/box2d/world_queries.rb +122 -0
- data/lib/box2d/world_registry.rb +95 -0
- data/lib/box2d.rb +31 -0
- data/script/build_platform_gem.rb +24 -0
- data/script/deterministic_scene.rb +56 -0
- data/script/update_deterministic_snapshot.rb +11 -0
- data/script/verify_platform_gem.rb +24 -0
- metadata +164 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2023 Erin Catto
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
#pragma once
|
|
5
|
+
|
|
6
|
+
#include "base.h"
|
|
7
|
+
|
|
8
|
+
#include <stdint.h>
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @defgroup id Ids
|
|
12
|
+
* These ids serve as handles to internal Box2D objects.
|
|
13
|
+
* These should be considered opaque data and passed by value.
|
|
14
|
+
* Include this header if you need the id types and not the whole Box2D API.
|
|
15
|
+
* All ids are considered null if initialized to zero.
|
|
16
|
+
*
|
|
17
|
+
* For example in C++:
|
|
18
|
+
*
|
|
19
|
+
* @code{.cxx}
|
|
20
|
+
* b2WorldId worldId = {};
|
|
21
|
+
* @endcode
|
|
22
|
+
*
|
|
23
|
+
* Or in C:
|
|
24
|
+
*
|
|
25
|
+
* @code{.c}
|
|
26
|
+
* b2WorldId worldId = {0};
|
|
27
|
+
* @endcode
|
|
28
|
+
*
|
|
29
|
+
* These are both considered null.
|
|
30
|
+
*
|
|
31
|
+
* @warning Do not use the internals of these ids. They are subject to change. Ids should be treated as opaque objects.
|
|
32
|
+
* @warning You should use ids to access objects in Box2D. Do not access files within the src folder. Such usage is unsupported.
|
|
33
|
+
* @{
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/// World id references a world instance. This should be treated as an opaque handle.
|
|
37
|
+
typedef struct b2WorldId
|
|
38
|
+
{
|
|
39
|
+
uint16_t index1;
|
|
40
|
+
uint16_t generation;
|
|
41
|
+
} b2WorldId;
|
|
42
|
+
|
|
43
|
+
/// Body id references a body instance. This should be treated as an opaque handle.
|
|
44
|
+
typedef struct b2BodyId
|
|
45
|
+
{
|
|
46
|
+
int32_t index1;
|
|
47
|
+
uint16_t world0;
|
|
48
|
+
uint16_t generation;
|
|
49
|
+
} b2BodyId;
|
|
50
|
+
|
|
51
|
+
/// Shape id references a shape instance. This should be treated as an opaque handle.
|
|
52
|
+
typedef struct b2ShapeId
|
|
53
|
+
{
|
|
54
|
+
int32_t index1;
|
|
55
|
+
uint16_t world0;
|
|
56
|
+
uint16_t generation;
|
|
57
|
+
} b2ShapeId;
|
|
58
|
+
|
|
59
|
+
/// Chain id references a chain instances. This should be treated as an opaque handle.
|
|
60
|
+
typedef struct b2ChainId
|
|
61
|
+
{
|
|
62
|
+
int32_t index1;
|
|
63
|
+
uint16_t world0;
|
|
64
|
+
uint16_t generation;
|
|
65
|
+
} b2ChainId;
|
|
66
|
+
|
|
67
|
+
/// Joint id references a joint instance. This should be treated as an opaque handle.
|
|
68
|
+
typedef struct b2JointId
|
|
69
|
+
{
|
|
70
|
+
int32_t index1;
|
|
71
|
+
uint16_t world0;
|
|
72
|
+
uint16_t generation;
|
|
73
|
+
} b2JointId;
|
|
74
|
+
|
|
75
|
+
/// Use these to make your identifiers null.
|
|
76
|
+
/// You may also use zero initialization to get null.
|
|
77
|
+
static const b2WorldId b2_nullWorldId = B2_ZERO_INIT;
|
|
78
|
+
static const b2BodyId b2_nullBodyId = B2_ZERO_INIT;
|
|
79
|
+
static const b2ShapeId b2_nullShapeId = B2_ZERO_INIT;
|
|
80
|
+
static const b2ChainId b2_nullChainId = B2_ZERO_INIT;
|
|
81
|
+
static const b2JointId b2_nullJointId = B2_ZERO_INIT;
|
|
82
|
+
|
|
83
|
+
/// Macro to determine if any id is null.
|
|
84
|
+
#define B2_IS_NULL( id ) ( id.index1 == 0 )
|
|
85
|
+
|
|
86
|
+
/// Macro to determine if any id is non-null.
|
|
87
|
+
#define B2_IS_NON_NULL( id ) ( id.index1 != 0 )
|
|
88
|
+
|
|
89
|
+
/// Compare two ids for equality. Doesn't work for b2WorldId.
|
|
90
|
+
#define B2_ID_EQUALS( id1, id2 ) ( id1.index1 == id2.index1 && id1.world0 == id2.world0 && id1.generation == id2.generation )
|
|
91
|
+
|
|
92
|
+
/// Store a body id into a uint64_t.
|
|
93
|
+
B2_INLINE uint64_t b2StoreBodyId( b2BodyId id )
|
|
94
|
+
{
|
|
95
|
+
return ( (uint64_t)id.index1 << 32 ) | ( (uint64_t)id.world0 ) << 16 | (uint64_t)id.generation;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/// Load a uint64_t into a body id.
|
|
99
|
+
B2_INLINE b2BodyId b2LoadBodyId( uint64_t x )
|
|
100
|
+
{
|
|
101
|
+
b2BodyId id = { (int32_t)( x >> 32 ), (uint16_t)( x >> 16 ), (uint16_t)( x ) };
|
|
102
|
+
return id;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/// Store a shape id into a uint64_t.
|
|
106
|
+
B2_INLINE uint64_t b2StoreShapeId( b2ShapeId id )
|
|
107
|
+
{
|
|
108
|
+
return ( (uint64_t)id.index1 << 32 ) | ( (uint64_t)id.world0 ) << 16 | (uint64_t)id.generation;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/// Load a uint64_t into a shape id.
|
|
112
|
+
B2_INLINE b2ShapeId b2LoadShapeId( uint64_t x )
|
|
113
|
+
{
|
|
114
|
+
b2ShapeId id = { (int32_t)( x >> 32 ), (uint16_t)( x >> 16 ), (uint16_t)( x ) };
|
|
115
|
+
return id;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/// Store a chain id into a uint64_t.
|
|
119
|
+
B2_INLINE uint64_t b2StoreChainId( b2ChainId id )
|
|
120
|
+
{
|
|
121
|
+
return ( (uint64_t)id.index1 << 32 ) | ( (uint64_t)id.world0 ) << 16 | (uint64_t)id.generation;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/// Load a uint64_t into a chain id.
|
|
125
|
+
B2_INLINE b2ChainId b2LoadChainId( uint64_t x )
|
|
126
|
+
{
|
|
127
|
+
b2ChainId id = { (int32_t)( x >> 32 ), (uint16_t)( x >> 16 ), (uint16_t)( x ) };
|
|
128
|
+
return id;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/// Store a joint id into a uint64_t.
|
|
132
|
+
B2_INLINE uint64_t b2StoreJointId( b2JointId id )
|
|
133
|
+
{
|
|
134
|
+
return ( (uint64_t)id.index1 << 32 ) | ( (uint64_t)id.world0 ) << 16 | (uint64_t)id.generation;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/// Load a uint64_t into a joint id.
|
|
138
|
+
B2_INLINE b2JointId b2LoadJointId( uint64_t x )
|
|
139
|
+
{
|
|
140
|
+
b2JointId id = { (int32_t)( x >> 32 ), (uint16_t)( x >> 16 ), (uint16_t)( x ) };
|
|
141
|
+
return id;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**@}*/
|