31 #include "BulletCollision/CollisionShapes/btCollisionShape.h"
32 #include "BulletDynamics/Dynamics/btDynamicsWorld.h"
33 #include "BulletDynamics/Dynamics/btRigidBody.h"
34 #include "LinearMath/btTransform.h"
35 #include "LinearMath/btDefaultMotionState.h"
39 btRigidBody* tgBulletUtil::createRigidBody(btDynamicsWorld* dynamicsWorld,
41 const btTransform& startTransform,
42 btCollisionShape* shape)
45 btAssert((!shape || shape->getShapeType() != INVALID_SHAPE_PROXYTYPE));
48 bool isDynamic = (mass != 0.f);
50 btVector3 localInertia(0,0,0);
52 shape->calculateLocalInertia(mass,localInertia);
56 #define USE_MOTIONSTATE 1
57 #ifdef USE_MOTIONSTATE
58 btDefaultMotionState* myMotionState =
new btDefaultMotionState(startTransform);
60 btRigidBody::btRigidBodyConstructionInfo cInfo(mass,myMotionState,shape,localInertia);
64 double defaultContactProcessingThreshold = 1.0e30;
66 btRigidBody* body =
new btRigidBody(cInfo);
67 body->setContactProcessingThreshold(defaultContactProcessingThreshold);
70 btRigidBody* body =
new btRigidBody(mass,0,shape,localInertia);
71 body->setWorldTransform(startTransform);
74 dynamicsWorld->addRigidBody(body);
Contains the definition of class tgWorldBulletPhysicsImpl.
static btDynamicsWorld & worldToDynamicsWorld(const tgWorld &world)
btDynamicsWorld & dynamicsWorld() const
tgWorldImpl & implementation() const
Contains the definition of class tgWorld $Id$.
Contains the definition of class tgBulletUtil.