// NOTE< implementation just checks for AABB bounds and doesn't handle the sphere of an proximity detector > public static void checkProximityDetectorsAndFireEventsForObjects(IEnumerable <ProximityDetector> proximityDetectors, IEnumerable <PhysicsComponent> objects) { foreach (ProximityDetector iProximityDetector in proximityDetectors) { // check and fire exit of objects IList <PhysicsComponent> removedElementsFromObjectsInside = new List <PhysicsComponent>(); foreach (PhysicsComponent iCheckExitedObject in iProximityDetector.objectsInside) { bool exited = checkObjectExitingExitOfObject(iProximityDetector, iCheckExitedObject); if (exited) { removedElementsFromObjectsInside.Add(iCheckExitedObject); iProximityDetector.handleExitEventForObject(iCheckExitedObject); } } // check for entered objects and fire foreach (PhysicsComponent iObject in objects) { if (!KDop.checkIntersectAabb(iObject.boundingVolume.kdop, iProximityDetector.cachedKDop)) { continue; } if (iProximityDetector.objectsInside.Contains(iObject)) { continue; } // fire iProximityDetector.handleEnterEventForObject(iObject); } // remove elements of list of objects inside which exited foreach (PhysicsComponent iExitedObject in removedElementsFromObjectsInside) { iProximityDetector.objectsInside.Remove(iExitedObject); } // fire inside event for all objects still inside foreach (PhysicsComponent iObjectInside in iProximityDetector.objectsInside) { iProximityDetector.handleInsideEventForObject(iObjectInside); } // add entered objects foreach (PhysicsComponent iObject in objects) { if (!KDop.checkIntersectAabb(iObject.boundingVolume.kdop, iProximityDetector.cachedKDop)) { continue; } if (iProximityDetector.objectsInside.Contains(iObject)) { continue; } iProximityDetector.objectsInside.Add(iObject); } } }
static bool checkObjectOverlap(ProximityDetector detector, PhysicsComponent object_) { return(!KDop.checkIntersectAabb(object_.boundingVolume.kdop, detector.cachedKDop)); }
void recalcBoundingVolumeKDop14(IList <SpatialVectorDouble> vertices) { boundingVolume = new BoundingVolume(); boundingVolume.kdop = KDop.calculateKdopFromVertices(vertices, 14); }