diff options
author | Daniel Genrich <daniel.genrich@gmx.net> | 2008-09-03 15:11:11 +0400 |
---|---|---|
committer | Daniel Genrich <daniel.genrich@gmx.net> | 2008-09-03 15:11:11 +0400 |
commit | 096b4638c461cba2e97d336553225e3001da438f (patch) | |
tree | f1b6d17fd26f04f54881ebbe649aba8c7321e5f0 /source/gameengine | |
parent | cfa07e8d2bdc0a8db15082a692ce25c2fb010ae6 (diff) |
Revert rev16344 on trunk, bullet work is done in sim_physics branch as discussed on sunday meeting
Diffstat (limited to 'source/gameengine')
4 files changed, 34 insertions, 51 deletions
diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index f5fb8ce852d..de91bce2ab1 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -245,11 +245,6 @@ 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 e85238b49c3..2ec96c75a68 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -126,14 +126,13 @@ void CcdPhysicsController::CreateRigidbody() m_bulletMotionState = new BlenderBulletMotionState(m_MotionState); - 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); - + 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); + // // init the rigidbody properly // diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index f9242e6876f..d14ddf8f65c 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -330,21 +330,30 @@ m_filterCallback(NULL) { m_triggerCallbacks[i] = 0; } - m_collisionConfiguration = new btDefaultCollisionConfiguration(); - if (!dispatcher) { - dispatcher = new btCollisionDispatcher(m_collisionConfiguration); + dispatcher = new btCollisionDispatcher(); m_ownDispatcher = dispatcher; } - m_broadphase = new btDbvtBroadphase(); + 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_filterCallback = new CcdOverlapFilterCallBack(this); - m_broadphase->getOverlappingPairCache()->setOverlapFilterCallback(m_filterCallback); + pairCache->setOverlapFilterCallback(m_filterCallback); setSolverType(1);//issues with quickstep and memory allocations - m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,m_broadphase,m_solver,m_collisionConfiguration); + m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,m_solver); m_debugDrawer = 0; m_gravity = btVector3(0.f,-10.f,0.f); m_dynamicsWorld->setGravity(m_gravity); @@ -510,9 +519,6 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep) veh->SyncWheels(); } - m_dynamicsWorld->debugDrawWorld(); - - CallbackTriggers(); return true; @@ -573,7 +579,7 @@ void CcdPhysicsEnvironment::setSolverDamping(float damping) void CcdPhysicsEnvironment::setLinearAirDamping(float damping) { - //gLinearAirDamping = damping; + gLinearAirDamping = damping; } void CcdPhysicsEnvironment::setUseEpa(bool epa) @@ -592,7 +598,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; } } @@ -654,10 +660,9 @@ int CcdPhysicsEnvironment::createUniversalD6Constraint( { - bool useReferenceFrameA = true; genericConstraint = new btGeneric6DofConstraint( *rb0,*rb1, - frameInA,frameInB,useReferenceFrameA); + frameInA,frameInB); genericConstraint->setLinearLowerLimit(linearMinLimits); genericConstraint->setLinearUpperLimit(linearMaxLimits); genericConstraint->setAngularLowerLimit(angularMinLimits); @@ -737,15 +742,14 @@ struct FilterClosestRayResultCallback : public btCollisionWorld::ClosestRayResul // save shape information as ClosestRayResultCallback::AddSingleResult() does not do it if (rayResult.m_localShapeInfo) { - m_hitTriangleShape = NULL;//rayResult.m_localShapeInfo->m_triangleShape; - m_hitTriangleIndex = 0;//rayResult.m_localShapeInfo->m_triangleIndex; + m_hitTriangleShape = rayResult.m_localShapeInfo->m_triangleShape; + m_hitTriangleIndex = rayResult.m_localShapeInfo->m_triangleIndex; } else { m_hitTriangleShape = NULL; m_hitTriangleIndex = 0; } - bool normalInWorldspace = true; - return ClosestRayResultCallback::addSingleResult(rayResult,normalInWorldspace); + return ClosestRayResultCallback::AddSingleResult(rayResult); } }; @@ -771,11 +775,8 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallbac memset(&result, 0, sizeof(result)); // don't collision with sensor object - rayCallback.m_collisionFilterMask = CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter; - //, ,filterCallback.m_faceNormal); - - m_dynamicsWorld->rayTest(rayFrom,rayTo,rayCallback); - if (rayCallback.hasHit()) + m_dynamicsWorld->rayTest(rayFrom,rayTo,rayCallback, CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter,filterCallback.m_faceNormal); + if (rayCallback.HasHit()) { CcdPhysicsController* controller = static_cast<CcdPhysicsController*>(rayCallback.m_collisionObject->getUserPointer()); result.m_controller = controller; @@ -880,12 +881,6 @@ CcdPhysicsEnvironment::~CcdPhysicsEnvironment() if (NULL != m_filterCallback) delete m_filterCallback; - - if (NULL != m_collisionConfiguration) - delete m_collisionConfiguration; - - if (NULL != m_broadphase) - delete m_broadphase; } @@ -898,7 +893,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: @@ -1244,11 +1239,10 @@ 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,useReferenceFrameA); + frameInA,frameInB); } else @@ -1269,10 +1263,9 @@ 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,useReferenceFrameA); + frameInA,frameInB); } if (genericConstraint) diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index 3cf5a943e3f..667e310dcb3 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -56,10 +56,6 @@ class CcdPhysicsEnvironment : public PHY_IPhysicsEnvironment protected: btIDebugDraw* m_debugDrawer; - - class btDefaultCollisionConfiguration* m_collisionConfiguration; - class btBroadphaseInterface* m_broadphase; - //solver iterations int m_numIterations; |