Changeset 3361

Show
Ignore:
Timestamp:
02/03/10 09:42:58 (6 weeks ago)
Author:
Azaezel
Message:

simple primitives + a NULL workaround

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

Legend:

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

    r3292 r3361  
    4747//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    4848CollisionShape::CollisionShape() 
    49 :   m_shape(NULL) 
     49:   m_pShape(NULL) 
    5050,   m_pScriptObject(NULL) 
    5151,   m_activationState(1) 
     
    5757 
    5858    m_name = ""; 
     59    m_IsNUllFlaged = false; 
    5960} 
    6061 
     
    6263CollisionShape::~CollisionShape() 
    6364{ 
     65    if (m_pShape != NULL) delete m_pShape; 
    6466} 
    6567 
     
    8284CollisionShape::getShapePtr() 
    8385{ 
    84     return m_shape; 
     86    return m_pShape; 
    8587} 
    8688 
     
    8991CollisionShape::setShapePtr(btCollisionShape* _shape) 
    9092{ 
    91     m_shape = _shape; 
     93    m_pShape = _shape; 
    9294} 
    9395 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBullet/src/CollisionShape.hpp

    r3349 r3361  
    6969 
    7070public: 
    71     /// @ For Internal Newton usage 
     71    /// @ For Internal Bullet usage 
    7272    /// @{ 
    7373    btCollisionShape* getShapePtr(); 
    7474    void setShapePtr(btCollisionShape* _shape); 
     75    void setIsNUllShape(bool _isnull){m_IsNUllFlaged = _isnull;}; 
     76    bool isNULLShape(){return m_IsNUllFlaged;}; 
    7577    /// @} 
    7678 
     
    103105    /// @{ 
    104106private: 
    105     btCollisionShape*                        m_shape; 
    106     wpPhysicsZone_type                     m_pZone; 
    107     Zen::Math::Real                                  m_scaleX, m_scaleY, m_scaleZ; 
    108     Scripting::I_ObjectReference*           m_pScriptObject; 
    109     std::string                             m_name; 
    110         Zen::Math::Real                                                 m_minStrikeLen; 
    111     unsigned                                m_activationState; 
    112         int                                                                             m_collisionGroup; 
    113  
    114         pOwningObject_type                      m_pOwner; 
     107    btCollisionShape*                   m_pShape; 
     108    wpPhysicsZone_type                  m_pZone; 
     109    Zen::Math::Real                     m_scaleX, m_scaleY, m_scaleZ; 
     110    Scripting::I_ObjectReference*       m_pScriptObject; 
     111    std::string                         m_name; 
     112    Zen::Math::Real                     m_minStrikeLen; 
     113    unsigned                            m_activationState; 
     114    int                                 m_collisionGroup; 
     115    bool                                m_IsNUllFlaged;     
     116    pOwningObject_type                  m_pOwner; 
    115117    /// @} 
    116118 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBullet/src/PhysicsActor.cpp

    r3353 r3361  
    6666{ 
    6767    if (m_MotionState != NULL) delete m_MotionState; 
     68    if (m_pActor != NULL) delete m_pActor; 
    6869} 
    6970 
     
    135136    m_pActor = new btRigidBody(rbInfo); 
    136137    m_pActor->setUserPointer(this); 
    137     m_pActor->setCollisionFlags(m_pActor->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK); 
     138    //http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=4461&hilit=btRigidBody+vs+btCollisionObject 
     139    //might rework this to be part of collisiongroups later 
     140    if (dynamic_cast<CollisionShape*>(_collision.get())->isNULLShape()) 
     141    { 
     142        m_pActor->setCollisionFlags(m_pActor->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK | btCollisionObject::CF_NO_CONTACT_RESPONSE); 
     143    } 
     144    else 
     145    { 
     146        m_pActor->setCollisionFlags(m_pActor->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK); 
     147    } 
    138148    return true; 
    139149} 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBullet/src/PhysicsZone.cpp

    r3358 r3361  
    7171PhysicsZone::~PhysicsZone() 
    7272{ 
    73     delete m_pZone; 
    74     delete m_pSolver; 
    75     delete m_pDispatcher; 
    76     delete m_pCollisionConfiguration; 
    77     delete m_pBroadphase; 
     73    if (m_pZone!= NULL) delete m_pZone; 
     74    if (m_pSolver!= NULL) delete m_pSolver; 
     75    if (m_pDispatcher!= NULL) delete m_pDispatcher; 
     76    if (m_pCollisionConfiguration!= NULL) delete m_pCollisionConfiguration; 
     77    if (m_pBroadphase != NULL) delete m_pBroadphase; 
    7878} 
    7979 
     
    312312    CollisionShape* pRawPointer = new CollisionShape(); 
    313313    pCollisionShape_type pShape(pRawPointer, boost::bind(&PhysicsZone::destroyCollisionShape, this, _1)); 
    314     dynamic_cast<CollisionShape*>(pShape.get())->setShapePtr(NewtonCreateNull(m_pZone)); 
     314 
     315    //bit of a hacktastic workaround, but see http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=4461&hilit=btRigidBody+vs+btCollisionObject for intent 
     316    pRawPointer->setShapePtr(new btSphereShape(btScalar(1.))); 
     317    pRawPointer->setIsNUllShape(true); 
    315318    // TODO - set offsetMatrix (currently passing NULL, which centers the body at its origin) 
    316319    return pShape; 
     
    323326    CollisionShape* pRawPointer = new CollisionShape(); 
    324327    pCollisionShape_type pShape(pRawPointer, boost::bind(&PhysicsZone::destroyCollisionShape, this, _1)); 
    325     dynamic_cast<CollisionShape*>(pShape.get())->setShapePtr(NewtonCreateBox(m_pZone, _dx, _dy, _dz, NULL)); 
     328 
     329    pRawPointer->setShapePtr(new btBoxShape(btVector3(_dx,_dy,_dz))); 
    326330    // TODO - set offsetMatrix (currently passing NULL, which centers the body at its origin) 
    327331    return pShape; 
     
    334338    CollisionShape* pRawPointer = new CollisionShape(); 
    335339    pCollisionShape_type pShape(pRawPointer, boost::bind(&PhysicsZone::destroyCollisionShape, this, _1)); 
    336     dynamic_cast<CollisionShape*>(pShape.get())->setShapePtr(NewtonCreateSphere(m_pZone, _radiusX, _radiusY, _radiusZ, NULL)); 
     340 
     341    //seem to recall something about a multisphere shape being scalable in multiple directions... research further 
     342    pRawPointer->setShapePtr(new btSphereShape(btScalar(_radiusX))); 
    337343    // TODO - set offsetMatrix (currently passing NULL, which centers the body at its origin) 
    338344    return pShape; 
     
    346352    CollisionShape* pRawPointer = new CollisionShape(); 
    347353    pCollisionShape_type pShape(pRawPointer, boost::bind(&PhysicsZone::destroyCollisionShape, this, _1)); 
    348     dynamic_cast<CollisionShape*>(pShape.get())->setShapePtr(NewtonCreateCapsule(m_pZone, _radius, _height, NULL)); 
     354 
     355    pRawPointer->setShapePtr(new btCapsuleShape(_radius, _height)); 
    349356    // TODO - set offsetMatrix (currently passing NULL, which centers the body at its origin) 
    350357    return pShape;