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;
|
||||
}
|
||||
|
||||
@@ -264,8 +268,8 @@ bool CollisionDispatcher::NeedsCollision(BroadphaseProxy& proxy0,BroadphaseProxy
|
||||
if ((body0->m_collisionFlags & CollisionObject::isStatic) &&
|
||||
(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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user