enable to suspend and restore dynamics. also, catched the case where failed dynamics (resulting in infinite AABB sizes) doesn't mess up the entire simulation, it just get's deactivated (with a message that a simulation error happened)
This commit is contained in:
@@ -243,10 +243,14 @@ CollisionAlgorithm* CollisionDispatcher::InternalFindAlgorithm(BroadphaseProxy&
|
||||
|
||||
bool CollisionDispatcher::NeedsResponse(const CollisionObject& colObj0,const CollisionObject& colObj1)
|
||||
{
|
||||
|
||||
|
||||
//here you can do filtering
|
||||
bool hasResponse =
|
||||
(!(colObj0.m_collisionFlags & CollisionObject::noContactResponse)) &&
|
||||
(!(colObj1.m_collisionFlags & CollisionObject::noContactResponse));
|
||||
hasResponse = hasResponse &&
|
||||
(colObj0.IsActive() || colObj1.IsActive());
|
||||
return hasResponse;
|
||||
}
|
||||
|
||||
@@ -265,7 +269,7 @@ bool CollisionDispatcher::NeedsCollision(BroadphaseProxy& proxy0,BroadphaseProxy
|
||||
(body1->m_collisionFlags & CollisionObject::isStatic))
|
||||
needsCollision = false;
|
||||
|
||||
if ((body0->GetActivationState() == 2) &&(body1->GetActivationState() == 2))
|
||||
if ((!body0->IsActive()) && (!body1->IsActive()))
|
||||
needsCollision = false;
|
||||
|
||||
return needsCollision ;
|
||||
|
||||
@@ -31,7 +31,7 @@ CollisionObject::CollisionObject()
|
||||
|
||||
void CollisionObject::SetActivationState(int newState)
|
||||
{
|
||||
if (m_activationState1 != DISABLE_DEACTIVATION)
|
||||
if ( (m_activationState1 != DISABLE_DEACTIVATION) && (m_activationState1 != DISABLE_SIMULATION))
|
||||
m_activationState1 = newState;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ subject to the following restrictions:
|
||||
#define ISLAND_SLEEPING 2
|
||||
#define WANTS_DEACTIVATION 3
|
||||
#define DISABLE_DEACTIVATION 4
|
||||
#define DISABLE_SIMULATION 5
|
||||
|
||||
struct BroadphaseProxy;
|
||||
class CollisionShape;
|
||||
@@ -94,6 +95,10 @@ struct CollisionObject
|
||||
|
||||
void activate();
|
||||
|
||||
inline bool IsActive() const
|
||||
{
|
||||
return ((GetActivationState() != ISLAND_SLEEPING) && (GetActivationState() != DISABLE_SIMULATION));
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -171,6 +171,7 @@ void CollisionWorld::RemoveCollisionObject(CollisionObject* collisionObject)
|
||||
//
|
||||
GetBroadphase()->CleanProxyFromPairs(bp);
|
||||
GetBroadphase()->DestroyProxy(bp);
|
||||
collisionObject->m_broadphaseHandle = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -638,7 +638,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
|
||||
CcdPhysicsController* ctrl = m_controllers[k];
|
||||
// SimdTransform predictedTrans;
|
||||
RigidBody* body = ctrl->GetRigidBody();
|
||||
if (body->GetActivationState() != ISLAND_SLEEPING)
|
||||
if (body->IsActive())
|
||||
{
|
||||
if (!body->IsStatic())
|
||||
{
|
||||
@@ -695,14 +695,17 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
|
||||
{
|
||||
TypedConstraint* constraint = m_constraints[i];
|
||||
|
||||
const CollisionObject* colObj0 = &constraint->GetRigidBodyA();
|
||||
const CollisionObject* colObj1 = &constraint->GetRigidBodyB();
|
||||
const RigidBody* colObj0 = &constraint->GetRigidBodyA();
|
||||
const RigidBody* colObj1 = &constraint->GetRigidBodyB();
|
||||
|
||||
if (((colObj0) && ((colObj0)->mergesSimulationIslands())) &&
|
||||
((colObj1) && ((colObj1)->mergesSimulationIslands())))
|
||||
{
|
||||
GetDispatcher()->GetUnionFind().unite((colObj0)->m_islandTag1,
|
||||
(colObj1)->m_islandTag1);
|
||||
if (colObj0->IsActive() || colObj1->IsActive())
|
||||
{
|
||||
GetDispatcher()->GetUnionFind().unite((colObj0)->m_islandTag1,
|
||||
(colObj1)->m_islandTag1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -863,7 +866,8 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
|
||||
|
||||
SimdTransform predictedTrans;
|
||||
RigidBody* body = ctrl->GetRigidBody();
|
||||
if (body->GetActivationState() != ISLAND_SLEEPING)
|
||||
|
||||
if (body->IsActive())
|
||||
{
|
||||
|
||||
if (!body->IsStatic())
|
||||
@@ -1698,9 +1702,27 @@ void CcdPhysicsEnvironment::UpdateAabbs(float timeStep)
|
||||
}
|
||||
}
|
||||
|
||||
scene->SetAabb(bp,minAabb,maxAabb);
|
||||
|
||||
if ( (maxAabb-minAabb).length2() < 1e12f)
|
||||
{
|
||||
scene->SetAabb(bp,minAabb,maxAabb);
|
||||
} else
|
||||
{
|
||||
//something went wrong, investigate
|
||||
//removeCcdPhysicsController(ctrl);
|
||||
body->SetActivationState(DISABLE_SIMULATION);
|
||||
|
||||
static bool reportMe = true;
|
||||
if (reportMe)
|
||||
{
|
||||
reportMe = false;
|
||||
printf("Overflow in AABB, object removed from simulation \n");
|
||||
printf("If you can reproduce this, please email bugs@continuousphysics.com\n");
|
||||
printf("Please include above information, your Platform, version of OS.\n");
|
||||
printf("Thanks.\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user