PhyWorld.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. #include "PhyWorld.h"
  2. //======================================================================================================================
  3. // createNewRigidBody =
  4. //======================================================================================================================
  5. btRigidBody* PhyWorld::createNewRigidBody( float mass, const Transform& startTransform, btCollisionShape* shape, SceneNode* node, int group,
  6. int mask )
  7. {
  8. DEBUG_ERR( shape==NULL || shape->getShapeType()==INVALID_SHAPE_PROXYTYPE );
  9. //rigidbody is dynamic if and only if mass is non zero, otherwise static
  10. bool isDynamic = (mass != 0.0);
  11. btVector3 localInertia( 0, 0, 0 );
  12. if( isDynamic )
  13. shape->calculateLocalInertia( mass,localInertia );
  14. MotionState* myMotionState = new MotionState( toBt(startTransform), node );
  15. btRigidBody::btRigidBodyConstructionInfo cInfo( mass, myMotionState, shape, localInertia );
  16. btRigidBody* body = new btRigidBody( cInfo );
  17. body->setContactProcessingThreshold( defaultContactProcessingThreshold );
  18. if( mask==-1 & group==-1 )
  19. dynamicsWorld->addRigidBody( body );
  20. else
  21. dynamicsWorld->addRigidBody( body, group, mask );
  22. return body;
  23. }