Verify the number of contact points in manifold in case collision event processing changes the physics world. Closes #358.

This commit is contained in:
Lasse Öörni 2014-05-21 13:44:21 +03:00
Родитель 17dcffb095
Коммит 0a4f813389
1 изменённых файлов: 3 добавлений и 5 удалений

Просмотреть файл

@ -621,9 +621,8 @@ void PhysicsWorld::SendCollisionEvents()
for (int i = 0; i < numManifolds; ++i)
{
btPersistentManifold* contactManifold = collisionDispatcher_->getManifoldByIndexInternal(i);
int numContacts = contactManifold->getNumContacts();
// First check that there are actual contacts, as the manifold exists also when objects are close but not touching
if (!numContacts)
if (!contactManifold->getNumContacts())
continue;
const btCollisionObject* objectA = contactManifold->getBody0();
@ -667,7 +666,6 @@ void PhysicsWorld::SendCollisionEvents()
continue;
btPersistentManifold* contactManifold = i->second_;
int numContacts = contactManifold->getNumContacts();
Node* nodeA = bodyA->GetNode();
Node* nodeB = bodyB->GetNode();
@ -685,7 +683,7 @@ void PhysicsWorld::SendCollisionEvents()
contacts_.Clear();
for (int j = 0; j < numContacts; ++j)
for (int j = 0; j < contactManifold->getNumContacts(); ++j)
{
btManifoldPoint& point = contactManifold->getContactPoint(j);
contacts_.WriteVector3(ToVector3(point.m_positionWorldOnB));
@ -728,7 +726,7 @@ void PhysicsWorld::SendCollisionEvents()
continue;
contacts_.Clear();
for (int j = 0; j < numContacts; ++j)
for (int j = 0; j < contactManifold->getNumContacts(); ++j)
{
btManifoldPoint& point = contactManifold->getContactPoint(j);
contacts_.WriteVector3(ToVector3(point.m_positionWorldOnB));