btPersistentManifold returns 0 contacts (getNumContacts)

Post Reply
Pacha
Posts: 26
Joined: Sat Jun 15, 2013 2:29 am

btPersistentManifold returns 0 contacts (getNumContacts)

Post by Pacha »

I am using a contact manifold to do some normal processing. It sometimes returns 0 when calling getNumContacts().

Thanks.

Code: Select all

static_cast<PlayerController*>(world->getWorldUserInfo())->_clearTouchingPlatforms();

int numManifolds = world->getDispatcher()->getNumManifolds();
DEBUG_PRINT(3, %d, numManifolds);
for (int i=0;i<numManifolds;i++)
{
	btPersistentManifold* contactManifold =  world->getDispatcher()->getManifoldByIndexInternal(i);
	const btCollisionObject* obA = (contactManifold->getBody0());
	const btCollisionObject* obB = (contactManifold->getBody1());

	auto body = static_cast<PlayerController*>(world->getWorldUserInfo())->getBody();
	if (obA == body || obB == body)
	{
		int numContacts = contactManifold->getNumContacts();
		DEBUG_PRINT(4, %d, numContacts);
		for (int j=0;j<numContacts;j++)
		{
			auto normal = TO_OGRE(contactManifold->getContactPoint(j).m_normalWorldOnB * (obB == body ? -1 : 1));
			if (obA->platformPointer)
			{
				static_cast<PlayerController*>(world->getWorldUserInfo())->_addTouchingPlatform(obA->platformPointer, normal);
			}
			if (obB->platformPointer)
			{
				static_cast<PlayerController*>(world->getWorldUserInfo())->_addTouchingPlatform(obB->platformPointer, normal);
			}
			//if (pt.getDistance()<0.f)
			//{
			//	btVector3 normalOnB = pt.m_normalWorldOnB;
			//	if (obB == body)
			//	{
			//		normalOnB *= -1;
			//	}
			//	
			//	static_cast<PlayerController*>(world->getWorldUserInfo())->_addNormal(normalOnB);
			//}
		}
	}
}
Post Reply