public void AxisSweepRayTest() { var rayFromWorld = new Vector3(-2, 2, 0); var rayToWorld = new Vector3(4, 2, 0); using (var rayCallback = new CustomBroadphaseRayTestCallback(ref rayFromWorld, ref rayToWorld)) { broadphase.RayTest(rayFromWorld, rayToWorld, rayCallback, Vector3.Zero, Vector3.Zero); Assert.True(rayCallback.HasHit, "Broadphase ray test 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(); }