Remove ProxyShapes pointers from OverlappingPair

This commit is contained in:
Daniel Chappuis 2015-10-13 19:10:13 +02:00
parent 3acdeb8cd2
commit 20c9794a20
4 changed files with 24 additions and 15 deletions

View File

@ -163,10 +163,11 @@ short int ContactManifoldSet::computeCubemapNormalId(const Vector3& normal) cons
} }
// Update the contact manifolds // Update the contact manifolds
void ContactManifoldSet::update(const Transform& transform1, const Transform& transform2) { void ContactManifoldSet::update() {
for (int i=0; i<mNbManifolds; i++) { for (int i=0; i<mNbManifolds; i++) {
mManifolds[i]->update(transform1, transform2); mManifolds[i]->update(mShape1->getBody()->getTransform() * mShape1->getLocalToBodyTransform(),
mShape2->getBody()->getTransform() * mShape2->getLocalToBodyTransform());
} }
} }

View File

@ -93,11 +93,17 @@ class ContactManifoldSet {
/// Destructor /// Destructor
~ContactManifoldSet(); ~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 /// Add a contact point to the manifold set
void addContactPoint(ContactPoint* contact); void addContactPoint(ContactPoint* contact);
/// Update the contact manifolds /// Update the contact manifolds
void update(const Transform& transform1, const Transform& transform2); void update();
/// Clear the contact manifold set /// Clear the contact manifold set
void clear(); void clear();
@ -112,6 +118,16 @@ class ContactManifoldSet {
int getTotalNbContactPoints() const; 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 // Return the number of manifolds in the set
inline int ContactManifoldSet::getNbContactManifolds() const { inline int ContactManifoldSet::getNbContactManifolds() const {
return mNbManifolds; return mNbManifolds;

View File

@ -32,8 +32,7 @@ using namespace reactphysics3d;
// Constructor // Constructor
OverlappingPair::OverlappingPair(ProxyShape* shape1, ProxyShape* shape2, OverlappingPair::OverlappingPair(ProxyShape* shape1, ProxyShape* shape2,
int nbMaxContactManifolds, MemoryAllocator& memoryAllocator) 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) { mCachedSeparatingAxis(1.0, 1.0, 1.0) {
} }

View File

@ -51,12 +51,6 @@ class OverlappingPair {
// -------------------- Attributes -------------------- // // -------------------- Attributes -------------------- //
/// Pointer to the first proxy collision shape
ProxyShape* mShape1;
/// Pointer to the second proxy collision shape
ProxyShape* mShape2;
/// Set of persistent contact manifolds /// Set of persistent contact manifolds
ContactManifoldSet mContactManifoldSet; ContactManifoldSet mContactManifoldSet;
@ -122,12 +116,12 @@ class OverlappingPair {
// Return the pointer to first body // Return the pointer to first body
inline ProxyShape* OverlappingPair::getShape1() const { inline ProxyShape* OverlappingPair::getShape1() const {
return mShape1; return mContactManifoldSet.getShape1();
} }
// Return the pointer to second body // Return the pointer to second body
inline ProxyShape* OverlappingPair::getShape2() const { inline ProxyShape* OverlappingPair::getShape2() const {
return mShape2; return mContactManifoldSet.getShape2();
} }
// Add a contact to the contact manifold // Add a contact to the contact manifold
@ -137,8 +131,7 @@ inline void OverlappingPair::addContact(ContactPoint* contact) {
// Update the contact manifold // Update the contact manifold
inline void OverlappingPair::update() { inline void OverlappingPair::update() {
mContactManifoldSet.update(mShape1->getBody()->getTransform() * mShape1->getLocalToBodyTransform(), mContactManifoldSet.update();
mShape2->getBody()->getTransform() *mShape2->getLocalToBodyTransform());
} }
// Return the cached separating axis // Return the cached separating axis