Skip to content

Instantly share code, notes, and snippets.

@waldnercharles
Last active October 12, 2024 06:32
Show Gist options
  • Save waldnercharles/3d69da3695f28b6a290ba2aa132dc9c3 to your computer and use it in GitHub Desktop.
Save waldnercharles/3d69da3695f28b6a290ba2aa132dc9c3 to your computer and use it in GitHub Desktop.
local ffi = require 'ffi'
ffi.cdef [[
typedef void* b2AllocFcn( unsigned int size, int alignment );
typedef void b2FreeFcn( void* mem );
typedef int b2AssertFcn( const char* condition, const char* fileName, int lineNumber );
void b2SetAllocator( b2AllocFcn* allocFcn, b2FreeFcn* freeFcn );
int b2GetByteCount( void );
void b2SetAssertFcn( b2AssertFcn* assertFcn );
typedef struct b2Version { int major; int minor; int revision; } b2Version;
b2Version b2GetVersion( void );
typedef struct b2Timer { int64_t start; } b2Timer;
b2Timer b2CreateTimer( void );
int64_t b2GetTicks( b2Timer* timer );
float b2GetMilliseconds( const b2Timer* timer );
float b2GetMillisecondsAndReset( b2Timer* timer );
void b2SleepMilliseconds( int milliseconds );
void b2Yield( void );
uint32_t b2Hash( uint32_t hash, const uint8_t* data, int count );
typedef struct b2Vec2 { float x, y; } b2Vec2;
typedef struct b2CosSin { float cosine; float sine; } b2CosSin;
typedef struct b2Rot { float c, s; } b2Rot;
typedef struct b2Transform { b2Vec2 p; b2Rot q; } b2Transform;
typedef struct b2Mat22 { b2Vec2 cx, cy; } b2Mat22;
typedef struct b2AABB { b2Vec2 lowerBound; b2Vec2 upperBound; } b2AABB;
float b2Atan2( float y, float x );
b2CosSin b2ComputeCosSin( float angle );
bool b2IsValid( float a );
bool b2Vec2_IsValid( b2Vec2 v );
bool b2Rot_IsValid( b2Rot q );
bool b2AABB_IsValid( b2AABB aabb );
void b2SetLengthUnitsPerMeter( float lengthUnits );
float b2GetLengthUnitsPerMeter( void );
typedef struct b2Circle b2Circle;
typedef struct b2Capsule b2Capsule;
typedef struct b2DistanceCache b2DistanceCache;
typedef struct b2Polygon b2Polygon;
typedef struct b2Segment b2Segment;
typedef struct b2ChainSegment b2ChainSegment;
typedef struct b2Hull b2Hull;
typedef struct b2RayCastInput { b2Vec2 origin; b2Vec2 translation; float maxFraction; } b2RayCastInput;
typedef struct b2ShapeCastInput { b2Vec2 points[8]; int32_t count; float radius; b2Vec2 translation; float maxFraction; } b2ShapeCastInput;
typedef struct b2CastOutput
{
b2Vec2 normal;
b2Vec2 point;
float fraction;
int32_t iterations;
bool hit;
} b2CastOutput;
typedef struct b2MassData
{
float mass;
b2Vec2 center;
float rotationalInertia;
} b2MassData;
typedef struct b2Circle
{
b2Vec2 center;
float radius;
} b2Circle;
typedef struct b2Capsule
{
b2Vec2 center1;
b2Vec2 center2;
float radius;
} b2Capsule;
typedef struct b2Polygon
{
b2Vec2 vertices[8];
b2Vec2 normals[8];
b2Vec2 centroid;
float radius;
int32_t count;
} b2Polygon;
typedef struct b2Segment
{
b2Vec2 point1;
b2Vec2 point2;
} b2Segment;
typedef struct b2ChainSegment
{
b2Vec2 ghost1;
b2Segment segment;
b2Vec2 ghost2;
int32_t chainId;
} b2ChainSegment;
bool b2IsValidRay( const b2RayCastInput* input );
b2Polygon b2MakePolygon( const b2Hull* hull, float radius );
b2Polygon b2MakeOffsetPolygon( const b2Hull* hull, float radius, b2Transform transform );
b2Polygon b2MakeSquare( float h );
b2Polygon b2MakeBox( float hx, float hy );
b2Polygon b2MakeRoundedBox( float hx, float hy, float radius );
b2Polygon b2MakeOffsetBox( float hx, float hy, b2Vec2 center, b2Rot rotation );
b2Polygon b2TransformPolygon( b2Transform transform, const b2Polygon* polygon );
b2MassData b2ComputeCircleMass( const b2Circle* shape, float density );
b2MassData b2ComputeCapsuleMass( const b2Capsule* shape, float density );
b2MassData b2ComputePolygonMass( const b2Polygon* shape, float density );
b2AABB b2ComputeCircleAABB( const b2Circle* shape, b2Transform transform );
b2AABB b2ComputeCapsuleAABB( const b2Capsule* shape, b2Transform transform );
b2AABB b2ComputePolygonAABB( const b2Polygon* shape, b2Transform transform );
b2AABB b2ComputeSegmentAABB( const b2Segment* shape, b2Transform transform );
bool b2PointInCircle( b2Vec2 point, const b2Circle* shape );
bool b2PointInCapsule( b2Vec2 point, const b2Capsule* shape );
bool b2PointInPolygon( b2Vec2 point, const b2Polygon* shape );
b2CastOutput b2RayCastCircle( const b2RayCastInput* input, const b2Circle* shape );
b2CastOutput b2RayCastCapsule( const b2RayCastInput* input, const b2Capsule* shape );
b2CastOutput b2RayCastSegment( const b2RayCastInput* input, const b2Segment* shape, bool oneSided );
b2CastOutput b2RayCastPolygon( const b2RayCastInput* input, const b2Polygon* shape );
b2CastOutput b2ShapeCastCircle( const b2ShapeCastInput* input, const b2Circle* shape );
b2CastOutput b2ShapeCastCapsule( const b2ShapeCastInput* input, const b2Capsule* shape );
b2CastOutput b2ShapeCastSegment( const b2ShapeCastInput* input, const b2Segment* shape );
b2CastOutput b2ShapeCastPolygon( const b2ShapeCastInput* input, const b2Polygon* shape );
typedef struct b2Hull
{
b2Vec2 points[8];
int32_t count;
} b2Hull;
b2Hull b2ComputeHull( const b2Vec2* points, int32_t count );
bool b2ValidateHull( const b2Hull* hull );
typedef struct b2SegmentDistanceResult
{
b2Vec2 closest1;
b2Vec2 closest2;
float fraction1;
float fraction2;
float distanceSquared;
} b2SegmentDistanceResult;
b2SegmentDistanceResult b2SegmentDistance( b2Vec2 p1, b2Vec2 q1, b2Vec2 p2, b2Vec2 q2 );
typedef struct b2DistanceProxy
{
b2Vec2 points[8];
int32_t count;
float radius;
} b2DistanceProxy;
typedef struct b2DistanceCache
{
uint16_t count;
uint8_t indexA[3];
uint8_t indexB[3];
} b2DistanceCache;
typedef struct b2DistanceInput
{
b2DistanceProxy proxyA;
b2DistanceProxy proxyB;
b2Transform transformA;
b2Transform transformB;
bool useRadii;
} b2DistanceInput;
typedef struct b2DistanceOutput
{
b2Vec2 pointA;
b2Vec2 pointB;
float distance;
int32_t iterations;
int32_t simplexCount;
} b2DistanceOutput;
typedef struct b2SimplexVertex
{
b2Vec2 wA;
b2Vec2 wB;
b2Vec2 w;
float a;
int32_t indexA;
int32_t indexB;
} b2SimplexVertex;
typedef struct b2Simplex
{
b2SimplexVertex v1, v2, v3;
int32_t count;
} b2Simplex;
b2DistanceOutput b2ShapeDistance( b2DistanceCache* cache, const b2DistanceInput* input, b2Simplex* simplexes, int simplexCapacity );
typedef struct b2ShapeCastPairInput
{
b2DistanceProxy proxyA;
b2DistanceProxy proxyB;
b2Transform transformA;
b2Transform transformB;
b2Vec2 translationB;
float maxFraction;
} b2ShapeCastPairInput;
b2CastOutput b2ShapeCast( const b2ShapeCastPairInput* input );
b2DistanceProxy b2MakeProxy( const b2Vec2* vertices, int32_t count, float radius );
typedef struct b2Sweep
{
b2Vec2 localCenter;
b2Vec2 c1;
b2Vec2 c2;
b2Rot q1;
b2Rot q2;
} b2Sweep;
b2Transform b2GetSweepTransform( const b2Sweep* sweep, float time );
typedef struct b2TOIInput
{
b2DistanceProxy proxyA;
b2DistanceProxy proxyB;
b2Sweep sweepA;
b2Sweep sweepB;
float tMax;
} b2TOIInput;
typedef enum b2TOIState
{
b2_toiStateUnknown,
b2_toiStateFailed,
b2_toiStateOverlapped,
b2_toiStateHit,
b2_toiStateSeparated
} b2TOIState;
typedef struct b2TOIOutput
{
b2TOIState state;
float t;
} b2TOIOutput;
b2TOIOutput b2TimeOfImpact( const b2TOIInput* input );
typedef struct b2ManifoldPoint
{
b2Vec2 point;
b2Vec2 anchorA;
b2Vec2 anchorB;
float separation;
float normalImpulse;
float tangentImpulse;
float maxNormalImpulse;
float normalVelocity;
uint16_t id;
bool persisted;
} b2ManifoldPoint;
typedef struct b2Manifold
{
b2ManifoldPoint points[2];
b2Vec2 normal;
int32_t pointCount;
} b2Manifold;
b2Manifold b2CollideCircles( const b2Circle* circleA, b2Transform xfA, const b2Circle* circleB, b2Transform xfB );
b2Manifold b2CollideCapsuleAndCircle( const b2Capsule* capsuleA, b2Transform xfA, const b2Circle* circleB, b2Transform xfB );
b2Manifold b2CollideSegmentAndCircle( const b2Segment* segmentA, b2Transform xfA, const b2Circle* circleB, b2Transform xfB );
b2Manifold b2CollidePolygonAndCircle( const b2Polygon* polygonA, b2Transform xfA, const b2Circle* circleB, b2Transform xfB );
b2Manifold b2CollideCapsules( const b2Capsule* capsuleA, b2Transform xfA, const b2Capsule* capsuleB, b2Transform xfB );
b2Manifold b2CollideSegmentAndCapsule( const b2Segment* segmentA, b2Transform xfA, const b2Capsule* capsuleB, b2Transform xfB );
b2Manifold b2CollidePolygonAndCapsule( const b2Polygon* polygonA, b2Transform xfA, const b2Capsule* capsuleB, b2Transform xfB );
b2Manifold b2CollidePolygons( const b2Polygon* polygonA, b2Transform xfA, const b2Polygon* polygonB, b2Transform xfB );
b2Manifold b2CollideSegmentAndPolygon( const b2Segment* segmentA, b2Transform xfA, const b2Polygon* polygonB, b2Transform xfB );
b2Manifold b2CollideChainSegmentAndCircle( const b2ChainSegment* segmentA, b2Transform xfA, const b2Circle* circleB, b2Transform xfB );
b2Manifold b2CollideChainSegmentAndCapsule( const b2ChainSegment* segmentA, b2Transform xfA, const b2Capsule* capsuleB, b2Transform xfB, b2DistanceCache* cache );
b2Manifold b2CollideChainSegmentAndPolygon( const b2ChainSegment* segmentA, b2Transform xfA, const b2Polygon* polygonB, b2Transform xfB, b2DistanceCache* cache );
typedef struct b2TreeNode
{
b2AABB aabb;
uint64_t categoryBits;
union
{
int32_t parent;
int32_t next;
};
int32_t child1;
int32_t child2;
int32_t userData;
int16_t height;
bool enlarged;
char pad[5];
} b2TreeNode;
typedef struct b2DynamicTree
{
b2TreeNode* nodes;
int32_t root;
int32_t nodeCount;
int32_t nodeCapacity;
int32_t freeList;
int32_t proxyCount;
int32_t* leafIndices;
b2AABB* leafBoxes;
b2Vec2* leafCenters;
int32_t* binIndices;
int32_t rebuildCapacity;
} b2DynamicTree;
b2DynamicTree b2DynamicTree_Create( void );
void b2DynamicTree_Destroy( b2DynamicTree* tree );
int32_t b2DynamicTree_CreateProxy( b2DynamicTree* tree, b2AABB aabb, uint64_t categoryBits, int32_t userData );
void b2DynamicTree_DestroyProxy( b2DynamicTree* tree, int32_t proxyId );
void b2DynamicTree_MoveProxy( b2DynamicTree* tree, int32_t proxyId, b2AABB aabb );
void b2DynamicTree_EnlargeProxy( b2DynamicTree* tree, int32_t proxyId, b2AABB aabb );
typedef bool b2TreeQueryCallbackFcn( int32_t proxyId, int32_t userData, void* context );
void b2DynamicTree_Query( const b2DynamicTree* tree, b2AABB aabb, uint64_t maskBits, b2TreeQueryCallbackFcn* callback, void* context );
typedef float b2TreeRayCastCallbackFcn( const b2RayCastInput* input, int32_t proxyId, int32_t userData, void* context );
void b2DynamicTree_RayCast( const b2DynamicTree* tree, const b2RayCastInput* input, uint64_t maskBits, b2TreeRayCastCallbackFcn* callback, void* context );
typedef float b2TreeShapeCastCallbackFcn( const b2ShapeCastInput* input, int32_t proxyId, int32_t userData, void* context );
void b2DynamicTree_ShapeCast( const b2DynamicTree* tree, const b2ShapeCastInput* input, uint64_t maskBits, b2TreeShapeCastCallbackFcn* callback, void* context );
void b2DynamicTree_Validate( const b2DynamicTree* tree );
int b2DynamicTree_GetHeight( const b2DynamicTree* tree );
int b2DynamicTree_GetMaxBalance( const b2DynamicTree* tree );
float b2DynamicTree_GetAreaRatio( const b2DynamicTree* tree );
void b2DynamicTree_RebuildBottomUp( b2DynamicTree* tree );
int b2DynamicTree_GetProxyCount( const b2DynamicTree* tree );
int b2DynamicTree_Rebuild( b2DynamicTree* tree, bool fullBuild );
void b2DynamicTree_ShiftOrigin( b2DynamicTree* tree, b2Vec2 newOrigin );
int b2DynamicTree_GetByteCount( const b2DynamicTree* tree );
typedef struct b2WorldId { uint16_t index1; uint16_t revision; } b2WorldId;
typedef struct b2BodyId { int32_t index1; uint16_t world0; uint16_t revision; } b2BodyId;
typedef struct b2ShapeId { int32_t index1; uint16_t world0; uint16_t revision; } b2ShapeId;
typedef struct b2JointId { int32_t index1; uint16_t world0; uint16_t revision; } b2JointId;
typedef struct b2ChainId { int32_t index1; uint16_t world0; uint16_t revision; } b2ChainId;
typedef void b2TaskCallback( int32_t startIndex, int32_t endIndex, uint32_t workerIndex, void* taskContext );
typedef void* b2EnqueueTaskCallback( b2TaskCallback* task, int32_t itemCount, int32_t minRange, void* taskContext, void* userContext );
typedef void b2FinishTaskCallback( void* userTask, void* userContext );
typedef struct b2RayResult
{
b2ShapeId shapeId;
b2Vec2 point;
b2Vec2 normal;
float fraction;
bool hit;
} b2RayResult;
typedef enum b2MixingRule
{
b2_mixAverage,
b2_mixGeometricMean,
b2_mixMultiply,
b2_mixMinimum,
b2_mixMaximum
} b2MixingRule;
typedef struct b2WorldDef
{
b2Vec2 gravity;
float restitutionThreshold;
float contactPushoutVelocity;
float hitEventThreshold;
float contactHertz;
float contactDampingRatio;
float jointHertz;
float jointDampingRatio;
float maximumLinearVelocity;
b2MixingRule frictionMixingRule;
b2MixingRule restitutionMixingRule;
bool enableSleep;
bool enableContinuous;
int32_t workerCount;
b2EnqueueTaskCallback* enqueueTask;
b2FinishTaskCallback* finishTask;
void* userTaskContext;
int32_t internalValue;
} b2WorldDef;
b2WorldDef b2DefaultWorldDef( void );
typedef enum b2BodyType
{
b2_staticBody = 0,
b2_kinematicBody = 1,
b2_dynamicBody = 2,
b2_bodyTypeCount,
} b2BodyType;
typedef struct b2BodyDef
{
b2BodyType type;
b2Vec2 position;
b2Rot rotation;
b2Vec2 linearVelocity;
float angularVelocity;
float linearDamping;
float angularDamping;
float gravityScale;
float sleepThreshold;
void* userData;
bool enableSleep;
bool isAwake;
bool fixedRotation;
bool isBullet;
bool isEnabled;
bool automaticMass;
bool allowFastRotation;
int32_t internalValue;
} b2BodyDef;
b2BodyDef b2DefaultBodyDef( void );
typedef struct b2Filter
{
uint64_t categoryBits;
uint64_t maskBits;
int32_t groupIndex;
} b2Filter;
b2Filter b2DefaultFilter( void );
typedef struct b2QueryFilter
{
uint64_t categoryBits;
uint64_t maskBits;
} b2QueryFilter;
b2QueryFilter b2DefaultQueryFilter( void );
typedef enum b2ShapeType
{
b2_circleShape,
b2_capsuleShape,
b2_segmentShape,
b2_polygonShape,
b2_chainSegmentShape,
b2_shapeTypeCount
} b2ShapeType;
typedef struct b2ShapeDef
{
void* userData;
float friction;
float restitution;
float density;
b2Filter filter;
uint32_t customColor;
bool isSensor;
bool enableSensorEvents;
bool enableContactEvents;
bool enableHitEvents;
bool enablePreSolveEvents;
bool forceContactCreation;
int32_t internalValue;
} b2ShapeDef;
b2ShapeDef b2DefaultShapeDef( void );
typedef struct b2ChainDef
{
void* userData;
const b2Vec2* points;
int32_t count;
float friction;
float restitution;
b2Filter filter;
uint32_t customColor;
bool isLoop;
int32_t internalValue;
} b2ChainDef;
b2ChainDef b2DefaultChainDef( void );
typedef struct b2Profile
{
float step;
float pairs;
float collide;
float solve;
float buildIslands;
float solveConstraints;
float prepareTasks;
float solverTasks;
float prepareConstraints;
float integrateVelocities;
float warmStart;
float solveVelocities;
float integratePositions;
float relaxVelocities;
float applyRestitution;
float storeImpulses;
float finalizeBodies;
float splitIslands;
float sleepIslands;
float hitEvents;
float broadphase;
float continuous;
} b2Profile;
typedef struct b2Counters
{
int32_t bodyCount;
int32_t shapeCount;
int32_t contactCount;
int32_t jointCount;
int32_t islandCount;
int32_t stackUsed;
int32_t staticTreeHeight;
int32_t treeHeight;
int32_t byteCount;
int32_t taskCount;
int32_t colorCounts[12];
} b2Counters;
typedef enum b2JointType
{
b2_distanceJoint,
b2_motorJoint,
b2_mouseJoint,
b2_prismaticJoint,
b2_revoluteJoint,
b2_weldJoint,
b2_wheelJoint,
} b2JointType;
typedef struct b2DistanceJointDef
{
b2BodyId bodyIdA;
b2BodyId bodyIdB;
b2Vec2 localAnchorA;
b2Vec2 localAnchorB;
float length;
bool enableSpring;
float hertz;
float dampingRatio;
bool enableLimit;
float minLength;
float maxLength;
bool enableMotor;
float maxMotorForce;
float motorSpeed;
bool collideConnected;
void* userData;
int32_t internalValue;
} b2DistanceJointDef;
b2DistanceJointDef b2DefaultDistanceJointDef( void );
typedef struct b2MotorJointDef
{
b2BodyId bodyIdA;
b2BodyId bodyIdB;
b2Vec2 linearOffset;
float angularOffset;
float maxForce;
float maxTorque;
float correctionFactor;
bool collideConnected;
void* userData;
int32_t internalValue;
} b2MotorJointDef;
b2MotorJointDef b2DefaultMotorJointDef( void );
typedef struct b2MouseJointDef
{
b2BodyId bodyIdA;
b2BodyId bodyIdB;
b2Vec2 target;
float hertz;
float dampingRatio;
float maxForce;
bool collideConnected;
void* userData;
int32_t internalValue;
} b2MouseJointDef;
b2MouseJointDef b2DefaultMouseJointDef( void );
typedef struct b2PrismaticJointDef
{
b2BodyId bodyIdA;
b2BodyId bodyIdB;
b2Vec2 localAnchorA;
b2Vec2 localAnchorB;
b2Vec2 localAxisA;
float referenceAngle;
bool enableSpring;
float hertz;
float dampingRatio;
bool enableLimit;
float lowerTranslation;
float upperTranslation;
bool enableMotor;
float maxMotorForce;
float motorSpeed;
bool collideConnected;
void* userData;
int32_t internalValue;
} b2PrismaticJointDef;
b2PrismaticJointDef b2DefaultPrismaticJointDef( void );
typedef struct b2RevoluteJointDef
{
b2BodyId bodyIdA;
b2BodyId bodyIdB;
b2Vec2 localAnchorA;
b2Vec2 localAnchorB;
float referenceAngle;
bool enableSpring;
float hertz;
float dampingRatio;
bool enableLimit;
float lowerAngle;
float upperAngle;
bool enableMotor;
float maxMotorTorque;
float motorSpeed;
float drawSize;
bool collideConnected;
void* userData;
int32_t internalValue;
} b2RevoluteJointDef;
b2RevoluteJointDef b2DefaultRevoluteJointDef( void );
typedef struct b2WeldJointDef
{
b2BodyId bodyIdA;
b2BodyId bodyIdB;
b2Vec2 localAnchorA;
b2Vec2 localAnchorB;
float referenceAngle;
float linearHertz;
float angularHertz;
float linearDampingRatio;
float angularDampingRatio;
bool collideConnected;
void* userData;
int32_t internalValue;
} b2WeldJointDef;
b2WeldJointDef b2DefaultWeldJointDef( void );
typedef struct b2WheelJointDef
{
b2BodyId bodyIdA;
b2BodyId bodyIdB;
b2Vec2 localAnchorA;
b2Vec2 localAnchorB;
b2Vec2 localAxisA;
bool enableSpring;
float hertz;
float dampingRatio;
bool enableLimit;
float lowerTranslation;
float upperTranslation;
bool enableMotor;
float maxMotorTorque;
float motorSpeed;
bool collideConnected;
void* userData;
int32_t internalValue;
} b2WheelJointDef;
b2WheelJointDef b2DefaultWheelJointDef( void );
typedef struct b2ExplosionDef
{
uint64_t maskBits;
b2Vec2 position;
float radius;
float falloff;
float impulsePerLength;
} b2ExplosionDef;
b2ExplosionDef b2DefaultExplosionDef( void );
typedef struct b2SensorBeginTouchEvent
{
b2ShapeId sensorShapeId;
b2ShapeId visitorShapeId;
} b2SensorBeginTouchEvent;
typedef struct b2SensorEndTouchEvent
{
b2ShapeId sensorShapeId;
b2ShapeId visitorShapeId;
} b2SensorEndTouchEvent;
typedef struct b2SensorEvents
{
b2SensorBeginTouchEvent* beginEvents;
b2SensorEndTouchEvent* endEvents;
int32_t beginCount;
int32_t endCount;
} b2SensorEvents;
typedef struct b2ContactBeginTouchEvent
{
b2ShapeId shapeIdA;
b2ShapeId shapeIdB;
b2Manifold manifold;
} b2ContactBeginTouchEvent;
typedef struct b2ContactEndTouchEvent
{
b2ShapeId shapeIdA;
b2ShapeId shapeIdB;
} b2ContactEndTouchEvent;
typedef struct b2ContactHitEvent
{
b2ShapeId shapeIdA;
b2ShapeId shapeIdB;
b2Vec2 point;
b2Vec2 normal;
float approachSpeed;
} b2ContactHitEvent;
typedef struct b2ContactEvents
{
b2ContactBeginTouchEvent* beginEvents;
b2ContactEndTouchEvent* endEvents;
b2ContactHitEvent* hitEvents;
int32_t beginCount;
int32_t endCount;
int32_t hitCount;
} b2ContactEvents;
typedef struct b2BodyMoveEvent
{
b2Transform transform;
b2BodyId bodyId;
void* userData;
bool fellAsleep;
} b2BodyMoveEvent;
typedef struct b2BodyEvents
{
b2BodyMoveEvent* moveEvents;
int32_t moveCount;
} b2BodyEvents;
typedef struct b2ContactData
{
b2ShapeId shapeIdA;
b2ShapeId shapeIdB;
b2Manifold manifold;
} b2ContactData;
typedef bool b2CustomFilterFcn( b2ShapeId shapeIdA, b2ShapeId shapeIdB, void* context );
typedef bool b2PreSolveFcn( b2ShapeId shapeIdA, b2ShapeId shapeIdB, b2Manifold* manifold, void* context );
typedef bool b2OverlapResultFcn( b2ShapeId shapeId, void* context );
typedef float b2CastResultFcn( b2ShapeId shapeId, b2Vec2 point, b2Vec2 normal, float fraction, void* context );
typedef enum b2HexColor
{
b2_colorAliceBlue = 0xf0f8ff,
b2_colorAntiqueWhite = 0xfaebd7,
b2_colorAquamarine = 0x7fffd4,
b2_colorAzure = 0xf0ffff,
b2_colorBeige = 0xf5f5dc,
b2_colorBisque = 0xffe4c4,
b2_colorBlack = 0x000000,
b2_colorBlanchedAlmond = 0xffebcd,
b2_colorBlue = 0x0000ff,
b2_colorBlueViolet = 0x8a2be2,
b2_colorBrown = 0xa52a2a,
b2_colorBurlywood = 0xdeb887,
b2_colorCadetBlue = 0x5f9ea0,
b2_colorChartreuse = 0x7fff00,
b2_colorChocolate = 0xd2691e,
b2_colorCoral = 0xff7f50,
b2_colorCornflowerBlue = 0x6495ed,
b2_colorCornsilk = 0xfff8dc,
b2_colorCrimson = 0xdc143c,
b2_colorCyan = 0x00ffff,
b2_colorDarkBlue = 0x00008b,
b2_colorDarkCyan = 0x008b8b,
b2_colorDarkGoldenrod = 0xb8860b,
b2_colorDarkGray = 0xa9a9a9,
b2_colorDarkGreen = 0x006400,
b2_colorDarkKhaki = 0xbdb76b,
b2_colorDarkMagenta = 0x8b008b,
b2_colorDarkOliveGreen = 0x556b2f,
b2_colorDarkOrange = 0xff8c00,
b2_colorDarkOrchid = 0x9932cc,
b2_colorDarkRed = 0x8b0000,
b2_colorDarkSalmon = 0xe9967a,
b2_colorDarkSeaGreen = 0x8fbc8f,
b2_colorDarkSlateBlue = 0x483d8b,
b2_colorDarkSlateGray = 0x2f4f4f,
b2_colorDarkTurquoise = 0x00ced1,
b2_colorDarkViolet = 0x9400d3,
b2_colorDeepPink = 0xff1493,
b2_colorDeepSkyBlue = 0x00bfff,
b2_colorDimGray = 0x696969,
b2_colorDodgerBlue = 0x1e90ff,
b2_colorFirebrick = 0xb22222,
b2_colorFloralWhite = 0xfffaf0,
b2_colorForestGreen = 0x228b22,
b2_colorGainsboro = 0xdcdcdc,
b2_colorGhostWhite = 0xf8f8ff,
b2_colorGold = 0xffd700,
b2_colorGoldenrod = 0xdaa520,
b2_colorGray = 0xbebebe,
b2_colorGray1 = 0x1a1a1a,
b2_colorGray2 = 0x333333,
b2_colorGray3 = 0x4d4d4d,
b2_colorGray4 = 0x666666,
b2_colorGray5 = 0x7f7f7f,
b2_colorGray6 = 0x999999,
b2_colorGray7 = 0xb3b3b3,
b2_colorGray8 = 0xcccccc,
b2_colorGray9 = 0xe5e5e5,
b2_colorGreen = 0x00ff00,
b2_colorGreenYellow = 0xadff2f,
b2_colorHoneydew = 0xf0fff0,
b2_colorHotPink = 0xff69b4,
b2_colorIndianRed = 0xcd5c5c,
b2_colorIndigo = 0x4b0082,
b2_colorIvory = 0xfffff0,
b2_colorKhaki = 0xf0e68c,
b2_colorLavender = 0xe6e6fa,
b2_colorLavenderBlush = 0xfff0f5,
b2_colorLawnGreen = 0x7cfc00,
b2_colorLemonChiffon = 0xfffacd,
b2_colorLightBlue = 0xadd8e6,
b2_colorLightCoral = 0xf08080,
b2_colorLightCyan = 0xe0ffff,
b2_colorLightGoldenrod = 0xeedd82,
b2_colorLightGoldenrodYellow = 0xfafad2,
b2_colorLightGray = 0xd3d3d3,
b2_colorLightGreen = 0x90ee90,
b2_colorLightPink = 0xffb6c1,
b2_colorLightSalmon = 0xffa07a,
b2_colorLightSeaGreen = 0x20b2aa,
b2_colorLightSkyBlue = 0x87cefa,
b2_colorLightSlateBlue = 0x8470ff,
b2_colorLightSlateGray = 0x778899,
b2_colorLightSteelBlue = 0xb0c4de,
b2_colorLightYellow = 0xffffe0,
b2_colorLimeGreen = 0x32cd32,
b2_colorLinen = 0xfaf0e6,
b2_colorMagenta = 0xff00ff,
b2_colorMaroon = 0xb03060,
b2_colorMediumAquamarine = 0x66cdaa,
b2_colorMediumBlue = 0x0000cd,
b2_colorMediumOrchid = 0xba55d3,
b2_colorMediumPurple = 0x9370db,
b2_colorMediumSeaGreen = 0x3cb371,
b2_colorMediumSlateBlue = 0x7b68ee,
b2_colorMediumSpringGreen = 0x00fa9a,
b2_colorMediumTurquoise = 0x48d1cc,
b2_colorMediumVioletRed = 0xc71585,
b2_colorMidnightBlue = 0x191970,
b2_colorMintCream = 0xf5fffa,
b2_colorMistyRose = 0xffe4e1,
b2_colorMoccasin = 0xffe4b5,
b2_colorNavajoWhite = 0xffdead,
b2_colorNavyBlue = 0x000080,
b2_colorOldLace = 0xfdf5e6,
b2_colorOlive = 0x808000,
b2_colorOliveDrab = 0x6b8e23,
b2_colorOrange = 0xffa500,
b2_colorOrangeRed = 0xff4500,
b2_colorOrchid = 0xda70d6,
b2_colorPaleGoldenrod = 0xeee8aa,
b2_colorPaleGreen = 0x98fb98,
b2_colorPaleTurquoise = 0xafeeee,
b2_colorPaleVioletRed = 0xdb7093,
b2_colorPapayaWhip = 0xffefd5,
b2_colorPeachPuff = 0xffdab9,
b2_colorPeru = 0xcd853f,
b2_colorPink = 0xffc0cb,
b2_colorPlum = 0xdda0dd,
b2_colorPowderBlue = 0xb0e0e6,
b2_colorPurple = 0xa020f0,
b2_colorRebeccaPurple = 0x663399,
b2_colorRed = 0xff0000,
b2_colorRosyBrown = 0xbc8f8f,
b2_colorRoyalBlue = 0x4169e1,
b2_colorSaddleBrown = 0x8b4513,
b2_colorSalmon = 0xfa8072,
b2_colorSandyBrown = 0xf4a460,
b2_colorSeaGreen = 0x2e8b57,
b2_colorSeashell = 0xfff5ee,
b2_colorSienna = 0xa0522d,
b2_colorSilver = 0xc0c0c0,
b2_colorSkyBlue = 0x87ceeb,
b2_colorSlateBlue = 0x6a5acd,
b2_colorSlateGray = 0x708090,
b2_colorSnow = 0xfffafa,
b2_colorSpringGreen = 0x00ff7f,
b2_colorSteelBlue = 0x4682b4,
b2_colorTan = 0xd2b48c,
b2_colorTeal = 0x008080,
b2_colorThistle = 0xd8bfd8,
b2_colorTomato = 0xff6347,
b2_colorTurquoise = 0x40e0d0,
b2_colorViolet = 0xee82ee,
b2_colorVioletRed = 0xd02090,
b2_colorWheat = 0xf5deb3,
b2_colorWhite = 0xffffff,
b2_colorWhiteSmoke = 0xf5f5f5,
b2_colorYellow = 0xffff00,
b2_colorYellowGreen = 0x9acd32,
b2_colorBox2DRed = 0xdc3132,
b2_colorBox2DBlue = 0x30aebf,
b2_colorBox2DGreen = 0x8cc924,
b2_colorBox2DYellow = 0xffee8c
} b2HexColor;
typedef struct b2DebugDraw
{
void ( *DrawPolygon )( const b2Vec2* vertices, int vertexCount, b2HexColor color, void* context );
void ( *DrawSolidPolygon )( b2Transform transform, const b2Vec2* vertices, int vertexCount, float radius, b2HexColor color, void* context );
void ( *DrawCircle )( b2Vec2 center, float radius, b2HexColor color, void* context );
void ( *DrawSolidCircle )( b2Transform transform, float radius, b2HexColor color, void* context );
void ( *DrawSolidCapsule )( b2Vec2 p1, b2Vec2 p2, float radius, b2HexColor color, void* context );
void ( *DrawSegment )( b2Vec2 p1, b2Vec2 p2, b2HexColor color, void* context );
void ( *DrawTransform )( b2Transform transform, void* context );
void ( *DrawPoint )( b2Vec2 p, float size, b2HexColor color, void* context );
void ( *DrawString )( b2Vec2 p, const char* s, void* context );
b2AABB drawingBounds;
bool useDrawingBounds;
bool drawShapes;
bool drawJoints;
bool drawJointExtras;
bool drawAABBs;
bool drawMass;
bool drawContacts;
bool drawGraphColors;
bool drawContactNormals;
bool drawContactImpulses;
bool drawFrictionImpulses;
void* context;
} b2DebugDraw;
b2DebugDraw b2DefaultDebugDraw( void );
b2WorldId b2CreateWorld( const b2WorldDef* def );
void b2DestroyWorld( b2WorldId worldId );
bool b2World_IsValid( b2WorldId id );
void b2World_Step( b2WorldId worldId, float timeStep, int subStepCount );
void b2World_Draw( b2WorldId worldId, b2DebugDraw* draw );
b2BodyEvents b2World_GetBodyEvents( b2WorldId worldId );
b2SensorEvents b2World_GetSensorEvents( b2WorldId worldId );
b2ContactEvents b2World_GetContactEvents( b2WorldId worldId );
void b2World_OverlapAABB( b2WorldId worldId, b2AABB aabb, b2QueryFilter filter, b2OverlapResultFcn* fcn, void* context );
void b2World_OverlapCircle( b2WorldId worldId, const b2Circle* circle, b2Transform transform, b2QueryFilter filter, b2OverlapResultFcn* fcn, void* context );
void b2World_OverlapCapsule( b2WorldId worldId, const b2Capsule* capsule, b2Transform transform, b2QueryFilter filter, b2OverlapResultFcn* fcn, void* context );
void b2World_OverlapPolygon( b2WorldId worldId, const b2Polygon* polygon, b2Transform transform, b2QueryFilter filter, b2OverlapResultFcn* fcn, void* context );
void b2World_CastRay( b2WorldId worldId, b2Vec2 origin, b2Vec2 translation, b2QueryFilter filter, b2CastResultFcn* fcn, void* context );
b2RayResult b2World_CastRayClosest( b2WorldId worldId, b2Vec2 origin, b2Vec2 translation, b2QueryFilter filter );
void b2World_CastCircle( b2WorldId worldId, const b2Circle* circle, b2Transform originTransform, b2Vec2 translation, b2QueryFilter filter, b2CastResultFcn* fcn, void* context );
void b2World_CastCapsule( b2WorldId worldId, const b2Capsule* capsule, b2Transform originTransform, b2Vec2 translation, b2QueryFilter filter, b2CastResultFcn* fcn, void* context );
void b2World_CastPolygon( b2WorldId worldId, const b2Polygon* polygon, b2Transform originTransform, b2Vec2 translation, b2QueryFilter filter, b2CastResultFcn* fcn, void* context );
void b2World_EnableSleeping( b2WorldId worldId, bool flag );
bool b2World_IsSleepingEnabled( b2WorldId worldId );
void b2World_EnableContinuous( b2WorldId worldId, bool flag );
bool b2World_IsContinuousEnabled( b2WorldId worldId );
void b2World_SetRestitutionThreshold( b2WorldId worldId, float value );
float b2World_GetRestitutionThreshold( b2WorldId worldId );
void b2World_SetHitEventThreshold( b2WorldId worldId, float value );
float b2World_GetHitEventThreshold( b2WorldId worldId );
void b2World_SetCustomFilterCallback( b2WorldId worldId, b2CustomFilterFcn* fcn, void* context );
void b2World_SetPreSolveCallback( b2WorldId worldId, b2PreSolveFcn* fcn, void* context );
void b2World_SetGravity( b2WorldId worldId, b2Vec2 gravity );
b2Vec2 b2World_GetGravity( b2WorldId worldId );
void b2World_Explode( b2WorldId worldId, const b2ExplosionDef* explosionDef );
void b2World_SetContactTuning( b2WorldId worldId, float hertz, float dampingRatio, float pushVelocity );
void b2World_SetJointTuning( b2WorldId worldId, float hertz, float dampingRatio );
void b2World_SetMaximumLinearVelocity( b2WorldId worldId, float maximumLinearVelocity );
float b2World_GetMaximumLinearVelocity( b2WorldId worldId );
void b2World_EnableWarmStarting( b2WorldId worldId, bool flag );
bool b2World_IsWarmStartingEnabled( b2WorldId worldId );
b2Profile b2World_GetProfile( b2WorldId worldId );
b2Counters b2World_GetCounters( b2WorldId worldId );
void b2World_DumpMemoryStats( b2WorldId worldId );
b2BodyId b2CreateBody( b2WorldId worldId, const b2BodyDef* def );
void b2DestroyBody( b2BodyId bodyId );
bool b2Body_IsValid( b2BodyId id );
b2BodyType b2Body_GetType( b2BodyId bodyId );
void b2Body_SetType( b2BodyId bodyId, b2BodyType type );
void b2Body_SetUserData( b2BodyId bodyId, void* userData );
void* b2Body_GetUserData( b2BodyId bodyId );
b2Vec2 b2Body_GetPosition( b2BodyId bodyId );
b2Rot b2Body_GetRotation( b2BodyId bodyId );
b2Transform b2Body_GetTransform( b2BodyId bodyId );
void b2Body_SetTransform( b2BodyId bodyId, b2Vec2 position, b2Rot rotation );
b2Vec2 b2Body_GetLocalPoint( b2BodyId bodyId, b2Vec2 worldPoint );
b2Vec2 b2Body_GetWorldPoint( b2BodyId bodyId, b2Vec2 localPoint );
b2Vec2 b2Body_GetLocalVector( b2BodyId bodyId, b2Vec2 worldVector );
b2Vec2 b2Body_GetWorldVector( b2BodyId bodyId, b2Vec2 localVector );
b2Vec2 b2Body_GetLinearVelocity( b2BodyId bodyId );
float b2Body_GetAngularVelocity( b2BodyId bodyId );
void b2Body_SetLinearVelocity( b2BodyId bodyId, b2Vec2 linearVelocity );
void b2Body_SetAngularVelocity( b2BodyId bodyId, float angularVelocity );
void b2Body_ApplyForce( b2BodyId bodyId, b2Vec2 force, b2Vec2 point, bool wake );
void b2Body_ApplyForceToCenter( b2BodyId bodyId, b2Vec2 force, bool wake );
void b2Body_ApplyTorque( b2BodyId bodyId, float torque, bool wake );
void b2Body_ApplyLinearImpulse( b2BodyId bodyId, b2Vec2 impulse, b2Vec2 point, bool wake );
void b2Body_ApplyLinearImpulseToCenter( b2BodyId bodyId, b2Vec2 impulse, bool wake );
void b2Body_ApplyAngularImpulse( b2BodyId bodyId, float impulse, bool wake );
float b2Body_GetMass( b2BodyId bodyId );
float b2Body_GetRotationalInertia( b2BodyId bodyId );
b2Vec2 b2Body_GetLocalCenterOfMass( b2BodyId bodyId );
b2Vec2 b2Body_GetWorldCenterOfMass( b2BodyId bodyId );
void b2Body_SetMassData( b2BodyId bodyId, b2MassData massData );
b2MassData b2Body_GetMassData( b2BodyId bodyId );
void b2Body_ApplyMassFromShapes( b2BodyId bodyId );
void b2Body_SetAutomaticMass( b2BodyId bodyId, bool automaticMass );
bool b2Body_GetAutomaticMass( b2BodyId bodyId );
void b2Body_SetLinearDamping( b2BodyId bodyId, float linearDamping );
float b2Body_GetLinearDamping( b2BodyId bodyId );
void b2Body_SetAngularDamping( b2BodyId bodyId, float angularDamping );
float b2Body_GetAngularDamping( b2BodyId bodyId );
void b2Body_SetGravityScale( b2BodyId bodyId, float gravityScale );
float b2Body_GetGravityScale( b2BodyId bodyId );
bool b2Body_IsAwake( b2BodyId bodyId );
void b2Body_SetAwake( b2BodyId bodyId, bool awake );
void b2Body_EnableSleep( b2BodyId bodyId, bool enableSleep );
bool b2Body_IsSleepEnabled( b2BodyId bodyId );
void b2Body_SetSleepThreshold( b2BodyId bodyId, float sleepThreshold );
float b2Body_GetSleepThreshold( b2BodyId bodyId );
bool b2Body_IsEnabled( b2BodyId bodyId );
void b2Body_Disable( b2BodyId bodyId );
void b2Body_Enable( b2BodyId bodyId );
void b2Body_SetFixedRotation( b2BodyId bodyId, bool flag );
bool b2Body_IsFixedRotation( b2BodyId bodyId );
void b2Body_SetBullet( b2BodyId bodyId, bool flag );
bool b2Body_IsBullet( b2BodyId bodyId );
void b2Body_EnableHitEvents( b2BodyId bodyId, bool enableHitEvents );
b2WorldId b2Body_GetWorld( b2BodyId bodyId );
int b2Body_GetShapeCount( b2BodyId bodyId );
int b2Body_GetShapes( b2BodyId bodyId, b2ShapeId* shapeArray, int capacity );
int b2Body_GetJointCount( b2BodyId bodyId );
int b2Body_GetJoints( b2BodyId bodyId, b2JointId* jointArray, int capacity );
int b2Body_GetContactCapacity( b2BodyId bodyId );
int b2Body_GetContactData( b2BodyId bodyId, b2ContactData* contactData, int capacity );
b2AABB b2Body_ComputeAABB( b2BodyId bodyId );
b2ShapeId b2CreateCircleShape( b2BodyId bodyId, const b2ShapeDef* def, const b2Circle* circle );
b2ShapeId b2CreateSegmentShape( b2BodyId bodyId, const b2ShapeDef* def, const b2Segment* segment );
b2ShapeId b2CreateCapsuleShape( b2BodyId bodyId, const b2ShapeDef* def, const b2Capsule* capsule );
b2ShapeId b2CreatePolygonShape( b2BodyId bodyId, const b2ShapeDef* def, const b2Polygon* polygon );
void b2DestroyShape( b2ShapeId shapeId );
bool b2Shape_IsValid( b2ShapeId id );
b2ShapeType b2Shape_GetType( b2ShapeId shapeId );
b2BodyId b2Shape_GetBody( b2ShapeId shapeId );
b2WorldId b2Shape_GetWorld( b2ShapeId shapeId );
bool b2Shape_IsSensor( b2ShapeId shapeId );
void b2Shape_SetUserData( b2ShapeId shapeId, void* userData );
void* b2Shape_GetUserData( b2ShapeId shapeId );
void b2Shape_SetDensity( b2ShapeId shapeId, float density );
float b2Shape_GetDensity( b2ShapeId shapeId );
void b2Shape_SetFriction( b2ShapeId shapeId, float friction );
float b2Shape_GetFriction( b2ShapeId shapeId );
void b2Shape_SetRestitution( b2ShapeId shapeId, float restitution );
float b2Shape_GetRestitution( b2ShapeId shapeId );
b2Filter b2Shape_GetFilter( b2ShapeId shapeId );
void b2Shape_SetFilter( b2ShapeId shapeId, b2Filter filter );
void b2Shape_EnableSensorEvents( b2ShapeId shapeId, bool flag );
bool b2Shape_AreSensorEventsEnabled( b2ShapeId shapeId );
void b2Shape_EnableContactEvents( b2ShapeId shapeId, bool flag );
bool b2Shape_AreContactEventsEnabled( b2ShapeId shapeId );
void b2Shape_EnablePreSolveEvents( b2ShapeId shapeId, bool flag );
bool b2Shape_ArePreSolveEventsEnabled( b2ShapeId shapeId );
void b2Shape_EnableHitEvents( b2ShapeId shapeId, bool flag );
bool b2Shape_AreHitEventsEnabled( b2ShapeId shapeId );
bool b2Shape_TestPoint( b2ShapeId shapeId, b2Vec2 point );
b2CastOutput b2Shape_RayCast( b2ShapeId shapeId, const b2RayCastInput* input );
b2Circle b2Shape_GetCircle( b2ShapeId shapeId );
b2Segment b2Shape_GetSegment( b2ShapeId shapeId );
b2ChainSegment b2Shape_GetChainSegment( b2ShapeId shapeId );
b2Capsule b2Shape_GetCapsule( b2ShapeId shapeId );
b2Polygon b2Shape_GetPolygon( b2ShapeId shapeId );
void b2Shape_SetCircle( b2ShapeId shapeId, const b2Circle* circle );
void b2Shape_SetCapsule( b2ShapeId shapeId, const b2Capsule* capsule );
void b2Shape_SetSegment( b2ShapeId shapeId, const b2Segment* segment );
void b2Shape_SetPolygon( b2ShapeId shapeId, const b2Polygon* polygon );
b2ChainId b2Shape_GetParentChain( b2ShapeId shapeId );
int b2Shape_GetContactCapacity( b2ShapeId shapeId );
int b2Shape_GetContactData( b2ShapeId shapeId, b2ContactData* contactData, int capacity );
b2AABB b2Shape_GetAABB( b2ShapeId shapeId );
b2Vec2 b2Shape_GetClosestPoint( b2ShapeId shapeId, b2Vec2 target );
b2ChainId b2CreateChain( b2BodyId bodyId, const b2ChainDef* def );
void b2DestroyChain( b2ChainId chainId );
b2WorldId b2Chain_GetWorld( b2ChainId chainId );
int b2Chain_GetSegmentCount( b2ChainId chainId );
int b2Chain_GetSegments( b2ChainId chainId, b2ShapeId* segmentArray, int capacity );
void b2Chain_SetFriction( b2ChainId chainId, float friction );
void b2Chain_SetRestitution( b2ChainId chainId, float restitution );
bool b2Chain_IsValid( b2ChainId id );
void b2DestroyJoint( b2JointId jointId );
bool b2Joint_IsValid( b2JointId id );
b2JointType b2Joint_GetType( b2JointId jointId );
b2BodyId b2Joint_GetBodyA( b2JointId jointId );
b2BodyId b2Joint_GetBodyB( b2JointId jointId );
b2WorldId b2Joint_GetWorld( b2JointId jointId );
b2Vec2 b2Joint_GetLocalAnchorA( b2JointId jointId );
b2Vec2 b2Joint_GetLocalAnchorB( b2JointId jointId );
void b2Joint_SetCollideConnected( b2JointId jointId, bool shouldCollide );
bool b2Joint_GetCollideConnected( b2JointId jointId );
void b2Joint_SetUserData( b2JointId jointId, void* userData );
void* b2Joint_GetUserData( b2JointId jointId );
void b2Joint_WakeBodies( b2JointId jointId );
b2Vec2 b2Joint_GetConstraintForce( b2JointId jointId );
float b2Joint_GetConstraintTorque( b2JointId jointId );
b2JointId b2CreateDistanceJoint( b2WorldId worldId, const b2DistanceJointDef* def );
void b2DistanceJoint_SetLength( b2JointId jointId, float length );
float b2DistanceJoint_GetLength( b2JointId jointId );
void b2DistanceJoint_EnableSpring( b2JointId jointId, bool enableSpring );
bool b2DistanceJoint_IsSpringEnabled( b2JointId jointId );
void b2DistanceJoint_SetSpringHertz( b2JointId jointId, float hertz );
void b2DistanceJoint_SetSpringDampingRatio( b2JointId jointId, float dampingRatio );
float b2DistanceJoint_GetSpringHertz( b2JointId jointId );
float b2DistanceJoint_GetSpringDampingRatio( b2JointId jointId );
void b2DistanceJoint_EnableLimit( b2JointId jointId, bool enableLimit );
bool b2DistanceJoint_IsLimitEnabled( b2JointId jointId );
void b2DistanceJoint_SetLengthRange( b2JointId jointId, float minLength, float maxLength );
float b2DistanceJoint_GetMinLength( b2JointId jointId );
float b2DistanceJoint_GetMaxLength( b2JointId jointId );
float b2DistanceJoint_GetCurrentLength( b2JointId jointId );
void b2DistanceJoint_EnableMotor( b2JointId jointId, bool enableMotor );
bool b2DistanceJoint_IsMotorEnabled( b2JointId jointId );
void b2DistanceJoint_SetMotorSpeed( b2JointId jointId, float motorSpeed );
float b2DistanceJoint_GetMotorSpeed( b2JointId jointId );
void b2DistanceJoint_SetMaxMotorForce( b2JointId jointId, float force );
float b2DistanceJoint_GetMaxMotorForce( b2JointId jointId );
float b2DistanceJoint_GetMotorForce( b2JointId jointId );
b2JointId b2CreateMotorJoint( b2WorldId worldId, const b2MotorJointDef* def );
void b2MotorJoint_SetLinearOffset( b2JointId jointId, b2Vec2 linearOffset );
b2Vec2 b2MotorJoint_GetLinearOffset( b2JointId jointId );
void b2MotorJoint_SetAngularOffset( b2JointId jointId, float angularOffset );
float b2MotorJoint_GetAngularOffset( b2JointId jointId );
void b2MotorJoint_SetMaxForce( b2JointId jointId, float maxForce );
float b2MotorJoint_GetMaxForce( b2JointId jointId );
void b2MotorJoint_SetMaxTorque( b2JointId jointId, float maxTorque );
float b2MotorJoint_GetMaxTorque( b2JointId jointId );
void b2MotorJoint_SetCorrectionFactor( b2JointId jointId, float correctionFactor );
float b2MotorJoint_GetCorrectionFactor( b2JointId jointId );
b2JointId b2CreateMouseJoint( b2WorldId worldId, const b2MouseJointDef* def );
void b2MouseJoint_SetTarget( b2JointId jointId, b2Vec2 target );
b2Vec2 b2MouseJoint_GetTarget( b2JointId jointId );
void b2MouseJoint_SetSpringHertz( b2JointId jointId, float hertz );
float b2MouseJoint_GetSpringHertz( b2JointId jointId );
void b2MouseJoint_SetSpringDampingRatio( b2JointId jointId, float dampingRatio );
float b2MouseJoint_GetSpringDampingRatio( b2JointId jointId );
void b2MouseJoint_SetMaxForce( b2JointId jointId, float maxForce );
float b2MouseJoint_GetMaxForce( b2JointId jointId );
b2JointId b2CreatePrismaticJoint( b2WorldId worldId, const b2PrismaticJointDef* def );
void b2PrismaticJoint_EnableSpring( b2JointId jointId, bool enableSpring );
bool b2PrismaticJoint_IsSpringEnabled( b2JointId jointId );
void b2PrismaticJoint_SetSpringHertz( b2JointId jointId, float hertz );
float b2PrismaticJoint_GetSpringHertz( b2JointId jointId );
void b2PrismaticJoint_SetSpringDampingRatio( b2JointId jointId, float dampingRatio );
float b2PrismaticJoint_GetSpringDampingRatio( b2JointId jointId );
void b2PrismaticJoint_EnableLimit( b2JointId jointId, bool enableLimit );
bool b2PrismaticJoint_IsLimitEnabled( b2JointId jointId );
float b2PrismaticJoint_GetLowerLimit( b2JointId jointId );
float b2PrismaticJoint_GetUpperLimit( b2JointId jointId );
void b2PrismaticJoint_SetLimits( b2JointId jointId, float lower, float upper );
void b2PrismaticJoint_EnableMotor( b2JointId jointId, bool enableMotor );
bool b2PrismaticJoint_IsMotorEnabled( b2JointId jointId );
void b2PrismaticJoint_SetMotorSpeed( b2JointId jointId, float motorSpeed );
float b2PrismaticJoint_GetMotorSpeed( b2JointId jointId );
void b2PrismaticJoint_SetMaxMotorForce( b2JointId jointId, float force );
float b2PrismaticJoint_GetMaxMotorForce( b2JointId jointId );
float b2PrismaticJoint_GetMotorForce( b2JointId jointId );
b2JointId b2CreateRevoluteJoint( b2WorldId worldId, const b2RevoluteJointDef* def );
void b2RevoluteJoint_EnableSpring( b2JointId jointId, bool enableSpring );
bool b2RevoluteJoint_IsSpringEnabled( b2JointId jointId );
void b2RevoluteJoint_SetSpringHertz( b2JointId jointId, float hertz );
float b2RevoluteJoint_GetSpringHertz( b2JointId jointId );
void b2RevoluteJoint_SetSpringDampingRatio( b2JointId jointId, float dampingRatio );
float b2RevoluteJoint_GetSpringDampingRatio( b2JointId jointId );
float b2RevoluteJoint_GetAngle( b2JointId jointId );
void b2RevoluteJoint_EnableLimit( b2JointId jointId, bool enableLimit );
bool b2RevoluteJoint_IsLimitEnabled( b2JointId jointId );
float b2RevoluteJoint_GetLowerLimit( b2JointId jointId );
float b2RevoluteJoint_GetUpperLimit( b2JointId jointId );
void b2RevoluteJoint_SetLimits( b2JointId jointId, float lower, float upper );
void b2RevoluteJoint_EnableMotor( b2JointId jointId, bool enableMotor );
bool b2RevoluteJoint_IsMotorEnabled( b2JointId jointId );
void b2RevoluteJoint_SetMotorSpeed( b2JointId jointId, float motorSpeed );
float b2RevoluteJoint_GetMotorSpeed( b2JointId jointId );
float b2RevoluteJoint_GetMotorTorque( b2JointId jointId );
void b2RevoluteJoint_SetMaxMotorTorque( b2JointId jointId, float torque );
float b2RevoluteJoint_GetMaxMotorTorque( b2JointId jointId );
b2JointId b2CreateWeldJoint( b2WorldId worldId, const b2WeldJointDef* def );
float b2WeldJoint_GetReferenceAngle( b2JointId jointId );
void b2WeldJoint_SetReferenceAngle( b2JointId jointId, float angleInRadians );
void b2WeldJoint_SetLinearHertz( b2JointId jointId, float hertz );
float b2WeldJoint_GetLinearHertz( b2JointId jointId );
void b2WeldJoint_SetLinearDampingRatio( b2JointId jointId, float dampingRatio );
float b2WeldJoint_GetLinearDampingRatio( b2JointId jointId );
void b2WeldJoint_SetAngularHertz( b2JointId jointId, float hertz );
float b2WeldJoint_GetAngularHertz( b2JointId jointId );
void b2WeldJoint_SetAngularDampingRatio( b2JointId jointId, float dampingRatio );
float b2WeldJoint_GetAngularDampingRatio( b2JointId jointId );
b2JointId b2CreateWheelJoint( b2WorldId worldId, const b2WheelJointDef* def );
void b2WheelJoint_EnableSpring( b2JointId jointId, bool enableSpring );
bool b2WheelJoint_IsSpringEnabled( b2JointId jointId );
void b2WheelJoint_SetSpringHertz( b2JointId jointId, float hertz );
float b2WheelJoint_GetSpringHertz( b2JointId jointId );
void b2WheelJoint_SetSpringDampingRatio( b2JointId jointId, float dampingRatio );
float b2WheelJoint_GetSpringDampingRatio( b2JointId jointId );
void b2WheelJoint_EnableLimit( b2JointId jointId, bool enableLimit );
bool b2WheelJoint_IsLimitEnabled( b2JointId jointId );
float b2WheelJoint_GetLowerLimit( b2JointId jointId );
float b2WheelJoint_GetUpperLimit( b2JointId jointId );
void b2WheelJoint_SetLimits( b2JointId jointId, float lower, float upper );
void b2WheelJoint_EnableMotor( b2JointId jointId, bool enableMotor );
bool b2WheelJoint_IsMotorEnabled( b2JointId jointId );
void b2WheelJoint_SetMotorSpeed( b2JointId jointId, float motorSpeed );
float b2WheelJoint_GetMotorSpeed( b2JointId jointId );
void b2WheelJoint_SetMaxMotorTorque( b2JointId jointId, float torque );
float b2WheelJoint_GetMaxMotorTorque( b2JointId jointId );
float b2WheelJoint_GetMotorTorque( b2JointId jointId );
]]
box2d = ffi.load('box2d', true)
b2_maxPolygonVertices = 8
B2_DEFAULT_CATEGORY_BITS = ffi.new('unsigned long long', 0x0000000000000001)
B2_DEFAULT_MASK_BITS = ffi.new('unsigned long long', 0xffffffffffffffff)
b2_defaultCategoryBits = B2_DEFAULT_CATEGORY_BITS
b2_defaultMaskBits = B2_DEFAULT_MASK_BITS
b2_nullWorldId = ffi.new('b2WorldId', {})
b2_nullBodyId = ffi.new('b2BodyId', {})
b2_nullShapeId = ffi.new('b2ShapeId', {})
b2_nullJointId = ffi.new('b2JointId', {})
b2_nullChainId = ffi.new('b2ChainId', {})
function B2_IS_NULL(id) return id.index1 == 0 end
function B2_IS_NON_NULL(id) return id.index1 ~= 0 end
function B2_IS_EQUALS(id1, id2) return id1.index1 == id2.index1 and id1.world0 == id2.world0 and id1.revision == id2.revision end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment