Changeset 3323

Show
Ignore:
Timestamp:
01/28/10 14:26:31 (7 weeks ago)
Author:
Azaezel
Message:

further documentation on motionstates. removes ApplyForceAndTorqueCallback?. highly newton specific

Location:
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBullet/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBullet/src/PhysicsActor.cpp

    r3318 r3323  
    460460 
    461461//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    462 void 
    463 PhysicsActor::ApplyForceAndTorqueCallback(const btRigidBody* _body) 
    464 { 
    465     class ApplyForcesEventData 
    466     :   public I_ApplyForcesEventData 
    467     { 
    468         /// @name I_ApplyForcesEventData implementation 
    469         /// @{ 
    470     public: 
    471         /// Get the physics shape associated with this event 
    472         virtual I_PhysicsActor& getActor() 
    473         { 
    474             return *m_pShape; 
    475         } 
    476  
    477         /// Apply a force to this shape 
    478         virtual void applyForce(const Math::Vector3& _force) 
    479         { 
    480             m_pShape->applyForce(_force); 
    481         } 
    482  
    483         /// Apply torque to this shape 
    484         virtual void applyTorque(const Math::Vector3& _torque) 
    485         { 
    486             m_pShape->applyTorque(_torque); 
    487         } 
    488  
    489         /// @} 
    490  
    491         /// @name 'Structors 
    492         /// @{ 
    493     public: 
    494         ApplyForcesEventData(PhysicsActor* _pShape) 
    495         :   m_pShape(_pShape) 
    496         { 
    497         } 
    498  
    499         virtual ~ApplyForcesEventData() 
    500         { 
    501         } 
    502         /// @} 
    503  
    504         /// @name Member Variables 
    505         /// @{ 
    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 active 
    518         if (pPhysicsActor->m_activationState != 0) 
    519         { 
    520             ApplyForcesEventData eventData(pPhysicsActor); 
    521             eventData.getActor().onApplyForcesEvent(eventData); 
    522         } 
    523     } 
    524 } 
    525  
    526 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    527 void 
    528 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 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    538462Engine::Physics::I_PhysicsActor& 
    539463PhysicsActor::TransformEventData::getActor() 
     
    561485    return m_otherActor; 
    562486} 
    563  
     487//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
     488void  
     489PhysicsActor::ZenMotionState::setWorldTransform(const btTransform &_worldTrans) 
     490{ 
     491 
     492} 
    564493//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    565494Scripting::I_ObjectReference* 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBullet/src/PhysicsActor.hpp

    r3322 r3323  
    113113private: 
    114114    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  
    118115    void applyForce(const Math::Vector3& _force); 
    119116    void applyTorque(const Math::Vector3& _torque); 
     
    354351 
    355352    };  // 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) 
    357357        class ZenMotionState : public btMotionState 
    358358        { 
     
    360360            ZenMotionState(); 
    361361            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); 
    364365        }; 
    365  
    366366    /// @name Extended Member Variables 
    367367    /// @{ 
     
    376376,   m_transform(_transform) 
    377377{ 
    378     m_MotionState->setWorldTransform(_transform); 
    379378} 
    380379