|
@@ -308,12 +308,12 @@ void BodyInterface::SetShape(const BodyID &inBodyID, const Shape *inShape, bool
|
|
// Update the shape
|
|
// Update the shape
|
|
body.SetShapeInternal(inShape, inUpdateMassProperties);
|
|
body.SetShapeInternal(inShape, inUpdateMassProperties);
|
|
|
|
|
|
- // Flag collision cache invalid for this body
|
|
|
|
- mBodyManager->InvalidateContactCacheForBody(body);
|
|
|
|
-
|
|
|
|
// Notify broadphase of change
|
|
// Notify broadphase of change
|
|
if (body.IsInBroadPhase())
|
|
if (body.IsInBroadPhase())
|
|
{
|
|
{
|
|
|
|
+ // Flag collision cache invalid for this body
|
|
|
|
+ mBodyManager->InvalidateContactCacheForBody(body);
|
|
|
|
+
|
|
BodyID id = body.GetID();
|
|
BodyID id = body.GetID();
|
|
mBroadPhase->NotifyBodiesAABBChanged(&id, 1);
|
|
mBroadPhase->NotifyBodiesAABBChanged(&id, 1);
|
|
|
|
|
|
@@ -338,12 +338,12 @@ void BodyInterface::NotifyShapeChanged(const BodyID &inBodyID, Vec3Arg inPreviou
|
|
// Recalculate bounding box
|
|
// Recalculate bounding box
|
|
body.CalculateWorldSpaceBoundsInternal();
|
|
body.CalculateWorldSpaceBoundsInternal();
|
|
|
|
|
|
- // Flag collision cache invalid for this body
|
|
|
|
- mBodyManager->InvalidateContactCacheForBody(body);
|
|
|
|
-
|
|
|
|
// Notify broadphase of change
|
|
// Notify broadphase of change
|
|
if (body.IsInBroadPhase())
|
|
if (body.IsInBroadPhase())
|
|
{
|
|
{
|
|
|
|
+ // Flag collision cache invalid for this body
|
|
|
|
+ mBodyManager->InvalidateContactCacheForBody(body);
|
|
|
|
+
|
|
BodyID id = body.GetID();
|
|
BodyID id = body.GetID();
|
|
mBroadPhase->NotifyBodiesAABBChanged(&id, 1);
|
|
mBroadPhase->NotifyBodiesAABBChanged(&id, 1);
|
|
|
|
|
|
@@ -553,7 +553,7 @@ void BodyInterface::MoveKinematic(const BodyID &inBodyID, RVec3Arg inTargetPosit
|
|
|
|
|
|
body.MoveKinematic(inTargetPosition, inTargetRotation, inDeltaTime);
|
|
body.MoveKinematic(inTargetPosition, inTargetRotation, inDeltaTime);
|
|
|
|
|
|
- if (!body.IsActive() && (!body.GetLinearVelocity().IsNearZero() || !body.GetAngularVelocity().IsNearZero()))
|
|
|
|
|
|
+ if (!body.IsActive() && (!body.GetLinearVelocity().IsNearZero() || !body.GetAngularVelocity().IsNearZero()) && body.IsInBroadPhase())
|
|
mBodyManager->ActivateBodies(&inBodyID, 1);
|
|
mBodyManager->ActivateBodies(&inBodyID, 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -569,7 +569,7 @@ void BodyInterface::SetLinearAndAngularVelocity(const BodyID &inBodyID, Vec3Arg
|
|
body.SetLinearVelocityClamped(inLinearVelocity);
|
|
body.SetLinearVelocityClamped(inLinearVelocity);
|
|
body.SetAngularVelocityClamped(inAngularVelocity);
|
|
body.SetAngularVelocityClamped(inAngularVelocity);
|
|
|
|
|
|
- if (!body.IsActive() && (!inLinearVelocity.IsNearZero() || !inAngularVelocity.IsNearZero()))
|
|
|
|
|
|
+ if (!body.IsActive() && (!inLinearVelocity.IsNearZero() || !inAngularVelocity.IsNearZero()) && body.IsInBroadPhase())
|
|
mBodyManager->ActivateBodies(&inBodyID, 1);
|
|
mBodyManager->ActivateBodies(&inBodyID, 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -602,7 +602,7 @@ void BodyInterface::SetLinearVelocity(const BodyID &inBodyID, Vec3Arg inLinearVe
|
|
{
|
|
{
|
|
body.SetLinearVelocityClamped(inLinearVelocity);
|
|
body.SetLinearVelocityClamped(inLinearVelocity);
|
|
|
|
|
|
- if (!body.IsActive() && !inLinearVelocity.IsNearZero())
|
|
|
|
|
|
+ if (!body.IsActive() && !inLinearVelocity.IsNearZero() && body.IsInBroadPhase())
|
|
mBodyManager->ActivateBodies(&inBodyID, 1);
|
|
mBodyManager->ActivateBodies(&inBodyID, 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -631,7 +631,7 @@ void BodyInterface::AddLinearVelocity(const BodyID &inBodyID, Vec3Arg inLinearVe
|
|
{
|
|
{
|
|
body.SetLinearVelocityClamped(body.GetLinearVelocity() + inLinearVelocity);
|
|
body.SetLinearVelocityClamped(body.GetLinearVelocity() + inLinearVelocity);
|
|
|
|
|
|
- if (!body.IsActive() && !body.GetLinearVelocity().IsNearZero())
|
|
|
|
|
|
+ if (!body.IsActive() && !body.GetLinearVelocity().IsNearZero() && body.IsInBroadPhase())
|
|
mBodyManager->ActivateBodies(&inBodyID, 1);
|
|
mBodyManager->ActivateBodies(&inBodyID, 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -648,7 +648,7 @@ void BodyInterface::AddLinearAndAngularVelocity(const BodyID &inBodyID, Vec3Arg
|
|
body.SetLinearVelocityClamped(body.GetLinearVelocity() + inLinearVelocity);
|
|
body.SetLinearVelocityClamped(body.GetLinearVelocity() + inLinearVelocity);
|
|
body.SetAngularVelocityClamped(body.GetAngularVelocity() + inAngularVelocity);
|
|
body.SetAngularVelocityClamped(body.GetAngularVelocity() + inAngularVelocity);
|
|
|
|
|
|
- if (!body.IsActive() && (!body.GetLinearVelocity().IsNearZero() || !body.GetAngularVelocity().IsNearZero()))
|
|
|
|
|
|
+ if (!body.IsActive() && (!body.GetLinearVelocity().IsNearZero() || !body.GetAngularVelocity().IsNearZero()) && body.IsInBroadPhase())
|
|
mBodyManager->ActivateBodies(&inBodyID, 1);
|
|
mBodyManager->ActivateBodies(&inBodyID, 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -664,7 +664,7 @@ void BodyInterface::SetAngularVelocity(const BodyID &inBodyID, Vec3Arg inAngular
|
|
{
|
|
{
|
|
body.SetAngularVelocityClamped(inAngularVelocity);
|
|
body.SetAngularVelocityClamped(inAngularVelocity);
|
|
|
|
|
|
- if (!body.IsActive() && !inAngularVelocity.IsNearZero())
|
|
|
|
|
|
+ if (!body.IsActive() && !inAngularVelocity.IsNearZero() && body.IsInBroadPhase())
|
|
mBodyManager->ActivateBodies(&inBodyID, 1);
|
|
mBodyManager->ActivateBodies(&inBodyID, 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -849,7 +849,7 @@ void BodyInterface::SetPositionRotationAndVelocity(const BodyID &inBodyID, RVec3
|
|
body.SetAngularVelocityClamped(inAngularVelocity);
|
|
body.SetAngularVelocityClamped(inAngularVelocity);
|
|
|
|
|
|
// Optionally activate body
|
|
// Optionally activate body
|
|
- if (!body.IsActive() && (!inLinearVelocity.IsNearZero() || !inAngularVelocity.IsNearZero()))
|
|
|
|
|
|
+ if (!body.IsActive() && (!inLinearVelocity.IsNearZero() || !inAngularVelocity.IsNearZero()) && body.IsInBroadPhase())
|
|
mBodyManager->ActivateBodies(&inBodyID, 1);
|
|
mBodyManager->ActivateBodies(&inBodyID, 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -869,7 +869,7 @@ void BodyInterface::SetMotionType(const BodyID &inBodyID, EMotionType inMotionTy
|
|
body.SetMotionType(inMotionType);
|
|
body.SetMotionType(inMotionType);
|
|
|
|
|
|
// Activate body if requested
|
|
// Activate body if requested
|
|
- if (inMotionType != EMotionType::Static && inActivationMode == EActivation::Activate)
|
|
|
|
|
|
+ if (inMotionType != EMotionType::Static && inActivationMode == EActivation::Activate && body.IsInBroadPhase())
|
|
ActivateBodyInternal(body);
|
|
ActivateBodyInternal(body);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -976,7 +976,8 @@ void BodyInterface::SetUseManifoldReduction(const BodyID &inBodyID, bool inUseRe
|
|
body.SetUseManifoldReduction(inUseReduction);
|
|
body.SetUseManifoldReduction(inUseReduction);
|
|
|
|
|
|
// Flag collision cache invalid for this body
|
|
// Flag collision cache invalid for this body
|
|
- mBodyManager->InvalidateContactCacheForBody(body);
|
|
|
|
|
|
+ if (body.IsInBroadPhase())
|
|
|
|
+ mBodyManager->InvalidateContactCacheForBody(body);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1043,7 +1044,7 @@ const PhysicsMaterial *BodyInterface::GetMaterial(const BodyID &inBodyID, const
|
|
void BodyInterface::InvalidateContactCache(const BodyID &inBodyID)
|
|
void BodyInterface::InvalidateContactCache(const BodyID &inBodyID)
|
|
{
|
|
{
|
|
BodyLockWrite lock(*mBodyLockInterface, inBodyID);
|
|
BodyLockWrite lock(*mBodyLockInterface, inBodyID);
|
|
- if (lock.Succeeded())
|
|
|
|
|
|
+ if (lock.SucceededAndIsInBroadPhase())
|
|
mBodyManager->InvalidateContactCacheForBody(lock.GetBody());
|
|
mBodyManager->InvalidateContactCacheForBody(lock.GetBody());
|
|
}
|
|
}
|
|
|
|
|