private void add(Body body) { if (body == null) throw new IllegalArgumentException("bodies cannot contain null"); broadPhase.add(body); if (broadPhase != rayBroadPhase) { rayBroadPhase.add(body); } }
/** * Returns all contacts made by a ray. * * @param ray * @return Ray contacts, never null */ public List<RayContact> allReached(Ray ray) { List<RayContact> contacts = new ArrayList<RayContact>(); for (Body body : rayBroadPhase.potentialBodies(ray)) { RayContact contact = isReached(body, ray); if (contact != null) { contacts.add(contact); } } sort(contacts, byAscendingDistanceFromRayStart()); return contacts; }
public void clearBodies() { broadPhase.clear(); if (broadPhase != rayBroadPhase) { rayBroadPhase.clear(); } }