// TODO: Optimize this, heavily!
		virtual void postSolveContact(btSolverBody *body0, btSolverBody *body1, btManifoldPoint *cp) {
			btRigidBody *rb0 = btRigidBody::upcast(body0->m_originalColObj);
			btRigidBody *rb1 = btRigidBody::upcast(body1->m_originalColObj);

			// FIXME: Problem with bullet code, only one solver body created for static objects!
			// There could be more than one static object created by us!
			CPhysicsObject *pObj0 = (CPhysicsObject *)body0->m_originalColObj->getUserPointer();
			CPhysicsObject *pObj1 = (CPhysicsObject *)body1->m_originalColObj->getUserPointer();
			if (pObj0->GetCallbackFlags() & CALLBACK_MARKED_FOR_DELETE || pObj1->GetCallbackFlags() & CALLBACK_MARKED_FOR_DELETE)
				return;

			//unsigned int flags0 = pObj0->GetCallbackFlags();
			//unsigned int flags1 = pObj1->GetCallbackFlags();

			btScalar combinedInvMass = rb0->getInvMass() + rb1->getInvMass();
			m_tmpEvent.collisionSpeed = BULL2HL(cp->m_appliedImpulse * combinedInvMass); // Speed of body 1 rel to body 2 on axis of constraint normal

			// FIXME: Find a way to track the real delta time
			// IVP tracks this delta time between object pairs
			m_tmpEvent.deltaCollisionTime = 10.f;
			/*
			m_tmpEvent.isCollision = (flags0 & flags1 & CALLBACK_GLOBAL_COLLISION); // False when either one of the objects don't have CALLBACK_GLOBAL_COLLISION
			m_tmpEvent.isShadowCollision = (flags0 ^ flags1) & CALLBACK_SHADOW_COLLISION; // True when only one of the objects is a shadow

			m_tmpEvent.pObjects[0] = pObj0;
			m_tmpEvent.pObjects[1] = pObj1;	
			m_tmpEvent.surfaceProps[0] = pObj0 ? pObj0->GetMaterialIndex() : 0;
			m_tmpEvent.surfaceProps[1] = pObj1 ? pObj1->GetMaterialIndex() : 0;
			*/

			if (!m_tmpEvent.isCollision && !m_tmpEvent.isShadowCollision) return;

			CPhysicsCollisionData data(cp);
			m_tmpEvent.pInternalData = &data;

			// Give the game its stupid velocities
			if (body0->m_originalBody) {
				body0->m_originalBody->setLinearVelocity(m_tmpVelocities[0] + body0->internalGetDeltaLinearVelocity());
				body0->m_originalBody->setAngularVelocity(m_tmpAngVelocities[0] + body0->internalGetDeltaAngularVelocity());
			}
			if (body1->m_originalBody) {
				body1->m_originalBody->setLinearVelocity(m_tmpVelocities[1] + body1->internalGetDeltaLinearVelocity());
				body1->m_originalBody->setAngularVelocity(m_tmpAngVelocities[1] + body1->internalGetDeltaAngularVelocity());
			}

			if (m_pCallback)
				m_pCallback->PostCollision(&m_tmpEvent);

			// Restore the velocities
			if (body0->m_originalBody) {
				body0->m_originalBody->setLinearVelocity(m_tmpVelocities[0]);
				body0->m_originalBody->setAngularVelocity(m_tmpAngVelocities[0]);
			}
			if (body1->m_originalBody) {
				body1->m_originalBody->setLinearVelocity(m_tmpVelocities[1]);
				body1->m_originalBody->setAngularVelocity(m_tmpAngVelocities[1]);
			}
		}
Example #2
0
void ConvertPosToHL(const btVector3& pos, Vector& hl) {
	hl.x = BULL2HL(pos.x());
	hl.y = -BULL2HL(pos.z());
	hl.z = BULL2HL(pos.y());
}
Example #3
0
float ConvertDistanceToHL(float distance) {
	return BULL2HL(distance);
}