Ejemplo n.º 1
0
void gkPhysicsController::_handleManifold(btPersistentManifold* manifold)
{
	if (m_suspend
			|| !m_props.isContactListener()
			|| !m_object->isInstanced())
		return;


	gkPhysicsController* colA = castController(manifold->getBody0());
	gkPhysicsController* colB = castController(manifold->getBody1());

	gkPhysicsController* collider = colB;

	if (collider == this)
	{
		collider = colA;
	}


	if (collider->m_object->getProperties().isGhost()){
		m_localContacts.reserve(1);

		gkContactInfo cinf;
		cinf.collider = collider;
		m_localContacts.push_back(cinf);
	}
	else {
		int nrc = manifold->getNumContacts();

		if (nrc)
		{
			m_localContacts.reserve(nrc);

			for (int j = 0; j < nrc; ++j)
			{
				gkContactInfo cinf;
				btManifoldPoint& pt = manifold->getContactPoint(j);

				if (pt.getDistance() < 0.f)
				{
					cinf.collider = collider;
					cinf.point    = pt;

					m_localContacts.push_back(cinf);
				}
			}
		}
	}
}
void gkGhost::_handleManifold(btPersistentManifold* manifold)
{
	gkPhysicsController* colA = castController(manifold->getBody0());
	gkPhysicsController* colB = castController(manifold->getBody1());

	gkPhysicsController* collider = colB;

	if (collider == this)
	{
		collider = colA;
	}

	m_localContacts.reserve(1);

	gkContactInfo cinf;
	cinf.collider = collider;
	m_localContacts.push_back(cinf);
}
Ejemplo n.º 3
0
gkPhysicsController* gkPhysicsController::castController(void* colObj)
{
	GK_ASSERT(colObj);
	return castController(static_cast<btCollisionObject*>(colObj));
}