public void AxisSweepAabbTest() { var rayFromWorld = new Vector3(-2, 2, 0); var rayToWorld = new Vector3(4, 2, 0); using (var aabbCallback = new CustomBroadphaseAabbCallback()) { broadphase.AabbTest(new Vector3(-1000, -1000, -1000), new Vector3(1000, 1000, 1000), aabbCallback); Assert.True(aabbCallback.Processed, "Broadphase AABB callback failed"); } }
void TestAxisSweepOverlapCallback() { var conf = new DefaultCollisionConfiguration(); var dispatcher = new CollisionDispatcher(conf); var broadphase = new AxisSweep3(new Vector3(-1000, -1000, -1000), new Vector3(1000, 1000, 1000)); world = new DiscreteDynamicsWorld(dispatcher, broadphase, null, conf); broadphase.OverlappingPairUserCallback = new AxisSweepUserCallback(); AddToDisposeQueue(broadphase.OverlappingPairUserCallback); CreateBody(10.0f, new SphereShape(1.0f), new Vector3(2, 2, 0)); CreateBody(1.0f, new SphereShape(1.0f), new Vector3(0, 2, 0)); CustomBroadphaseAabbCallback aabbCallback = new CustomBroadphaseAabbCallback(); broadphase.AabbTest(new Vector3(-1000, -1000, -1000), new Vector3(1000, 1000, 1000), aabbCallback); AddToDisposeQueue(aabbCallback); aabbCallback = null; var rayFromWorld = new Vector3(-2, 2, 0); var rayToWorld = new Vector3(4, 2, 0); CustomBroadphaseRayTestCallback rayCallback = new CustomBroadphaseRayTestCallback(ref rayFromWorld, ref rayToWorld); broadphase.RayTest(rayFromWorld, rayToWorld, rayCallback, Vector3.Zero, Vector3.Zero); if (!rayCallback.HasHit) { Console.WriteLine("Broadphase ray test FAILED!"); } AddToDisposeQueue(rayCallback); rayCallback = null; broadphase = null; world.StepSimulation(1.0f / 60.0f); world.Dispose(); world = null; ForceGC(); TestWeakRefs(); ClearRefs(); }
static void TestAxisSweepOverlapCallback() { var conf = new DefaultCollisionConfiguration(); var dispatcher = new CollisionDispatcher(conf); var broadphase = new AxisSweep3(new Vector3(-1000, -1000, -1000), new Vector3(1000, 1000, 1000)); world = new DiscreteDynamicsWorld(dispatcher, broadphase, null, conf); //broadphase.OverlappingPairUserCallback = new AxisSweepUserCallback(); //AddToDisposeQueue(broadphase.OverlappingPairUserCallback); CreateBody(10.0f, new SphereShape(1.0f), new Vector3(2, 2, 0)); CreateBody(1.0f, new SphereShape(1.0f), new Vector3(0, 2, 0)); CustomBroadphaseAabbCallback aabbCallback = new CustomBroadphaseAabbCallback(); broadphase.AabbTest(new Vector3(-1000, -1000, -1000), new Vector3(1000, 1000, 1000), aabbCallback); AddToDisposeQueue(aabbCallback); aabbCallback = null; // FIXME: RayTest crashes for DbvtBroadphase CustomBroadphaseRayTestCallback rayCallback = new CustomBroadphaseRayTestCallback(); //broadphase.RayTest(new Vector3(0, 2, 0), new Vector3(2, 2, 0), rayCallback); AddToDisposeQueue(rayCallback); rayCallback = null; broadphase = null; world.StepSimulation(1.0f / 60.0f); world.Dispose(); world = null; GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced); GC.WaitForPendingFinalizers(); TestWeakRefs(); disposeQueue.Clear(); }