There is a player ship, some enemy ships, player-fired bullets and a bounding wall ( which is a ghost object, destroys the bullets that come in contact with it )
This function checks and destroys the bullets colliding with the wall
Code: Select all
void GameState::boundChecks() {
btAlignedObjectArray<btCollisionObject*>& boundCollisionList = m_pGhostPlane->getOverlappingPairs();
int size = boundCollisionList.size();
for(int i = 0 ; i < size ; i++ ) {
btCollisionObject* obj = boundCollisionList[i];
m_DeadWeights.insert(obj);
}
}
Code: Select all
void GameState::processPhysics() {
int i,
numManifolds = m_pCollisionWorld->getDispatcher()->getNumManifolds();
for(i = 0 ; i < numManifolds ; i++ ) {
btPersistentManifold* contactManifold = m_pCollisionWorld->getDispatcher()->getManifoldByIndexInternal(i);
btCollisionObject* objA = const_cast<btCollisionObject*>(contactManifold->getBody0());
btCollisionObject* objB = const_cast<btCollisionObject*>(contactManifold->getBody1());
m_DeadWeights.insert(objA);
m_DeadWeights.insert(objB);
}
}
How do you manage collisions when there are both ghost and non-ghost objects and the non-ghost objects need to interact with each other as well?
Thank you