|
@@ -155,7 +155,8 @@ BroadPhase::AddState BroadPhaseQuadTree::AddBodiesPrepare(BodyID *ioBodies, int
|
|
|
{
|
|
|
JPH_PROFILE_FUNCTION();
|
|
|
|
|
|
- JPH_ASSERT(inNumber >= 0);
|
|
|
+ if (inNumber <= 0)
|
|
|
+ return nullptr;
|
|
|
|
|
|
const BodyVector &bodies = mBodyManager->GetBodies();
|
|
|
JPH_ASSERT(mMaxBodies == mBodyManager->GetMaxBodies());
|
|
@@ -208,6 +209,12 @@ void BroadPhaseQuadTree::AddBodiesFinalize(BodyID *ioBodies, int inNumber, AddSt
|
|
|
{
|
|
|
JPH_PROFILE_FUNCTION();
|
|
|
|
|
|
+ if (inNumber <= 0)
|
|
|
+ {
|
|
|
+ JPH_ASSERT(inAddState == nullptr);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
// This cannot run concurrently with UpdatePrepare()/UpdateFinalize()
|
|
|
SharedLock lock(mUpdateMutex JPH_IF_ENABLE_ASSERTS(, mLockContext, EPhysicsLockTypes::BroadPhaseUpdate));
|
|
|
|
|
@@ -244,6 +251,12 @@ void BroadPhaseQuadTree::AddBodiesAbort(BodyID *ioBodies, int inNumber, AddState
|
|
|
{
|
|
|
JPH_PROFILE_FUNCTION();
|
|
|
|
|
|
+ if (inNumber <= 0)
|
|
|
+ {
|
|
|
+ JPH_ASSERT(inAddState == nullptr);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
JPH_IF_ENABLE_ASSERTS(const BodyVector &bodies = mBodyManager->GetBodies();)
|
|
|
JPH_ASSERT(mMaxBodies == mBodyManager->GetMaxBodies());
|
|
|
|
|
@@ -278,11 +291,12 @@ void BroadPhaseQuadTree::RemoveBodies(BodyID *ioBodies, int inNumber)
|
|
|
{
|
|
|
JPH_PROFILE_FUNCTION();
|
|
|
|
|
|
+ if (inNumber <= 0)
|
|
|
+ return;
|
|
|
+
|
|
|
// This cannot run concurrently with UpdatePrepare()/UpdateFinalize()
|
|
|
SharedLock lock(mUpdateMutex JPH_IF_ENABLE_ASSERTS(, mLockContext, EPhysicsLockTypes::BroadPhaseUpdate));
|
|
|
|
|
|
- JPH_ASSERT(inNumber > 0);
|
|
|
-
|
|
|
BodyVector &bodies = mBodyManager->GetBodies();
|
|
|
JPH_ASSERT(mMaxBodies == mBodyManager->GetMaxBodies());
|
|
|
|
|
@@ -325,7 +339,8 @@ void BroadPhaseQuadTree::NotifyBodiesAABBChanged(BodyID *ioBodies, int inNumber,
|
|
|
{
|
|
|
JPH_PROFILE_FUNCTION();
|
|
|
|
|
|
- JPH_ASSERT(inNumber > 0);
|
|
|
+ if (inNumber <= 0)
|
|
|
+ return;
|
|
|
|
|
|
// This cannot run concurrently with UpdatePrepare()/UpdateFinalize()
|
|
|
if (inTakeLock)
|
|
@@ -365,7 +380,8 @@ void BroadPhaseQuadTree::NotifyBodiesLayerChanged(BodyID *ioBodies, int inNumber
|
|
|
{
|
|
|
JPH_PROFILE_FUNCTION();
|
|
|
|
|
|
- JPH_ASSERT(inNumber > 0);
|
|
|
+ if (inNumber <= 0)
|
|
|
+ return;
|
|
|
|
|
|
// First sort the bodies that actually changed layer to beginning of the array
|
|
|
const BodyVector &bodies = mBodyManager->GetBodies();
|