Changeset 3360

Show
Ignore:
Timestamp:
02/02/10 15:59:55 (7 weeks ago)
Author:
Azaezel
Message:

joints now use a 6dof constraint for their up-joint that's created on initialization. we'll likely be adding additional joints to this for linking disparate physics objects later

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/PhysicsJoint.cpp

    r3292 r3360  
    3838:   m_pZone(_zone) 
    3939{ 
     40    m_pConstraint = NULL; 
    4041} 
    4142 
     
    4344PhysicsJoint::~PhysicsJoint() 
    4445{ 
     46    if (m_pConstraint != NULL) delete m_pConstraint; 
    4547} 
    4648 
     
    5658PhysicsJoint::initUpVectorJoint(const Math::Vector3& _upVector) 
    5759{ 
    58     NewtonConstraintCreateUpVector(dynamic_cast<PhysicsZone*>(m_pShape->getPhysicsZone().get())->getZonePtr(), _upVector.m_array, dynamic_cast<PhysicsActor*>(m_pShape.get())->getActorPtr()); 
     60    //reference: http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=4457&hilit=keep+body+upright  
     61    // and http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=2027&hilit=+new+btGeneric6DofConstraint+ 
     62    // see btRotationalLimitMotor::testLimitValue specificly 
     63 
     64    btTransform trans = btTransform(btQuaternion(_upVector.m_x,_upVector.m_y,_upVector.m_z)); 
     65    m_pConstraint = new btGeneric6DofConstraint(*(static_cast<PhysicsActor*>(m_pShape.get())->getActorPtr()), 
     66        *(static_cast<PhysicsActor*>(m_pShape.get())->getActorPtr()), trans, trans.inverse(), false);  
     67 
     68    m_pConstraint->setAngularLowerLimit(btVector3(FLT_MAX,0,0)); 
     69    m_pConstraint->setAngularUpperLimit(btVector3(-FLT_MAX,0,0)); 
     70 
     71    //NewtonConstraintCreateUpVector(dynamic_cast<PhysicsZone*>(m_pShape->getPhysicsZone().get())->getZonePtr(), _upVector.m_array, dynamic_cast<PhysicsActor*>(m_pShape.get())->getActorPtr()); 
    5972} 
    6073 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBullet/src/PhysicsJoint.hpp

    r3292 r3360  
    7171    pPhysicsActor_type m_pShape; 
    7272    wpPhysicsZone_type m_pZone; 
     73    btGeneric6DofConstraint* m_pConstraint; 
    7374    /// @} 
    7475