diff options
9 files changed, 35 insertions, 13 deletions
diff --git a/extern/bullet/Bullet/CollisionDispatch/CollisionDispatcher.cpp b/extern/bullet/Bullet/CollisionDispatch/CollisionDispatcher.cpp index a12051455fa..cd2da116522 100644 --- a/extern/bullet/Bullet/CollisionDispatch/CollisionDispatcher.cpp +++ b/extern/bullet/Bullet/CollisionDispatch/CollisionDispatcher.cpp @@ -119,6 +119,11 @@ void CollisionDispatcher::BuildAndProcessIslands(int numBodies, IslandCallback* { allSleeping = false; } + if ((((CollisionObject*)manifold->GetBody0()) && ((CollisionObject*)manifold->GetBody0())->GetActivationState()== DISABLE_DEACTIVATION) || + (((CollisionObject*)manifold->GetBody1()) && ((CollisionObject*)manifold->GetBody1())->GetActivationState() == DISABLE_DEACTIVATION)) + { + allSleeping = false; + } islandmanifold.push_back(manifold); } diff --git a/extern/bullet/Bullet/NarrowPhaseCollision/CollisionObject.h b/extern/bullet/Bullet/NarrowPhaseCollision/CollisionObject.h index c83d73938ee..4df10832dea 100644 --- a/extern/bullet/Bullet/NarrowPhaseCollision/CollisionObject.h +++ b/extern/bullet/Bullet/NarrowPhaseCollision/CollisionObject.h @@ -7,6 +7,7 @@ #define ACTIVE_TAG 1 #define ISLAND_SLEEPING 2 #define WANTS_DEACTIVATION 3 +#define DISABLE_DEACTIVATION 4 struct BroadphaseProxy; class CollisionShape; diff --git a/extern/bullet/BulletDynamics/Vehicle/RaycastVehicle.cpp b/extern/bullet/BulletDynamics/Vehicle/RaycastVehicle.cpp index 096ccfd85d2..a4bd0612833 100755 --- a/extern/bullet/BulletDynamics/Vehicle/RaycastVehicle.cpp +++ b/extern/bullet/BulletDynamics/Vehicle/RaycastVehicle.cpp @@ -92,7 +92,9 @@ const SimdTransform& RaycastVehicle::GetWheelTransformWS( int wheelIndex ) const void RaycastVehicle::UpdateWheelTransform( int wheelIndex ) { + WheelInfo& wheel = m_wheelInfo[ wheelIndex ]; + UpdateWheelTransformsWS(wheel); SimdVector3 up = -wheel.m_raycastInfo.m_wheelDirectionWS; const SimdVector3& right = wheel.m_raycastInfo.m_wheelAxleWS; SimdVector3 fwd = up.cross(right); diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c index d4f4d182b8f..9840f254020 100644 --- a/source/blender/src/buttons_logic.c +++ b/source/blender/src/buttons_logic.c @@ -2378,20 +2378,24 @@ void buttons_enji(uiBlock *block, Object *ob) void buttons_ketsji(uiBlock *block, Object *ob) { uiDefButBitI(block, TOG, OB_ACTOR, B_REDR, "Actor", - 10,205,75,19, &ob->gameflag, 0, 0, 0, 0, + 10,205,55,19, &ob->gameflag, 0, 0, 0, 0, "Objects that are evaluated by the engine "); if(ob->gameflag & OB_ACTOR) { - uiDefButBitI(block, TOG, OB_GHOST, B_REDR, "Ghost", 85,205,65,19, + uiDefButBitI(block, TOG, OB_GHOST, B_REDR, "Ghost", 65,205,55,19, &ob->gameflag, 0, 0, 0, 0, "Objects that don't restitute collisions (like a ghost)"); - uiDefButBitI(block, TOG, OB_DYNAMIC, B_REDR, "Dynamic", 150,205,65,19, + uiDefButBitI(block, TOG, OB_DYNAMIC, B_REDR, "Dynamic", 120,205,70,19, &ob->gameflag, 0, 0, 0, 0, "Motion defined by laws of physics"); if(ob->gameflag & OB_DYNAMIC) { - uiDefButBitI(block, TOG, OB_RIGID_BODY, B_REDR, "Rigid Body", 215,205,135,19, + uiDefButBitI(block, TOG, OB_RIGID_BODY, B_REDR, "Rigid Body", 180,205,70,19, &ob->gameflag, 0, 0, 0, 0, "Enable rolling physics"); + uiDefButBitI(block, TOG, OB_COLLISION_RESPONSE, B_REDR, "No sleeping", 250,205,100,19, + &ob->gameflag, 0, 0, 0, 0, + "Disable auto (de)activation"); + uiDefButBitI(block, TOG, OB_DO_FH, B_DIFF, "Do Fh", 10,185,50,19, &ob->gameflag, 0, 0, 0, 0, "Use Fh settings in Materials"); diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index f07cb80d1bf..b21eb743334 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1231,10 +1231,12 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj, objprop.m_dyna = (blenderobject->gameflag & OB_DYNAMIC) != 0; objprop.m_angular_rigidbody = (blenderobject->gameflag & OB_RIGID_BODY) != 0; objprop.m_ghost = (blenderobject->gameflag & OB_GHOST) != 0; + objprop.m_disableSleeping = (blenderobject->gameflag & OB_COLLISION_RESPONSE) != 0;//abuse the OB_COLLISION_RESPONSE flag } else { objprop.m_dyna = false; objprop.m_angular_rigidbody = false; objprop.m_ghost = false; + objprop.m_disableSleeping = false; } //mmm, for now, taks this for the size of the dynamicobject // Blender uses inertia for radius of dynamic object diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h index b1922e247d1..a976a6b13b1 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h @@ -85,6 +85,7 @@ struct KX_ObjectProperties bool m_isactor; bool m_concave; bool m_isdeformable; + bool m_disableSleeping; KX_BoundBoxClass m_boundclass; union { KX_BoxBounds box; diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index 73b49150414..8f3a6a2470c 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -1033,6 +1033,10 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, gameobj->SetPhysicsController(physicscontroller,isbulletdyna); physicscontroller->setNewClientInfo(gameobj->getClientInfo()); + + if (objprop->m_disableSleeping) + physicscontroller->GetRigidBody()->SetActivationState(DISABLE_DEACTIVATION); + bool isActor = objprop->m_isactor; gameobj->getClientInfo()->m_type = (isActor ? KX_ClientObjectInfo::ACTOR : KX_ClientObjectInfo::STATIC); // store materialname in auxinfo, needed for touchsensors diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 2f8f4a4e2ab..fdb30faa5cf 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -374,9 +374,8 @@ void CcdPhysicsController::setNewClientInfo(void* clientinfo) void CcdPhysicsController::UpdateDeactivation(float timeStep) { - if ( (m_body->GetActivationState() == 2)) + if ( (m_body->GetActivationState() == ISLAND_SLEEPING) || (m_body->GetActivationState() == DISABLE_DEACTIVATION)) return; - if ((m_body->getLinearVelocity().length2() < gLinearSleepingTreshold*gLinearSleepingTreshold) && (m_body->getAngularVelocity().length2() < gAngularSleepingTreshold*gAngularSleepingTreshold)) @@ -393,6 +392,9 @@ void CcdPhysicsController::UpdateDeactivation(float timeStep) bool CcdPhysicsController::wantsSleeping() { + if (m_body->GetActivationState() == DISABLE_DEACTIVATION) + return false; + //disable deactivation if (gDisableDeactivation || (gDeactivationTime == 0.f)) return false; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index b39591fc627..7bc2eb73cbc 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -115,6 +115,7 @@ public: { WheelInfo& info = m_vehicle->GetWheelInfo(i); PHY_IMotionState* motionState = (PHY_IMotionState*)info.m_clientInfo ; + m_vehicle->UpdateWheelTransform(i); SimdTransform trans = m_vehicle->GetWheelTransformWS(i); SimdQuaternion orn = trans.getRotation(); const SimdVector3& pos = trans.getOrigin(); @@ -668,6 +669,10 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) { break; } + case DISABLE_DEACTIVATION: + { + color.setValue(1,0,1); + }; }; @@ -751,7 +756,8 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) body->SetActivationState( WANTS_DEACTIVATION ); } else { - body->SetActivationState( ACTIVE_TAG ); + if (body->GetActivationState() != DISABLE_DEACTIVATION) + body->SetActivationState( ACTIVE_TAG ); } if (useIslands) @@ -785,12 +791,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) for (int i=0;i<numVehicles;i++) { WrapperVehicle* wrapperVehicle = m_wrapperVehicles[i]; - - for (int j=0;j<wrapperVehicle->GetVehicle()->GetNumWheels();j++) - { - wrapperVehicle->GetVehicle()->UpdateWheelTransform(j); - } - + wrapperVehicle->SyncWheels(); } #endif //NEW_BULLET_VEHICLE_SUPPORT |