- Timestamp:
- 02/01/10 15:59:41 (6 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBullet/src/PhysicsActor.cpp
r3349 r3352 59 59 m_name = ""; 60 60 m_MotionState = NULL; 61 m_mass = 0.0f; 61 62 } 62 63 … … 79 80 { 80 81 m_CollisionShape = _pCollisionShape; 82 m_mass = 0.0f; 81 83 attachBody(m_CollisionShape); 82 84 } … … 126 128 // TreeCollision (not impl yet), UserMesh (heightfield) 127 129 128 129 130 m_pActor = NewtonCreateBody(dynamic_cast<PhysicsZone*>(m_pZone.get())->getZonePtr(), dynamic_cast<CollisionShape*>(_collision.get())->getShapePtr());131 NewtonReleaseCollision(dynamic_cast<PhysicsZone*>(m_pZone.get())->getZonePtr(), dynamic_cast<CollisionShape*>(_collision.get())->getShapePtr());132 133 130 // set the transform call back function 134 m_MotionState = new PhysicsActor::ZenMotionState(this); 135 131 m_MotionState = new MotionState(this); 132 //mass, motionstate, collisionshape, and inertia are all necessary prior to creation for bullet 133 btRigidBody::btRigidBodyConstructionInfo rbInfo(m_mass,m_MotionState,dynamic_cast<CollisionShape*>(_collision.get())->getShapePtr(),btVector3(0.0f,0.0f,0.0f)); 134 135 m_pActor = new btRigidBody(rbInfo); 136 136 m_pActor->setUserPointer(this); 137 137 m_pActor->setCollisionFlags(m_pActor->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK); 138 138 return true; 139 139 } … … 204 204 PhysicsActor::getMass() 205 205 { 206 Zen::Math::Real mass; 207 Zen::Math::Real Ixx; 208 Zen::Math::Real Iyy; 209 Zen::Math::Real Izz; 210 btRigidBodyGetMassMatrix(m_pActor, &mass, &Ixx, &Iyy, &Izz); 211 212 return mass; 213 } 214 215 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 206 return m_mass; 207 } 208 209 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 210 //this gets a bit arcane since we're dealing with bit-flags. see http://www.cprogramming.com/tutorial/bitwise_operators.html for reference - bjr 216 211 void 217 212 PhysicsActor::SetStatic(bool _isStatic = false) … … 221 216 { 222 217 setMass(0); 218 m_pActor->setCollisionFlags(m_pActor->getCollisionFlags() | btCollisionObject::CF_STATIC_OBJECT); 223 219 } 224 220 else 221 { 225 222 setMass(m_mass); 223 m_pActor->setCollisionFlags(m_pActor->getCollisionFlags() & ~btCollisionObject::CF_STATIC_OBJECT); 224 } 226 225 } 227 226 … … 245 244 PhysicsActor::setMass(float _mass) 246 245 { 247 // set the mass to zero to make this a static body. 248 // set the mass to any positive value to make this a dynamic body. 249 Zen::Math::Real Ixx = _mass * m_scaleX * m_scaleX; 250 Zen::Math::Real Iyy = _mass * m_scaleY * m_scaleY; 251 Zen::Math::Real Izz = _mass * m_scaleZ * m_scaleZ; 252 btRigidBodySetMassMatrix(m_pActor, _mass, Ixx, Iyy, Izz); 246 m_mass = _mass; 253 247 } 254 248 … … 425 419 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 426 420 void 427 PhysicsActor:: ZenMotionState::getWorldTransform(btTransform& _worldTrans) const428 { 429 430 } 431 432 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 433 void 434 PhysicsActor:: ZenMotionState::setWorldTransform(const btTransform& _worldTrans)421 PhysicsActor::MotionState::getWorldTransform(btTransform& _worldTrans) const 422 { 423 //don't belive we really need anything here since were updating visuals on the set end... might need to crosscheck later -bjr 424 } 425 426 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 427 void 428 PhysicsActor::MotionState::setWorldTransform(const btTransform& _worldTrans) 435 429 { 436 430 if (m_userPointer == NULL) return;
