Move contacts creation before islands creation
This commit is contained in:
parent
92b39ca6c0
commit
5f05fa372d
|
@ -121,9 +121,6 @@ void DynamicsWorld::update(decimal timeStep) {
|
||||||
// Create the islands
|
// Create the islands
|
||||||
createIslands();
|
createIslands();
|
||||||
|
|
||||||
// Create the actual narrow-phase contacts
|
|
||||||
mCollisionDetection.createContacts();
|
|
||||||
|
|
||||||
// Report the contacts to the user
|
// Report the contacts to the user
|
||||||
mCollisionDetection.reportContacts();
|
mCollisionDetection.reportContacts();
|
||||||
|
|
||||||
|
@ -580,9 +577,6 @@ void DynamicsWorld::createIslands() {
|
||||||
|
|
||||||
nbTotalManifolds += pair.potentialContactManifoldsIndices.size();
|
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
|
// Add the contact manifold into the island
|
||||||
mIslands.nbContactManifolds[islandIndex] += pair.potentialContactManifoldsIndices.size();
|
mIslands.nbContactManifolds[islandIndex] += pair.potentialContactManifoldsIndices.size();
|
||||||
pair.isAlreadyInIsland = true;
|
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);
|
mCollisionDetection.mMapBodyToContactPairs.clear(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,6 @@ CollisionDetectionSystem::CollisionDetectionSystem(CollisionWorld* world, ProxyS
|
||||||
mContactPairs2(mMemoryManager.getPoolAllocator()), mPreviousContactPairs(&mContactPairs1), mCurrentContactPairs(&mContactPairs2),
|
mContactPairs2(mMemoryManager.getPoolAllocator()), mPreviousContactPairs(&mContactPairs1), mCurrentContactPairs(&mContactPairs2),
|
||||||
mMapPairIdToContactPairIndex1(mMemoryManager.getPoolAllocator()), mMapPairIdToContactPairIndex2(mMemoryManager.getPoolAllocator()),
|
mMapPairIdToContactPairIndex1(mMemoryManager.getPoolAllocator()), mMapPairIdToContactPairIndex2(mMemoryManager.getPoolAllocator()),
|
||||||
mPreviousMapPairIdToContactPairIndex(&mMapPairIdToContactPairIndex1), mCurrentMapPairIdToContactPairIndex(&mMapPairIdToContactPairIndex2),
|
mPreviousMapPairIdToContactPairIndex(&mMapPairIdToContactPairIndex1), mCurrentMapPairIdToContactPairIndex(&mMapPairIdToContactPairIndex2),
|
||||||
mContactPairsIndicesOrderingForContacts(memoryManager.getSingleFrameAllocator()),
|
|
||||||
mContactManifolds1(mMemoryManager.getPoolAllocator()), mContactManifolds2(mMemoryManager.getPoolAllocator()),
|
mContactManifolds1(mMemoryManager.getPoolAllocator()), mContactManifolds2(mMemoryManager.getPoolAllocator()),
|
||||||
mPreviousContactManifolds(&mContactManifolds1), mCurrentContactManifolds(&mContactManifolds2),
|
mPreviousContactManifolds(&mContactManifolds1), mCurrentContactManifolds(&mContactManifolds2),
|
||||||
mContactPoints1(mMemoryManager.getPoolAllocator()),
|
mContactPoints1(mMemoryManager.getPoolAllocator()),
|
||||||
|
@ -464,7 +463,8 @@ void CollisionDetectionSystem::computeNarrowPhase() {
|
||||||
assert(mCurrentContactManifolds->size() == 0);
|
assert(mCurrentContactManifolds->size() == 0);
|
||||||
assert(mCurrentContactPoints->size() == 0);
|
assert(mCurrentContactPoints->size() == 0);
|
||||||
|
|
||||||
mContactPairsIndicesOrderingForContacts.reserve(mCurrentContactPairs->size());
|
// Create the actual narrow-phase contacts
|
||||||
|
createContacts();
|
||||||
|
|
||||||
mNarrowPhaseInput.clear();
|
mNarrowPhaseInput.clear();
|
||||||
}
|
}
|
||||||
|
@ -605,17 +605,15 @@ void CollisionDetectionSystem::swapPreviousAndCurrentContacts() {
|
||||||
// Create the actual contact manifolds and contacts points
|
// Create the actual contact manifolds and contacts points
|
||||||
void CollisionDetectionSystem::createContacts() {
|
void CollisionDetectionSystem::createContacts() {
|
||||||
|
|
||||||
RP3D_PROFILE("CollisionDetection::createContacts()", mProfiler);
|
RP3D_PROFILE("CollisionDetectionSystem::createContacts()", mProfiler);
|
||||||
|
|
||||||
assert(mCurrentContactPairs->size() == mContactPairsIndicesOrderingForContacts.size());
|
|
||||||
|
|
||||||
mCurrentContactManifolds->reserve(mCurrentContactPairs->size());
|
mCurrentContactManifolds->reserve(mCurrentContactPairs->size());
|
||||||
mCurrentContactPoints->reserve(mCurrentContactManifolds->size());
|
mCurrentContactPoints->reserve(mCurrentContactManifolds->size());
|
||||||
|
|
||||||
// For each contact pair
|
// 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);
|
assert(contactPair.potentialContactManifoldsIndices.size() > 0);
|
||||||
|
|
||||||
contactPair.contactManifoldsIndex = mCurrentContactManifolds->size();
|
contactPair.contactManifoldsIndex = mCurrentContactManifolds->size();
|
||||||
|
@ -666,7 +664,6 @@ void CollisionDetectionSystem::createContacts() {
|
||||||
// Reset the potential contacts
|
// Reset the potential contacts
|
||||||
mPotentialContactPoints.clear(true);
|
mPotentialContactPoints.clear(true);
|
||||||
mPotentialContactManifolds.clear(true);
|
mPotentialContactManifolds.clear(true);
|
||||||
mContactPairsIndicesOrderingForContacts.clear(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the actual contact manifolds and contacts points for testCollision() methods
|
// Create the actual contact manifolds and contacts points for testCollision() methods
|
||||||
|
|
|
@ -135,12 +135,6 @@ class CollisionDetectionSystem {
|
||||||
/// (either mMapPairIdToContactPairIndex1 or mMapPairIdToContactPairIndex2)
|
/// (either mMapPairIdToContactPairIndex1 or mMapPairIdToContactPairIndex2)
|
||||||
Map<OverlappingPair::OverlappingPairId, uint>* mCurrentMapPairIdToContactPairIndex;
|
Map<OverlappingPair::OverlappingPairId, uint>* 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<uint> mContactPairsIndicesOrderingForContacts;
|
|
||||||
|
|
||||||
/// First list with the contact manifolds
|
/// First list with the contact manifolds
|
||||||
List<ContactManifold> mContactManifolds1;
|
List<ContactManifold> mContactManifolds1;
|
||||||
|
|
||||||
|
|
|
@ -492,6 +492,8 @@ void ContactSolverSystem::solve() {
|
||||||
decimal lambdaTemp;
|
decimal lambdaTemp;
|
||||||
uint contactPointIndex = 0;
|
uint contactPointIndex = 0;
|
||||||
|
|
||||||
|
const decimal beta = mIsSplitImpulseActive ? BETA_SPLIT_IMPULSE : BETA;
|
||||||
|
|
||||||
// For each contact manifold
|
// For each contact manifold
|
||||||
for (uint c=0; c<mNbContactManifolds; c++) {
|
for (uint c=0; c<mNbContactManifolds; c++) {
|
||||||
|
|
||||||
|
@ -520,7 +522,6 @@ void ContactSolverSystem::solve() {
|
||||||
decimal Jv = deltaVDotN;
|
decimal Jv = deltaVDotN;
|
||||||
|
|
||||||
// Compute the bias "b" of the constraint
|
// Compute the bias "b" of the constraint
|
||||||
decimal beta = mIsSplitImpulseActive ? BETA_SPLIT_IMPULSE : BETA;
|
|
||||||
decimal biasPenetrationDepth = 0.0;
|
decimal biasPenetrationDepth = 0.0;
|
||||||
if (mContactPoints[contactPointIndex].penetrationDepth > SLOP) biasPenetrationDepth = -(beta/mTimeStep) *
|
if (mContactPoints[contactPointIndex].penetrationDepth > SLOP) biasPenetrationDepth = -(beta/mTimeStep) *
|
||||||
max(0.0f, float(mContactPoints[contactPointIndex].penetrationDepth - SLOP));
|
max(0.0f, float(mContactPoints[contactPointIndex].penetrationDepth - SLOP));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user