Changeset 3323
- Timestamp:
- 01/28/10 14:26:31 (7 weeks ago)
- Location:
- plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBullet/src
- Files:
-
- 2 modified
-
PhysicsActor.cpp (modified) (2 diffs)
-
PhysicsActor.hpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBullet/src/PhysicsActor.cpp
r3318 r3323 460 460 461 461 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 462 void463 PhysicsActor::ApplyForceAndTorqueCallback(const btRigidBody* _body)464 {465 class ApplyForcesEventData466 : public I_ApplyForcesEventData467 {468 /// @name I_ApplyForcesEventData implementation469 /// @{470 public:471 /// Get the physics shape associated with this event472 virtual I_PhysicsActor& getActor()473 {474 return *m_pShape;475 }476 477 /// Apply a force to this shape478 virtual void applyForce(const Math::Vector3& _force)479 {480 m_pShape->applyForce(_force);481 }482 483 /// Apply torque to this shape484 virtual void applyTorque(const Math::Vector3& _torque)485 {486 m_pShape->applyTorque(_torque);487 }488 489 /// @}490 491 /// @name 'Structors492 /// @{493 public:494 ApplyForcesEventData(PhysicsActor* _pShape)495 : m_pShape(_pShape)496 {497 }498 499 virtual ~ApplyForcesEventData()500 {501 }502 /// @}503 504 /// @name Member Variables505 /// @{506 private:507 PhysicsActor* m_pShape;508 /// @}509 510 }; // class ApplyForcesEventData;511 512 void* pBody = btRigidBodyGetUserData(_body);513 if (pBody != NULL)514 {515 PhysicsActor* pPhysicsActor = static_cast<PhysicsActor*>(pBody);516 517 // Only apply forces if the state is active518 if (pPhysicsActor->m_activationState != 0)519 {520 ApplyForcesEventData eventData(pPhysicsActor);521 eventData.getActor().onApplyForcesEvent(eventData);522 }523 }524 }525 526 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~527 void528 PhysicsActor::ActivationStateCallback(const btRigidBody* _body, unsigned _state)529 {530 void* pBody = btRigidBodyGetUserData(_body);531 if (pBody != NULL)532 {533 static_cast<PhysicsActor*>(pBody)->setActivationState(_state);534 }535 }536 537 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~538 462 Engine::Physics::I_PhysicsActor& 539 463 PhysicsActor::TransformEventData::getActor() … … 561 485 return m_otherActor; 562 486 } 563 487 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 488 void 489 PhysicsActor::ZenMotionState::setWorldTransform(const btTransform &_worldTrans) 490 { 491 492 } 564 493 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 565 494 Scripting::I_ObjectReference* -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBullet/src/PhysicsActor.hpp
r3322 r3323 113 113 private: 114 114 static void TransformCallback(const btRigidBody* _body, const Zen::Math::Real* _matrix); 115 static void ApplyForceAndTorqueCallback(const btRigidBody* _pBody);116 static void ActivationStateCallback(const btRigidBody* body, unsigned state);117 118 115 void applyForce(const Math::Vector3& _force); 119 116 void applyTorque(const Math::Vector3& _torque); … … 354 351 355 352 }; // class EndCollisionEventData 356 private: 353 public: 354 //copied from the bullet headers: 355 //The btMotionState interface class allows the dynamics world to synchronize and interpolate the updated world transforms with graphics 356 //For optimizations, potentially only moving objects get synchronized (using setWorldPosition/setWorldOrientation) 357 357 class ZenMotionState : public btMotionState 358 358 { … … 360 360 ZenMotionState(); 361 361 virtual ~ZenMotionState(); 362 virtual void getWorldTransform(btTransform &worldTrans) const; 363 virtual void setWorldTransform(const btTransform &worldTrans); 362 virtual void getWorldTransform(btTransform& _worldTrans) const; 363 //Bullet only calls the update of worldtransform for active objects 364 virtual void setWorldTransform(const btTransform& _worldTrans); 364 365 }; 365 366 366 /// @name Extended Member Variables 367 367 /// @{ … … 376 376 , m_transform(_transform) 377 377 { 378 m_MotionState->setWorldTransform(_transform);379 378 } 380 379
