Box2D 3.1.0
A 2D physics engine for games
 
Loading...
Searching...
No Matches
box2d.h
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
23
27B2_API b2WorldId b2CreateWorld( const b2WorldDef* def );
28
30B2_API void b2DestroyWorld( b2WorldId worldId );
31
33B2_API bool b2World_IsValid( b2WorldId id );
34
39B2_API void b2World_Step( b2WorldId worldId, float timeStep, int subStepCount );
40
42B2_API void b2World_Draw( b2WorldId worldId, b2DebugDraw* draw );
43
46
49
52
55 void* context );
56
59 b2OverlapResultFcn* fcn, void* context );
60
72B2_API b2TreeStats b2World_CastRay( b2WorldId worldId, b2Vec2 origin, b2Vec2 translation, b2QueryFilter filter,
73 b2CastResultFcn* fcn, void* context );
74
77B2_API b2RayResult b2World_CastRayClosest( b2WorldId worldId, b2Vec2 origin, b2Vec2 translation, b2QueryFilter filter );
78
81B2_API b2TreeStats b2World_CastShape( b2WorldId worldId, const b2ShapeProxy* proxy, b2Vec2 translation, b2QueryFilter filter,
82 b2CastResultFcn* fcn, void* context );
83
86B2_API float b2World_CastMover( b2WorldId worldId, const b2Capsule* mover, b2Vec2 translation, b2QueryFilter filter );
87
90B2_API void b2World_CollideMover( b2WorldId worldId, const b2Capsule* mover, b2QueryFilter filter, b2PlaneResultFcn* fcn,
91 void* context );
92
96B2_API void b2World_EnableSleeping( b2WorldId worldId, bool flag );
97
99B2_API bool b2World_IsSleepingEnabled( b2WorldId worldId );
100
105B2_API void b2World_EnableContinuous( b2WorldId worldId, bool flag );
106
109
113B2_API void b2World_SetRestitutionThreshold( b2WorldId worldId, float value );
114
117
121B2_API void b2World_SetHitEventThreshold( b2WorldId worldId, float value );
122
125
127B2_API void b2World_SetCustomFilterCallback( b2WorldId worldId, b2CustomFilterFcn* fcn, void* context );
128
130B2_API void b2World_SetPreSolveCallback( b2WorldId worldId, b2PreSolveFcn* fcn, void* context );
131
135B2_API void b2World_SetGravity( b2WorldId worldId, b2Vec2 gravity );
136
139
143B2_API void b2World_Explode( b2WorldId worldId, const b2ExplosionDef* explosionDef );
144
151B2_API void b2World_SetContactTuning( b2WorldId worldId, float hertz, float dampingRatio, float pushSpeed );
152
158B2_API void b2World_SetJointTuning( b2WorldId worldId, float hertz, float dampingRatio );
159
161B2_API void b2World_SetMaximumLinearSpeed( b2WorldId worldId, float maximumLinearSpeed );
162
165
168B2_API void b2World_EnableWarmStarting( b2WorldId worldId, bool flag );
169
172
175
177B2_API b2Profile b2World_GetProfile( b2WorldId worldId );
178
180B2_API b2Counters b2World_GetCounters( b2WorldId worldId );
181
183B2_API void b2World_SetUserData( b2WorldId worldId, void* userData );
184
186B2_API void* b2World_GetUserData( b2WorldId worldId );
187
190
193
195B2_API void b2World_DumpMemoryStats( b2WorldId worldId );
196
199
201B2_API void b2World_EnableSpeculative( b2WorldId worldId, bool flag );
202
204
210
218B2_API b2BodyId b2CreateBody( b2WorldId worldId, const b2BodyDef* def );
219
222B2_API void b2DestroyBody( b2BodyId bodyId );
223
225B2_API bool b2Body_IsValid( b2BodyId id );
226
229
232B2_API void b2Body_SetType( b2BodyId bodyId, b2BodyType type );
233
235B2_API void b2Body_SetName( b2BodyId bodyId, const char* name );
236
238B2_API const char* b2Body_GetName( b2BodyId bodyId );
239
241B2_API void b2Body_SetUserData( b2BodyId bodyId, void* userData );
242
244B2_API void* b2Body_GetUserData( b2BodyId bodyId );
245
248
251
254
258B2_API void b2Body_SetTransform( b2BodyId bodyId, b2Vec2 position, b2Rot rotation );
259
261B2_API b2Vec2 b2Body_GetLocalPoint( b2BodyId bodyId, b2Vec2 worldPoint );
262
264B2_API b2Vec2 b2Body_GetWorldPoint( b2BodyId bodyId, b2Vec2 localPoint );
265
267B2_API b2Vec2 b2Body_GetLocalVector( b2BodyId bodyId, b2Vec2 worldVector );
268
270B2_API b2Vec2 b2Body_GetWorldVector( b2BodyId bodyId, b2Vec2 localVector );
271
274
276B2_API float b2Body_GetAngularVelocity( b2BodyId bodyId );
277
279B2_API void b2Body_SetLinearVelocity( b2BodyId bodyId, b2Vec2 linearVelocity );
280
282B2_API void b2Body_SetAngularVelocity( b2BodyId bodyId, float angularVelocity );
283
287B2_API void b2Body_SetTargetTransform( b2BodyId bodyId, b2Transform target, float timeStep );
288
291
294
302B2_API void b2Body_ApplyForce( b2BodyId bodyId, b2Vec2 force, b2Vec2 point, bool wake );
303
309B2_API void b2Body_ApplyForceToCenter( b2BodyId bodyId, b2Vec2 force, bool wake );
310
316B2_API void b2Body_ApplyTorque( b2BodyId bodyId, float torque, bool wake );
317
328B2_API void b2Body_ApplyLinearImpulse( b2BodyId bodyId, b2Vec2 impulse, b2Vec2 point, bool wake );
329
337B2_API void b2Body_ApplyLinearImpulseToCenter( b2BodyId bodyId, b2Vec2 impulse, bool wake );
338
346B2_API void b2Body_ApplyAngularImpulse( b2BodyId bodyId, float impulse, bool wake );
347
349B2_API float b2Body_GetMass( b2BodyId bodyId );
350
353
356
359
363B2_API void b2Body_SetMassData( b2BodyId bodyId, b2MassData massData );
364
367
375
377B2_API void b2Body_SetLinearDamping( b2BodyId bodyId, float linearDamping );
378
380B2_API float b2Body_GetLinearDamping( b2BodyId bodyId );
381
383B2_API void b2Body_SetAngularDamping( b2BodyId bodyId, float angularDamping );
384
386B2_API float b2Body_GetAngularDamping( b2BodyId bodyId );
387
390B2_API void b2Body_SetGravityScale( b2BodyId bodyId, float gravityScale );
391
393B2_API float b2Body_GetGravityScale( b2BodyId bodyId );
394
396B2_API bool b2Body_IsAwake( b2BodyId bodyId );
397
401B2_API void b2Body_SetAwake( b2BodyId bodyId, bool awake );
402
404B2_API void b2Body_EnableSleep( b2BodyId bodyId, bool enableSleep );
405
407B2_API bool b2Body_IsSleepEnabled( b2BodyId bodyId );
408
410B2_API void b2Body_SetSleepThreshold( b2BodyId bodyId, float sleepThreshold );
411
413B2_API float b2Body_GetSleepThreshold( b2BodyId bodyId );
414
416B2_API bool b2Body_IsEnabled( b2BodyId bodyId );
417
419B2_API void b2Body_Disable( b2BodyId bodyId );
420
422B2_API void b2Body_Enable( b2BodyId bodyId );
423
425B2_API void b2Body_SetFixedRotation( b2BodyId bodyId, bool flag );
426
428B2_API bool b2Body_IsFixedRotation( b2BodyId bodyId );
429
432B2_API void b2Body_SetBullet( b2BodyId bodyId, bool flag );
433
435B2_API bool b2Body_IsBullet( b2BodyId bodyId );
436
440B2_API void b2Body_EnableContactEvents( b2BodyId bodyId, bool flag );
441
444B2_API void b2Body_EnableHitEvents( b2BodyId bodyId, bool flag );
445
448
450B2_API int b2Body_GetShapeCount( b2BodyId bodyId );
451
454B2_API int b2Body_GetShapes( b2BodyId bodyId, b2ShapeId* shapeArray, int capacity );
455
457B2_API int b2Body_GetJointCount( b2BodyId bodyId );
458
461B2_API int b2Body_GetJoints( b2BodyId bodyId, b2JointId* jointArray, int capacity );
462
465
470B2_API int b2Body_GetContactData( b2BodyId bodyId, b2ContactData* contactData, int capacity );
471
475
477
484
488B2_API b2ShapeId b2CreateCircleShape( b2BodyId bodyId, const b2ShapeDef* def, const b2Circle* circle );
489
493B2_API b2ShapeId b2CreateSegmentShape( b2BodyId bodyId, const b2ShapeDef* def, const b2Segment* segment );
494
498B2_API b2ShapeId b2CreateCapsuleShape( b2BodyId bodyId, const b2ShapeDef* def, const b2Capsule* capsule );
499
503B2_API b2ShapeId b2CreatePolygonShape( b2BodyId bodyId, const b2ShapeDef* def, const b2Polygon* polygon );
504
508B2_API void b2DestroyShape( b2ShapeId shapeId, bool updateBodyMass );
509
511B2_API bool b2Shape_IsValid( b2ShapeId id );
512
515
518
521
525B2_API bool b2Shape_IsSensor( b2ShapeId shapeId );
526
528B2_API void b2Shape_SetUserData( b2ShapeId shapeId, void* userData );
529
532B2_API void* b2Shape_GetUserData( b2ShapeId shapeId );
533
537B2_API void b2Shape_SetDensity( b2ShapeId shapeId, float density, bool updateBodyMass );
538
540B2_API float b2Shape_GetDensity( b2ShapeId shapeId );
541
544B2_API void b2Shape_SetFriction( b2ShapeId shapeId, float friction );
545
547B2_API float b2Shape_GetFriction( b2ShapeId shapeId );
548
551B2_API void b2Shape_SetRestitution( b2ShapeId shapeId, float restitution );
552
554B2_API float b2Shape_GetRestitution( b2ShapeId shapeId );
555
558B2_API void b2Shape_SetMaterial( b2ShapeId shapeId, int material );
559
561B2_API int b2Shape_GetMaterial( b2ShapeId shapeId );
562
565
570B2_API void b2Shape_SetFilter( b2ShapeId shapeId, b2Filter filter );
571
574B2_API void b2Shape_EnableSensorEvents( b2ShapeId shapeId, bool flag );
575
578
582B2_API void b2Shape_EnableContactEvents( b2ShapeId shapeId, bool flag );
583
586
590B2_API void b2Shape_EnablePreSolveEvents( b2ShapeId shapeId, bool flag );
591
594
597B2_API void b2Shape_EnableHitEvents( b2ShapeId shapeId, bool flag );
598
601
603B2_API bool b2Shape_TestPoint( b2ShapeId shapeId, b2Vec2 point );
604
606B2_API b2CastOutput b2Shape_RayCast( b2ShapeId shapeId, const b2RayCastInput* input );
607
610
613
617
620
623
627B2_API void b2Shape_SetCircle( b2ShapeId shapeId, const b2Circle* circle );
628
632B2_API void b2Shape_SetCapsule( b2ShapeId shapeId, const b2Capsule* capsule );
633
635B2_API void b2Shape_SetSegment( b2ShapeId shapeId, const b2Segment* segment );
636
640B2_API void b2Shape_SetPolygon( b2ShapeId shapeId, const b2Polygon* polygon );
641
645
648
653B2_API int b2Shape_GetContactData( b2ShapeId shapeId, b2ContactData* contactData, int capacity );
654
660
668B2_API int b2Shape_GetSensorOverlaps( b2ShapeId shapeId, b2ShapeId* overlaps, int capacity );
669
672
675
679
681
684B2_API b2ChainId b2CreateChain( b2BodyId bodyId, const b2ChainDef* def );
685
687B2_API void b2DestroyChain( b2ChainId chainId );
688
691
693B2_API int b2Chain_GetSegmentCount( b2ChainId chainId );
694
697B2_API int b2Chain_GetSegments( b2ChainId chainId, b2ShapeId* segmentArray, int capacity );
698
701B2_API void b2Chain_SetFriction( b2ChainId chainId, float friction );
702
704B2_API float b2Chain_GetFriction( b2ChainId chainId );
705
708B2_API void b2Chain_SetRestitution( b2ChainId chainId, float restitution );
709
711B2_API float b2Chain_GetRestitution( b2ChainId chainId );
712
715B2_API void b2Chain_SetMaterial( b2ChainId chainId, int material );
716
718B2_API int b2Chain_GetMaterial( b2ChainId chainId );
719
721B2_API bool b2Chain_IsValid( b2ChainId id );
722
724
730
732B2_API void b2DestroyJoint( b2JointId jointId );
733
735B2_API bool b2Joint_IsValid( b2JointId id );
736
739
742
745
748
751
754
756B2_API void b2Joint_SetCollideConnected( b2JointId jointId, bool shouldCollide );
757
760
762B2_API void b2Joint_SetUserData( b2JointId jointId, void* userData );
763
765B2_API void* b2Joint_GetUserData( b2JointId jointId );
766
768B2_API void b2Joint_WakeBodies( b2JointId jointId );
769
772
775
781
785
789B2_API void b2DistanceJoint_SetLength( b2JointId jointId, float length );
790
792B2_API float b2DistanceJoint_GetLength( b2JointId jointId );
793
795B2_API void b2DistanceJoint_EnableSpring( b2JointId jointId, bool enableSpring );
796
799
801B2_API void b2DistanceJoint_SetSpringHertz( b2JointId jointId, float hertz );
802
804B2_API void b2DistanceJoint_SetSpringDampingRatio( b2JointId jointId, float dampingRatio );
805
808
811
814B2_API void b2DistanceJoint_EnableLimit( b2JointId jointId, bool enableLimit );
815
818
820B2_API void b2DistanceJoint_SetLengthRange( b2JointId jointId, float minLength, float maxLength );
821
824
827
830
832B2_API void b2DistanceJoint_EnableMotor( b2JointId jointId, bool enableMotor );
833
836
838B2_API void b2DistanceJoint_SetMotorSpeed( b2JointId jointId, float motorSpeed );
839
842
844B2_API void b2DistanceJoint_SetMaxMotorForce( b2JointId jointId, float force );
845
848
851
853
863
867
869B2_API void b2MotorJoint_SetLinearOffset( b2JointId jointId, b2Vec2 linearOffset );
870
873
875B2_API void b2MotorJoint_SetAngularOffset( b2JointId jointId, float angularOffset );
876
879
881B2_API void b2MotorJoint_SetMaxForce( b2JointId jointId, float maxForce );
882
884B2_API float b2MotorJoint_GetMaxForce( b2JointId jointId );
885
887B2_API void b2MotorJoint_SetMaxTorque( b2JointId jointId, float maxTorque );
888
890B2_API float b2MotorJoint_GetMaxTorque( b2JointId jointId );
891
893B2_API void b2MotorJoint_SetCorrectionFactor( b2JointId jointId, float correctionFactor );
894
897
899
908
912
914B2_API void b2MouseJoint_SetTarget( b2JointId jointId, b2Vec2 target );
915
918
920B2_API void b2MouseJoint_SetSpringHertz( b2JointId jointId, float hertz );
921
924
926B2_API void b2MouseJoint_SetSpringDampingRatio( b2JointId jointId, float dampingRatio );
927
930
932B2_API void b2MouseJoint_SetMaxForce( b2JointId jointId, float maxForce );
933
935B2_API float b2MouseJoint_GetMaxForce( b2JointId jointId );
936
938
947
951
953
962
966
968B2_API void b2PrismaticJoint_EnableSpring( b2JointId jointId, bool enableSpring );
969
972
976B2_API void b2PrismaticJoint_SetSpringHertz( b2JointId jointId, float hertz );
977
980
982B2_API void b2PrismaticJoint_SetSpringDampingRatio( b2JointId jointId, float dampingRatio );
983
986
988B2_API void b2PrismaticJoint_EnableLimit( b2JointId jointId, bool enableLimit );
989
992
995
998
1000B2_API void b2PrismaticJoint_SetLimits( b2JointId jointId, float lower, float upper );
1001
1003B2_API void b2PrismaticJoint_EnableMotor( b2JointId jointId, bool enableMotor );
1004
1007
1009B2_API void b2PrismaticJoint_SetMotorSpeed( b2JointId jointId, float motorSpeed );
1010
1013
1015B2_API void b2PrismaticJoint_SetMaxMotorForce( b2JointId jointId, float force );
1016
1019
1022
1025
1027B2_API float b2PrismaticJoint_GetSpeed( b2JointId jointId );
1028
1030
1039
1043
1045B2_API void b2RevoluteJoint_EnableSpring( b2JointId jointId, bool enableSpring );
1046
1049
1051B2_API void b2RevoluteJoint_SetSpringHertz( b2JointId jointId, float hertz );
1052
1055
1057B2_API void b2RevoluteJoint_SetSpringDampingRatio( b2JointId jointId, float dampingRatio );
1058
1061
1064B2_API float b2RevoluteJoint_GetAngle( b2JointId jointId );
1065
1067B2_API void b2RevoluteJoint_EnableLimit( b2JointId jointId, bool enableLimit );
1068
1071
1074
1077
1080B2_API void b2RevoluteJoint_SetLimits( b2JointId jointId, float lower, float upper );
1081
1083B2_API void b2RevoluteJoint_EnableMotor( b2JointId jointId, bool enableMotor );
1084
1087
1089B2_API void b2RevoluteJoint_SetMotorSpeed( b2JointId jointId, float motorSpeed );
1090
1093
1096
1098B2_API void b2RevoluteJoint_SetMaxMotorTorque( b2JointId jointId, float torque );
1099
1102
1104
1115
1119
1122
1124B2_API void b2WeldJoint_SetReferenceAngle( b2JointId jointId, float angleInRadians );
1125
1127B2_API void b2WeldJoint_SetLinearHertz( b2JointId jointId, float hertz );
1128
1131
1133B2_API void b2WeldJoint_SetLinearDampingRatio( b2JointId jointId, float dampingRatio );
1134
1137
1139B2_API void b2WeldJoint_SetAngularHertz( b2JointId jointId, float hertz );
1140
1143
1145B2_API void b2WeldJoint_SetAngularDampingRatio( b2JointId jointId, float dampingRatio );
1146
1149
1151
1161
1165
1167B2_API void b2WheelJoint_EnableSpring( b2JointId jointId, bool enableSpring );
1168
1171
1173B2_API void b2WheelJoint_SetSpringHertz( b2JointId jointId, float hertz );
1174
1177
1179B2_API void b2WheelJoint_SetSpringDampingRatio( b2JointId jointId, float dampingRatio );
1180
1183
1185B2_API void b2WheelJoint_EnableLimit( b2JointId jointId, bool enableLimit );
1186
1189
1192
1195
1197B2_API void b2WheelJoint_SetLimits( b2JointId jointId, float lower, float upper );
1198
1200B2_API void b2WheelJoint_EnableMotor( b2JointId jointId, bool enableMotor );
1201
1204
1206B2_API void b2WheelJoint_SetMotorSpeed( b2JointId jointId, float motorSpeed );
1207
1210
1212B2_API void b2WheelJoint_SetMaxMotorTorque( b2JointId jointId, float torque );
1213
1216
1219
1221
B2_API b2Vec2 b2Body_GetWorldCenterOfMass(b2BodyId bodyId)
Get the center of mass position of the body in world space.
B2_API b2BodyType b2Body_GetType(b2BodyId bodyId)
Get the body type: static, kinematic, or dynamic.
B2_API void b2Body_SetMassData(b2BodyId bodyId, b2MassData massData)
Override the body's mass properties.
B2_API void * b2Body_GetUserData(b2BodyId bodyId)
Get the user data stored in a body.
B2_API void b2Body_SetGravityScale(b2BodyId bodyId, float gravityScale)
Adjust the gravity scale.
B2_API void b2Body_ApplyLinearImpulse(b2BodyId bodyId, b2Vec2 impulse, b2Vec2 point, bool wake)
Apply an impulse at a point.
B2_API void b2Body_EnableHitEvents(b2BodyId bodyId, bool flag)
Enable/disable hit events on all shapes.
B2_API void b2Body_SetBullet(b2BodyId bodyId, bool flag)
Set this body to be a bullet.
B2_API void b2Body_ApplyForceToCenter(b2BodyId bodyId, b2Vec2 force, bool wake)
Apply a force to the center of mass.
B2_API void b2Body_SetType(b2BodyId bodyId, b2BodyType type)
Change the body type.
B2_API int b2Body_GetJointCount(b2BodyId bodyId)
Get the number of joints on this body.
B2_API float b2Body_GetSleepThreshold(b2BodyId bodyId)
Get the sleep threshold, usually in meters per second.
B2_API void b2Body_ApplyForce(b2BodyId bodyId, b2Vec2 force, b2Vec2 point, bool wake)
Apply a force at a world point.
B2_API float b2Body_GetMass(b2BodyId bodyId)
Get the mass of the body, usually in kilograms.
B2_API void b2Body_SetAwake(b2BodyId bodyId, bool awake)
Wake a body from sleep.
B2_API b2Vec2 b2Body_GetPosition(b2BodyId bodyId)
Get the world position of a body. This is the location of the body origin.
B2_API int b2Body_GetShapeCount(b2BodyId bodyId)
Get the number of shapes on this body.
B2_API float b2Body_GetAngularVelocity(b2BodyId bodyId)
Get the angular velocity of a body in radians per second.
B2_API void b2Body_ApplyMassFromShapes(b2BodyId bodyId)
This update the mass properties to the sum of the mass properties of the shapes.
B2_API b2WorldId b2Body_GetWorld(b2BodyId bodyId)
Get the world that owns this body.
B2_API bool b2Body_IsValid(b2BodyId id)
Body identifier validation. Can be used to detect orphaned ids. Provides validation for up to 64K all...
B2_API b2Vec2 b2Body_GetWorldPointVelocity(b2BodyId bodyId, b2Vec2 worldPoint)
Get the linear velocity of a world point attached to a body. Usually in meters per second.
B2_API void b2Body_SetFixedRotation(b2BodyId bodyId, bool flag)
Set this body to have fixed rotation. This causes the mass to be reset in all cases.
B2_API void b2Body_SetLinearDamping(b2BodyId bodyId, float linearDamping)
Adjust the linear damping. Normally this is set in b2BodyDef before creation.
B2_API bool b2Body_IsSleepEnabled(b2BodyId bodyId)
Returns true if sleeping is enabled for this body.
B2_API b2BodyId b2CreateBody(b2WorldId worldId, const b2BodyDef *def)
Create a rigid body given a definition.
B2_API bool b2Body_IsEnabled(b2BodyId bodyId)
Returns true if this body is enabled.
B2_API void b2Body_ApplyTorque(b2BodyId bodyId, float torque, bool wake)
Apply a torque.
B2_API float b2Body_GetLinearDamping(b2BodyId bodyId)
Get the current linear damping.
B2_API void b2Body_SetUserData(b2BodyId bodyId, void *userData)
Set the user data for a body.
B2_API void b2Body_Disable(b2BodyId bodyId)
Disable a body by removing it completely from the simulation. This is expensive.
B2_API bool b2Body_IsFixedRotation(b2BodyId bodyId)
Does this body have fixed rotation?
B2_API void b2Body_ApplyAngularImpulse(b2BodyId bodyId, float impulse, bool wake)
Apply an angular impulse.
b2BodyType
The body simulation type.
Definition types.h:158
B2_API void b2Body_SetSleepThreshold(b2BodyId bodyId, float sleepThreshold)
Set the sleep threshold, usually in meters per second.
B2_API void b2Body_SetTransform(b2BodyId bodyId, b2Vec2 position, b2Rot rotation)
Set the world transform of a body.
B2_API void b2Body_SetTargetTransform(b2BodyId bodyId, b2Transform target, float timeStep)
Set the velocity to reach the given transform after a given time step.
B2_API void b2Body_EnableSleep(b2BodyId bodyId, bool enableSleep)
Enable or disable sleeping for this body. If sleeping is disabled the body will wake.
B2_API b2Vec2 b2Body_GetLocalCenterOfMass(b2BodyId bodyId)
Get the center of mass position of the body in local space.
B2_API void b2DestroyBody(b2BodyId bodyId)
Destroy a rigid body given an id.
B2_API b2Transform b2Body_GetTransform(b2BodyId bodyId)
Get the world transform of a body.
B2_API void b2Body_Enable(b2BodyId bodyId)
Enable a body by adding it to the simulation. This is expensive.
B2_API float b2Body_GetAngularDamping(b2BodyId bodyId)
Get the current angular damping.
B2_API b2Vec2 b2Body_GetLocalVector(b2BodyId bodyId, b2Vec2 worldVector)
Get a local vector on a body given a world vector.
B2_API b2MassData b2Body_GetMassData(b2BodyId bodyId)
Get the mass data for a body.
B2_API b2Rot b2Body_GetRotation(b2BodyId bodyId)
Get the world rotation of a body as a cosine/sine pair (complex number)
B2_API int b2Body_GetJoints(b2BodyId bodyId, b2JointId *jointArray, int capacity)
Get the joint ids for all joints on this body, up to the provided capacity.
B2_API void b2Body_SetName(b2BodyId bodyId, const char *name)
Set the body name. Up to 31 characters excluding 0 termination.
B2_API b2Vec2 b2Body_GetWorldVector(b2BodyId bodyId, b2Vec2 localVector)
Get a world vector on a body given a local vector.
B2_API void b2Body_SetAngularDamping(b2BodyId bodyId, float angularDamping)
Adjust the angular damping. Normally this is set in b2BodyDef before creation.
B2_API const char * b2Body_GetName(b2BodyId bodyId)
Get the body name. May be null.
B2_API b2Vec2 b2Body_GetLocalPoint(b2BodyId bodyId, b2Vec2 worldPoint)
Get a local point on a body given a world point.
B2_API void b2Body_ApplyLinearImpulseToCenter(b2BodyId bodyId, b2Vec2 impulse, bool wake)
Apply an impulse to the center of mass.
B2_API b2Vec2 b2Body_GetLinearVelocity(b2BodyId bodyId)
Get the linear velocity of a body's center of mass. Usually in meters per second.
B2_API b2Vec2 b2Body_GetLocalPointVelocity(b2BodyId bodyId, b2Vec2 localPoint)
Get the linear velocity of a local point attached to a body. Usually in meters per second.
B2_API int b2Body_GetContactData(b2BodyId bodyId, b2ContactData *contactData, int capacity)
Get the touching contact data for a body.
B2_API void b2Body_SetAngularVelocity(b2BodyId bodyId, float angularVelocity)
Set the angular velocity of a body in radians per second.
B2_API bool b2Body_IsBullet(b2BodyId bodyId)
Is this body a bullet?
B2_API bool b2Body_IsAwake(b2BodyId bodyId)
B2_API b2Vec2 b2Body_GetWorldPoint(b2BodyId bodyId, b2Vec2 localPoint)
Get a world point on a body given a local point.
B2_API int b2Body_GetShapes(b2BodyId bodyId, b2ShapeId *shapeArray, int capacity)
Get the shape ids for all shapes on this body, up to the provided capacity.
B2_API float b2Body_GetGravityScale(b2BodyId bodyId)
Get the current gravity scale.
B2_API float b2Body_GetRotationalInertia(b2BodyId bodyId)
Get the rotational inertia of the body, usually in kg*m^2.
B2_API void b2Body_SetLinearVelocity(b2BodyId bodyId, b2Vec2 linearVelocity)
Set the linear velocity of a body. Usually in meters per second.
B2_API int b2Body_GetContactCapacity(b2BodyId bodyId)
Get the maximum capacity required for retrieving all the touching contacts on a body.
B2_API b2AABB b2Body_ComputeAABB(b2BodyId bodyId)
Get the current world AABB that contains all the attached shapes.
B2_API void b2Body_EnableContactEvents(b2BodyId bodyId, bool flag)
Enable/disable contact events on all shapes.
A body definition holds all the data needed to construct a rigid body.
Definition types.h:178
B2_API void b2DistanceJoint_SetLength(b2JointId jointId, float length)
Set the rest length of a distance joint.
B2_API float b2DistanceJoint_GetMotorForce(b2JointId jointId)
Get the distance joint current motor force, usually in newtons.
B2_API void b2DistanceJoint_EnableLimit(b2JointId jointId, bool enableLimit)
Enable joint limit.
B2_API bool b2DistanceJoint_IsLimitEnabled(b2JointId jointId)
Is the distance joint limit enabled?
B2_API void b2DistanceJoint_SetSpringHertz(b2JointId jointId, float hertz)
Set the spring stiffness in Hertz.
B2_API void b2DistanceJoint_SetLengthRange(b2JointId jointId, float minLength, float maxLength)
Set the minimum and maximum length parameters of a distance joint.
B2_API void b2DistanceJoint_SetMotorSpeed(b2JointId jointId, float motorSpeed)
Set the distance joint motor speed, usually in meters per second.
B2_API b2JointId b2CreateDistanceJoint(b2WorldId worldId, const b2DistanceJointDef *def)
Create a distance joint.
B2_API float b2DistanceJoint_GetLength(b2JointId jointId)
Get the rest length of a distance joint.
B2_API float b2DistanceJoint_GetMaxLength(b2JointId jointId)
Get the distance joint maximum length.
B2_API float b2DistanceJoint_GetSpringDampingRatio(b2JointId jointId)
Get the spring damping ratio.
B2_API float b2DistanceJoint_GetMotorSpeed(b2JointId jointId)
Get the distance joint motor speed, usually in meters per second.
B2_API void b2DistanceJoint_EnableMotor(b2JointId jointId, bool enableMotor)
Enable/disable the distance joint motor.
B2_API float b2DistanceJoint_GetCurrentLength(b2JointId jointId)
Get the current length of a distance joint.
B2_API void b2DistanceJoint_SetMaxMotorForce(b2JointId jointId, float force)
Set the distance joint maximum motor force, usually in newtons.
B2_API bool b2DistanceJoint_IsSpringEnabled(b2JointId jointId)
Is the distance joint spring enabled?
B2_API void b2DistanceJoint_EnableSpring(b2JointId jointId, bool enableSpring)
Enable/disable the distance joint spring. When disabled the distance joint is rigid.
B2_API float b2DistanceJoint_GetMinLength(b2JointId jointId)
Get the distance joint minimum length.
B2_API float b2DistanceJoint_GetMaxMotorForce(b2JointId jointId)
Get the distance joint maximum motor force, usually in newtons.
B2_API bool b2DistanceJoint_IsMotorEnabled(b2JointId jointId)
Is the distance joint motor enabled?
B2_API float b2DistanceJoint_GetSpringHertz(b2JointId jointId)
Get the spring Hertz.
B2_API void b2DistanceJoint_SetSpringDampingRatio(b2JointId jointId, float dampingRatio)
Set the spring damping ratio, non-dimensional.
Distance joint definition.
Definition types.h:539
Body events are buffered in the Box2D world and are available as event arrays after the time step is ...
Definition types.h:1142
The contact data for two shapes.
Definition types.h:1154
Contact events are buffered in the Box2D world and are available as event arrays after the time step ...
Definition types.h:1100
Sensor events are buffered in the Box2D world and are available as begin/end overlap event arrays aft...
Definition types.h:1032
B2_API b2JointId b2CreateFilterJoint(b2WorldId worldId, const b2FilterJointDef *def)
Create a filter joint.
A filter joint is used to disable collision between two specific bodies.
Definition types.h:681
A solid capsule can be viewed as two semicircles connected by a rectangle.
Definition collision.h:116
Low level ray cast or shape-cast output data.
Definition collision.h:73
A line segment with one-sided collision.
Definition collision.h:165
A solid circle.
Definition collision.h:105
This holds the mass data computed for a shape.
Definition collision.h:92
A solid convex polygon.
Definition collision.h:134
Low level ray cast input data.
Definition collision.h:28
A line segment with two-sided collision.
Definition collision.h:153
A distance proxy is used by the GJK algorithm.
Definition collision.h:42
Body id references a body instance. This should be treated as an opaque handle.
Definition id.h:45
Chain id references a chain instances. This should be treated as an opaque handle.
Definition id.h:61
Joint id references a joint instance. This should be treated as an opaque handle.
Definition id.h:69
Shape id references a shape instance. This should be treated as an opaque handle.
Definition id.h:53
World id references a world instance. This should be treated as an opaque handle.
Definition id.h:38
B2_API b2JointType b2Joint_GetType(b2JointId jointId)
Get the joint type.
b2JointType
Joint type enumeration.
Definition types.h:520
B2_API b2WorldId b2Joint_GetWorld(b2JointId jointId)
Get the world that owns this joint.
B2_API void * b2Joint_GetUserData(b2JointId jointId)
Get the user data on a joint.
B2_API void b2Joint_SetCollideConnected(b2JointId jointId, bool shouldCollide)
Toggle collision between connected bodies.
B2_API bool b2Joint_GetCollideConnected(b2JointId jointId)
Is collision allowed between connected bodies?
B2_API bool b2Joint_IsValid(b2JointId id)
Joint identifier validation. Provides validation for up to 64K allocations.
B2_API b2Vec2 b2Joint_GetLocalAnchorA(b2JointId jointId)
Get the local anchor on bodyA.
B2_API b2Vec2 b2Joint_GetConstraintForce(b2JointId jointId)
Get the current constraint force for this joint. Usually in Newtons.
B2_API b2BodyId b2Joint_GetBodyB(b2JointId jointId)
Get body B id on a joint.
B2_API b2BodyId b2Joint_GetBodyA(b2JointId jointId)
Get body A id on a joint.
B2_API b2Vec2 b2Joint_GetLocalAnchorB(b2JointId jointId)
Get the local anchor on bodyB.
B2_API float b2Joint_GetConstraintTorque(b2JointId jointId)
Get the current constraint torque for this joint. Usually in Newton * meters.
B2_API void b2Joint_WakeBodies(b2JointId jointId)
Wake the bodies connect to this joint.
B2_API void b2DestroyJoint(b2JointId jointId)
Destroy a joint.
B2_API void b2Joint_SetUserData(b2JointId jointId, void *userData)
Set the user data on a joint.
Axis-aligned bounding box.
Definition math_functions.h:59
2D rotation This is similar to using a complex number for rotation
Definition math_functions.h:38
A 2D rigid transform.
Definition math_functions.h:45
2D vector This can be used to represent a point or free vector
Definition math_functions.h:21
B2_API void b2MotorJoint_SetAngularOffset(b2JointId jointId, float angularOffset)
Set the motor joint angular offset target in radians.
B2_API void b2MotorJoint_SetLinearOffset(b2JointId jointId, b2Vec2 linearOffset)
Set the motor joint linear offset target.
B2_API void b2MotorJoint_SetMaxTorque(b2JointId jointId, float maxTorque)
Set the motor joint maximum torque, usually in newton-meters.
B2_API b2Vec2 b2MotorJoint_GetLinearOffset(b2JointId jointId)
Get the motor joint linear offset target.
B2_API void b2MotorJoint_SetMaxForce(b2JointId jointId, float maxForce)
Set the motor joint maximum force, usually in newtons.
B2_API float b2MotorJoint_GetAngularOffset(b2JointId jointId)
Get the motor joint angular offset target in radians.
B2_API float b2MotorJoint_GetCorrectionFactor(b2JointId jointId)
Get the motor joint correction factor, usually in [0, 1].
B2_API float b2MotorJoint_GetMaxTorque(b2JointId jointId)
Get the motor joint maximum torque, usually in newton-meters.
B2_API float b2MotorJoint_GetMaxForce(b2JointId jointId)
Get the motor joint maximum force, usually in newtons.
B2_API void b2MotorJoint_SetCorrectionFactor(b2JointId jointId, float correctionFactor)
Set the motor joint correction factor, usually in [0, 1].
B2_API b2JointId b2CreateMotorJoint(b2WorldId worldId, const b2MotorJointDef *def)
Create a motor joint.
A motor joint is used to control the relative motion between two bodies.
Definition types.h:602
B2_API b2Vec2 b2MouseJoint_GetTarget(b2JointId jointId)
Get the mouse joint target.
B2_API void b2MouseJoint_SetMaxForce(b2JointId jointId, float maxForce)
Set the mouse joint maximum force, usually in newtons.
B2_API void b2MouseJoint_SetSpringHertz(b2JointId jointId, float hertz)
Set the mouse joint spring stiffness in Hertz.
B2_API void b2MouseJoint_SetSpringDampingRatio(b2JointId jointId, float dampingRatio)
Set the mouse joint spring damping ratio, non-dimensional.
B2_API float b2MouseJoint_GetSpringDampingRatio(b2JointId jointId)
Get the mouse joint damping ratio, non-dimensional.
B2_API b2JointId b2CreateMouseJoint(b2WorldId worldId, const b2MouseJointDef *def)
Create a mouse joint.
B2_API void b2MouseJoint_SetTarget(b2JointId jointId, b2Vec2 target)
Set the mouse joint target.
B2_API float b2MouseJoint_GetSpringHertz(b2JointId jointId)
Get the mouse joint spring stiffness in Hertz.
B2_API float b2MouseJoint_GetMaxForce(b2JointId jointId)
Get the mouse joint maximum force, usually in newtons.
A mouse joint is used to make a point on a body track a specified world point.
Definition types.h:644
B2_API bool b2PrismaticJoint_IsLimitEnabled(b2JointId jointId)
Is the prismatic joint limit enabled?
B2_API float b2PrismaticJoint_GetUpperLimit(b2JointId jointId)
Get the prismatic joint upper limit.
B2_API void b2PrismaticJoint_SetSpringHertz(b2JointId jointId, float hertz)
Set the prismatic joint stiffness in Hertz.
B2_API b2JointId b2CreatePrismaticJoint(b2WorldId worldId, const b2PrismaticJointDef *def)
Create a prismatic (slider) joint.
B2_API void b2PrismaticJoint_SetSpringDampingRatio(b2JointId jointId, float dampingRatio)
Set the prismatic joint damping ratio (non-dimensional)
B2_API float b2PrismaticJoint_GetSpringHertz(b2JointId jointId)
Get the prismatic joint stiffness in Hertz.
B2_API float b2PrismaticJoint_GetMaxMotorForce(b2JointId jointId)
Get the prismatic joint maximum motor force, usually in newtons.
B2_API bool b2PrismaticJoint_IsSpringEnabled(b2JointId jointId)
Is the prismatic joint spring enabled or not?
B2_API void b2PrismaticJoint_EnableLimit(b2JointId jointId, bool enableLimit)
Enable/disable a prismatic joint limit.
B2_API float b2PrismaticJoint_GetSpringDampingRatio(b2JointId jointId)
Get the prismatic spring damping ratio (non-dimensional)
B2_API void b2PrismaticJoint_SetMaxMotorForce(b2JointId jointId, float force)
Set the prismatic joint maximum motor force, usually in newtons.
B2_API float b2PrismaticJoint_GetLowerLimit(b2JointId jointId)
Get the prismatic joint lower limit.
B2_API void b2PrismaticJoint_SetMotorSpeed(b2JointId jointId, float motorSpeed)
Set the prismatic joint motor speed, usually in meters per second.
B2_API float b2PrismaticJoint_GetSpeed(b2JointId jointId)
Get the current joint translation speed, usually in meters per second.
B2_API float b2PrismaticJoint_GetMotorSpeed(b2JointId jointId)
Get the prismatic joint motor speed, usually in meters per second.
B2_API void b2PrismaticJoint_SetLimits(b2JointId jointId, float lower, float upper)
Set the prismatic joint limits.
B2_API float b2PrismaticJoint_GetTranslation(b2JointId jointId)
Get the current joint translation, usually in meters.
B2_API void b2PrismaticJoint_EnableSpring(b2JointId jointId, bool enableSpring)
Enable/disable the joint spring.
B2_API bool b2PrismaticJoint_IsMotorEnabled(b2JointId jointId)
Is the prismatic joint motor enabled?
B2_API float b2PrismaticJoint_GetMotorForce(b2JointId jointId)
Get the prismatic joint current motor force, usually in newtons.
B2_API void b2PrismaticJoint_EnableMotor(b2JointId jointId, bool enableMotor)
Enable/disable a prismatic joint motor.
Prismatic joint definition.
Definition types.h:707
B2_API void b2RevoluteJoint_EnableMotor(b2JointId jointId, bool enableMotor)
Enable/disable a revolute joint motor.
B2_API float b2RevoluteJoint_GetUpperLimit(b2JointId jointId)
Get the revolute joint upper limit in radians.
B2_API float b2RevoluteJoint_GetSpringHertz(b2JointId jointId)
Get the revolute joint spring stiffness in Hertz.
B2_API float b2RevoluteJoint_GetLowerLimit(b2JointId jointId)
Get the revolute joint lower limit in radians.
B2_API float b2RevoluteJoint_GetMaxMotorTorque(b2JointId jointId)
Get the revolute joint maximum motor torque, usually in newton-meters.
B2_API bool b2RevoluteJoint_IsSpringEnabled(b2JointId jointId)
It the revolute angular spring enabled?
B2_API float b2RevoluteJoint_GetMotorSpeed(b2JointId jointId)
Get the revolute joint motor speed in radians per second.
B2_API float b2RevoluteJoint_GetMotorTorque(b2JointId jointId)
Get the revolute joint current motor torque, usually in newton-meters.
B2_API b2JointId b2CreateRevoluteJoint(b2WorldId worldId, const b2RevoluteJointDef *def)
Create a revolute joint.
B2_API void b2RevoluteJoint_EnableSpring(b2JointId jointId, bool enableSpring)
Enable/disable the revolute joint spring.
B2_API void b2RevoluteJoint_EnableLimit(b2JointId jointId, bool enableLimit)
Enable/disable the revolute joint limit.
B2_API bool b2RevoluteJoint_IsLimitEnabled(b2JointId jointId)
Is the revolute joint limit enabled?
B2_API void b2RevoluteJoint_SetMaxMotorTorque(b2JointId jointId, float torque)
Set the revolute joint maximum motor torque, usually in newton-meters.
B2_API void b2RevoluteJoint_SetSpringHertz(b2JointId jointId, float hertz)
Set the revolute joint spring stiffness in Hertz.
B2_API void b2RevoluteJoint_SetLimits(b2JointId jointId, float lower, float upper)
Set the revolute joint limits in radians.
B2_API float b2RevoluteJoint_GetAngle(b2JointId jointId)
Get the revolute joint current angle in radians relative to the reference angle.
B2_API void b2RevoluteJoint_SetMotorSpeed(b2JointId jointId, float motorSpeed)
Set the revolute joint motor speed in radians per second.
B2_API bool b2RevoluteJoint_IsMotorEnabled(b2JointId jointId)
Is the revolute joint motor enabled?
B2_API void b2RevoluteJoint_SetSpringDampingRatio(b2JointId jointId, float dampingRatio)
Set the revolute joint spring damping ratio, non-dimensional.
B2_API float b2RevoluteJoint_GetSpringDampingRatio(b2JointId jointId)
Get the revolute joint spring damping ratio, non-dimensional.
Revolute joint definition.
Definition types.h:780
B2_API int b2Chain_GetSegments(b2ChainId chainId, b2ShapeId *segmentArray, int capacity)
Fill a user array with chain segment shape ids up to the specified capacity.
B2_API bool b2Shape_TestPoint(b2ShapeId shapeId, b2Vec2 point)
Test a point for overlap with a shape.
B2_API b2WorldId b2Chain_GetWorld(b2ChainId chainId)
Get the world that owns this chain shape.
B2_API float b2Shape_GetFriction(b2ShapeId shapeId)
Get the friction of a shape.
B2_API void b2Shape_SetCapsule(b2ShapeId shapeId, const b2Capsule *capsule)
Allows you to change a shape to be a capsule or update the current capsule.
B2_API void b2Shape_SetDensity(b2ShapeId shapeId, float density, bool updateBodyMass)
Set the mass density of a shape, usually in kg/m^2.
B2_API void b2Chain_SetFriction(b2ChainId chainId, float friction)
Set the chain friction.
B2_API b2ShapeId b2CreateCapsuleShape(b2BodyId bodyId, const b2ShapeDef *def, const b2Capsule *capsule)
Create a capsule shape and attach it to a body.
B2_API bool b2Shape_AreContactEventsEnabled(b2ShapeId shapeId)
Returns true if contact events are enabled.
B2_API b2Segment b2Shape_GetSegment(b2ShapeId shapeId)
Get a copy of the shape's line segment. Asserts the type is correct.
B2_API float b2Chain_GetFriction(b2ChainId chainId)
Get the chain friction.
B2_API int b2Chain_GetMaterial(b2ChainId chainId)
Get the chain material.
B2_API void b2Shape_SetPolygon(b2ShapeId shapeId, const b2Polygon *polygon)
Allows you to change a shape to be a polygon or update the current polygon.
B2_API int b2Shape_GetSensorOverlaps(b2ShapeId shapeId, b2ShapeId *overlaps, int capacity)
Get the overlapped shapes for a sensor shape.
B2_API int b2Shape_GetMaterial(b2ShapeId shapeId)
Get the shape material identifier.
B2_API int b2Shape_GetContactData(b2ShapeId shapeId, b2ContactData *contactData, int capacity)
Get the touching contact data for a shape.
B2_API b2ShapeId b2CreateSegmentShape(b2BodyId bodyId, const b2ShapeDef *def, const b2Segment *segment)
Create a line segment shape and attach it to a body.
B2_API bool b2Chain_IsValid(b2ChainId id)
Chain identifier validation. Provides validation for up to 64K allocations.
B2_API b2ShapeId b2CreatePolygonShape(b2BodyId bodyId, const b2ShapeDef *def, const b2Polygon *polygon)
Create a polygon shape and attach it to a body.
B2_API b2WorldId b2Shape_GetWorld(b2ShapeId shapeId)
Get the world that owns this shape.
B2_API b2ChainSegment b2Shape_GetChainSegment(b2ShapeId shapeId)
Get a copy of the shape's chain segment.
B2_API b2Vec2 b2Shape_GetClosestPoint(b2ShapeId shapeId, b2Vec2 target)
Get the closest point on a shape to a target point.
B2_API bool b2Shape_IsValid(b2ShapeId id)
Shape identifier validation. Provides validation for up to 64K allocations.
B2_API float b2Shape_GetDensity(b2ShapeId shapeId)
Get the density of a shape, usually in kg/m^2.
B2_API b2ShapeType b2Shape_GetType(b2ShapeId shapeId)
Get the type of a shape.
B2_API void * b2Shape_GetUserData(b2ShapeId shapeId)
Get the user data for a shape.
B2_API void b2Shape_EnablePreSolveEvents(b2ShapeId shapeId, bool flag)
Enable pre-solve contact events for this shape.
B2_API void b2Shape_EnableHitEvents(b2ShapeId shapeId, bool flag)
Enable contact hit events for this shape.
B2_API b2ChainId b2CreateChain(b2BodyId bodyId, const b2ChainDef *def)
Chain Shape.
B2_API int b2Shape_GetSensorCapacity(b2ShapeId shapeId)
Get the maximum capacity required for retrieving all the overlapped shapes on a sensor shape.
B2_API bool b2Shape_AreHitEventsEnabled(b2ShapeId shapeId)
Returns true if hit events are enabled.
B2_API b2BodyId b2Shape_GetBody(b2ShapeId shapeId)
Get the id of the body that a shape is attached to.
B2_API void b2Shape_SetFilter(b2ShapeId shapeId, b2Filter filter)
Set the current filter.
b2ShapeType
Shape type.
Definition types.h:313
B2_API int b2Chain_GetSegmentCount(b2ChainId chainId)
Get the number of segments on this chain.
B2_API float b2Shape_GetRestitution(b2ShapeId shapeId)
Get the shape restitution.
B2_API void b2Shape_EnableContactEvents(b2ShapeId shapeId, bool flag)
Enable contact events for this shape.
B2_API b2ChainId b2Shape_GetParentChain(b2ShapeId shapeId)
Get the parent chain id if the shape type is a chain segment, otherwise returns b2_nullChainId.
B2_API b2CastOutput b2Shape_RayCast(b2ShapeId shapeId, const b2RayCastInput *input)
Ray cast a shape directly.
B2_API float b2Chain_GetRestitution(b2ChainId chainId)
Get the chain restitution.
B2_API b2Capsule b2Shape_GetCapsule(b2ShapeId shapeId)
Get a copy of the shape's capsule. Asserts the type is correct.
B2_API void b2DestroyChain(b2ChainId chainId)
Destroy a chain shape.
B2_API void b2Shape_SetSegment(b2ShapeId shapeId, const b2Segment *segment)
Allows you to change a shape to be a segment or update the current segment.
B2_API b2AABB b2Shape_GetAABB(b2ShapeId shapeId)
Get the current world AABB.
B2_API void b2DestroyShape(b2ShapeId shapeId, bool updateBodyMass)
Destroy a shape.
B2_API void b2Chain_SetRestitution(b2ChainId chainId, float restitution)
Set the chain restitution (bounciness)
B2_API bool b2Shape_ArePreSolveEventsEnabled(b2ShapeId shapeId)
Returns true if pre-solve events are enabled.
B2_API b2Filter b2Shape_GetFilter(b2ShapeId shapeId)
Get the shape filter.
B2_API void b2Shape_SetFriction(b2ShapeId shapeId, float friction)
Set the friction on a shape.
B2_API void b2Shape_SetRestitution(b2ShapeId shapeId, float restitution)
Set the shape restitution (bounciness)
B2_API b2Circle b2Shape_GetCircle(b2ShapeId shapeId)
Get a copy of the shape's circle. Asserts the type is correct.
B2_API void b2Shape_SetUserData(b2ShapeId shapeId, void *userData)
Set the user data for a shape.
B2_API bool b2Shape_AreSensorEventsEnabled(b2ShapeId shapeId)
Returns true if sensor events are enabled.
B2_API void b2Shape_SetCircle(b2ShapeId shapeId, const b2Circle *circle)
Allows you to change a shape to be a circle or update the current circle.
B2_API void b2Shape_EnableSensorEvents(b2ShapeId shapeId, bool flag)
Enable sensor events for this shape.
B2_API b2MassData b2Shape_GetMassData(b2ShapeId shapeId)
Get the mass data for a shape.
B2_API int b2Shape_GetContactCapacity(b2ShapeId shapeId)
Get the maximum capacity required for retrieving all the touching contacts on a shape.
B2_API b2Polygon b2Shape_GetPolygon(b2ShapeId shapeId)
Get a copy of the shape's convex polygon. Asserts the type is correct.
B2_API b2ShapeId b2CreateCircleShape(b2BodyId bodyId, const b2ShapeDef *def, const b2Circle *circle)
Create a circle shape and attach it to a body.
B2_API void b2Chain_SetMaterial(b2ChainId chainId, int material)
Set the chain material.
B2_API void b2Shape_SetMaterial(b2ShapeId shapeId, int material)
Set the shape material identifier.
B2_API bool b2Shape_IsSensor(b2ShapeId shapeId)
Returns true if the shape is a sensor.
Used to create a chain of line segments.
Definition types.h:435
This is used to filter collision on shapes.
Definition types.h:255
The query filter is used to filter collisions between queries and shapes.
Definition types.h:297
Used to create a shape.
Definition types.h:368
These are performance results returned by dynamic tree queries.
Definition collision.h:659
B2_API float b2WeldJoint_GetAngularDampingRatio(b2JointId jointId)
Get the weld joint angular damping ratio, non-dimensional.
B2_API void b2WeldJoint_SetAngularHertz(b2JointId jointId, float hertz)
Set the weld joint angular stiffness in Hertz. 0 is rigid.
B2_API float b2WeldJoint_GetLinearHertz(b2JointId jointId)
Get the weld joint linear stiffness in Hertz.
B2_API float b2WeldJoint_GetLinearDampingRatio(b2JointId jointId)
Get the weld joint linear damping ratio (non-dimensional)
B2_API void b2WeldJoint_SetLinearDampingRatio(b2JointId jointId, float dampingRatio)
Set the weld joint linear damping ratio (non-dimensional)
B2_API void b2WeldJoint_SetAngularDampingRatio(b2JointId jointId, float dampingRatio)
Set weld joint angular damping ratio, non-dimensional.
B2_API float b2WeldJoint_GetReferenceAngle(b2JointId jointId)
Get the weld joint reference angle in radians.
B2_API void b2WeldJoint_SetReferenceAngle(b2JointId jointId, float angleInRadians)
Set the weld joint reference angle in radians, must be in [-pi,pi].
B2_API float b2WeldJoint_GetAngularHertz(b2JointId jointId)
Get the weld joint angular stiffness in Hertz.
B2_API void b2WeldJoint_SetLinearHertz(b2JointId jointId, float hertz)
Set the weld joint linear stiffness in Hertz. 0 is rigid.
B2_API b2JointId b2CreateWeldJoint(b2WorldId worldId, const b2WeldJointDef *def)
Create a weld joint.
Weld joint definition.
Definition types.h:848
B2_API float b2WheelJoint_GetSpringHertz(b2JointId jointId)
Get the wheel joint stiffness in Hertz.
B2_API void b2WheelJoint_SetLimits(b2JointId jointId, float lower, float upper)
Set the wheel joint limits.
B2_API void b2WheelJoint_EnableMotor(b2JointId jointId, bool enableMotor)
Enable/disable the wheel joint motor.
B2_API void b2WheelJoint_SetSpringHertz(b2JointId jointId, float hertz)
Set the wheel joint stiffness in Hertz.
B2_API float b2WheelJoint_GetSpringDampingRatio(b2JointId jointId)
Get the wheel joint damping ratio, non-dimensional.
B2_API float b2WheelJoint_GetUpperLimit(b2JointId jointId)
Get the wheel joint upper limit.
B2_API float b2WheelJoint_GetMotorSpeed(b2JointId jointId)
Get the wheel joint motor speed in radians per second.
B2_API bool b2WheelJoint_IsMotorEnabled(b2JointId jointId)
Is the wheel joint motor enabled?
B2_API float b2WheelJoint_GetLowerLimit(b2JointId jointId)
Get the wheel joint lower limit.
B2_API float b2WheelJoint_GetMaxMotorTorque(b2JointId jointId)
Get the wheel joint maximum motor torque, usually in newton-meters.
B2_API void b2WheelJoint_EnableLimit(b2JointId jointId, bool enableLimit)
Enable/disable the wheel joint limit.
B2_API float b2WheelJoint_GetMotorTorque(b2JointId jointId)
Get the wheel joint current motor torque, usually in newton-meters.
B2_API bool b2WheelJoint_IsSpringEnabled(b2JointId jointId)
Is the wheel joint spring enabled?
B2_API void b2WheelJoint_SetSpringDampingRatio(b2JointId jointId, float dampingRatio)
Set the wheel joint damping ratio, non-dimensional.
B2_API bool b2WheelJoint_IsLimitEnabled(b2JointId jointId)
Is the wheel joint limit enabled?
B2_API void b2WheelJoint_SetMaxMotorTorque(b2JointId jointId, float torque)
Set the wheel joint maximum motor torque, usually in newton-meters.
B2_API void b2WheelJoint_EnableSpring(b2JointId jointId, bool enableSpring)
Enable/disable the wheel joint spring.
B2_API b2JointId b2CreateWheelJoint(b2WorldId worldId, const b2WheelJointDef *def)
Create a wheel joint.
B2_API void b2WheelJoint_SetMotorSpeed(b2JointId jointId, float motorSpeed)
Set the wheel joint motor speed in radians per second.
Wheel joint definition.
Definition types.h:899
B2_API int b2World_GetAwakeBodyCount(b2WorldId worldId)
Get the number of awake bodies.
float b2FrictionCallback(float frictionA, int userMaterialIdA, float frictionB, int userMaterialIdB)
Optional friction mixing callback.
Definition types.h:56
B2_API bool b2World_IsSleepingEnabled(b2WorldId worldId)
Is body sleeping enabled?
B2_API void b2World_SetRestitutionThreshold(b2WorldId worldId, float value)
Adjust the restitution threshold.
bool b2OverlapResultFcn(b2ShapeId shapeId, void *context)
Prototype callback for overlap queries.
Definition types.h:1196
B2_API float b2World_GetHitEventThreshold(b2WorldId worldId)
Get the the hit event speed threshold. Usually in meters per second.
B2_API void b2World_SetJointTuning(b2WorldId worldId, float hertz, float dampingRatio)
Adjust joint tuning parameters.
B2_API void b2World_EnableWarmStarting(b2WorldId worldId, bool flag)
Enable/disable constraint warm starting.
B2_API void b2World_Draw(b2WorldId worldId, b2DebugDraw *draw)
Call this to draw shapes and other debug draw data.
float b2RestitutionCallback(float restitutionA, int userMaterialIdA, float restitutionB, int userMaterialIdB)
Optional restitution mixing callback.
Definition types.h:62
B2_API void b2World_SetRestitutionCallback(b2WorldId worldId, b2RestitutionCallback *callback)
Set the restitution callback. Passing NULL resets to default.
B2_API void b2World_SetCustomFilterCallback(b2WorldId worldId, b2CustomFilterFcn *fcn, void *context)
Register the custom filter callback. This is optional.
B2_API void b2World_DumpMemoryStats(b2WorldId worldId)
Dump memory stats to box2d_memory.txt.
B2_API void b2World_RebuildStaticTree(b2WorldId worldId)
This is for internal testing.
B2_API b2BodyEvents b2World_GetBodyEvents(b2WorldId worldId)
Get the body events for the current time step. The event data is transient. Do not store a reference ...
B2_API void b2World_Explode(b2WorldId worldId, const b2ExplosionDef *explosionDef)
Apply a radial explosion.
B2_API b2SensorEvents b2World_GetSensorEvents(b2WorldId worldId)
Get sensor events for the current time step. The event data is transient. Do not store a reference to...
B2_API void b2World_EnableSleeping(b2WorldId worldId, bool flag)
Enable/disable sleep.
B2_API void b2World_CollideMover(b2WorldId worldId, const b2Capsule *mover, b2QueryFilter filter, b2PlaneResultFcn *fcn, void *context)
Collide a capsule mover with the world, gathering collision planes that can be fed to b2SolvePlanes.
B2_API void b2World_EnableContinuous(b2WorldId worldId, bool flag)
Enable/disable continuous collision between dynamic and static bodies.
B2_API b2Counters b2World_GetCounters(b2WorldId worldId)
Get world counters and sizes.
B2_API void b2World_EnableSpeculative(b2WorldId worldId, bool flag)
This is for internal testing.
B2_API void b2World_SetHitEventThreshold(b2WorldId worldId, float value)
Adjust the hit event threshold.
B2_API void b2World_Step(b2WorldId worldId, float timeStep, int subStepCount)
Simulate a world for one time step.
B2_API void b2DestroyWorld(b2WorldId worldId)
Destroy a world.
B2_API b2RayResult b2World_CastRayClosest(b2WorldId worldId, b2Vec2 origin, b2Vec2 translation, b2QueryFilter filter)
Cast a ray into the world to collect the closest hit.
B2_API b2ContactEvents b2World_GetContactEvents(b2WorldId worldId)
Get contact events for this current time step. The event data is transient. Do not store a reference ...
B2_API float b2World_GetRestitutionThreshold(b2WorldId worldId)
Get the the restitution speed threshold. Usually in meters per second.
B2_API bool b2World_IsValid(b2WorldId id)
World id validation. Provides validation for up to 64K allocations.
B2_API void b2World_SetContactTuning(b2WorldId worldId, float hertz, float dampingRatio, float pushSpeed)
Adjust contact tuning parameters.
B2_API void b2World_SetMaximumLinearSpeed(b2WorldId worldId, float maximumLinearSpeed)
Set the maximum linear speed. Usually in m/s.
B2_API b2Vec2 b2World_GetGravity(b2WorldId worldId)
Get the gravity vector.
B2_API b2WorldId b2CreateWorld(const b2WorldDef *def)
Create a world for rigid body simulation.
bool b2PreSolveFcn(b2ShapeId shapeIdA, b2ShapeId shapeIdB, b2Manifold *manifold, void *context)
Prototype for a pre-solve callback.
Definition types.h:1189
B2_API void b2World_SetUserData(b2WorldId worldId, void *userData)
Set the user data pointer.
B2_API bool b2World_IsContinuousEnabled(b2WorldId worldId)
Is continuous collision enabled?
B2_API void * b2World_GetUserData(b2WorldId worldId)
Get the user data pointer.
float b2CastResultFcn(b2ShapeId shapeId, b2Vec2 point, b2Vec2 normal, float fraction, void *context)
Prototype callback for ray casts.
Definition types.h:1213
B2_API b2TreeStats b2World_OverlapAABB(b2WorldId worldId, b2AABB aabb, b2QueryFilter filter, b2OverlapResultFcn *fcn, void *context)
Overlap test for all shapes that potentially overlap the provided AABB.
B2_API bool b2World_IsWarmStartingEnabled(b2WorldId worldId)
Is constraint warm starting enabled?
B2_API float b2World_GetMaximumLinearSpeed(b2WorldId worldId)
Get the maximum linear speed. Usually in m/s.
B2_API b2TreeStats b2World_CastShape(b2WorldId worldId, const b2ShapeProxy *proxy, b2Vec2 translation, b2QueryFilter filter, b2CastResultFcn *fcn, void *context)
Cast a shape through the world.
B2_API b2TreeStats b2World_CastRay(b2WorldId worldId, b2Vec2 origin, b2Vec2 translation, b2QueryFilter filter, b2CastResultFcn *fcn, void *context)
Cast a ray into the world to collect shapes in the path of the ray.
B2_API b2Profile b2World_GetProfile(b2WorldId worldId)
Get the current world performance profile.
B2_API void b2World_SetPreSolveCallback(b2WorldId worldId, b2PreSolveFcn *fcn, void *context)
Register the pre-solve callback. This is optional.
B2_API b2TreeStats b2World_OverlapShape(b2WorldId worldId, const b2ShapeProxy *proxy, b2QueryFilter filter, b2OverlapResultFcn *fcn, void *context)
Overlap test for all shapes that overlap the provided shape proxy.
B2_API void b2World_SetGravity(b2WorldId worldId, b2Vec2 gravity)
Set the gravity vector for the entire world.
bool b2CustomFilterFcn(b2ShapeId shapeIdA, b2ShapeId shapeIdB, void *context)
Prototype for a contact filter callback.
Definition types.h:1174
B2_API float b2World_CastMover(b2WorldId worldId, const b2Capsule *mover, b2Vec2 translation, b2QueryFilter filter)
Cast a capsule mover through the world.
B2_API void b2World_SetFrictionCallback(b2WorldId worldId, b2FrictionCallback *callback)
Set the friction callback. Passing NULL resets to default.
This struct holds callbacks you can implement to draw a Box2D world.
Definition types.h:1377
The explosion definition is used to configure options for explosions.
Definition types.h:960
Result from b2World_RayCastClosest.
Definition types.h:67
World definition used to create a simulation world.
Definition types.h:81