Better optimization to allocate correct amount of memory for potential manifolds and contact points
This commit is contained in:
parent
71f7980fdf
commit
fa722c129d
|
@ -162,6 +162,12 @@ class CollisionDetectionSystem {
|
|||
/// Array with the indices of all the contact pairs that have at least one CollisionBody
|
||||
Array<uint32> mCollisionBodyContactPairsIndices;
|
||||
|
||||
/// Number of potential contact manifolds in the previous frame
|
||||
uint32 mNbPreviousPotentialContactManifolds;
|
||||
|
||||
/// Number of potential contact points in the previous frame
|
||||
uint32 mNbPreviousPotentialContactPoints;
|
||||
|
||||
#ifdef IS_RP3D_PROFILING_ENABLED
|
||||
|
||||
/// Pointer to the profiler
|
||||
|
|
|
@ -67,7 +67,8 @@ CollisionDetectionSystem::CollisionDetectionSystem(PhysicsWorld* world, Collider
|
|||
mContactManifolds1(mMemoryManager.getPoolAllocator()), mContactManifolds2(mMemoryManager.getPoolAllocator()),
|
||||
mPreviousContactManifolds(&mContactManifolds1), mCurrentContactManifolds(&mContactManifolds2),
|
||||
mContactPoints1(mMemoryManager.getPoolAllocator()), mContactPoints2(mMemoryManager.getPoolAllocator()),
|
||||
mPreviousContactPoints(&mContactPoints1), mCurrentContactPoints(&mContactPoints2), mCollisionBodyContactPairsIndices(mMemoryManager.getSingleFrameAllocator()) {
|
||||
mPreviousContactPoints(&mContactPoints1), mCurrentContactPoints(&mContactPoints2), mCollisionBodyContactPairsIndices(mMemoryManager.getSingleFrameAllocator()),
|
||||
mNbPreviousPotentialContactManifolds(0), mNbPreviousPotentialContactPoints(0) {
|
||||
|
||||
#ifdef IS_RP3D_PROFILING_ENABLED
|
||||
|
||||
|
@ -595,8 +596,8 @@ void CollisionDetectionSystem::computeNarrowPhase() {
|
|||
// Swap the previous and current contacts arrays
|
||||
swapPreviousAndCurrentContacts();
|
||||
|
||||
mPotentialContactManifolds.reserve(mPreviousContactManifolds->size());
|
||||
mPotentialContactPoints.reserve(mPreviousContactPoints->size());
|
||||
mPotentialContactManifolds.reserve(mNbPreviousPotentialContactManifolds);
|
||||
mPotentialContactPoints.reserve(mNbPreviousPotentialContactPoints);
|
||||
|
||||
// Test the narrow-phase collision detection on the batches to be tested
|
||||
testNarrowPhaseCollision(mNarrowPhaseInput, true, allocator);
|
||||
|
@ -879,6 +880,9 @@ void CollisionDetectionSystem::createContacts() {
|
|||
mPreviousContactManifolds->clear();
|
||||
mPreviousContactPairs->clear();
|
||||
|
||||
mNbPreviousPotentialContactManifolds = mPotentialContactManifolds.capacity();
|
||||
mNbPreviousPotentialContactPoints = mPotentialContactPoints.capacity();
|
||||
|
||||
// Reset the potential contacts
|
||||
mPotentialContactPoints.clear(true);
|
||||
mPotentialContactManifolds.clear(true);
|
||||
|
|
Loading…
Reference in New Issue
Block a user