diff options
author | Erwin Coumans <blender@erwincoumans.com> | 2006-11-21 15:26:05 +0300 |
---|---|---|
committer | Erwin Coumans <blender@erwincoumans.com> | 2006-11-21 15:26:05 +0300 |
commit | 8ad6d7f401b5160cf1a762a27b844c7dd42be8a7 (patch) | |
tree | e9dd49d734df0f964ad0e724628f5c8a8f3aad6b /source | |
parent | 318b98fc9a8fe31a6b71c6e71eb0f486fd59b25a (diff) |
more Bullet 2.x upgrading. fair amount of functionality is now restored, not all yet.
Diffstat (limited to 'source')
4 files changed, 63 insertions, 23 deletions
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index d637df95756..ca75b77dfec 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -889,12 +889,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, CcdConstructionInfo ci; class PHY_IMotionState* motionstate = new KX_MotionState(gameobj->GetSGNode()); - if (objprop->m_ghost) - { - - ci.m_collisionFlags |= btCollisionObject::CF_NO_CONTACT_RESPONSE; - } if (!objprop->m_dyna) { @@ -973,7 +968,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, halfExtents /= 2.f; - bm = new btConeShape(objprop->m_boundobject.c.m_radius,objprop->m_boundobject.c.m_height); + bm = new btConeShapeZ(objprop->m_boundobject.c.m_radius,objprop->m_boundobject.c.m_height); bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor); break; @@ -1078,10 +1073,15 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, gameobj->SetPhysicsController(physicscontroller,isbulletdyna); physicscontroller->setNewClientInfo(gameobj->getClientInfo()); + btRigidBody* rbody = physicscontroller->GetRigidBody(); if (objprop->m_disableSleeping) - physicscontroller->GetRigidBody()->setActivationState(DISABLE_DEACTIVATION); + rbody->setActivationState(DISABLE_DEACTIVATION); + if (objprop->m_ghost) + { + rbody->setCollisionFlags(rbody->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE); + } if (objprop->m_dyna && !objprop->m_angular_rigidbody) { /* diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index e542c336559..31cea0be9e1 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -165,7 +165,7 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time) btVector3 worldPos; btQuaternion worldquat; - m_MotionState->getWorldPosition(worldPos[0],worldPos[1],worldPos[2]); +/* m_MotionState->getWorldPosition(worldPos[0],worldPos[1],worldPos[2]); m_MotionState->getWorldOrientation(worldquat[0],worldquat[1],worldquat[2],worldquat[3]); btTransform oldTrans = m_body->getCenterOfMassTransform(); btTransform newTrans(worldquat,worldPos); @@ -174,7 +174,7 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time) //need to keep track of previous position for friction effects... m_MotionState->calculateWorldTransformations(); - +*/ float scale[3]; m_MotionState->getWorldScaling(scale[0],scale[1],scale[2]); btVector3 scaling(scale[0],scale[1],scale[2]); @@ -245,7 +245,12 @@ void CcdPhysicsController::RelativeTranslate(float dlocX,float dlocY,float dloc { if (m_body) { - m_body->activate(); + m_body->activate(true); + if (m_body->isStaticObject()) + { + m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); + } + btVector3 dloc(dlocX,dlocY,dlocZ); btTransform xform = m_body->getCenterOfMassTransform(); @@ -265,7 +270,11 @@ void CcdPhysicsController::RelativeRotate(const float rotval[9],bool local) { if (m_body ) { - m_body->activate(); + m_body->activate(true); + if (m_body->isStaticObject()) + { + m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); + } btMatrix3x3 drotmat( rotval[0],rotval[1],rotval[2], rotval[4],rotval[5],rotval[6], @@ -303,7 +312,12 @@ void CcdPhysicsController::getOrientation(float &quatImag0,float &quatImag1,flo } void CcdPhysicsController::setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal) { - m_body->activate(); + m_body->activate(true); + if (m_body->isStaticObject()) + { + m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); + } + m_MotionState->setWorldOrientation(quatImag0,quatImag1,quatImag2,quatReal); btTransform xform = m_body->getCenterOfMassTransform(); xform.setRotation(btQuaternion(quatImag0,quatImag1,quatImag2,quatReal)); @@ -313,7 +327,11 @@ void CcdPhysicsController::setOrientation(float quatImag0,float quatImag1,float void CcdPhysicsController::setPosition(float posX,float posY,float posZ) { - m_body->activate(); + m_body->activate(true); + if (m_body->isStaticObject()) + { + m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); + } m_MotionState->setWorldPosition(posX,posY,posZ); btTransform xform = m_body->getCenterOfMassTransform(); xform.setOrigin(btVector3(posX,posY,posZ)); @@ -376,7 +394,7 @@ void CcdPhysicsController::SetAngularVelocity(float ang_velX,float ang_velY,flo btVector3 angvel(ang_velX,ang_velY,ang_velZ); if (angvel.length2() > (SIMD_EPSILON*SIMD_EPSILON)) { - m_body->activate(); + m_body->activate(true); } { @@ -396,7 +414,7 @@ void CcdPhysicsController::SetLinearVelocity(float lin_velX,float lin_velY,floa btVector3 linVel(lin_velX,lin_velY,lin_velZ); if (linVel.length2() > (SIMD_EPSILON*SIMD_EPSILON)) { - m_body->activate(); + m_body->activate(true); } { diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 9533adfa3d5..c9cd66bda8b 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -251,6 +251,12 @@ public: #endif //NEW_BULLET_VEHICLE_SUPPORT +void CcdPhysicsEnvironment::setDebugDrawer(btIDebugDraw* debugDrawer) +{ + if (debugDrawer && m_dynamicsWorld) + m_dynamicsWorld->setDebugDrawer(debugDrawer); + m_debugDrawer = debugDrawer; +} static void DrawAabb(btIDebugDraw* debugDrawer,const btVector3& from,const btVector3& to,const btVector3& color) { @@ -321,7 +327,7 @@ m_enableSatCollisionDetection(false) setSolverType(1);//issues with quickstep and memory allocations - m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache); + m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,new btSequentialImpulseConstraintSolver2()); m_debugDrawer = 0; m_gravity = btVector3(0.f,-10.f,0.f); m_dynamicsWorld->setGravity(m_gravity); @@ -340,6 +346,12 @@ void CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl) m_controllers.push_back(ctrl); m_dynamicsWorld->addRigidBody(body); + if (body->isStaticOrKinematicObject()) + { + body->setActivationState(ISLAND_SLEEPING); + } + + //CollisionObject(body,ctrl->GetCollisionFilterGroup(),ctrl->GetCollisionFilterMask()); assert(body->getBroadphaseHandle()); @@ -438,15 +450,28 @@ void CcdPhysicsEnvironment::beginFrame() bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep) { - int numCtrl = GetNumControllers(); - for (int i=0;i<numCtrl;i++) + int i,numCtrl = GetNumControllers(); + for (i=0;i<numCtrl;i++) { CcdPhysicsController* ctrl = GetPhysicsController(i); ctrl->SynchronizeMotionStates(timeStep); } - m_dynamicsWorld->stepSimulation(timeStep); + m_dynamicsWorld->stepSimulation(timeStep,5);//5); + numCtrl = GetNumControllers(); + for (i=0;i<numCtrl;i++) + { + CcdPhysicsController* ctrl = GetPhysicsController(i); + ctrl->SynchronizeMotionStates(timeStep); + } + + for (i=0;i<m_wrapperVehicles.size();i++) + { + WrapperVehicle* veh = m_wrapperVehicles[i]; + veh->SyncWheels(); + } + return true; } diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index 7911c3d1ed9..05c9e2a6b03 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -81,10 +81,7 @@ protected: /// Perform an integration step of duration 'timeStep'. - virtual void setDebugDrawer(btIDebugDraw* debugDrawer) - { - m_debugDrawer = debugDrawer; - } + virtual void setDebugDrawer(btIDebugDraw* debugDrawer); virtual void setNumIterations(int numIter); virtual void setNumTimeSubSteps(int numTimeSubSteps) |