use of com.nilunder.bdx.GameObject.ArrayListGameObject in project bdx by GoranM.
the class Scene method detectCollisions.
private void detectCollisions() {
for (GameObject g : objects) {
ArrayListGameObject hitLast = g.touchingObjectsLast;
g.touchingObjectsLast = g.touchingObjects;
g.touchingObjects = hitLast;
g.touchingObjects.clear();
g.contactManifolds.clear();
}
int numManifolds = world.getDispatcher().getNumManifolds();
for (int i = 0; i < numManifolds; ++i) {
PersistentManifold mani = world.getDispatcher().getManifoldByIndexInternal(i);
if (mani.getNumContacts() > 0) {
RigidBody a = (RigidBody) mani.getBody0();
RigidBody b = (RigidBody) mani.getBody1();
GameObject A = (GameObject) a.getUserPointer();
GameObject B = (GameObject) b.getUserPointer();
A.touchingObjects.add(B);
B.touchingObjects.add(A);
A.contactManifolds.add(mani);
B.contactManifolds.add(mani);
}
}
}
Aggregations