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,1222 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2023 Erin Catto
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
#pragma once
|
|
5
|
+
|
|
6
|
+
#include "base.h"
|
|
7
|
+
#include "collision.h"
|
|
8
|
+
#include "id.h"
|
|
9
|
+
#include "types.h"
|
|
10
|
+
|
|
11
|
+
#include <stdbool.h>
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @defgroup world World
|
|
15
|
+
* These functions allow you to create a simulation world.
|
|
16
|
+
*
|
|
17
|
+
* You can add rigid bodies and joint constraints to the world and run the simulation. You can get contact
|
|
18
|
+
* information to get contact points and normals as well as events. You can query to world, checking for overlaps and casting rays
|
|
19
|
+
* or shapes. There is also debugging information such as debug draw, timing information, and counters. You can find documentation
|
|
20
|
+
* here: https://box2d.org/
|
|
21
|
+
* @{
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/// Create a world for rigid body simulation. A world contains bodies, shapes, and constraints. You make create
|
|
25
|
+
/// up to 128 worlds. Each world is completely independent and may be simulated in parallel.
|
|
26
|
+
/// @return the world id.
|
|
27
|
+
B2_API b2WorldId b2CreateWorld( const b2WorldDef* def );
|
|
28
|
+
|
|
29
|
+
/// Destroy a world
|
|
30
|
+
B2_API void b2DestroyWorld( b2WorldId worldId );
|
|
31
|
+
|
|
32
|
+
/// World id validation. Provides validation for up to 64K allocations.
|
|
33
|
+
B2_API bool b2World_IsValid( b2WorldId id );
|
|
34
|
+
|
|
35
|
+
/// Simulate a world for one time step. This performs collision detection, integration, and constraint solution.
|
|
36
|
+
/// @param worldId The world to simulate
|
|
37
|
+
/// @param timeStep The amount of time to simulate, this should be a fixed number. Usually 1/60.
|
|
38
|
+
/// @param subStepCount The number of sub-steps, increasing the sub-step count can increase accuracy. Usually 4.
|
|
39
|
+
B2_API void b2World_Step( b2WorldId worldId, float timeStep, int subStepCount );
|
|
40
|
+
|
|
41
|
+
/// Call this to draw shapes and other debug draw data
|
|
42
|
+
B2_API void b2World_Draw( b2WorldId worldId, b2DebugDraw* draw );
|
|
43
|
+
|
|
44
|
+
/// Get the body events for the current time step. The event data is transient. Do not store a reference to this data.
|
|
45
|
+
B2_API b2BodyEvents b2World_GetBodyEvents( b2WorldId worldId );
|
|
46
|
+
|
|
47
|
+
/// Get sensor events for the current time step. The event data is transient. Do not store a reference to this data.
|
|
48
|
+
B2_API b2SensorEvents b2World_GetSensorEvents( b2WorldId worldId );
|
|
49
|
+
|
|
50
|
+
/// Get contact events for this current time step. The event data is transient. Do not store a reference to this data.
|
|
51
|
+
B2_API b2ContactEvents b2World_GetContactEvents( b2WorldId worldId );
|
|
52
|
+
|
|
53
|
+
/// Overlap test for all shapes that *potentially* overlap the provided AABB
|
|
54
|
+
B2_API b2TreeStats b2World_OverlapAABB( b2WorldId worldId, b2AABB aabb, b2QueryFilter filter, b2OverlapResultFcn* fcn,
|
|
55
|
+
void* context );
|
|
56
|
+
|
|
57
|
+
/// Overlap test for all shapes that overlap the provided shape proxy.
|
|
58
|
+
B2_API b2TreeStats b2World_OverlapShape( b2WorldId worldId, const b2ShapeProxy* proxy, b2QueryFilter filter,
|
|
59
|
+
b2OverlapResultFcn* fcn, void* context );
|
|
60
|
+
|
|
61
|
+
/// Cast a ray into the world to collect shapes in the path of the ray.
|
|
62
|
+
/// Your callback function controls whether you get the closest point, any point, or n-points.
|
|
63
|
+
/// The ray-cast ignores shapes that contain the starting point.
|
|
64
|
+
/// @note The callback function may receive shapes in any order
|
|
65
|
+
/// @param worldId The world to cast the ray against
|
|
66
|
+
/// @param origin The start point of the ray
|
|
67
|
+
/// @param translation The translation of the ray from the start point to the end point
|
|
68
|
+
/// @param filter Contains bit flags to filter unwanted shapes from the results
|
|
69
|
+
/// @param fcn A user implemented callback function
|
|
70
|
+
/// @param context A user context that is passed along to the callback function
|
|
71
|
+
/// @return traversal performance counters
|
|
72
|
+
B2_API b2TreeStats b2World_CastRay( b2WorldId worldId, b2Vec2 origin, b2Vec2 translation, b2QueryFilter filter,
|
|
73
|
+
b2CastResultFcn* fcn, void* context );
|
|
74
|
+
|
|
75
|
+
/// Cast a ray into the world to collect the closest hit. This is a convenience function.
|
|
76
|
+
/// This is less general than b2World_CastRay() and does not allow for custom filtering.
|
|
77
|
+
B2_API b2RayResult b2World_CastRayClosest( b2WorldId worldId, b2Vec2 origin, b2Vec2 translation, b2QueryFilter filter );
|
|
78
|
+
|
|
79
|
+
/// Cast a shape through the world. Similar to a cast ray except that a shape is cast instead of a point.
|
|
80
|
+
/// @see b2World_CastRay
|
|
81
|
+
B2_API b2TreeStats b2World_CastShape( b2WorldId worldId, const b2ShapeProxy* proxy, b2Vec2 translation, b2QueryFilter filter,
|
|
82
|
+
b2CastResultFcn* fcn, void* context );
|
|
83
|
+
|
|
84
|
+
/// Cast a capsule mover through the world. This is a special shape cast that handles sliding along other shapes while reducing
|
|
85
|
+
/// clipping.
|
|
86
|
+
B2_API float b2World_CastMover( b2WorldId worldId, const b2Capsule* mover, b2Vec2 translation, b2QueryFilter filter );
|
|
87
|
+
|
|
88
|
+
/// Collide a capsule mover with the world, gathering collision planes that can be fed to b2SolvePlanes. Useful for
|
|
89
|
+
/// kinematic character movement.
|
|
90
|
+
B2_API void b2World_CollideMover( b2WorldId worldId, const b2Capsule* mover, b2QueryFilter filter, b2PlaneResultFcn* fcn,
|
|
91
|
+
void* context );
|
|
92
|
+
|
|
93
|
+
/// Enable/disable sleep. If your application does not need sleeping, you can gain some performance
|
|
94
|
+
/// by disabling sleep completely at the world level.
|
|
95
|
+
/// @see b2WorldDef
|
|
96
|
+
B2_API void b2World_EnableSleeping( b2WorldId worldId, bool flag );
|
|
97
|
+
|
|
98
|
+
/// Is body sleeping enabled?
|
|
99
|
+
B2_API bool b2World_IsSleepingEnabled( b2WorldId worldId );
|
|
100
|
+
|
|
101
|
+
/// Enable/disable continuous collision between dynamic and static bodies. Generally you should keep continuous
|
|
102
|
+
/// collision enabled to prevent fast moving objects from going through static objects. The performance gain from
|
|
103
|
+
/// disabling continuous collision is minor.
|
|
104
|
+
/// @see b2WorldDef
|
|
105
|
+
B2_API void b2World_EnableContinuous( b2WorldId worldId, bool flag );
|
|
106
|
+
|
|
107
|
+
/// Is continuous collision enabled?
|
|
108
|
+
B2_API bool b2World_IsContinuousEnabled( b2WorldId worldId );
|
|
109
|
+
|
|
110
|
+
/// Adjust the restitution threshold. It is recommended not to make this value very small
|
|
111
|
+
/// because it will prevent bodies from sleeping. Usually in meters per second.
|
|
112
|
+
/// @see b2WorldDef
|
|
113
|
+
B2_API void b2World_SetRestitutionThreshold( b2WorldId worldId, float value );
|
|
114
|
+
|
|
115
|
+
/// Get the the restitution speed threshold. Usually in meters per second.
|
|
116
|
+
B2_API float b2World_GetRestitutionThreshold( b2WorldId worldId );
|
|
117
|
+
|
|
118
|
+
/// Adjust the hit event threshold. This controls the collision speed needed to generate a b2ContactHitEvent.
|
|
119
|
+
/// Usually in meters per second.
|
|
120
|
+
/// @see b2WorldDef::hitEventThreshold
|
|
121
|
+
B2_API void b2World_SetHitEventThreshold( b2WorldId worldId, float value );
|
|
122
|
+
|
|
123
|
+
/// Get the the hit event speed threshold. Usually in meters per second.
|
|
124
|
+
B2_API float b2World_GetHitEventThreshold( b2WorldId worldId );
|
|
125
|
+
|
|
126
|
+
/// Register the custom filter callback. This is optional.
|
|
127
|
+
B2_API void b2World_SetCustomFilterCallback( b2WorldId worldId, b2CustomFilterFcn* fcn, void* context );
|
|
128
|
+
|
|
129
|
+
/// Register the pre-solve callback. This is optional.
|
|
130
|
+
B2_API void b2World_SetPreSolveCallback( b2WorldId worldId, b2PreSolveFcn* fcn, void* context );
|
|
131
|
+
|
|
132
|
+
/// Set the gravity vector for the entire world. Box2D has no concept of an up direction and this
|
|
133
|
+
/// is left as a decision for the application. Usually in m/s^2.
|
|
134
|
+
/// @see b2WorldDef
|
|
135
|
+
B2_API void b2World_SetGravity( b2WorldId worldId, b2Vec2 gravity );
|
|
136
|
+
|
|
137
|
+
/// Get the gravity vector
|
|
138
|
+
B2_API b2Vec2 b2World_GetGravity( b2WorldId worldId );
|
|
139
|
+
|
|
140
|
+
/// Apply a radial explosion
|
|
141
|
+
/// @param worldId The world id
|
|
142
|
+
/// @param explosionDef The explosion definition
|
|
143
|
+
B2_API void b2World_Explode( b2WorldId worldId, const b2ExplosionDef* explosionDef );
|
|
144
|
+
|
|
145
|
+
/// Adjust contact tuning parameters
|
|
146
|
+
/// @param worldId The world id
|
|
147
|
+
/// @param hertz The contact stiffness (cycles per second)
|
|
148
|
+
/// @param dampingRatio The contact bounciness with 1 being critical damping (non-dimensional)
|
|
149
|
+
/// @param pushSpeed The maximum contact constraint push out speed (meters per second)
|
|
150
|
+
/// @note Advanced feature
|
|
151
|
+
B2_API void b2World_SetContactTuning( b2WorldId worldId, float hertz, float dampingRatio, float pushSpeed );
|
|
152
|
+
|
|
153
|
+
/// Adjust joint tuning parameters
|
|
154
|
+
/// @param worldId The world id
|
|
155
|
+
/// @param hertz The contact stiffness (cycles per second)
|
|
156
|
+
/// @param dampingRatio The contact bounciness with 1 being critical damping (non-dimensional)
|
|
157
|
+
/// @note Advanced feature
|
|
158
|
+
B2_API void b2World_SetJointTuning( b2WorldId worldId, float hertz, float dampingRatio );
|
|
159
|
+
|
|
160
|
+
/// Set the maximum linear speed. Usually in m/s.
|
|
161
|
+
B2_API void b2World_SetMaximumLinearSpeed( b2WorldId worldId, float maximumLinearSpeed );
|
|
162
|
+
|
|
163
|
+
/// Get the maximum linear speed. Usually in m/s.
|
|
164
|
+
B2_API float b2World_GetMaximumLinearSpeed( b2WorldId worldId );
|
|
165
|
+
|
|
166
|
+
/// Enable/disable constraint warm starting. Advanced feature for testing. Disabling
|
|
167
|
+
/// warm starting greatly reduces stability and provides no performance gain.
|
|
168
|
+
B2_API void b2World_EnableWarmStarting( b2WorldId worldId, bool flag );
|
|
169
|
+
|
|
170
|
+
/// Is constraint warm starting enabled?
|
|
171
|
+
B2_API bool b2World_IsWarmStartingEnabled( b2WorldId worldId );
|
|
172
|
+
|
|
173
|
+
/// Get the number of awake bodies.
|
|
174
|
+
B2_API int b2World_GetAwakeBodyCount( b2WorldId worldId );
|
|
175
|
+
|
|
176
|
+
/// Get the current world performance profile
|
|
177
|
+
B2_API b2Profile b2World_GetProfile( b2WorldId worldId );
|
|
178
|
+
|
|
179
|
+
/// Get world counters and sizes
|
|
180
|
+
B2_API b2Counters b2World_GetCounters( b2WorldId worldId );
|
|
181
|
+
|
|
182
|
+
/// Set the user data pointer.
|
|
183
|
+
B2_API void b2World_SetUserData( b2WorldId worldId, void* userData );
|
|
184
|
+
|
|
185
|
+
/// Get the user data pointer.
|
|
186
|
+
B2_API void* b2World_GetUserData( b2WorldId worldId );
|
|
187
|
+
|
|
188
|
+
/// Set the friction callback. Passing NULL resets to default.
|
|
189
|
+
B2_API void b2World_SetFrictionCallback( b2WorldId worldId, b2FrictionCallback* callback );
|
|
190
|
+
|
|
191
|
+
/// Set the restitution callback. Passing NULL resets to default.
|
|
192
|
+
B2_API void b2World_SetRestitutionCallback( b2WorldId worldId, b2RestitutionCallback* callback );
|
|
193
|
+
|
|
194
|
+
/// Dump memory stats to box2d_memory.txt
|
|
195
|
+
B2_API void b2World_DumpMemoryStats( b2WorldId worldId );
|
|
196
|
+
|
|
197
|
+
/// This is for internal testing
|
|
198
|
+
B2_API void b2World_RebuildStaticTree( b2WorldId worldId );
|
|
199
|
+
|
|
200
|
+
/// This is for internal testing
|
|
201
|
+
B2_API void b2World_EnableSpeculative( b2WorldId worldId, bool flag );
|
|
202
|
+
|
|
203
|
+
/** @} */
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* @defgroup body Body
|
|
207
|
+
* This is the body API.
|
|
208
|
+
* @{
|
|
209
|
+
*/
|
|
210
|
+
|
|
211
|
+
/// Create a rigid body given a definition. No reference to the definition is retained. So you can create the definition
|
|
212
|
+
/// on the stack and pass it as a pointer.
|
|
213
|
+
/// @code{.c}
|
|
214
|
+
/// b2BodyDef bodyDef = b2DefaultBodyDef();
|
|
215
|
+
/// b2BodyId myBodyId = b2CreateBody(myWorldId, &bodyDef);
|
|
216
|
+
/// @endcode
|
|
217
|
+
/// @warning This function is locked during callbacks.
|
|
218
|
+
B2_API b2BodyId b2CreateBody( b2WorldId worldId, const b2BodyDef* def );
|
|
219
|
+
|
|
220
|
+
/// Destroy a rigid body given an id. This destroys all shapes and joints attached to the body.
|
|
221
|
+
/// Do not keep references to the associated shapes and joints.
|
|
222
|
+
B2_API void b2DestroyBody( b2BodyId bodyId );
|
|
223
|
+
|
|
224
|
+
/// Body identifier validation. Can be used to detect orphaned ids. Provides validation for up to 64K allocations.
|
|
225
|
+
B2_API bool b2Body_IsValid( b2BodyId id );
|
|
226
|
+
|
|
227
|
+
/// Get the body type: static, kinematic, or dynamic
|
|
228
|
+
B2_API b2BodyType b2Body_GetType( b2BodyId bodyId );
|
|
229
|
+
|
|
230
|
+
/// Change the body type. This is an expensive operation. This automatically updates the mass
|
|
231
|
+
/// properties regardless of the automatic mass setting.
|
|
232
|
+
B2_API void b2Body_SetType( b2BodyId bodyId, b2BodyType type );
|
|
233
|
+
|
|
234
|
+
/// Set the body name. Up to 31 characters excluding 0 termination.
|
|
235
|
+
B2_API void b2Body_SetName( b2BodyId bodyId, const char* name );
|
|
236
|
+
|
|
237
|
+
/// Get the body name. May be null.
|
|
238
|
+
B2_API const char* b2Body_GetName( b2BodyId bodyId );
|
|
239
|
+
|
|
240
|
+
/// Set the user data for a body
|
|
241
|
+
B2_API void b2Body_SetUserData( b2BodyId bodyId, void* userData );
|
|
242
|
+
|
|
243
|
+
/// Get the user data stored in a body
|
|
244
|
+
B2_API void* b2Body_GetUserData( b2BodyId bodyId );
|
|
245
|
+
|
|
246
|
+
/// Get the world position of a body. This is the location of the body origin.
|
|
247
|
+
B2_API b2Vec2 b2Body_GetPosition( b2BodyId bodyId );
|
|
248
|
+
|
|
249
|
+
/// Get the world rotation of a body as a cosine/sine pair (complex number)
|
|
250
|
+
B2_API b2Rot b2Body_GetRotation( b2BodyId bodyId );
|
|
251
|
+
|
|
252
|
+
/// Get the world transform of a body.
|
|
253
|
+
B2_API b2Transform b2Body_GetTransform( b2BodyId bodyId );
|
|
254
|
+
|
|
255
|
+
/// Set the world transform of a body. This acts as a teleport and is fairly expensive.
|
|
256
|
+
/// @note Generally you should create a body with then intended transform.
|
|
257
|
+
/// @see b2BodyDef::position and b2BodyDef::angle
|
|
258
|
+
B2_API void b2Body_SetTransform( b2BodyId bodyId, b2Vec2 position, b2Rot rotation );
|
|
259
|
+
|
|
260
|
+
/// Get a local point on a body given a world point
|
|
261
|
+
B2_API b2Vec2 b2Body_GetLocalPoint( b2BodyId bodyId, b2Vec2 worldPoint );
|
|
262
|
+
|
|
263
|
+
/// Get a world point on a body given a local point
|
|
264
|
+
B2_API b2Vec2 b2Body_GetWorldPoint( b2BodyId bodyId, b2Vec2 localPoint );
|
|
265
|
+
|
|
266
|
+
/// Get a local vector on a body given a world vector
|
|
267
|
+
B2_API b2Vec2 b2Body_GetLocalVector( b2BodyId bodyId, b2Vec2 worldVector );
|
|
268
|
+
|
|
269
|
+
/// Get a world vector on a body given a local vector
|
|
270
|
+
B2_API b2Vec2 b2Body_GetWorldVector( b2BodyId bodyId, b2Vec2 localVector );
|
|
271
|
+
|
|
272
|
+
/// Get the linear velocity of a body's center of mass. Usually in meters per second.
|
|
273
|
+
B2_API b2Vec2 b2Body_GetLinearVelocity( b2BodyId bodyId );
|
|
274
|
+
|
|
275
|
+
/// Get the angular velocity of a body in radians per second
|
|
276
|
+
B2_API float b2Body_GetAngularVelocity( b2BodyId bodyId );
|
|
277
|
+
|
|
278
|
+
/// Set the linear velocity of a body. Usually in meters per second.
|
|
279
|
+
B2_API void b2Body_SetLinearVelocity( b2BodyId bodyId, b2Vec2 linearVelocity );
|
|
280
|
+
|
|
281
|
+
/// Set the angular velocity of a body in radians per second
|
|
282
|
+
B2_API void b2Body_SetAngularVelocity( b2BodyId bodyId, float angularVelocity );
|
|
283
|
+
|
|
284
|
+
/// Set the velocity to reach the given transform after a given time step.
|
|
285
|
+
/// The result will be close but maybe not exact. This is meant for kinematic bodies.
|
|
286
|
+
/// This will automatically wake the body if asleep.
|
|
287
|
+
B2_API void b2Body_SetTargetTransform( b2BodyId bodyId, b2Transform target, float timeStep );
|
|
288
|
+
|
|
289
|
+
/// Get the linear velocity of a local point attached to a body. Usually in meters per second.
|
|
290
|
+
B2_API b2Vec2 b2Body_GetLocalPointVelocity( b2BodyId bodyId, b2Vec2 localPoint );
|
|
291
|
+
|
|
292
|
+
/// Get the linear velocity of a world point attached to a body. Usually in meters per second.
|
|
293
|
+
B2_API b2Vec2 b2Body_GetWorldPointVelocity( b2BodyId bodyId, b2Vec2 worldPoint );
|
|
294
|
+
|
|
295
|
+
/// Apply a force at a world point. If the force is not applied at the center of mass,
|
|
296
|
+
/// it will generate a torque and affect the angular velocity. This optionally wakes up the body.
|
|
297
|
+
/// The force is ignored if the body is not awake.
|
|
298
|
+
/// @param bodyId The body id
|
|
299
|
+
/// @param force The world force vector, usually in newtons (N)
|
|
300
|
+
/// @param point The world position of the point of application
|
|
301
|
+
/// @param wake Option to wake up the body
|
|
302
|
+
B2_API void b2Body_ApplyForce( b2BodyId bodyId, b2Vec2 force, b2Vec2 point, bool wake );
|
|
303
|
+
|
|
304
|
+
/// Apply a force to the center of mass. This optionally wakes up the body.
|
|
305
|
+
/// The force is ignored if the body is not awake.
|
|
306
|
+
/// @param bodyId The body id
|
|
307
|
+
/// @param force the world force vector, usually in newtons (N).
|
|
308
|
+
/// @param wake also wake up the body
|
|
309
|
+
B2_API void b2Body_ApplyForceToCenter( b2BodyId bodyId, b2Vec2 force, bool wake );
|
|
310
|
+
|
|
311
|
+
/// Apply a torque. This affects the angular velocity without affecting the linear velocity.
|
|
312
|
+
/// This optionally wakes the body. The torque is ignored if the body is not awake.
|
|
313
|
+
/// @param bodyId The body id
|
|
314
|
+
/// @param torque about the z-axis (out of the screen), usually in N*m.
|
|
315
|
+
/// @param wake also wake up the body
|
|
316
|
+
B2_API void b2Body_ApplyTorque( b2BodyId bodyId, float torque, bool wake );
|
|
317
|
+
|
|
318
|
+
/// Apply an impulse at a point. This immediately modifies the velocity.
|
|
319
|
+
/// It also modifies the angular velocity if the point of application
|
|
320
|
+
/// is not at the center of mass. This optionally wakes the body.
|
|
321
|
+
/// The impulse is ignored if the body is not awake.
|
|
322
|
+
/// @param bodyId The body id
|
|
323
|
+
/// @param impulse the world impulse vector, usually in N*s or kg*m/s.
|
|
324
|
+
/// @param point the world position of the point of application.
|
|
325
|
+
/// @param wake also wake up the body
|
|
326
|
+
/// @warning This should be used for one-shot impulses. If you need a steady force,
|
|
327
|
+
/// use a force instead, which will work better with the sub-stepping solver.
|
|
328
|
+
B2_API void b2Body_ApplyLinearImpulse( b2BodyId bodyId, b2Vec2 impulse, b2Vec2 point, bool wake );
|
|
329
|
+
|
|
330
|
+
/// Apply an impulse to the center of mass. This immediately modifies the velocity.
|
|
331
|
+
/// The impulse is ignored if the body is not awake. This optionally wakes the body.
|
|
332
|
+
/// @param bodyId The body id
|
|
333
|
+
/// @param impulse the world impulse vector, usually in N*s or kg*m/s.
|
|
334
|
+
/// @param wake also wake up the body
|
|
335
|
+
/// @warning This should be used for one-shot impulses. If you need a steady force,
|
|
336
|
+
/// use a force instead, which will work better with the sub-stepping solver.
|
|
337
|
+
B2_API void b2Body_ApplyLinearImpulseToCenter( b2BodyId bodyId, b2Vec2 impulse, bool wake );
|
|
338
|
+
|
|
339
|
+
/// Apply an angular impulse. The impulse is ignored if the body is not awake.
|
|
340
|
+
/// This optionally wakes the body.
|
|
341
|
+
/// @param bodyId The body id
|
|
342
|
+
/// @param impulse the angular impulse, usually in units of kg*m*m/s
|
|
343
|
+
/// @param wake also wake up the body
|
|
344
|
+
/// @warning This should be used for one-shot impulses. If you need a steady force,
|
|
345
|
+
/// use a force instead, which will work better with the sub-stepping solver.
|
|
346
|
+
B2_API void b2Body_ApplyAngularImpulse( b2BodyId bodyId, float impulse, bool wake );
|
|
347
|
+
|
|
348
|
+
/// Get the mass of the body, usually in kilograms
|
|
349
|
+
B2_API float b2Body_GetMass( b2BodyId bodyId );
|
|
350
|
+
|
|
351
|
+
/// Get the rotational inertia of the body, usually in kg*m^2
|
|
352
|
+
B2_API float b2Body_GetRotationalInertia( b2BodyId bodyId );
|
|
353
|
+
|
|
354
|
+
/// Get the center of mass position of the body in local space
|
|
355
|
+
B2_API b2Vec2 b2Body_GetLocalCenterOfMass( b2BodyId bodyId );
|
|
356
|
+
|
|
357
|
+
/// Get the center of mass position of the body in world space
|
|
358
|
+
B2_API b2Vec2 b2Body_GetWorldCenterOfMass( b2BodyId bodyId );
|
|
359
|
+
|
|
360
|
+
/// Override the body's mass properties. Normally this is computed automatically using the
|
|
361
|
+
/// shape geometry and density. This information is lost if a shape is added or removed or if the
|
|
362
|
+
/// body type changes.
|
|
363
|
+
B2_API void b2Body_SetMassData( b2BodyId bodyId, b2MassData massData );
|
|
364
|
+
|
|
365
|
+
/// Get the mass data for a body
|
|
366
|
+
B2_API b2MassData b2Body_GetMassData( b2BodyId bodyId );
|
|
367
|
+
|
|
368
|
+
/// This update the mass properties to the sum of the mass properties of the shapes.
|
|
369
|
+
/// This normally does not need to be called unless you called SetMassData to override
|
|
370
|
+
/// the mass and you later want to reset the mass.
|
|
371
|
+
/// You may also use this when automatic mass computation has been disabled.
|
|
372
|
+
/// You should call this regardless of body type.
|
|
373
|
+
/// Note that sensor shapes may have mass.
|
|
374
|
+
B2_API void b2Body_ApplyMassFromShapes( b2BodyId bodyId );
|
|
375
|
+
|
|
376
|
+
/// Adjust the linear damping. Normally this is set in b2BodyDef before creation.
|
|
377
|
+
B2_API void b2Body_SetLinearDamping( b2BodyId bodyId, float linearDamping );
|
|
378
|
+
|
|
379
|
+
/// Get the current linear damping.
|
|
380
|
+
B2_API float b2Body_GetLinearDamping( b2BodyId bodyId );
|
|
381
|
+
|
|
382
|
+
/// Adjust the angular damping. Normally this is set in b2BodyDef before creation.
|
|
383
|
+
B2_API void b2Body_SetAngularDamping( b2BodyId bodyId, float angularDamping );
|
|
384
|
+
|
|
385
|
+
/// Get the current angular damping.
|
|
386
|
+
B2_API float b2Body_GetAngularDamping( b2BodyId bodyId );
|
|
387
|
+
|
|
388
|
+
/// Adjust the gravity scale. Normally this is set in b2BodyDef before creation.
|
|
389
|
+
/// @see b2BodyDef::gravityScale
|
|
390
|
+
B2_API void b2Body_SetGravityScale( b2BodyId bodyId, float gravityScale );
|
|
391
|
+
|
|
392
|
+
/// Get the current gravity scale
|
|
393
|
+
B2_API float b2Body_GetGravityScale( b2BodyId bodyId );
|
|
394
|
+
|
|
395
|
+
/// @return true if this body is awake
|
|
396
|
+
B2_API bool b2Body_IsAwake( b2BodyId bodyId );
|
|
397
|
+
|
|
398
|
+
/// Wake a body from sleep. This wakes the entire island the body is touching.
|
|
399
|
+
/// @warning Putting a body to sleep will put the entire island of bodies touching this body to sleep,
|
|
400
|
+
/// which can be expensive and possibly unintuitive.
|
|
401
|
+
B2_API void b2Body_SetAwake( b2BodyId bodyId, bool awake );
|
|
402
|
+
|
|
403
|
+
/// Enable or disable sleeping for this body. If sleeping is disabled the body will wake.
|
|
404
|
+
B2_API void b2Body_EnableSleep( b2BodyId bodyId, bool enableSleep );
|
|
405
|
+
|
|
406
|
+
/// Returns true if sleeping is enabled for this body
|
|
407
|
+
B2_API bool b2Body_IsSleepEnabled( b2BodyId bodyId );
|
|
408
|
+
|
|
409
|
+
/// Set the sleep threshold, usually in meters per second
|
|
410
|
+
B2_API void b2Body_SetSleepThreshold( b2BodyId bodyId, float sleepThreshold );
|
|
411
|
+
|
|
412
|
+
/// Get the sleep threshold, usually in meters per second.
|
|
413
|
+
B2_API float b2Body_GetSleepThreshold( b2BodyId bodyId );
|
|
414
|
+
|
|
415
|
+
/// Returns true if this body is enabled
|
|
416
|
+
B2_API bool b2Body_IsEnabled( b2BodyId bodyId );
|
|
417
|
+
|
|
418
|
+
/// Disable a body by removing it completely from the simulation. This is expensive.
|
|
419
|
+
B2_API void b2Body_Disable( b2BodyId bodyId );
|
|
420
|
+
|
|
421
|
+
/// Enable a body by adding it to the simulation. This is expensive.
|
|
422
|
+
B2_API void b2Body_Enable( b2BodyId bodyId );
|
|
423
|
+
|
|
424
|
+
/// Set this body to have fixed rotation. This causes the mass to be reset in all cases.
|
|
425
|
+
B2_API void b2Body_SetFixedRotation( b2BodyId bodyId, bool flag );
|
|
426
|
+
|
|
427
|
+
/// Does this body have fixed rotation?
|
|
428
|
+
B2_API bool b2Body_IsFixedRotation( b2BodyId bodyId );
|
|
429
|
+
|
|
430
|
+
/// Set this body to be a bullet. A bullet does continuous collision detection
|
|
431
|
+
/// against dynamic bodies (but not other bullets).
|
|
432
|
+
B2_API void b2Body_SetBullet( b2BodyId bodyId, bool flag );
|
|
433
|
+
|
|
434
|
+
/// Is this body a bullet?
|
|
435
|
+
B2_API bool b2Body_IsBullet( b2BodyId bodyId );
|
|
436
|
+
|
|
437
|
+
/// Enable/disable contact events on all shapes.
|
|
438
|
+
/// @see b2ShapeDef::enableContactEvents
|
|
439
|
+
/// @warning changing this at runtime may cause mismatched begin/end touch events
|
|
440
|
+
B2_API void b2Body_EnableContactEvents( b2BodyId bodyId, bool flag );
|
|
441
|
+
|
|
442
|
+
/// Enable/disable hit events on all shapes
|
|
443
|
+
/// @see b2ShapeDef::enableHitEvents
|
|
444
|
+
B2_API void b2Body_EnableHitEvents( b2BodyId bodyId, bool flag );
|
|
445
|
+
|
|
446
|
+
/// Get the world that owns this body
|
|
447
|
+
B2_API b2WorldId b2Body_GetWorld( b2BodyId bodyId );
|
|
448
|
+
|
|
449
|
+
/// Get the number of shapes on this body
|
|
450
|
+
B2_API int b2Body_GetShapeCount( b2BodyId bodyId );
|
|
451
|
+
|
|
452
|
+
/// Get the shape ids for all shapes on this body, up to the provided capacity.
|
|
453
|
+
/// @returns the number of shape ids stored in the user array
|
|
454
|
+
B2_API int b2Body_GetShapes( b2BodyId bodyId, b2ShapeId* shapeArray, int capacity );
|
|
455
|
+
|
|
456
|
+
/// Get the number of joints on this body
|
|
457
|
+
B2_API int b2Body_GetJointCount( b2BodyId bodyId );
|
|
458
|
+
|
|
459
|
+
/// Get the joint ids for all joints on this body, up to the provided capacity
|
|
460
|
+
/// @returns the number of joint ids stored in the user array
|
|
461
|
+
B2_API int b2Body_GetJoints( b2BodyId bodyId, b2JointId* jointArray, int capacity );
|
|
462
|
+
|
|
463
|
+
/// Get the maximum capacity required for retrieving all the touching contacts on a body
|
|
464
|
+
B2_API int b2Body_GetContactCapacity( b2BodyId bodyId );
|
|
465
|
+
|
|
466
|
+
/// Get the touching contact data for a body.
|
|
467
|
+
/// @note Box2D uses speculative collision so some contact points may be separated.
|
|
468
|
+
/// @returns the number of elements filled in the provided array
|
|
469
|
+
/// @warning do not ignore the return value, it specifies the valid number of elements
|
|
470
|
+
B2_API int b2Body_GetContactData( b2BodyId bodyId, b2ContactData* contactData, int capacity );
|
|
471
|
+
|
|
472
|
+
/// Get the current world AABB that contains all the attached shapes. Note that this may not encompass the body origin.
|
|
473
|
+
/// If there are no shapes attached then the returned AABB is empty and centered on the body origin.
|
|
474
|
+
B2_API b2AABB b2Body_ComputeAABB( b2BodyId bodyId );
|
|
475
|
+
|
|
476
|
+
/** @} */
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* @defgroup shape Shape
|
|
480
|
+
* Functions to create, destroy, and access.
|
|
481
|
+
* Shapes bind raw geometry to bodies and hold material properties including friction and restitution.
|
|
482
|
+
* @{
|
|
483
|
+
*/
|
|
484
|
+
|
|
485
|
+
/// Create a circle shape and attach it to a body. The shape definition and geometry are fully cloned.
|
|
486
|
+
/// Contacts are not created until the next time step.
|
|
487
|
+
/// @return the shape id for accessing the shape
|
|
488
|
+
B2_API b2ShapeId b2CreateCircleShape( b2BodyId bodyId, const b2ShapeDef* def, const b2Circle* circle );
|
|
489
|
+
|
|
490
|
+
/// Create a line segment shape and attach it to a body. The shape definition and geometry are fully cloned.
|
|
491
|
+
/// Contacts are not created until the next time step.
|
|
492
|
+
/// @return the shape id for accessing the shape
|
|
493
|
+
B2_API b2ShapeId b2CreateSegmentShape( b2BodyId bodyId, const b2ShapeDef* def, const b2Segment* segment );
|
|
494
|
+
|
|
495
|
+
/// Create a capsule shape and attach it to a body. The shape definition and geometry are fully cloned.
|
|
496
|
+
/// Contacts are not created until the next time step.
|
|
497
|
+
/// @return the shape id for accessing the shape
|
|
498
|
+
B2_API b2ShapeId b2CreateCapsuleShape( b2BodyId bodyId, const b2ShapeDef* def, const b2Capsule* capsule );
|
|
499
|
+
|
|
500
|
+
/// Create a polygon shape and attach it to a body. The shape definition and geometry are fully cloned.
|
|
501
|
+
/// Contacts are not created until the next time step.
|
|
502
|
+
/// @return the shape id for accessing the shape
|
|
503
|
+
B2_API b2ShapeId b2CreatePolygonShape( b2BodyId bodyId, const b2ShapeDef* def, const b2Polygon* polygon );
|
|
504
|
+
|
|
505
|
+
/// Destroy a shape. You may defer the body mass update which can improve performance if several shapes on a
|
|
506
|
+
/// body are destroyed at once.
|
|
507
|
+
/// @see b2Body_ApplyMassFromShapes
|
|
508
|
+
B2_API void b2DestroyShape( b2ShapeId shapeId, bool updateBodyMass );
|
|
509
|
+
|
|
510
|
+
/// Shape identifier validation. Provides validation for up to 64K allocations.
|
|
511
|
+
B2_API bool b2Shape_IsValid( b2ShapeId id );
|
|
512
|
+
|
|
513
|
+
/// Get the type of a shape
|
|
514
|
+
B2_API b2ShapeType b2Shape_GetType( b2ShapeId shapeId );
|
|
515
|
+
|
|
516
|
+
/// Get the id of the body that a shape is attached to
|
|
517
|
+
B2_API b2BodyId b2Shape_GetBody( b2ShapeId shapeId );
|
|
518
|
+
|
|
519
|
+
/// Get the world that owns this shape
|
|
520
|
+
B2_API b2WorldId b2Shape_GetWorld( b2ShapeId shapeId );
|
|
521
|
+
|
|
522
|
+
/// Returns true if the shape is a sensor. It is not possible to change a shape
|
|
523
|
+
/// from sensor to solid dynamically because this breaks the contract for
|
|
524
|
+
/// sensor events.
|
|
525
|
+
B2_API bool b2Shape_IsSensor( b2ShapeId shapeId );
|
|
526
|
+
|
|
527
|
+
/// Set the user data for a shape
|
|
528
|
+
B2_API void b2Shape_SetUserData( b2ShapeId shapeId, void* userData );
|
|
529
|
+
|
|
530
|
+
/// Get the user data for a shape. This is useful when you get a shape id
|
|
531
|
+
/// from an event or query.
|
|
532
|
+
B2_API void* b2Shape_GetUserData( b2ShapeId shapeId );
|
|
533
|
+
|
|
534
|
+
/// Set the mass density of a shape, usually in kg/m^2.
|
|
535
|
+
/// This will optionally update the mass properties on the parent body.
|
|
536
|
+
/// @see b2ShapeDef::density, b2Body_ApplyMassFromShapes
|
|
537
|
+
B2_API void b2Shape_SetDensity( b2ShapeId shapeId, float density, bool updateBodyMass );
|
|
538
|
+
|
|
539
|
+
/// Get the density of a shape, usually in kg/m^2
|
|
540
|
+
B2_API float b2Shape_GetDensity( b2ShapeId shapeId );
|
|
541
|
+
|
|
542
|
+
/// Set the friction on a shape
|
|
543
|
+
/// @see b2ShapeDef::friction
|
|
544
|
+
B2_API void b2Shape_SetFriction( b2ShapeId shapeId, float friction );
|
|
545
|
+
|
|
546
|
+
/// Get the friction of a shape
|
|
547
|
+
B2_API float b2Shape_GetFriction( b2ShapeId shapeId );
|
|
548
|
+
|
|
549
|
+
/// Set the shape restitution (bounciness)
|
|
550
|
+
/// @see b2ShapeDef::restitution
|
|
551
|
+
B2_API void b2Shape_SetRestitution( b2ShapeId shapeId, float restitution );
|
|
552
|
+
|
|
553
|
+
/// Get the shape restitution
|
|
554
|
+
B2_API float b2Shape_GetRestitution( b2ShapeId shapeId );
|
|
555
|
+
|
|
556
|
+
/// Set the shape material identifier
|
|
557
|
+
/// @see b2ShapeDef::material
|
|
558
|
+
B2_API void b2Shape_SetMaterial( b2ShapeId shapeId, int material );
|
|
559
|
+
|
|
560
|
+
/// Get the shape material identifier
|
|
561
|
+
B2_API int b2Shape_GetMaterial( b2ShapeId shapeId );
|
|
562
|
+
|
|
563
|
+
/// Get the shape filter
|
|
564
|
+
B2_API b2Filter b2Shape_GetFilter( b2ShapeId shapeId );
|
|
565
|
+
|
|
566
|
+
/// Set the current filter. This is almost as expensive as recreating the shape. This may cause
|
|
567
|
+
/// contacts to be immediately destroyed. However contacts are not created until the next world step.
|
|
568
|
+
/// Sensor overlap state is also not updated until the next world step.
|
|
569
|
+
/// @see b2ShapeDef::filter
|
|
570
|
+
B2_API void b2Shape_SetFilter( b2ShapeId shapeId, b2Filter filter );
|
|
571
|
+
|
|
572
|
+
/// Enable sensor events for this shape.
|
|
573
|
+
/// @see b2ShapeDef::enableSensorEvents
|
|
574
|
+
B2_API void b2Shape_EnableSensorEvents( b2ShapeId shapeId, bool flag );
|
|
575
|
+
|
|
576
|
+
/// Returns true if sensor events are enabled.
|
|
577
|
+
B2_API bool b2Shape_AreSensorEventsEnabled( b2ShapeId shapeId );
|
|
578
|
+
|
|
579
|
+
/// Enable contact events for this shape. Only applies to kinematic and dynamic bodies. Ignored for sensors.
|
|
580
|
+
/// @see b2ShapeDef::enableContactEvents
|
|
581
|
+
/// @warning changing this at run-time may lead to lost begin/end events
|
|
582
|
+
B2_API void b2Shape_EnableContactEvents( b2ShapeId shapeId, bool flag );
|
|
583
|
+
|
|
584
|
+
/// Returns true if contact events are enabled
|
|
585
|
+
B2_API bool b2Shape_AreContactEventsEnabled( b2ShapeId shapeId );
|
|
586
|
+
|
|
587
|
+
/// Enable pre-solve contact events for this shape. Only applies to dynamic bodies. These are expensive
|
|
588
|
+
/// and must be carefully handled due to multithreading. Ignored for sensors.
|
|
589
|
+
/// @see b2PreSolveFcn
|
|
590
|
+
B2_API void b2Shape_EnablePreSolveEvents( b2ShapeId shapeId, bool flag );
|
|
591
|
+
|
|
592
|
+
/// Returns true if pre-solve events are enabled
|
|
593
|
+
B2_API bool b2Shape_ArePreSolveEventsEnabled( b2ShapeId shapeId );
|
|
594
|
+
|
|
595
|
+
/// Enable contact hit events for this shape. Ignored for sensors.
|
|
596
|
+
/// @see b2WorldDef.hitEventThreshold
|
|
597
|
+
B2_API void b2Shape_EnableHitEvents( b2ShapeId shapeId, bool flag );
|
|
598
|
+
|
|
599
|
+
/// Returns true if hit events are enabled
|
|
600
|
+
B2_API bool b2Shape_AreHitEventsEnabled( b2ShapeId shapeId );
|
|
601
|
+
|
|
602
|
+
/// Test a point for overlap with a shape
|
|
603
|
+
B2_API bool b2Shape_TestPoint( b2ShapeId shapeId, b2Vec2 point );
|
|
604
|
+
|
|
605
|
+
/// Ray cast a shape directly
|
|
606
|
+
B2_API b2CastOutput b2Shape_RayCast( b2ShapeId shapeId, const b2RayCastInput* input );
|
|
607
|
+
|
|
608
|
+
/// Get a copy of the shape's circle. Asserts the type is correct.
|
|
609
|
+
B2_API b2Circle b2Shape_GetCircle( b2ShapeId shapeId );
|
|
610
|
+
|
|
611
|
+
/// Get a copy of the shape's line segment. Asserts the type is correct.
|
|
612
|
+
B2_API b2Segment b2Shape_GetSegment( b2ShapeId shapeId );
|
|
613
|
+
|
|
614
|
+
/// Get a copy of the shape's chain segment. These come from chain shapes.
|
|
615
|
+
/// Asserts the type is correct.
|
|
616
|
+
B2_API b2ChainSegment b2Shape_GetChainSegment( b2ShapeId shapeId );
|
|
617
|
+
|
|
618
|
+
/// Get a copy of the shape's capsule. Asserts the type is correct.
|
|
619
|
+
B2_API b2Capsule b2Shape_GetCapsule( b2ShapeId shapeId );
|
|
620
|
+
|
|
621
|
+
/// Get a copy of the shape's convex polygon. Asserts the type is correct.
|
|
622
|
+
B2_API b2Polygon b2Shape_GetPolygon( b2ShapeId shapeId );
|
|
623
|
+
|
|
624
|
+
/// Allows you to change a shape to be a circle or update the current circle.
|
|
625
|
+
/// This does not modify the mass properties.
|
|
626
|
+
/// @see b2Body_ApplyMassFromShapes
|
|
627
|
+
B2_API void b2Shape_SetCircle( b2ShapeId shapeId, const b2Circle* circle );
|
|
628
|
+
|
|
629
|
+
/// Allows you to change a shape to be a capsule or update the current capsule.
|
|
630
|
+
/// This does not modify the mass properties.
|
|
631
|
+
/// @see b2Body_ApplyMassFromShapes
|
|
632
|
+
B2_API void b2Shape_SetCapsule( b2ShapeId shapeId, const b2Capsule* capsule );
|
|
633
|
+
|
|
634
|
+
/// Allows you to change a shape to be a segment or update the current segment.
|
|
635
|
+
B2_API void b2Shape_SetSegment( b2ShapeId shapeId, const b2Segment* segment );
|
|
636
|
+
|
|
637
|
+
/// Allows you to change a shape to be a polygon or update the current polygon.
|
|
638
|
+
/// This does not modify the mass properties.
|
|
639
|
+
/// @see b2Body_ApplyMassFromShapes
|
|
640
|
+
B2_API void b2Shape_SetPolygon( b2ShapeId shapeId, const b2Polygon* polygon );
|
|
641
|
+
|
|
642
|
+
/// Get the parent chain id if the shape type is a chain segment, otherwise
|
|
643
|
+
/// returns b2_nullChainId.
|
|
644
|
+
B2_API b2ChainId b2Shape_GetParentChain( b2ShapeId shapeId );
|
|
645
|
+
|
|
646
|
+
/// Get the maximum capacity required for retrieving all the touching contacts on a shape
|
|
647
|
+
B2_API int b2Shape_GetContactCapacity( b2ShapeId shapeId );
|
|
648
|
+
|
|
649
|
+
/// Get the touching contact data for a shape. The provided shapeId will be either shapeIdA or shapeIdB on the contact data.
|
|
650
|
+
/// @note Box2D uses speculative collision so some contact points may be separated.
|
|
651
|
+
/// @returns the number of elements filled in the provided array
|
|
652
|
+
/// @warning do not ignore the return value, it specifies the valid number of elements
|
|
653
|
+
B2_API int b2Shape_GetContactData( b2ShapeId shapeId, b2ContactData* contactData, int capacity );
|
|
654
|
+
|
|
655
|
+
/// Get the maximum capacity required for retrieving all the overlapped shapes on a sensor shape.
|
|
656
|
+
/// This returns 0 if the provided shape is not a sensor.
|
|
657
|
+
/// @param shapeId the id of a sensor shape
|
|
658
|
+
/// @returns the required capacity to get all the overlaps in b2Shape_GetSensorOverlaps
|
|
659
|
+
B2_API int b2Shape_GetSensorCapacity( b2ShapeId shapeId );
|
|
660
|
+
|
|
661
|
+
/// Get the overlapped shapes for a sensor shape.
|
|
662
|
+
/// @param shapeId the id of a sensor shape
|
|
663
|
+
/// @param overlaps a user allocated array that is filled with the overlapping shapes
|
|
664
|
+
/// @param capacity the capacity of overlappedShapes
|
|
665
|
+
/// @returns the number of elements filled in the provided array
|
|
666
|
+
/// @warning do not ignore the return value, it specifies the valid number of elements
|
|
667
|
+
/// @warning overlaps may contain destroyed shapes so use b2Shape_IsValid to confirm each overlap
|
|
668
|
+
B2_API int b2Shape_GetSensorOverlaps( b2ShapeId shapeId, b2ShapeId* overlaps, int capacity );
|
|
669
|
+
|
|
670
|
+
/// Get the current world AABB
|
|
671
|
+
B2_API b2AABB b2Shape_GetAABB( b2ShapeId shapeId );
|
|
672
|
+
|
|
673
|
+
/// Get the mass data for a shape
|
|
674
|
+
B2_API b2MassData b2Shape_GetMassData( b2ShapeId shapeId );
|
|
675
|
+
|
|
676
|
+
/// Get the closest point on a shape to a target point. Target and result are in world space.
|
|
677
|
+
/// todo need sample
|
|
678
|
+
B2_API b2Vec2 b2Shape_GetClosestPoint( b2ShapeId shapeId, b2Vec2 target );
|
|
679
|
+
|
|
680
|
+
/// Chain Shape
|
|
681
|
+
|
|
682
|
+
/// Create a chain shape
|
|
683
|
+
/// @see b2ChainDef for details
|
|
684
|
+
B2_API b2ChainId b2CreateChain( b2BodyId bodyId, const b2ChainDef* def );
|
|
685
|
+
|
|
686
|
+
/// Destroy a chain shape
|
|
687
|
+
B2_API void b2DestroyChain( b2ChainId chainId );
|
|
688
|
+
|
|
689
|
+
/// Get the world that owns this chain shape
|
|
690
|
+
B2_API b2WorldId b2Chain_GetWorld( b2ChainId chainId );
|
|
691
|
+
|
|
692
|
+
/// Get the number of segments on this chain
|
|
693
|
+
B2_API int b2Chain_GetSegmentCount( b2ChainId chainId );
|
|
694
|
+
|
|
695
|
+
/// Fill a user array with chain segment shape ids up to the specified capacity. Returns
|
|
696
|
+
/// the actual number of segments returned.
|
|
697
|
+
B2_API int b2Chain_GetSegments( b2ChainId chainId, b2ShapeId* segmentArray, int capacity );
|
|
698
|
+
|
|
699
|
+
/// Set the chain friction
|
|
700
|
+
/// @see b2ChainDef::friction
|
|
701
|
+
B2_API void b2Chain_SetFriction( b2ChainId chainId, float friction );
|
|
702
|
+
|
|
703
|
+
/// Get the chain friction
|
|
704
|
+
B2_API float b2Chain_GetFriction( b2ChainId chainId );
|
|
705
|
+
|
|
706
|
+
/// Set the chain restitution (bounciness)
|
|
707
|
+
/// @see b2ChainDef::restitution
|
|
708
|
+
B2_API void b2Chain_SetRestitution( b2ChainId chainId, float restitution );
|
|
709
|
+
|
|
710
|
+
/// Get the chain restitution
|
|
711
|
+
B2_API float b2Chain_GetRestitution( b2ChainId chainId );
|
|
712
|
+
|
|
713
|
+
/// Set the chain material
|
|
714
|
+
/// @see b2ChainDef::material
|
|
715
|
+
B2_API void b2Chain_SetMaterial( b2ChainId chainId, int material );
|
|
716
|
+
|
|
717
|
+
/// Get the chain material
|
|
718
|
+
B2_API int b2Chain_GetMaterial( b2ChainId chainId );
|
|
719
|
+
|
|
720
|
+
/// Chain identifier validation. Provides validation for up to 64K allocations.
|
|
721
|
+
B2_API bool b2Chain_IsValid( b2ChainId id );
|
|
722
|
+
|
|
723
|
+
/** @} */
|
|
724
|
+
|
|
725
|
+
/**
|
|
726
|
+
* @defgroup joint Joint
|
|
727
|
+
* @brief Joints allow you to connect rigid bodies together while allowing various forms of relative motions.
|
|
728
|
+
* @{
|
|
729
|
+
*/
|
|
730
|
+
|
|
731
|
+
/// Destroy a joint
|
|
732
|
+
B2_API void b2DestroyJoint( b2JointId jointId );
|
|
733
|
+
|
|
734
|
+
/// Joint identifier validation. Provides validation for up to 64K allocations.
|
|
735
|
+
B2_API bool b2Joint_IsValid( b2JointId id );
|
|
736
|
+
|
|
737
|
+
/// Get the joint type
|
|
738
|
+
B2_API b2JointType b2Joint_GetType( b2JointId jointId );
|
|
739
|
+
|
|
740
|
+
/// Get body A id on a joint
|
|
741
|
+
B2_API b2BodyId b2Joint_GetBodyA( b2JointId jointId );
|
|
742
|
+
|
|
743
|
+
/// Get body B id on a joint
|
|
744
|
+
B2_API b2BodyId b2Joint_GetBodyB( b2JointId jointId );
|
|
745
|
+
|
|
746
|
+
/// Get the world that owns this joint
|
|
747
|
+
B2_API b2WorldId b2Joint_GetWorld( b2JointId jointId );
|
|
748
|
+
|
|
749
|
+
/// Get the local anchor on bodyA
|
|
750
|
+
B2_API b2Vec2 b2Joint_GetLocalAnchorA( b2JointId jointId );
|
|
751
|
+
|
|
752
|
+
/// Get the local anchor on bodyB
|
|
753
|
+
B2_API b2Vec2 b2Joint_GetLocalAnchorB( b2JointId jointId );
|
|
754
|
+
|
|
755
|
+
/// Toggle collision between connected bodies
|
|
756
|
+
B2_API void b2Joint_SetCollideConnected( b2JointId jointId, bool shouldCollide );
|
|
757
|
+
|
|
758
|
+
/// Is collision allowed between connected bodies?
|
|
759
|
+
B2_API bool b2Joint_GetCollideConnected( b2JointId jointId );
|
|
760
|
+
|
|
761
|
+
/// Set the user data on a joint
|
|
762
|
+
B2_API void b2Joint_SetUserData( b2JointId jointId, void* userData );
|
|
763
|
+
|
|
764
|
+
/// Get the user data on a joint
|
|
765
|
+
B2_API void* b2Joint_GetUserData( b2JointId jointId );
|
|
766
|
+
|
|
767
|
+
/// Wake the bodies connect to this joint
|
|
768
|
+
B2_API void b2Joint_WakeBodies( b2JointId jointId );
|
|
769
|
+
|
|
770
|
+
/// Get the current constraint force for this joint. Usually in Newtons.
|
|
771
|
+
B2_API b2Vec2 b2Joint_GetConstraintForce( b2JointId jointId );
|
|
772
|
+
|
|
773
|
+
/// Get the current constraint torque for this joint. Usually in Newton * meters.
|
|
774
|
+
B2_API float b2Joint_GetConstraintTorque( b2JointId jointId );
|
|
775
|
+
|
|
776
|
+
/**
|
|
777
|
+
* @defgroup distance_joint Distance Joint
|
|
778
|
+
* @brief Functions for the distance joint.
|
|
779
|
+
* @{
|
|
780
|
+
*/
|
|
781
|
+
|
|
782
|
+
/// Create a distance joint
|
|
783
|
+
/// @see b2DistanceJointDef for details
|
|
784
|
+
B2_API b2JointId b2CreateDistanceJoint( b2WorldId worldId, const b2DistanceJointDef* def );
|
|
785
|
+
|
|
786
|
+
/// Set the rest length of a distance joint
|
|
787
|
+
/// @param jointId The id for a distance joint
|
|
788
|
+
/// @param length The new distance joint length
|
|
789
|
+
B2_API void b2DistanceJoint_SetLength( b2JointId jointId, float length );
|
|
790
|
+
|
|
791
|
+
/// Get the rest length of a distance joint
|
|
792
|
+
B2_API float b2DistanceJoint_GetLength( b2JointId jointId );
|
|
793
|
+
|
|
794
|
+
/// Enable/disable the distance joint spring. When disabled the distance joint is rigid.
|
|
795
|
+
B2_API void b2DistanceJoint_EnableSpring( b2JointId jointId, bool enableSpring );
|
|
796
|
+
|
|
797
|
+
/// Is the distance joint spring enabled?
|
|
798
|
+
B2_API bool b2DistanceJoint_IsSpringEnabled( b2JointId jointId );
|
|
799
|
+
|
|
800
|
+
/// Set the spring stiffness in Hertz
|
|
801
|
+
B2_API void b2DistanceJoint_SetSpringHertz( b2JointId jointId, float hertz );
|
|
802
|
+
|
|
803
|
+
/// Set the spring damping ratio, non-dimensional
|
|
804
|
+
B2_API void b2DistanceJoint_SetSpringDampingRatio( b2JointId jointId, float dampingRatio );
|
|
805
|
+
|
|
806
|
+
/// Get the spring Hertz
|
|
807
|
+
B2_API float b2DistanceJoint_GetSpringHertz( b2JointId jointId );
|
|
808
|
+
|
|
809
|
+
/// Get the spring damping ratio
|
|
810
|
+
B2_API float b2DistanceJoint_GetSpringDampingRatio( b2JointId jointId );
|
|
811
|
+
|
|
812
|
+
/// Enable joint limit. The limit only works if the joint spring is enabled. Otherwise the joint is rigid
|
|
813
|
+
/// and the limit has no effect.
|
|
814
|
+
B2_API void b2DistanceJoint_EnableLimit( b2JointId jointId, bool enableLimit );
|
|
815
|
+
|
|
816
|
+
/// Is the distance joint limit enabled?
|
|
817
|
+
B2_API bool b2DistanceJoint_IsLimitEnabled( b2JointId jointId );
|
|
818
|
+
|
|
819
|
+
/// Set the minimum and maximum length parameters of a distance joint
|
|
820
|
+
B2_API void b2DistanceJoint_SetLengthRange( b2JointId jointId, float minLength, float maxLength );
|
|
821
|
+
|
|
822
|
+
/// Get the distance joint minimum length
|
|
823
|
+
B2_API float b2DistanceJoint_GetMinLength( b2JointId jointId );
|
|
824
|
+
|
|
825
|
+
/// Get the distance joint maximum length
|
|
826
|
+
B2_API float b2DistanceJoint_GetMaxLength( b2JointId jointId );
|
|
827
|
+
|
|
828
|
+
/// Get the current length of a distance joint
|
|
829
|
+
B2_API float b2DistanceJoint_GetCurrentLength( b2JointId jointId );
|
|
830
|
+
|
|
831
|
+
/// Enable/disable the distance joint motor
|
|
832
|
+
B2_API void b2DistanceJoint_EnableMotor( b2JointId jointId, bool enableMotor );
|
|
833
|
+
|
|
834
|
+
/// Is the distance joint motor enabled?
|
|
835
|
+
B2_API bool b2DistanceJoint_IsMotorEnabled( b2JointId jointId );
|
|
836
|
+
|
|
837
|
+
/// Set the distance joint motor speed, usually in meters per second
|
|
838
|
+
B2_API void b2DistanceJoint_SetMotorSpeed( b2JointId jointId, float motorSpeed );
|
|
839
|
+
|
|
840
|
+
/// Get the distance joint motor speed, usually in meters per second
|
|
841
|
+
B2_API float b2DistanceJoint_GetMotorSpeed( b2JointId jointId );
|
|
842
|
+
|
|
843
|
+
/// Set the distance joint maximum motor force, usually in newtons
|
|
844
|
+
B2_API void b2DistanceJoint_SetMaxMotorForce( b2JointId jointId, float force );
|
|
845
|
+
|
|
846
|
+
/// Get the distance joint maximum motor force, usually in newtons
|
|
847
|
+
B2_API float b2DistanceJoint_GetMaxMotorForce( b2JointId jointId );
|
|
848
|
+
|
|
849
|
+
/// Get the distance joint current motor force, usually in newtons
|
|
850
|
+
B2_API float b2DistanceJoint_GetMotorForce( b2JointId jointId );
|
|
851
|
+
|
|
852
|
+
/** @} */
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* @defgroup motor_joint Motor Joint
|
|
856
|
+
* @brief Functions for the motor joint.
|
|
857
|
+
*
|
|
858
|
+
* The motor joint is used to drive the relative transform between two bodies. It takes
|
|
859
|
+
* a relative position and rotation and applies the forces and torques needed to achieve
|
|
860
|
+
* that relative transform over time.
|
|
861
|
+
* @{
|
|
862
|
+
*/
|
|
863
|
+
|
|
864
|
+
/// Create a motor joint
|
|
865
|
+
/// @see b2MotorJointDef for details
|
|
866
|
+
B2_API b2JointId b2CreateMotorJoint( b2WorldId worldId, const b2MotorJointDef* def );
|
|
867
|
+
|
|
868
|
+
/// Set the motor joint linear offset target
|
|
869
|
+
B2_API void b2MotorJoint_SetLinearOffset( b2JointId jointId, b2Vec2 linearOffset );
|
|
870
|
+
|
|
871
|
+
/// Get the motor joint linear offset target
|
|
872
|
+
B2_API b2Vec2 b2MotorJoint_GetLinearOffset( b2JointId jointId );
|
|
873
|
+
|
|
874
|
+
/// Set the motor joint angular offset target in radians
|
|
875
|
+
B2_API void b2MotorJoint_SetAngularOffset( b2JointId jointId, float angularOffset );
|
|
876
|
+
|
|
877
|
+
/// Get the motor joint angular offset target in radians
|
|
878
|
+
B2_API float b2MotorJoint_GetAngularOffset( b2JointId jointId );
|
|
879
|
+
|
|
880
|
+
/// Set the motor joint maximum force, usually in newtons
|
|
881
|
+
B2_API void b2MotorJoint_SetMaxForce( b2JointId jointId, float maxForce );
|
|
882
|
+
|
|
883
|
+
/// Get the motor joint maximum force, usually in newtons
|
|
884
|
+
B2_API float b2MotorJoint_GetMaxForce( b2JointId jointId );
|
|
885
|
+
|
|
886
|
+
/// Set the motor joint maximum torque, usually in newton-meters
|
|
887
|
+
B2_API void b2MotorJoint_SetMaxTorque( b2JointId jointId, float maxTorque );
|
|
888
|
+
|
|
889
|
+
/// Get the motor joint maximum torque, usually in newton-meters
|
|
890
|
+
B2_API float b2MotorJoint_GetMaxTorque( b2JointId jointId );
|
|
891
|
+
|
|
892
|
+
/// Set the motor joint correction factor, usually in [0, 1]
|
|
893
|
+
B2_API void b2MotorJoint_SetCorrectionFactor( b2JointId jointId, float correctionFactor );
|
|
894
|
+
|
|
895
|
+
/// Get the motor joint correction factor, usually in [0, 1]
|
|
896
|
+
B2_API float b2MotorJoint_GetCorrectionFactor( b2JointId jointId );
|
|
897
|
+
|
|
898
|
+
/**@}*/
|
|
899
|
+
|
|
900
|
+
/**
|
|
901
|
+
* @defgroup mouse_joint Mouse Joint
|
|
902
|
+
* @brief Functions for the mouse joint.
|
|
903
|
+
*
|
|
904
|
+
* The mouse joint is designed for use in the samples application, but you may find it useful in applications where
|
|
905
|
+
* the user moves a rigid body with a cursor.
|
|
906
|
+
* @{
|
|
907
|
+
*/
|
|
908
|
+
|
|
909
|
+
/// Create a mouse joint
|
|
910
|
+
/// @see b2MouseJointDef for details
|
|
911
|
+
B2_API b2JointId b2CreateMouseJoint( b2WorldId worldId, const b2MouseJointDef* def );
|
|
912
|
+
|
|
913
|
+
/// Set the mouse joint target
|
|
914
|
+
B2_API void b2MouseJoint_SetTarget( b2JointId jointId, b2Vec2 target );
|
|
915
|
+
|
|
916
|
+
/// Get the mouse joint target
|
|
917
|
+
B2_API b2Vec2 b2MouseJoint_GetTarget( b2JointId jointId );
|
|
918
|
+
|
|
919
|
+
/// Set the mouse joint spring stiffness in Hertz
|
|
920
|
+
B2_API void b2MouseJoint_SetSpringHertz( b2JointId jointId, float hertz );
|
|
921
|
+
|
|
922
|
+
/// Get the mouse joint spring stiffness in Hertz
|
|
923
|
+
B2_API float b2MouseJoint_GetSpringHertz( b2JointId jointId );
|
|
924
|
+
|
|
925
|
+
/// Set the mouse joint spring damping ratio, non-dimensional
|
|
926
|
+
B2_API void b2MouseJoint_SetSpringDampingRatio( b2JointId jointId, float dampingRatio );
|
|
927
|
+
|
|
928
|
+
/// Get the mouse joint damping ratio, non-dimensional
|
|
929
|
+
B2_API float b2MouseJoint_GetSpringDampingRatio( b2JointId jointId );
|
|
930
|
+
|
|
931
|
+
/// Set the mouse joint maximum force, usually in newtons
|
|
932
|
+
B2_API void b2MouseJoint_SetMaxForce( b2JointId jointId, float maxForce );
|
|
933
|
+
|
|
934
|
+
/// Get the mouse joint maximum force, usually in newtons
|
|
935
|
+
B2_API float b2MouseJoint_GetMaxForce( b2JointId jointId );
|
|
936
|
+
|
|
937
|
+
/**@}*/
|
|
938
|
+
|
|
939
|
+
/**
|
|
940
|
+
* @defgroup filter_joint Filter Joint
|
|
941
|
+
* @brief Functions for the filter joint.
|
|
942
|
+
*
|
|
943
|
+
* The filter joint is used to disable collision between two bodies. As a side effect of being a joint, it also
|
|
944
|
+
* keeps the two bodies in the same simulation island.
|
|
945
|
+
* @{
|
|
946
|
+
*/
|
|
947
|
+
|
|
948
|
+
/// Create a filter joint.
|
|
949
|
+
/// @see b2FilterJointDef for details
|
|
950
|
+
B2_API b2JointId b2CreateFilterJoint( b2WorldId worldId, const b2FilterJointDef* def );
|
|
951
|
+
|
|
952
|
+
/**@}*/
|
|
953
|
+
|
|
954
|
+
/**
|
|
955
|
+
* @defgroup prismatic_joint Prismatic Joint
|
|
956
|
+
* @brief A prismatic joint allows for translation along a single axis with no rotation.
|
|
957
|
+
*
|
|
958
|
+
* The prismatic joint is useful for things like pistons and moving platforms, where you want a body to translate
|
|
959
|
+
* along an axis and have no rotation. Also called a *slider* joint.
|
|
960
|
+
* @{
|
|
961
|
+
*/
|
|
962
|
+
|
|
963
|
+
/// Create a prismatic (slider) joint.
|
|
964
|
+
/// @see b2PrismaticJointDef for details
|
|
965
|
+
B2_API b2JointId b2CreatePrismaticJoint( b2WorldId worldId, const b2PrismaticJointDef* def );
|
|
966
|
+
|
|
967
|
+
/// Enable/disable the joint spring.
|
|
968
|
+
B2_API void b2PrismaticJoint_EnableSpring( b2JointId jointId, bool enableSpring );
|
|
969
|
+
|
|
970
|
+
/// Is the prismatic joint spring enabled or not?
|
|
971
|
+
B2_API bool b2PrismaticJoint_IsSpringEnabled( b2JointId jointId );
|
|
972
|
+
|
|
973
|
+
/// Set the prismatic joint stiffness in Hertz.
|
|
974
|
+
/// This should usually be less than a quarter of the simulation rate. For example, if the simulation
|
|
975
|
+
/// runs at 60Hz then the joint stiffness should be 15Hz or less.
|
|
976
|
+
B2_API void b2PrismaticJoint_SetSpringHertz( b2JointId jointId, float hertz );
|
|
977
|
+
|
|
978
|
+
/// Get the prismatic joint stiffness in Hertz
|
|
979
|
+
B2_API float b2PrismaticJoint_GetSpringHertz( b2JointId jointId );
|
|
980
|
+
|
|
981
|
+
/// Set the prismatic joint damping ratio (non-dimensional)
|
|
982
|
+
B2_API void b2PrismaticJoint_SetSpringDampingRatio( b2JointId jointId, float dampingRatio );
|
|
983
|
+
|
|
984
|
+
/// Get the prismatic spring damping ratio (non-dimensional)
|
|
985
|
+
B2_API float b2PrismaticJoint_GetSpringDampingRatio( b2JointId jointId );
|
|
986
|
+
|
|
987
|
+
/// Enable/disable a prismatic joint limit
|
|
988
|
+
B2_API void b2PrismaticJoint_EnableLimit( b2JointId jointId, bool enableLimit );
|
|
989
|
+
|
|
990
|
+
/// Is the prismatic joint limit enabled?
|
|
991
|
+
B2_API bool b2PrismaticJoint_IsLimitEnabled( b2JointId jointId );
|
|
992
|
+
|
|
993
|
+
/// Get the prismatic joint lower limit
|
|
994
|
+
B2_API float b2PrismaticJoint_GetLowerLimit( b2JointId jointId );
|
|
995
|
+
|
|
996
|
+
/// Get the prismatic joint upper limit
|
|
997
|
+
B2_API float b2PrismaticJoint_GetUpperLimit( b2JointId jointId );
|
|
998
|
+
|
|
999
|
+
/// Set the prismatic joint limits
|
|
1000
|
+
B2_API void b2PrismaticJoint_SetLimits( b2JointId jointId, float lower, float upper );
|
|
1001
|
+
|
|
1002
|
+
/// Enable/disable a prismatic joint motor
|
|
1003
|
+
B2_API void b2PrismaticJoint_EnableMotor( b2JointId jointId, bool enableMotor );
|
|
1004
|
+
|
|
1005
|
+
/// Is the prismatic joint motor enabled?
|
|
1006
|
+
B2_API bool b2PrismaticJoint_IsMotorEnabled( b2JointId jointId );
|
|
1007
|
+
|
|
1008
|
+
/// Set the prismatic joint motor speed, usually in meters per second
|
|
1009
|
+
B2_API void b2PrismaticJoint_SetMotorSpeed( b2JointId jointId, float motorSpeed );
|
|
1010
|
+
|
|
1011
|
+
/// Get the prismatic joint motor speed, usually in meters per second
|
|
1012
|
+
B2_API float b2PrismaticJoint_GetMotorSpeed( b2JointId jointId );
|
|
1013
|
+
|
|
1014
|
+
/// Set the prismatic joint maximum motor force, usually in newtons
|
|
1015
|
+
B2_API void b2PrismaticJoint_SetMaxMotorForce( b2JointId jointId, float force );
|
|
1016
|
+
|
|
1017
|
+
/// Get the prismatic joint maximum motor force, usually in newtons
|
|
1018
|
+
B2_API float b2PrismaticJoint_GetMaxMotorForce( b2JointId jointId );
|
|
1019
|
+
|
|
1020
|
+
/// Get the prismatic joint current motor force, usually in newtons
|
|
1021
|
+
B2_API float b2PrismaticJoint_GetMotorForce( b2JointId jointId );
|
|
1022
|
+
|
|
1023
|
+
/// Get the current joint translation, usually in meters.
|
|
1024
|
+
B2_API float b2PrismaticJoint_GetTranslation( b2JointId jointId );
|
|
1025
|
+
|
|
1026
|
+
/// Get the current joint translation speed, usually in meters per second.
|
|
1027
|
+
B2_API float b2PrismaticJoint_GetSpeed( b2JointId jointId );
|
|
1028
|
+
|
|
1029
|
+
/** @} */
|
|
1030
|
+
|
|
1031
|
+
/**
|
|
1032
|
+
* @defgroup revolute_joint Revolute Joint
|
|
1033
|
+
* @brief A revolute joint allows for relative rotation in the 2D plane with no relative translation.
|
|
1034
|
+
*
|
|
1035
|
+
* The revolute joint is probably the most common joint. It can be used for ragdolls and chains.
|
|
1036
|
+
* Also called a *hinge* or *pin* joint.
|
|
1037
|
+
* @{
|
|
1038
|
+
*/
|
|
1039
|
+
|
|
1040
|
+
/// Create a revolute joint
|
|
1041
|
+
/// @see b2RevoluteJointDef for details
|
|
1042
|
+
B2_API b2JointId b2CreateRevoluteJoint( b2WorldId worldId, const b2RevoluteJointDef* def );
|
|
1043
|
+
|
|
1044
|
+
/// Enable/disable the revolute joint spring
|
|
1045
|
+
B2_API void b2RevoluteJoint_EnableSpring( b2JointId jointId, bool enableSpring );
|
|
1046
|
+
|
|
1047
|
+
/// It the revolute angular spring enabled?
|
|
1048
|
+
B2_API bool b2RevoluteJoint_IsSpringEnabled( b2JointId jointId );
|
|
1049
|
+
|
|
1050
|
+
/// Set the revolute joint spring stiffness in Hertz
|
|
1051
|
+
B2_API void b2RevoluteJoint_SetSpringHertz( b2JointId jointId, float hertz );
|
|
1052
|
+
|
|
1053
|
+
/// Get the revolute joint spring stiffness in Hertz
|
|
1054
|
+
B2_API float b2RevoluteJoint_GetSpringHertz( b2JointId jointId );
|
|
1055
|
+
|
|
1056
|
+
/// Set the revolute joint spring damping ratio, non-dimensional
|
|
1057
|
+
B2_API void b2RevoluteJoint_SetSpringDampingRatio( b2JointId jointId, float dampingRatio );
|
|
1058
|
+
|
|
1059
|
+
/// Get the revolute joint spring damping ratio, non-dimensional
|
|
1060
|
+
B2_API float b2RevoluteJoint_GetSpringDampingRatio( b2JointId jointId );
|
|
1061
|
+
|
|
1062
|
+
/// Get the revolute joint current angle in radians relative to the reference angle
|
|
1063
|
+
/// @see b2RevoluteJointDef::referenceAngle
|
|
1064
|
+
B2_API float b2RevoluteJoint_GetAngle( b2JointId jointId );
|
|
1065
|
+
|
|
1066
|
+
/// Enable/disable the revolute joint limit
|
|
1067
|
+
B2_API void b2RevoluteJoint_EnableLimit( b2JointId jointId, bool enableLimit );
|
|
1068
|
+
|
|
1069
|
+
/// Is the revolute joint limit enabled?
|
|
1070
|
+
B2_API bool b2RevoluteJoint_IsLimitEnabled( b2JointId jointId );
|
|
1071
|
+
|
|
1072
|
+
/// Get the revolute joint lower limit in radians
|
|
1073
|
+
B2_API float b2RevoluteJoint_GetLowerLimit( b2JointId jointId );
|
|
1074
|
+
|
|
1075
|
+
/// Get the revolute joint upper limit in radians
|
|
1076
|
+
B2_API float b2RevoluteJoint_GetUpperLimit( b2JointId jointId );
|
|
1077
|
+
|
|
1078
|
+
/// Set the revolute joint limits in radians. It is expected that lower <= upper
|
|
1079
|
+
/// and that -0.95 * B2_PI <= lower && upper <= -0.95 * B2_PI.
|
|
1080
|
+
B2_API void b2RevoluteJoint_SetLimits( b2JointId jointId, float lower, float upper );
|
|
1081
|
+
|
|
1082
|
+
/// Enable/disable a revolute joint motor
|
|
1083
|
+
B2_API void b2RevoluteJoint_EnableMotor( b2JointId jointId, bool enableMotor );
|
|
1084
|
+
|
|
1085
|
+
/// Is the revolute joint motor enabled?
|
|
1086
|
+
B2_API bool b2RevoluteJoint_IsMotorEnabled( b2JointId jointId );
|
|
1087
|
+
|
|
1088
|
+
/// Set the revolute joint motor speed in radians per second
|
|
1089
|
+
B2_API void b2RevoluteJoint_SetMotorSpeed( b2JointId jointId, float motorSpeed );
|
|
1090
|
+
|
|
1091
|
+
/// Get the revolute joint motor speed in radians per second
|
|
1092
|
+
B2_API float b2RevoluteJoint_GetMotorSpeed( b2JointId jointId );
|
|
1093
|
+
|
|
1094
|
+
/// Get the revolute joint current motor torque, usually in newton-meters
|
|
1095
|
+
B2_API float b2RevoluteJoint_GetMotorTorque( b2JointId jointId );
|
|
1096
|
+
|
|
1097
|
+
/// Set the revolute joint maximum motor torque, usually in newton-meters
|
|
1098
|
+
B2_API void b2RevoluteJoint_SetMaxMotorTorque( b2JointId jointId, float torque );
|
|
1099
|
+
|
|
1100
|
+
/// Get the revolute joint maximum motor torque, usually in newton-meters
|
|
1101
|
+
B2_API float b2RevoluteJoint_GetMaxMotorTorque( b2JointId jointId );
|
|
1102
|
+
|
|
1103
|
+
/**@}*/
|
|
1104
|
+
|
|
1105
|
+
/**
|
|
1106
|
+
* @defgroup weld_joint Weld Joint
|
|
1107
|
+
* @brief A weld joint fully constrains the relative transform between two bodies while allowing for springiness
|
|
1108
|
+
*
|
|
1109
|
+
* A weld joint constrains the relative rotation and translation between two bodies. Both rotation and translation
|
|
1110
|
+
* can have damped springs.
|
|
1111
|
+
*
|
|
1112
|
+
* @note The accuracy of weld joint is limited by the accuracy of the solver. Long chains of weld joints may flex.
|
|
1113
|
+
* @{
|
|
1114
|
+
*/
|
|
1115
|
+
|
|
1116
|
+
/// Create a weld joint
|
|
1117
|
+
/// @see b2WeldJointDef for details
|
|
1118
|
+
B2_API b2JointId b2CreateWeldJoint( b2WorldId worldId, const b2WeldJointDef* def );
|
|
1119
|
+
|
|
1120
|
+
/// Get the weld joint reference angle in radians
|
|
1121
|
+
B2_API float b2WeldJoint_GetReferenceAngle( b2JointId jointId );
|
|
1122
|
+
|
|
1123
|
+
/// Set the weld joint reference angle in radians, must be in [-pi,pi].
|
|
1124
|
+
B2_API void b2WeldJoint_SetReferenceAngle( b2JointId jointId, float angleInRadians );
|
|
1125
|
+
|
|
1126
|
+
/// Set the weld joint linear stiffness in Hertz. 0 is rigid.
|
|
1127
|
+
B2_API void b2WeldJoint_SetLinearHertz( b2JointId jointId, float hertz );
|
|
1128
|
+
|
|
1129
|
+
/// Get the weld joint linear stiffness in Hertz
|
|
1130
|
+
B2_API float b2WeldJoint_GetLinearHertz( b2JointId jointId );
|
|
1131
|
+
|
|
1132
|
+
/// Set the weld joint linear damping ratio (non-dimensional)
|
|
1133
|
+
B2_API void b2WeldJoint_SetLinearDampingRatio( b2JointId jointId, float dampingRatio );
|
|
1134
|
+
|
|
1135
|
+
/// Get the weld joint linear damping ratio (non-dimensional)
|
|
1136
|
+
B2_API float b2WeldJoint_GetLinearDampingRatio( b2JointId jointId );
|
|
1137
|
+
|
|
1138
|
+
/// Set the weld joint angular stiffness in Hertz. 0 is rigid.
|
|
1139
|
+
B2_API void b2WeldJoint_SetAngularHertz( b2JointId jointId, float hertz );
|
|
1140
|
+
|
|
1141
|
+
/// Get the weld joint angular stiffness in Hertz
|
|
1142
|
+
B2_API float b2WeldJoint_GetAngularHertz( b2JointId jointId );
|
|
1143
|
+
|
|
1144
|
+
/// Set weld joint angular damping ratio, non-dimensional
|
|
1145
|
+
B2_API void b2WeldJoint_SetAngularDampingRatio( b2JointId jointId, float dampingRatio );
|
|
1146
|
+
|
|
1147
|
+
/// Get the weld joint angular damping ratio, non-dimensional
|
|
1148
|
+
B2_API float b2WeldJoint_GetAngularDampingRatio( b2JointId jointId );
|
|
1149
|
+
|
|
1150
|
+
/** @} */
|
|
1151
|
+
|
|
1152
|
+
/**
|
|
1153
|
+
* @defgroup wheel_joint Wheel Joint
|
|
1154
|
+
* The wheel joint can be used to simulate wheels on vehicles.
|
|
1155
|
+
*
|
|
1156
|
+
* The wheel joint restricts body B to move along a local axis in body A. Body B is free to
|
|
1157
|
+
* rotate. Supports a linear spring, linear limits, and a rotational motor.
|
|
1158
|
+
*
|
|
1159
|
+
* @{
|
|
1160
|
+
*/
|
|
1161
|
+
|
|
1162
|
+
/// Create a wheel joint
|
|
1163
|
+
/// @see b2WheelJointDef for details
|
|
1164
|
+
B2_API b2JointId b2CreateWheelJoint( b2WorldId worldId, const b2WheelJointDef* def );
|
|
1165
|
+
|
|
1166
|
+
/// Enable/disable the wheel joint spring
|
|
1167
|
+
B2_API void b2WheelJoint_EnableSpring( b2JointId jointId, bool enableSpring );
|
|
1168
|
+
|
|
1169
|
+
/// Is the wheel joint spring enabled?
|
|
1170
|
+
B2_API bool b2WheelJoint_IsSpringEnabled( b2JointId jointId );
|
|
1171
|
+
|
|
1172
|
+
/// Set the wheel joint stiffness in Hertz
|
|
1173
|
+
B2_API void b2WheelJoint_SetSpringHertz( b2JointId jointId, float hertz );
|
|
1174
|
+
|
|
1175
|
+
/// Get the wheel joint stiffness in Hertz
|
|
1176
|
+
B2_API float b2WheelJoint_GetSpringHertz( b2JointId jointId );
|
|
1177
|
+
|
|
1178
|
+
/// Set the wheel joint damping ratio, non-dimensional
|
|
1179
|
+
B2_API void b2WheelJoint_SetSpringDampingRatio( b2JointId jointId, float dampingRatio );
|
|
1180
|
+
|
|
1181
|
+
/// Get the wheel joint damping ratio, non-dimensional
|
|
1182
|
+
B2_API float b2WheelJoint_GetSpringDampingRatio( b2JointId jointId );
|
|
1183
|
+
|
|
1184
|
+
/// Enable/disable the wheel joint limit
|
|
1185
|
+
B2_API void b2WheelJoint_EnableLimit( b2JointId jointId, bool enableLimit );
|
|
1186
|
+
|
|
1187
|
+
/// Is the wheel joint limit enabled?
|
|
1188
|
+
B2_API bool b2WheelJoint_IsLimitEnabled( b2JointId jointId );
|
|
1189
|
+
|
|
1190
|
+
/// Get the wheel joint lower limit
|
|
1191
|
+
B2_API float b2WheelJoint_GetLowerLimit( b2JointId jointId );
|
|
1192
|
+
|
|
1193
|
+
/// Get the wheel joint upper limit
|
|
1194
|
+
B2_API float b2WheelJoint_GetUpperLimit( b2JointId jointId );
|
|
1195
|
+
|
|
1196
|
+
/// Set the wheel joint limits
|
|
1197
|
+
B2_API void b2WheelJoint_SetLimits( b2JointId jointId, float lower, float upper );
|
|
1198
|
+
|
|
1199
|
+
/// Enable/disable the wheel joint motor
|
|
1200
|
+
B2_API void b2WheelJoint_EnableMotor( b2JointId jointId, bool enableMotor );
|
|
1201
|
+
|
|
1202
|
+
/// Is the wheel joint motor enabled?
|
|
1203
|
+
B2_API bool b2WheelJoint_IsMotorEnabled( b2JointId jointId );
|
|
1204
|
+
|
|
1205
|
+
/// Set the wheel joint motor speed in radians per second
|
|
1206
|
+
B2_API void b2WheelJoint_SetMotorSpeed( b2JointId jointId, float motorSpeed );
|
|
1207
|
+
|
|
1208
|
+
/// Get the wheel joint motor speed in radians per second
|
|
1209
|
+
B2_API float b2WheelJoint_GetMotorSpeed( b2JointId jointId );
|
|
1210
|
+
|
|
1211
|
+
/// Set the wheel joint maximum motor torque, usually in newton-meters
|
|
1212
|
+
B2_API void b2WheelJoint_SetMaxMotorTorque( b2JointId jointId, float torque );
|
|
1213
|
+
|
|
1214
|
+
/// Get the wheel joint maximum motor torque, usually in newton-meters
|
|
1215
|
+
B2_API float b2WheelJoint_GetMaxMotorTorque( b2JointId jointId );
|
|
1216
|
+
|
|
1217
|
+
/// Get the wheel joint current motor torque, usually in newton-meters
|
|
1218
|
+
B2_API float b2WheelJoint_GetMotorTorque( b2JointId jointId );
|
|
1219
|
+
|
|
1220
|
+
/**@}*/
|
|
1221
|
+
|
|
1222
|
+
/**@}*/
|