Browse Source

Fixed contact reservation that could cause a crash if you were hitting mMaxNumHits objects

Jorrit Rouwe 2 years ago
parent
commit
934fc99335
1 changed files with 1 additions and 1 deletions
  1. 1 1
      Jolt/Physics/Character/CharacterVirtual.cpp

+ 1 - 1
Jolt/Physics/Character/CharacterVirtual.cpp

@@ -960,7 +960,7 @@ void CharacterVirtual::MoveToContact(Vec3Arg inPosition, const Contact &inContac
 
 	// Determine the contacts
 	TempContactList contacts(inAllocator);
-	contacts.reserve(mMaxNumHits);
+	contacts.reserve(mMaxNumHits + 1); // +1 because we can add one extra below
 	GetContactsAtPosition(mPosition, mLinearVelocity.NormalizedOr(Vec3::sZero()), mShape, contacts, inBroadPhaseLayerFilter, inObjectLayerFilter, inBodyFilter);
 
 	// Ensure that we mark inContact as colliding