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,89 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2023 Erin Catto
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
#pragma once
|
|
5
|
+
|
|
6
|
+
#include "array.h"
|
|
7
|
+
|
|
8
|
+
#include <stdbool.h>
|
|
9
|
+
#include <stdint.h>
|
|
10
|
+
|
|
11
|
+
typedef struct b2Contact b2Contact;
|
|
12
|
+
typedef struct b2Joint b2Joint;
|
|
13
|
+
typedef struct b2World b2World;
|
|
14
|
+
|
|
15
|
+
// Deterministic solver
|
|
16
|
+
//
|
|
17
|
+
// Collide all awake contacts
|
|
18
|
+
// Use bit array to emit start/stop touching events in defined order, per thread. Try using contact index, assuming contacts are
|
|
19
|
+
// created in a deterministic order. bit-wise OR together bit arrays and issue changes:
|
|
20
|
+
// - start touching: merge islands - temporary linked list - mark root island dirty - wake all - largest island is root
|
|
21
|
+
// - stop touching: increment constraintRemoveCount
|
|
22
|
+
|
|
23
|
+
// Persistent island for awake bodies, joints, and contacts
|
|
24
|
+
// https://en.wikipedia.org/wiki/Component_(graph_theory)
|
|
25
|
+
// https://en.wikipedia.org/wiki/Dynamic_connectivity
|
|
26
|
+
// map from int to solver set and index
|
|
27
|
+
typedef struct b2Island
|
|
28
|
+
{
|
|
29
|
+
// index of solver set stored in b2World
|
|
30
|
+
// may be B2_NULL_INDEX
|
|
31
|
+
int setIndex;
|
|
32
|
+
|
|
33
|
+
// island index within set
|
|
34
|
+
// may be B2_NULL_INDEX
|
|
35
|
+
int localIndex;
|
|
36
|
+
|
|
37
|
+
int islandId;
|
|
38
|
+
|
|
39
|
+
int headBody;
|
|
40
|
+
int tailBody;
|
|
41
|
+
int bodyCount;
|
|
42
|
+
|
|
43
|
+
int headContact;
|
|
44
|
+
int tailContact;
|
|
45
|
+
int contactCount;
|
|
46
|
+
|
|
47
|
+
int headJoint;
|
|
48
|
+
int tailJoint;
|
|
49
|
+
int jointCount;
|
|
50
|
+
|
|
51
|
+
// Union find
|
|
52
|
+
// todo this could go away if islands are merged immediately with b2LinkJoint and b2LinkContact
|
|
53
|
+
int parentIsland;
|
|
54
|
+
|
|
55
|
+
// Keeps track of how many contacts have been removed from this island.
|
|
56
|
+
// This is used to determine if an island is a candidate for splitting.
|
|
57
|
+
int constraintRemoveCount;
|
|
58
|
+
} b2Island;
|
|
59
|
+
|
|
60
|
+
// This is used to move islands across solver sets
|
|
61
|
+
typedef struct b2IslandSim
|
|
62
|
+
{
|
|
63
|
+
int islandId;
|
|
64
|
+
} b2IslandSim;
|
|
65
|
+
|
|
66
|
+
b2Island* b2CreateIsland( b2World* world, int setIndex );
|
|
67
|
+
void b2DestroyIsland( b2World* world, int islandId );
|
|
68
|
+
|
|
69
|
+
// Link contacts into the island graph when it starts having contact points
|
|
70
|
+
void b2LinkContact( b2World* world, b2Contact* contact );
|
|
71
|
+
|
|
72
|
+
// Unlink contact from the island graph when it stops having contact points
|
|
73
|
+
void b2UnlinkContact( b2World* world, b2Contact* contact );
|
|
74
|
+
|
|
75
|
+
// Link a joint into the island graph when it is created
|
|
76
|
+
void b2LinkJoint( b2World* world, b2Joint* joint, bool mergeIslands );
|
|
77
|
+
|
|
78
|
+
// Unlink a joint from the island graph when it is destroyed
|
|
79
|
+
void b2UnlinkJoint( b2World* world, b2Joint* joint );
|
|
80
|
+
|
|
81
|
+
void b2MergeAwakeIslands( b2World* world );
|
|
82
|
+
|
|
83
|
+
void b2SplitIsland( b2World* world, int baseId );
|
|
84
|
+
void b2SplitIslandTask( int startIndex, int endIndex, uint32_t threadIndex, void* context );
|
|
85
|
+
|
|
86
|
+
void b2ValidateIsland( b2World* world, int islandId );
|
|
87
|
+
|
|
88
|
+
B2_ARRAY_INLINE( b2Island, b2Island )
|
|
89
|
+
B2_ARRAY_INLINE( b2IslandSim, b2IslandSim )
|