Optimization of contacts processing
This commit is contained in:
parent
98ac47cbad
commit
8fd5c58986
|
@ -55,7 +55,7 @@ struct ContactManifoldInfo {
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
ContactManifoldInfo(uint64 pairId, MemoryAllocator& allocator)
|
ContactManifoldInfo(uint64 pairId, MemoryAllocator& allocator)
|
||||||
: potentialContactPointsIndices(allocator), pairId(pairId) {
|
: potentialContactPointsIndices(allocator, 4), pairId(pairId) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ struct ContactPair {
|
||||||
/// Constructor
|
/// Constructor
|
||||||
ContactPair(uint64 pairId, Entity body1Entity, Entity body2Entity, Entity collider1Entity,
|
ContactPair(uint64 pairId, Entity body1Entity, Entity body2Entity, Entity collider1Entity,
|
||||||
Entity collider2Entity, uint contactPairIndex, bool collidingInPreviousFrame, bool isTrigger, MemoryAllocator& allocator)
|
Entity collider2Entity, uint contactPairIndex, bool collidingInPreviousFrame, bool isTrigger, MemoryAllocator& allocator)
|
||||||
: pairId(pairId), potentialContactManifoldsIndices(allocator), body1Entity(body1Entity), body2Entity(body2Entity),
|
: pairId(pairId), potentialContactManifoldsIndices(allocator, 8), body1Entity(body1Entity), body2Entity(body2Entity),
|
||||||
collider1Entity(collider1Entity), collider2Entity(collider2Entity),
|
collider1Entity(collider1Entity), collider2Entity(collider2Entity),
|
||||||
isAlreadyInIsland(false), contactPairIndex(contactPairIndex), contactManifoldsIndex(0), nbContactManifolds(0),
|
isAlreadyInIsland(false), contactPairIndex(contactPairIndex), contactManifoldsIndex(0), nbContactManifolds(0),
|
||||||
contactPointsIndex(0), nbToTalContactPoints(0), collidingInPreviousFrame(collidingInPreviousFrame), isTrigger(isTrigger) {
|
contactPointsIndex(0), nbToTalContactPoints(0), collidingInPreviousFrame(collidingInPreviousFrame), isTrigger(isTrigger) {
|
||||||
|
|
|
@ -36,7 +36,7 @@ ContactPoint::ContactPoint(const ContactPointInfo* contactInfo, decimal persiste
|
||||||
mPenetrationDepth(contactInfo->penetrationDepth),
|
mPenetrationDepth(contactInfo->penetrationDepth),
|
||||||
mLocalPointOnShape1(contactInfo->localPoint1),
|
mLocalPointOnShape1(contactInfo->localPoint1),
|
||||||
mLocalPointOnShape2(contactInfo->localPoint2),
|
mLocalPointOnShape2(contactInfo->localPoint2),
|
||||||
mIsRestingContact(false), mIsObsolete(false), mNext(nullptr), mPrevious(nullptr),
|
mIsRestingContact(false), mIsObsolete(false),
|
||||||
mPersistentContactDistanceThreshold(persistentContactDistanceThreshold) {
|
mPersistentContactDistanceThreshold(persistentContactDistanceThreshold) {
|
||||||
|
|
||||||
assert(mPenetrationDepth > decimal(0.0));
|
assert(mPenetrationDepth > decimal(0.0));
|
||||||
|
|
|
@ -520,6 +520,9 @@ void CollisionDetectionSystem::computeNarrowPhase() {
|
||||||
// Swap the previous and current contacts lists
|
// Swap the previous and current contacts lists
|
||||||
swapPreviousAndCurrentContacts();
|
swapPreviousAndCurrentContacts();
|
||||||
|
|
||||||
|
mPotentialContactManifolds.reserve(mPreviousContactManifolds->size());
|
||||||
|
mPotentialContactPoints.reserve(mPreviousContactPoints->size());
|
||||||
|
|
||||||
// Test the narrow-phase collision detection on the batches to be tested
|
// Test the narrow-phase collision detection on the batches to be tested
|
||||||
testNarrowPhaseCollision(mNarrowPhaseInput, true, allocator);
|
testNarrowPhaseCollision(mNarrowPhaseInput, true, allocator);
|
||||||
|
|
||||||
|
|
|
@ -125,17 +125,17 @@ void ContactSolverSystem::initializeForIsland(uint islandIndex) {
|
||||||
|
|
||||||
assert(externalManifold.nbContactPoints > 0);
|
assert(externalManifold.nbContactPoints > 0);
|
||||||
|
|
||||||
|
const uint rigidBodyIndex1 = mRigidBodyComponents.getEntityIndex(externalManifold.bodyEntity1);
|
||||||
|
const uint rigidBodyIndex2 = mRigidBodyComponents.getEntityIndex(externalManifold.bodyEntity2);
|
||||||
|
|
||||||
// Get the two bodies of the contact
|
// Get the two bodies of the contact
|
||||||
RigidBody* body1 = static_cast<RigidBody*>(mBodyComponents.getBody(externalManifold.bodyEntity1));
|
RigidBody* body1 = mRigidBodyComponents.mRigidBodies[rigidBodyIndex1];
|
||||||
RigidBody* body2 = static_cast<RigidBody*>(mBodyComponents.getBody(externalManifold.bodyEntity2));
|
RigidBody* body2 = mRigidBodyComponents.mRigidBodies[rigidBodyIndex2];
|
||||||
assert(body1 != nullptr);
|
assert(body1 != nullptr);
|
||||||
assert(body2 != nullptr);
|
assert(body2 != nullptr);
|
||||||
assert(!mBodyComponents.getIsEntityDisabled(externalManifold.bodyEntity1));
|
assert(!mBodyComponents.getIsEntityDisabled(externalManifold.bodyEntity1));
|
||||||
assert(!mBodyComponents.getIsEntityDisabled(externalManifold.bodyEntity2));
|
assert(!mBodyComponents.getIsEntityDisabled(externalManifold.bodyEntity2));
|
||||||
|
|
||||||
const uint rigidBodyIndex1 = mRigidBodyComponents.getEntityIndex(externalManifold.bodyEntity1);
|
|
||||||
const uint rigidBodyIndex2 = mRigidBodyComponents.getEntityIndex(externalManifold.bodyEntity2);
|
|
||||||
|
|
||||||
Collider* collider1 = mColliderComponents.getCollider(externalManifold.colliderEntity1);
|
Collider* collider1 = mColliderComponents.getCollider(externalManifold.colliderEntity1);
|
||||||
Collider* collider2 = mColliderComponents.getCollider(externalManifold.colliderEntity2);
|
Collider* collider2 = mColliderComponents.getCollider(externalManifold.colliderEntity2);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user