diff --git a/src/collision/ContactManifoldSet.cpp b/src/collision/ContactManifoldSet.cpp index 86c31371..49362032 100644 --- a/src/collision/ContactManifoldSet.cpp +++ b/src/collision/ContactManifoldSet.cpp @@ -163,10 +163,11 @@ short int ContactManifoldSet::computeCubemapNormalId(const Vector3& normal) cons } // Update the contact manifolds -void ContactManifoldSet::update(const Transform& transform1, const Transform& transform2) { +void ContactManifoldSet::update() { for (int i=0; iupdate(transform1, transform2); + mManifolds[i]->update(mShape1->getBody()->getTransform() * mShape1->getLocalToBodyTransform(), + mShape2->getBody()->getTransform() * mShape2->getLocalToBodyTransform()); } } diff --git a/src/collision/ContactManifoldSet.h b/src/collision/ContactManifoldSet.h index 9df75ae3..cb0bd2a7 100644 --- a/src/collision/ContactManifoldSet.h +++ b/src/collision/ContactManifoldSet.h @@ -93,11 +93,17 @@ class ContactManifoldSet { /// Destructor ~ContactManifoldSet(); + /// Return the first proxy shape + ProxyShape* getShape1() const; + + /// Return the second proxy shape + ProxyShape* getShape2() const; + /// Add a contact point to the manifold set void addContactPoint(ContactPoint* contact); /// Update the contact manifolds - void update(const Transform& transform1, const Transform& transform2); + void update(); /// Clear the contact manifold set void clear(); @@ -112,6 +118,16 @@ class ContactManifoldSet { int getTotalNbContactPoints() const; }; +// Return the first proxy shape +inline ProxyShape* ContactManifoldSet::getShape1() const { + return mShape1; +} + +// Return the second proxy shape +inline ProxyShape* ContactManifoldSet::getShape2() const { + return mShape2; +} + // Return the number of manifolds in the set inline int ContactManifoldSet::getNbContactManifolds() const { return mNbManifolds; diff --git a/src/engine/OverlappingPair.cpp b/src/engine/OverlappingPair.cpp index d08b3f5f..300c4527 100644 --- a/src/engine/OverlappingPair.cpp +++ b/src/engine/OverlappingPair.cpp @@ -32,8 +32,7 @@ using namespace reactphysics3d; // Constructor OverlappingPair::OverlappingPair(ProxyShape* shape1, ProxyShape* shape2, int nbMaxContactManifolds, MemoryAllocator& memoryAllocator) - : mShape1(shape1), mShape2(shape2), - mContactManifoldSet(shape1, shape2, memoryAllocator, nbMaxContactManifolds), + : mContactManifoldSet(shape1, shape2, memoryAllocator, nbMaxContactManifolds), mCachedSeparatingAxis(1.0, 1.0, 1.0) { } diff --git a/src/engine/OverlappingPair.h b/src/engine/OverlappingPair.h index 89c612b9..134770f0 100644 --- a/src/engine/OverlappingPair.h +++ b/src/engine/OverlappingPair.h @@ -51,12 +51,6 @@ class OverlappingPair { // -------------------- Attributes -------------------- // - /// Pointer to the first proxy collision shape - ProxyShape* mShape1; - - /// Pointer to the second proxy collision shape - ProxyShape* mShape2; - /// Set of persistent contact manifolds ContactManifoldSet mContactManifoldSet; @@ -122,12 +116,12 @@ class OverlappingPair { // Return the pointer to first body inline ProxyShape* OverlappingPair::getShape1() const { - return mShape1; + return mContactManifoldSet.getShape1(); } // Return the pointer to second body inline ProxyShape* OverlappingPair::getShape2() const { - return mShape2; + return mContactManifoldSet.getShape2(); } // Add a contact to the contact manifold @@ -137,8 +131,7 @@ inline void OverlappingPair::addContact(ContactPoint* contact) { // Update the contact manifold inline void OverlappingPair::update() { - mContactManifoldSet.update(mShape1->getBody()->getTransform() * mShape1->getLocalToBodyTransform(), - mShape2->getBody()->getTransform() *mShape2->getLocalToBodyTransform()); + mContactManifoldSet.update(); } // Return the cached separating axis