Changeset 3317

Show
Ignore:
Timestamp:
01/26/10 10:55:08 (8 weeks ago)
Author:
Azaezel
Message:

world initialization rough draft

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

    r3294 r3317  
    3737#include <Zen/Core/Math/Vector4.hpp> 
    3838 
    39 //#include <dVector.h> //no likey. recheck 
    40  
    4139//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    4240namespace Zen { 
    4341namespace ZBullet { 
    4442//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
     43//refnote: http://bulletphysics.org/mediawiki-1.5.8/index.php/Hello_World 
    4544PhysicsZone::PhysicsZone() 
    4645:   m_pScriptModule(Engine::Physics::I_PhysicsManager::getSingleton().getDefaultScriptModule()) 
    4746,   m_pScriptObject(NULL) 
    4847{ 
    49     m_pZone = NewtonCreate(NULL, NULL); 
    50  
    51     m_vGravity = Math::Vector3(0.0f, -9.8f, 0.0f); 
     48 
    5249    m_bDefaultMaterialCreated = false; 
    5350 
    54     NewtonSetFrictionModel(m_pZone, 1); 
    55     NewtonSetSolverModel(m_pZone, 2); 
     51    // Build the broadphase 
     52    int maxProxies = 1024; 
     53    btVector3 worldAabbMin(-10000,-10000,-10000); 
     54    btVector3 worldAabbMax(10000,10000,10000); 
     55    m_pBroadphase = new btAxisSweep3(worldAabbMin,worldAabbMax,maxProxies); 
     56  
     57    // Set up the collision configuration and dispatcher 
     58    m_pCollisionConfiguration = new btDefaultCollisionConfiguration(); 
     59    m_pDispatcher = new btCollisionDispatcher(collisionConfiguration); 
     60  
     61    // The actual physics solver 
     62    m_pSolver = new btSequentialImpulseConstraintSolver; 
     63  
     64    // The world. 
     65    m_pZone = new btDiscreteDynamicsWorld(m_pDispatcher,m_pBroadphase,m_pSolver,m_pCollisionConfiguration); 
     66    m_pZone->setGravity(btVector3(0.0f, -9.8f, 0.0f)); 
    5667} 
    5768 
     
    5970PhysicsZone::~PhysicsZone() 
    6071{ 
    61     NewtonDestroy(m_pZone); 
     72    delete m_pDynamicsWorld; 
     73    delete m_pSolver; 
     74    delete m_pDispatcher; 
     75    delete m_pCollisionConfiguration; 
     76    delete m_pBroadphase; 
    6277} 
    6378 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBullet/src/PhysicsZone.hpp

    r3294 r3317  
    159159    /// @{ 
    160160private: 
    161     btDiscreteDynamicsWorld*                        m_pZone; 
     161    btDiscreteDynamicsWorld*            m_pZone; 
     162    btAxisSweep3*                       m_pBroadphase; 
     163    btCollisionDispatcher*              m_pDispatcher; 
     164    btDefaultCollisionConfiguration*    m_pCollisionConfiguration; 
     165    btSequentialImpulseConstraintSolver* m_pSolver; 
    162166    Math::Vector3                       m_vGravity; 
    163167    bool                                m_bDefaultMaterialCreated;