diff options
author | Erwin Coumans <blender@erwincoumans.com> | 2008-09-03 06:27:16 +0400 |
---|---|---|
committer | Erwin Coumans <blender@erwincoumans.com> | 2008-09-03 06:27:16 +0400 |
commit | 1926e846500212d11061c23cacdbd08d88e375da (patch) | |
tree | ad72fe64632cfc22a4878e065578b66d52de218d /source | |
parent | 33ac84e888ee3e3217f15f955e1b389a9c4bb230 (diff) |
Finally upgraded to latest Bullet subversion, about to release 2.71. Some recent changes in extern/bullet2 need to be re-applied, will check with Benoit. Ray tests in 0_FPS_Template.blend is broken, didn't figure out why yet.
HELP BUILD SYSTEM MAINTAINERS: Please help with updating all build systems: the newly added files need to be added. Note that the src/SoftBody has been added for future extension of real-time soft bodies.
Diffstat (limited to 'source')
4 files changed, 51 insertions, 34 deletions
diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index de91bce2ab1..f5fb8ce852d 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -245,6 +245,11 @@ struct BlenderDebugDraw : public btIDebugDraw { return m_debugMode; } + ///todo: find out if Blender can do this + virtual void draw3dText(const btVector3& location,const char* textString) + { + + } }; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 2ec96c75a68..e85238b49c3 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -126,13 +126,14 @@ void CcdPhysicsController::CreateRigidbody() m_bulletMotionState = new BlenderBulletMotionState(m_MotionState); - m_body = new btRigidBody(m_cci.m_mass, - m_bulletMotionState, - m_collisionShape, - m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor, - m_cci.m_linearDamping,m_cci.m_angularDamping, - m_cci.m_friction,m_cci.m_restitution); - + btRigidBody::btRigidBodyConstructionInfo rbci(m_cci.m_mass,m_bulletMotionState,m_collisionShape,m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor); + rbci.m_linearDamping = m_cci.m_linearDamping; + rbci.m_angularDamping = m_cci.m_angularDamping; + rbci.m_friction = m_cci.m_friction; + rbci.m_restitution = m_cci.m_restitution; + + m_body = new btRigidBody(rbci); + // // init the rigidbody properly // diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index d14ddf8f65c..f9242e6876f 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -330,30 +330,21 @@ m_filterCallback(NULL) { m_triggerCallbacks[i] = 0; } + m_collisionConfiguration = new btDefaultCollisionConfiguration(); + if (!dispatcher) { - dispatcher = new btCollisionDispatcher(); + dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_ownDispatcher = dispatcher; } - if(!pairCache) - { - - //todo: calculate/let user specify this world sizes - btVector3 worldMin(-10000,-10000,-10000); - btVector3 worldMax(10000,10000,10000); - - pairCache = new btAxisSweep3(worldMin,worldMax); - // remember that this was allocated by us so that we can release it - m_ownPairCache = pairCache; - //broadphase = new btSimpleBroadphase(); - } + m_broadphase = new btDbvtBroadphase(); m_filterCallback = new CcdOverlapFilterCallBack(this); - pairCache->setOverlapFilterCallback(m_filterCallback); + m_broadphase->getOverlappingPairCache()->setOverlapFilterCallback(m_filterCallback); setSolverType(1);//issues with quickstep and memory allocations - m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,m_solver); + m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,m_broadphase,m_solver,m_collisionConfiguration); m_debugDrawer = 0; m_gravity = btVector3(0.f,-10.f,0.f); m_dynamicsWorld->setGravity(m_gravity); @@ -519,6 +510,9 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep) veh->SyncWheels(); } + m_dynamicsWorld->debugDrawWorld(); + + CallbackTriggers(); return true; @@ -579,7 +573,7 @@ void CcdPhysicsEnvironment::setSolverDamping(float damping) void CcdPhysicsEnvironment::setLinearAirDamping(float damping) { - gLinearAirDamping = damping; + //gLinearAirDamping = damping; } void CcdPhysicsEnvironment::setUseEpa(bool epa) @@ -598,7 +592,7 @@ void CcdPhysicsEnvironment::setSolverType(int solverType) { m_solver = new btSequentialImpulseConstraintSolver(); - ((btSequentialImpulseConstraintSolver*)m_solver)->setSolverMode(btSequentialImpulseConstraintSolver::SOLVER_USE_WARMSTARTING | btSequentialImpulseConstraintSolver::SOLVER_RANDMIZE_ORDER); +// ((btSequentialImpulseConstraintSolver*)m_solver)->setSolverMode(btSequentialImpulseConstraintSolver::SOLVER_USE_WARMSTARTING | btSequentialImpulseConstraintSolver::SOLVER_RANDMIZE_ORDER); break; } } @@ -660,9 +654,10 @@ int CcdPhysicsEnvironment::createUniversalD6Constraint( { + bool useReferenceFrameA = true; genericConstraint = new btGeneric6DofConstraint( *rb0,*rb1, - frameInA,frameInB); + frameInA,frameInB,useReferenceFrameA); genericConstraint->setLinearLowerLimit(linearMinLimits); genericConstraint->setLinearUpperLimit(linearMaxLimits); genericConstraint->setAngularLowerLimit(angularMinLimits); @@ -742,14 +737,15 @@ struct FilterClosestRayResultCallback : public btCollisionWorld::ClosestRayResul // save shape information as ClosestRayResultCallback::AddSingleResult() does not do it if (rayResult.m_localShapeInfo) { - m_hitTriangleShape = rayResult.m_localShapeInfo->m_triangleShape; - m_hitTriangleIndex = rayResult.m_localShapeInfo->m_triangleIndex; + m_hitTriangleShape = NULL;//rayResult.m_localShapeInfo->m_triangleShape; + m_hitTriangleIndex = 0;//rayResult.m_localShapeInfo->m_triangleIndex; } else { m_hitTriangleShape = NULL; m_hitTriangleIndex = 0; } - return ClosestRayResultCallback::AddSingleResult(rayResult); + bool normalInWorldspace = true; + return ClosestRayResultCallback::addSingleResult(rayResult,normalInWorldspace); } }; @@ -775,8 +771,11 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallbac memset(&result, 0, sizeof(result)); // don't collision with sensor object - m_dynamicsWorld->rayTest(rayFrom,rayTo,rayCallback, CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter,filterCallback.m_faceNormal); - if (rayCallback.HasHit()) + rayCallback.m_collisionFilterMask = CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter; + //, ,filterCallback.m_faceNormal); + + m_dynamicsWorld->rayTest(rayFrom,rayTo,rayCallback); + if (rayCallback.hasHit()) { CcdPhysicsController* controller = static_cast<CcdPhysicsController*>(rayCallback.m_collisionObject->getUserPointer()); result.m_controller = controller; @@ -881,6 +880,12 @@ CcdPhysicsEnvironment::~CcdPhysicsEnvironment() if (NULL != m_filterCallback) delete m_filterCallback; + + if (NULL != m_collisionConfiguration) + delete m_collisionConfiguration; + + if (NULL != m_broadphase) + delete m_broadphase; } @@ -893,7 +898,7 @@ void CcdPhysicsEnvironment::setConstraintParam(int constraintId,int param,float { //param = 1..12, min0,max0,min1,max1...min6,max6 btGeneric6DofConstraint* genCons = (btGeneric6DofConstraint*)typedConstraint; - genCons->SetLimit(param,value0,value1); + genCons->setLimit(param,value0,value1); break; }; default: @@ -1239,10 +1244,11 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl btTransform globalFrameA = rb0->getCenterOfMassTransform() * frameInA; frameInB = inv * globalFrameA; - + bool useReferenceFrameA = true; + genericConstraint = new btGeneric6DofConstraint( *rb0,*rb1, - frameInA,frameInB); + frameInA,frameInB,useReferenceFrameA); } else @@ -1263,9 +1269,10 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl ///frameInB in worldspace frameInB = rb0->getCenterOfMassTransform() * frameInA; + bool useReferenceFrameA = true; genericConstraint = new btGeneric6DofConstraint( *rb0,s_fixedObject2, - frameInA,frameInB); + frameInA,frameInB,useReferenceFrameA); } if (genericConstraint) diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index 667e310dcb3..3cf5a943e3f 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -56,6 +56,10 @@ class CcdPhysicsEnvironment : public PHY_IPhysicsEnvironment protected: btIDebugDraw* m_debugDrawer; + + class btDefaultCollisionConfiguration* m_collisionConfiguration; + class btBroadphaseInterface* m_broadphase; + //solver iterations int m_numIterations; |