Back to index

supertuxkart  0.5+dfsg1
Classes | Defines | Typedefs | Functions
Bullet-C-Api.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  plRayCastResult

Defines

#define PL_DECLARE_HANDLE(name)   typedef struct name##__ { int unused; } *name

Typedefs

typedef float plReal
typedef plReal plVector3 [3]
typedef plReal plQuaternion [4]
typedef void(* btBroadphaseCallback )(void *clientData, void *object1, void *object2)
typedef struct plRayCastResult plRayCastResult

Functions

 PL_DECLARE_HANDLE (plPhysicsSdkHandle)
 PL_DECLARE_HANDLE (plDynamicsWorldHandle)
 PL_DECLARE_HANDLE (plRigidBodyHandle)
 PL_DECLARE_HANDLE (plCollisionShapeHandle)
 PL_DECLARE_HANDLE (plConstraintHandle)
 PL_DECLARE_HANDLE (plMeshInterfaceHandle)
 PL_DECLARE_HANDLE (plCollisionBroadphaseHandle)
 PL_DECLARE_HANDLE (plBroadphaseProxyHandle)
 PL_DECLARE_HANDLE (plCollisionWorldHandle)
plPhysicsSdkHandle plNewBulletSdk ()
void plDeletePhysicsSdk (plPhysicsSdkHandle physicsSdk)
plCollisionBroadphaseHandle plCreateSapBroadphase (btBroadphaseCallback beginCallback, btBroadphaseCallback endCallback)
void plDestroyBroadphase (plCollisionBroadphaseHandle bp)
plBroadphaseProxyHandle plCreateProxy (plCollisionBroadphaseHandle bp, void *clientData, plReal minX, plReal minY, plReal minZ, plReal maxX, plReal maxY, plReal maxZ)
void plDestroyProxy (plCollisionBroadphaseHandle bp, plBroadphaseProxyHandle proxyHandle)
void plSetBoundingBox (plBroadphaseProxyHandle proxyHandle, plReal minX, plReal minY, plReal minZ, plReal maxX, plReal maxY, plReal maxZ)
plCollisionWorldHandle plCreateCollisionWorld (plPhysicsSdkHandle physicsSdk)
plDynamicsWorldHandle plCreateDynamicsWorld (plPhysicsSdkHandle physicsSdk)
void plDeleteDynamicsWorld (plDynamicsWorldHandle world)
void plStepSimulation (plDynamicsWorldHandle, plReal timeStep)
void plAddRigidBody (plDynamicsWorldHandle world, plRigidBodyHandle object)
void plRemoveRigidBody (plDynamicsWorldHandle world, plRigidBodyHandle object)
plRigidBodyHandle plCreateRigidBody (void *user_data, float mass, plCollisionShapeHandle cshape)
void plDeleteRigidBody (plRigidBodyHandle body)
plCollisionShapeHandle plNewSphereShape (plReal radius)
plCollisionShapeHandle plNewBoxShape (plReal x, plReal y, plReal z)
plCollisionShapeHandle plNewCapsuleShape (plReal radius, plReal height)
plCollisionShapeHandle plNewConeShape (plReal radius, plReal height)
plCollisionShapeHandle plNewCylinderShape (plReal radius, plReal height)
plCollisionShapeHandle plNewCompoundShape ()
void plAddChildShape (plCollisionShapeHandle compoundShape, plCollisionShapeHandle childShape, plVector3 childPos, plQuaternion childOrn)
void plDeleteShape (plCollisionShapeHandle shape)
plCollisionShapeHandle plNewConvexHullShape ()
void plAddVertex (plCollisionShapeHandle convexHull, plReal x, plReal y, plReal z)
plMeshInterfaceHandle plNewMeshInterface ()
void plAddTriangle (plMeshInterfaceHandle meshHandle, plVector3 v0, plVector3 v1, plVector3 v2)
plCollisionShapeHandle plNewStaticTriangleMeshShape (plMeshInterfaceHandle)
void plSetScaling (plCollisionShapeHandle shape, plVector3 scaling)
void plGetOpenGLMatrix (plRigidBodyHandle object, plReal *matrix)
void plGetPosition (plRigidBodyHandle object, plVector3 position)
void plGetOrientation (plRigidBodyHandle object, plQuaternion orientation)
void plSetPosition (plRigidBodyHandle object, const plVector3 position)
void plSetOrientation (plRigidBodyHandle object, const plQuaternion orientation)
void plSetEuler (plReal yaw, plReal pitch, plReal roll, plQuaternion orient)
int plRayCast (plDynamicsWorldHandle world, const plVector3 rayStart, const plVector3 rayEnd, plRayCastResult res)

Class Documentation

struct plRayCastResult

Definition at line 151 of file Bullet-C-Api.h.

Class Members
plRigidBodyHandle m_body
plVector3 m_normalWorld
plVector3 m_positionWorld
plCollisionShapeHandle m_shape

Define Documentation

#define PL_DECLARE_HANDLE (   name)    typedef struct name##__ { int unused; } *name

Definition at line 26 of file Bullet-C-Api.h.


Typedef Documentation

typedef void(* btBroadphaseCallback)(void *clientData, void *object1, void *object2)

Definition at line 73 of file Bullet-C-Api.h.

typedef plReal plQuaternion[4]

Definition at line 35 of file Bullet-C-Api.h.

typedef float plReal

Definition at line 31 of file Bullet-C-Api.h.

typedef plReal plVector3[3]

Definition at line 34 of file Bullet-C-Api.h.


Function Documentation

PL_DECLARE_HANDLE ( plPhysicsSdkHandle  )
PL_DECLARE_HANDLE ( plDynamicsWorldHandle  )
PL_DECLARE_HANDLE ( plRigidBodyHandle  )
PL_DECLARE_HANDLE ( plCollisionShapeHandle  )
PL_DECLARE_HANDLE ( plConstraintHandle  )
PL_DECLARE_HANDLE ( plMeshInterfaceHandle  )
PL_DECLARE_HANDLE ( plCollisionBroadphaseHandle  )
PL_DECLARE_HANDLE ( plBroadphaseProxyHandle  )
PL_DECLARE_HANDLE ( plCollisionWorldHandle  )
void plAddChildShape ( plCollisionShapeHandle  compoundShape,
plCollisionShapeHandle  childShape,
plVector3  childPos,
plQuaternion  childOrn 
)

Definition at line 202 of file Bullet-C-API.cpp.

{
       btCollisionShape* colShape = reinterpret_cast<btCollisionShape*>(compoundShapeHandle);
       btAssert(colShape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE);
       btCompoundShape* compoundShape = reinterpret_cast<btCompoundShape*>(colShape);
       btCollisionShape* childShape = reinterpret_cast<btCollisionShape*>(childShapeHandle);
       btTransform   localTrans;
       localTrans.setIdentity();
       localTrans.setOrigin(btVector3(childPos[0],childPos[1],childPos[2]));
       localTrans.setRotation(btQuaternion(childOrn[0],childOrn[1],childOrn[2],childOrn[3]));
       compoundShape->addChildShape(localTrans,childShape);
}

Here is the call graph for this function:

void plAddRigidBody ( plDynamicsWorldHandle  world,
plRigidBodyHandle  object 
)

Definition at line 96 of file Bullet-C-API.cpp.

{
       btDynamicsWorld* dynamicsWorld = reinterpret_cast< btDynamicsWorld* >(world);
       assert(dynamicsWorld);
       btRigidBody* body = reinterpret_cast< btRigidBody* >(object);
       assert(body);

       dynamicsWorld->addRigidBody(body);
}

Here is the call graph for this function:

void plAddTriangle ( plMeshInterfaceHandle  meshHandle,
plVector3  v0,
plVector3  v1,
plVector3  v2 
)
void plAddVertex ( plCollisionShapeHandle  convexHull,
plReal  x,
plReal  y,
plReal  z 
)

Definition at line 231 of file Bullet-C-API.cpp.

{
       btCollisionShape* colShape = reinterpret_cast<btCollisionShape*>( cshape);
       btAssert(colShape->getShapeType()==CONVEX_HULL_SHAPE_PROXYTYPE);
       btConvexHullShape* convexHullShape = reinterpret_cast<btConvexHullShape*>( cshape);
       convexHullShape->addPoint(btPoint3(x,y,z));

}

Here is the call graph for this function:

plCollisionWorldHandle plCreateCollisionWorld ( plPhysicsSdkHandle  physicsSdk)
plDynamicsWorldHandle plCreateDynamicsWorld ( plPhysicsSdkHandle  physicsSdk)

Definition at line 67 of file Bullet-C-API.cpp.

{
       btPhysicsSdk* physicsSdk = reinterpret_cast<btPhysicsSdk*>(physicsSdkHandle);
       void* mem = btAlignedAlloc(sizeof(btDefaultCollisionConfiguration),16);
       btDefaultCollisionConfiguration* collisionConfiguration = new (mem)btDefaultCollisionConfiguration();
       mem = btAlignedAlloc(sizeof(btCollisionDispatcher),16);
       btDispatcher*                      dispatcher = new (mem)btCollisionDispatcher(collisionConfiguration);
       mem = btAlignedAlloc(sizeof(btAxisSweep3),16);
       btBroadphaseInterface*             pairCache = new (mem)btAxisSweep3(physicsSdk->m_worldAabbMin,physicsSdk->m_worldAabbMax);
       mem = btAlignedAlloc(sizeof(btSequentialImpulseConstraintSolver),16);
       btConstraintSolver*                constraintSolver = new(mem) btSequentialImpulseConstraintSolver();

       mem = btAlignedAlloc(sizeof(btDiscreteDynamicsWorld),16);
       return (plDynamicsWorldHandle) new (mem)btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver,collisionConfiguration);
}
plBroadphaseProxyHandle plCreateProxy ( plCollisionBroadphaseHandle  bp,
void *  clientData,
plReal  minX,
plReal  minY,
plReal  minZ,
plReal  maxX,
plReal  maxY,
plReal  maxZ 
)
plRigidBodyHandle plCreateRigidBody ( void *  user_data,
float  mass,
plCollisionShapeHandle  cshape 
)

Definition at line 118 of file Bullet-C-API.cpp.

{
       btTransform trans;
       trans.setIdentity();
       btVector3 localInertia(0,0,0);
       btCollisionShape* shape = reinterpret_cast<btCollisionShape*>( cshape);
       assert(shape);
       if (mass)
       {
              shape->calculateLocalInertia(mass,localInertia);
       }
       void* mem = btAlignedAlloc(sizeof(btRigidBody),16);
       btRigidBody::btRigidBodyConstructionInfo rbci(mass, 0,shape,localInertia);
       btRigidBody* body = new (mem)btRigidBody(rbci);
       body->setWorldTransform(trans);
       body->setUserPointer(user_data);
       return (plRigidBodyHandle) body;
}

Here is the call graph for this function:

plCollisionBroadphaseHandle plCreateSapBroadphase ( btBroadphaseCallback  beginCallback,
btBroadphaseCallback  endCallback 
)
void plDeleteDynamicsWorld ( plDynamicsWorldHandle  world)

Definition at line 82 of file Bullet-C-API.cpp.

{
       //todo: also clean up the other allocations, axisSweep, pairCache,dispatcher,constraintSolver,collisionConfiguration
       btDynamicsWorld* dynamicsWorld = reinterpret_cast< btDynamicsWorld* >(world);
       btAlignedFree(dynamicsWorld);
}
void plDeletePhysicsSdk ( plPhysicsSdkHandle  physicsSdk)

Definition at line 59 of file Bullet-C-API.cpp.

{
       btPhysicsSdk* phys = reinterpret_cast<btPhysicsSdk*>(physicsSdk);
       btAlignedFree(phys); 
}
void plDeleteRigidBody ( plRigidBodyHandle  body)

Definition at line 137 of file Bullet-C-API.cpp.

{
       btRigidBody* body = reinterpret_cast< btRigidBody* >(cbody);
       assert(body);
       btAlignedFree( body);
}
void plDeleteShape ( plCollisionShapeHandle  shape)

Definition at line 240 of file Bullet-C-API.cpp.

{
       btCollisionShape* shape = reinterpret_cast<btCollisionShape*>( cshape);
       assert(shape);
       btAlignedFree(shape);
}
void plDestroyBroadphase ( plCollisionBroadphaseHandle  bp)
void plDestroyProxy ( plCollisionBroadphaseHandle  bp,
plBroadphaseProxyHandle  proxyHandle 
)
void plGetOpenGLMatrix ( plRigidBodyHandle  object,
plReal matrix 
)

Definition at line 276 of file Bullet-C-API.cpp.

{
       btRigidBody* body = reinterpret_cast< btRigidBody* >(object);
       btAssert(body);
       body->getWorldTransform().getOpenGLMatrix(matrix);

}
void plGetOrientation ( plRigidBodyHandle  object,
plQuaternion  orientation 
)

Definition at line 294 of file Bullet-C-API.cpp.

{
       btRigidBody* body = reinterpret_cast< btRigidBody* >(object);
       btAssert(body);
       const btQuaternion& orn = body->getWorldTransform().getRotation();
       orientation[0] = orn.getX();
       orientation[1] = orn.getY();
       orientation[2] = orn.getZ();
       orientation[3] = orn.getW();
}

Here is the call graph for this function:

void plGetPosition ( plRigidBodyHandle  object,
plVector3  position 
)

Definition at line 284 of file Bullet-C-API.cpp.

{
       btRigidBody* body = reinterpret_cast< btRigidBody* >(object);
       btAssert(body);
       const btVector3& pos = body->getWorldTransform().getOrigin();
       position[0] = pos.getX();
       position[1] = pos.getY();
       position[2] = pos.getZ();
}

Here is the call graph for this function:

plCollisionShapeHandle plNewBoxShape ( plReal  x,
plReal  y,
plReal  z 
)

Definition at line 154 of file Bullet-C-API.cpp.

{
       void* mem = btAlignedAlloc(sizeof(btBoxShape),16);
       return (plCollisionShapeHandle) new (mem)btBoxShape(btVector3(x,y,z));
}
plPhysicsSdkHandle plNewBulletSdk ( )

Definition at line 53 of file Bullet-C-API.cpp.

{
       void* mem = btAlignedAlloc(sizeof(btPhysicsSdk),16);
       return (plPhysicsSdkHandle)new (mem)btPhysicsSdk;
}
plCollisionShapeHandle plNewCapsuleShape ( plReal  radius,
plReal  height 
)

Definition at line 160 of file Bullet-C-API.cpp.

{
       //capsule is convex hull of 2 spheres, so use btMultiSphereShape
       btVector3 inertiaHalfExtents(radius,height,radius);
       const int numSpheres = 2;
       btVector3 positions[numSpheres] = {btVector3(0,height,0),btVector3(0,-height,0)};
       btScalar radi[numSpheres] = {radius,radius};
       void* mem = btAlignedAlloc(sizeof(btMultiSphereShape),16);
       return (plCollisionShapeHandle) new (mem)btMultiSphereShape(inertiaHalfExtents,positions,radi,numSpheres);
}
plCollisionShapeHandle plNewCompoundShape ( )

Definition at line 196 of file Bullet-C-API.cpp.

{
       void* mem = btAlignedAlloc(sizeof(btCompoundShape),16);
       return (plCollisionShapeHandle) new (mem)btCompoundShape();
}
plCollisionShapeHandle plNewConeShape ( plReal  radius,
plReal  height 
)

Definition at line 170 of file Bullet-C-API.cpp.

{
       void* mem = btAlignedAlloc(sizeof(btConeShape),16);
       return (plCollisionShapeHandle) new (mem)btConeShape(radius,height);
}
plCollisionShapeHandle plNewConvexHullShape ( )

Definition at line 183 of file Bullet-C-API.cpp.

{
       void* mem = btAlignedAlloc(sizeof(btConvexHullShape),16);
       return (plCollisionShapeHandle) new (mem)btConvexHullShape();
}
plCollisionShapeHandle plNewCylinderShape ( plReal  radius,
plReal  height 
)

Definition at line 176 of file Bullet-C-API.cpp.

{
       void* mem = btAlignedAlloc(sizeof(btCylinderShape),16);
       return (plCollisionShapeHandle) new (mem)btCylinderShape(btVector3(radius,height,radius));
}
plMeshInterfaceHandle plNewMeshInterface ( )

Definition at line 191 of file Bullet-C-API.cpp.

{
       return 0;
}
plCollisionShapeHandle plNewSphereShape ( plReal  radius)

Definition at line 147 of file Bullet-C-API.cpp.

{
       void* mem = btAlignedAlloc(sizeof(btSphereShape),16);
       return (plCollisionShapeHandle) new (mem)btSphereShape(radius);
       
}
plCollisionShapeHandle plNewStaticTriangleMeshShape ( plMeshInterfaceHandle  )
int plRayCast ( plDynamicsWorldHandle  world,
const plVector3  rayStart,
const plVector3  rayEnd,
plRayCastResult  res 
)
void plRemoveRigidBody ( plDynamicsWorldHandle  world,
plRigidBodyHandle  object 
)

Definition at line 106 of file Bullet-C-API.cpp.

{
       btDynamicsWorld* dynamicsWorld = reinterpret_cast< btDynamicsWorld* >(world);
       assert(dynamicsWorld);
       btRigidBody* body = reinterpret_cast< btRigidBody* >(object);
       assert(body);

       dynamicsWorld->removeRigidBody(body);
}

Here is the call graph for this function:

void plSetBoundingBox ( plBroadphaseProxyHandle  proxyHandle,
plReal  minX,
plReal  minY,
plReal  minZ,
plReal  maxX,
plReal  maxY,
plReal  maxZ 
)
void plSetEuler ( plReal  yaw,
plReal  pitch,
plReal  roll,
plQuaternion  orient 
)

Definition at line 215 of file Bullet-C-API.cpp.

{
       btQuaternion orn;
       orn.setEuler(yaw,pitch,roll);
       orient[0] = orn.getX();
       orient[1] = orn.getY();
       orient[2] = orn.getZ();
       orient[3] = orn.getW();

}

Here is the call graph for this function:

void plSetOrientation ( plRigidBodyHandle  object,
const plQuaternion  orientation 
)

Definition at line 266 of file Bullet-C-API.cpp.

{
       btRigidBody* body = reinterpret_cast< btRigidBody* >(object);
       btAssert(body);
       btQuaternion orn(orientation[0],orientation[1],orientation[2],orientation[3]);
       btTransform worldTrans = body->getWorldTransform();
       worldTrans.setRotation(orn);
       body->setWorldTransform(worldTrans);
}

Here is the call graph for this function:

void plSetPosition ( plRigidBodyHandle  object,
const plVector3  position 
)

Definition at line 256 of file Bullet-C-API.cpp.

{
       btRigidBody* body = reinterpret_cast< btRigidBody* >(object);
       btAssert(body);
       btVector3 pos(position[0],position[1],position[2]);
       btTransform worldTrans = body->getWorldTransform();
       worldTrans.setOrigin(pos);
       body->setWorldTransform(worldTrans);
}

Here is the call graph for this function:

void plSetScaling ( plCollisionShapeHandle  shape,
plVector3  scaling 
)

Definition at line 246 of file Bullet-C-API.cpp.

{
       btCollisionShape* shape = reinterpret_cast<btCollisionShape*>( cshape);
       assert(shape);
       btVector3 scaling(cscaling[0],cscaling[1],cscaling[2]);
       shape->setLocalScaling(scaling);   
}

Here is the call graph for this function:

void plStepSimulation ( plDynamicsWorldHandle  ,
plReal  timeStep 
)

Definition at line 89 of file Bullet-C-API.cpp.

{
       btDynamicsWorld* dynamicsWorld = reinterpret_cast< btDynamicsWorld* >(world);
       assert(dynamicsWorld);
       dynamicsWorld->stepSimulation(timeStep);
}

Here is the call graph for this function: