diff --git a/src/engine/DynamicsWorld.cpp b/src/engine/DynamicsWorld.cpp index 6cf68204..0bc02766 100644 --- a/src/engine/DynamicsWorld.cpp +++ b/src/engine/DynamicsWorld.cpp @@ -121,9 +121,6 @@ void DynamicsWorld::update(decimal timeStep) { // Create the islands createIslands(); - // Create the actual narrow-phase contacts - mCollisionDetection.createContacts(); - // Report the contacts to the user mCollisionDetection.reportContacts(); @@ -580,9 +577,6 @@ void DynamicsWorld::createIslands() { nbTotalManifolds += pair.potentialContactManifoldsIndices.size(); - // Add the pair into the list of pair to process to create contacts - mCollisionDetection.mContactPairsIndicesOrderingForContacts.add(pair.contactPairIndex); - // Add the contact manifold into the island mIslands.nbContactManifolds[islandIndex] += pair.potentialContactManifoldsIndices.size(); pair.isAlreadyInIsland = true; @@ -638,11 +632,6 @@ void DynamicsWorld::createIslands() { } } - // Add the contact pairs that are not part of islands at the end of the array of pairs for contacts creations - mCollisionDetection.mContactPairsIndicesOrderingForContacts.addRange(nonRigidBodiesContactPairs); - - assert(mCollisionDetection.mCurrentContactPairs->size() == mCollisionDetection.mContactPairsIndicesOrderingForContacts.size()); - mCollisionDetection.mMapBodyToContactPairs.clear(true); } diff --git a/src/systems/CollisionDetectionSystem.cpp b/src/systems/CollisionDetectionSystem.cpp index 6349cfc4..a45ef2e6 100644 --- a/src/systems/CollisionDetectionSystem.cpp +++ b/src/systems/CollisionDetectionSystem.cpp @@ -64,7 +64,6 @@ CollisionDetectionSystem::CollisionDetectionSystem(CollisionWorld* world, ProxyS mContactPairs2(mMemoryManager.getPoolAllocator()), mPreviousContactPairs(&mContactPairs1), mCurrentContactPairs(&mContactPairs2), mMapPairIdToContactPairIndex1(mMemoryManager.getPoolAllocator()), mMapPairIdToContactPairIndex2(mMemoryManager.getPoolAllocator()), mPreviousMapPairIdToContactPairIndex(&mMapPairIdToContactPairIndex1), mCurrentMapPairIdToContactPairIndex(&mMapPairIdToContactPairIndex2), - mContactPairsIndicesOrderingForContacts(memoryManager.getSingleFrameAllocator()), mContactManifolds1(mMemoryManager.getPoolAllocator()), mContactManifolds2(mMemoryManager.getPoolAllocator()), mPreviousContactManifolds(&mContactManifolds1), mCurrentContactManifolds(&mContactManifolds2), mContactPoints1(mMemoryManager.getPoolAllocator()), @@ -464,7 +463,8 @@ void CollisionDetectionSystem::computeNarrowPhase() { assert(mCurrentContactManifolds->size() == 0); assert(mCurrentContactPoints->size() == 0); - mContactPairsIndicesOrderingForContacts.reserve(mCurrentContactPairs->size()); + // Create the actual narrow-phase contacts + createContacts(); mNarrowPhaseInput.clear(); } @@ -605,17 +605,15 @@ void CollisionDetectionSystem::swapPreviousAndCurrentContacts() { // Create the actual contact manifolds and contacts points void CollisionDetectionSystem::createContacts() { - RP3D_PROFILE("CollisionDetection::createContacts()", mProfiler); - - assert(mCurrentContactPairs->size() == mContactPairsIndicesOrderingForContacts.size()); + RP3D_PROFILE("CollisionDetectionSystem::createContacts()", mProfiler); mCurrentContactManifolds->reserve(mCurrentContactPairs->size()); mCurrentContactPoints->reserve(mCurrentContactManifolds->size()); // For each contact pair - for (uint p=0; p < mContactPairsIndicesOrderingForContacts.size(); p++) { + for (uint p=0; p < (*mCurrentContactPairs).size(); p++) { - ContactPair& contactPair = (*mCurrentContactPairs)[mContactPairsIndicesOrderingForContacts[p]]; + ContactPair& contactPair = (*mCurrentContactPairs)[p]; assert(contactPair.potentialContactManifoldsIndices.size() > 0); contactPair.contactManifoldsIndex = mCurrentContactManifolds->size(); @@ -666,7 +664,6 @@ void CollisionDetectionSystem::createContacts() { // Reset the potential contacts mPotentialContactPoints.clear(true); mPotentialContactManifolds.clear(true); - mContactPairsIndicesOrderingForContacts.clear(true); } // Create the actual contact manifolds and contacts points for testCollision() methods diff --git a/src/systems/CollisionDetectionSystem.h b/src/systems/CollisionDetectionSystem.h index 15e85b0c..87a27e86 100644 --- a/src/systems/CollisionDetectionSystem.h +++ b/src/systems/CollisionDetectionSystem.h @@ -135,12 +135,6 @@ class CollisionDetectionSystem { /// (either mMapPairIdToContactPairIndex1 or mMapPairIdToContactPairIndex2) Map* mCurrentMapPairIdToContactPairIndex; - /// List of the indices of the contact pairs (in mCurrentContacPairs array) with contact pairs of - /// same islands packed together linearly and contact pairs that are not part of islands at the end. - /// This is used when we create contact manifolds and contact points so that there are also packed - /// together linearly if they are part of the same island. - List mContactPairsIndicesOrderingForContacts; - /// First list with the contact manifolds List mContactManifolds1; diff --git a/src/systems/ContactSolverSystem.cpp b/src/systems/ContactSolverSystem.cpp index ac54f36f..6b270cab 100644 --- a/src/systems/ContactSolverSystem.cpp +++ b/src/systems/ContactSolverSystem.cpp @@ -492,6 +492,8 @@ void ContactSolverSystem::solve() { decimal lambdaTemp; uint contactPointIndex = 0; + const decimal beta = mIsSplitImpulseActive ? BETA_SPLIT_IMPULSE : BETA; + // For each contact manifold for (uint c=0; c SLOP) biasPenetrationDepth = -(beta/mTimeStep) * max(0.0f, float(mContactPoints[contactPointIndex].penetrationDepth - SLOP));