Changeset 3347

Show
Ignore:
Timestamp:
02/01/10 12:08:08 (7 weeks ago)
Author:
Azaezel
Message:

bullet userdata and applyForce conversions, zone simulation stepping, adds applyImpulse to both plugins. also: setAdvancedCollisionPrediction made irrelevant for this plugin.

NOTE: major difference in applyImpulse implementations: for newton, the position is in world-space. for bullet, it's in object-space... need to resolve that

Location:
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2
Files:
6 modified

Legend:

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

    r3339 r3347  
    141141PhysicsActor::setAdvancedCollisionPrediction(bool _mode) 
    142142{ 
    143     if (_mode) 
    144     { 
    145         btRigidBodySetContinuousCollisionMode(m_pActor, 1); 
    146     } 
    147     else 
    148     { 
    149         btRigidBodySetContinuousCollisionMode(m_pActor, 0); 
    150     } 
     143//no ccd switch available 
    151144} 
    152145 
     
    155148PhysicsActor::getAdvancedCollisionPrediction() const 
    156149{ 
    157     return (btRigidBodyGetContinuousCollisionMode(m_pActor) != 0); 
     150    return 1;//no ccd switch available 
    158151} 
    159152 
     
    512505PhysicsActor::applyForce(const Math::Vector3& _force) 
    513506{ 
    514     btRigidBodyAddForce(m_pActor, _force.m_array); 
     507    m_pActor->applyCentralImpulse(btVector3(_force.m_x,_force.m_y,_force.m_z)); 
     508} 
     509 
     510//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
     511void 
     512PhysicsActor::applyImpulse(const Math::Vector3& _force, const Math::Vector3& _worldPos) 
     513{ 
     514    //todo: bullet needs it's force fed to it in local space coords 
     515     m_pActor->applyForce(btVector3(_force.m_x,_force.m_y,_force.m_z), btVector3(_worldPos.m_x,_worldPos.m_y,_worldPos.m_z)); 
    515516} 
    516517 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBullet/src/PhysicsActor.hpp

    r3339 r3347  
    116116    static void TransformCallback(const btRigidBody* _body, const Zen::Math::Real* _matrix); 
    117117    void applyForce(const Math::Vector3& _force); 
     118    void applyImpulse(const Math::Vector3& _force, const Math::Vector3& _worldPos); 
     119 
    118120    void applyTorque(const Math::Vector3& _torque); 
    119121    /// @} 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBullet/src/PhysicsService.cpp

    r3342 r3347  
    5656    // TODO evaluate whether or not we should have an unregister function for removing worlds from the list. 
    5757 
    58     PhysicsZone* pRawZone = new PhysicsZone(); 
     58    PhysicsZone* pRawZone = new PhysicsZone(_min,_max); 
    5959    pPhysicsZone_type pZone = pPhysicsZone_type(pRawZone, boost::bind(&PhysicsService::onDestroyPhysicsZone, this, _1)); 
    6060    m_zoneSet.insert(pZone); 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBullet/src/PhysicsZone.cpp

    r3342 r3347  
    269269{ 
    270270    PhysicsZone::RayCastResult* pCastquery = static_cast<PhysicsZone::RayCastResult*>(_pUserData); 
    271     PhysicsActor* pRawPhysicsActor = static_cast<PhysicsActor*>(btRigidBodyGetUserData(_pBody)); 
     271    PhysicsActor* pRawPhysicsActor = static_cast<PhysicsActor*>(_pBody->getUserPointer()); 
    272272    assert(pCastquery != NULL); 
    273273    assert(pRawPhysicsActor != NULL); 
     
    290290{ 
    291291    PhysicsZone::RayCastResult* pCastquery = static_cast<PhysicsZone::RayCastResult*>(_pUserData); 
    292     PhysicsActor* pRawPhysicsActor = static_cast<PhysicsActor*>(btRigidBodyGetUserData(_pBody)); 
     292    PhysicsActor* pRawPhysicsActor = static_cast<PhysicsActor*>(_pBody->getUserPointer()); 
    293293    assert(pCastquery != NULL); 
    294294    assert(pRawPhysicsActor != NULL); 
     
    594594PhysicsZone::stepSimulation(double _elapsedTime) 
    595595{ 
    596     NewtonUpdate(getZonePtr(), (Zen::Math::Real)_elapsedTime); 
     596    getZonePtr()->stepSimulation((Zen::Math::Real)_elapsedTime); 
    597597} 
    598598 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZNewton/src/PhysicsActor.cpp

    r3339 r3347  
    618618//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    619619void 
     620PhysicsActor::applyImpulse(const Math::Vector3& _force, const Math::Vector3& _worldPos) 
     621{ 
     622    //todo: bullet needs it's force fed to it in local space coords 
     623     NewtonAddBodyImpulse(m_pActor, _force.m_array, _worldPos.m_array); 
     624} 
     625 
     626//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
     627void 
    620628PhysicsActor::applyTorque(const Math::Vector3& _torque) 
    621629{ 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZNewton/src/PhysicsActor.hpp

    r3339 r3347  
    117117 
    118118    void applyForce(const Math::Vector3& _force); 
     119    void applyImpulse(const Math::Vector3& _force, const Math::Vector3& _worldPos); 
    119120    void applyTorque(const Math::Vector3& _torque); 
    120121    /// @}