diff options
author | Erwin Coumans <blender@erwincoumans.com> | 2006-05-11 04:13:42 +0400 |
---|---|---|
committer | Erwin Coumans <blender@erwincoumans.com> | 2006-05-11 04:13:42 +0400 |
commit | 93c47e107198c91ad28d72acc2c6659d862e496e (patch) | |
tree | ef9f2dffc4573e339a0102a333b9123229055fa3 /source | |
parent | 2358e85b6d250b3e4597ec8bd23890bf95f41ebb (diff) |
- Added support for kinematic objects (interaction between rigidbodies), deriving linear/angular velocity from previous transform/current transform and deltatime.
- Made another attempt to migrate from Sumo to Bullet: import of older files automatically switch to Bullet, but you can override it, and save the file in 2.42 version. then it stays Sumo physics.
Diffstat (limited to 'source')
6 files changed, 52 insertions, 9 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 3e265451c1e..338e1e075b7 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -4440,14 +4440,30 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } + + if(main->versionfile <= 225) { World *wo; /* Use Sumo for old games */ for (wo = main->world.first; wo; wo= wo->id.next) { wo->physicsEngine = 2; } + } else + { + if(main->versionfile <= 241) { + World *wo; + /* Migrate to Bullet for recent games */ + /* People can still explicitely choose for Sumo */ + for (wo = main->world.first; wo; wo= wo->id.next) { + wo->physicsEngine = 5; + } + + } } + + + if(main->versionfile <= 227) { Scene *sce; Material *ma; @@ -4891,6 +4907,10 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } } + + + + if(main->versionfile <= 234) { Scene *sce; World *wo; diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c index 6cd8dcdbe34..2fbf725f6d3 100644 --- a/source/blender/src/buttons_shading.c +++ b/source/blender/src/buttons_shading.c @@ -1742,7 +1742,7 @@ static void world_panel_mistaph(World *wrld) "Physics %t|None %x0|Sumo %x2|Ode %x4 |Bullet %x5", #else //"Physics %t|None %x0|Sumo %x2|Bullet %x5", //disable Sumo, until too many people complain ;-) - "Physics %t|None %x0|Bullet %x2|Bullet %x5", + "Physics %t|None %x0|Sumo (deprecated) %x2|Bullet %x5", #endif 10,180,140,19, &wrld->physicsEngine, 0, 0, 0, 0, "Physics Engine"); diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index ae117be8093..bc2352d713e 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -281,7 +281,7 @@ void KX_BlenderSceneConverter::ConvertScene(const STR_String& scenename, } case WOPHY_SUMO: { - physics_engine = UseBullet;//UseSumo; //disable Sumo, just use Bullet for now (unless too many people complain) + physics_engine = UseSumo; break; } case WOPHY_NONE: diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 79b311bd691..b8ce09729c2 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -31,7 +31,7 @@ class BP_Proxy; float gDeactivationTime = 2.f; bool gDisableDeactivation = false; -float gLinearSleepingTreshold = 0.8f; +float gLinearSleepingTreshold = 0.4f; float gAngularSleepingTreshold = 1.0f; #include "Dynamics/MassProps.h" @@ -136,7 +136,7 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time) m_MotionState->getWorldOrientation(worldquat[0],worldquat[1],worldquat[2],worldquat[3]); SimdTransform oldTrans = m_body->getCenterOfMassTransform(); SimdTransform newTrans(worldquat,worldPos); - + m_body->setCenterOfMassTransform(newTrans); //need to keep track of previous position for friction effects... diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index f1933d55137..646b21f285e 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -171,6 +171,17 @@ class CcdPhysicsController : public PHY_IPhysicsController void SetAabb(const SimdVector3& aabbMin,const SimdVector3& aabbMax); + class PHY_IMotionState* GetMotionState() + { + return m_MotionState; + } + + const class PHY_IMotionState* GetMotionState() const + { + return m_MotionState; + } + + }; #endif //BULLET2_PHYSICSCONTROLLER_H diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 9583839a7ae..7afd7bf8fc5 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -586,6 +586,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) m_scalingPropagated = true; } + #ifdef USE_QUICKPROF Profiler::endBlock("SyncMotionStates"); @@ -605,9 +606,12 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) RigidBody* body = ctrl->GetRigidBody(); if (body->GetActivationState() != ISLAND_SLEEPING) { - body->applyForces( timeStep); - body->integrateVelocities( timeStep); - body->predictIntegratedTransform(timeStep,body->m_nextPredictedWorldTransform); + if (!body->IsStatic()) + { + body->applyForces( timeStep); + body->integrateVelocities( timeStep); + body->predictIntegratedTransform(timeStep,body->m_interpolationWorldTransform); + } } } @@ -807,8 +811,15 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) if (body->GetActivationState() != ISLAND_SLEEPING) { - body->predictIntegratedTransform(timeStep* toi, predictedTrans); - body->proceedToTransform( predictedTrans); + if (body->IsStatic()) + { + //to calculate velocities next frame + body->saveKinematicState(timeStep); + } else + { + body->predictIntegratedTransform(timeStep* toi, predictedTrans); + body->proceedToTransform( predictedTrans); + } } } @@ -893,6 +904,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) } #endif //NEW_BULLET_VEHICLE_SUPPORT } + return true; } |