public void TestFindDynamicContact() { float?impactTime = AabbAabbCollider.FindContact( testBox.Min, testBox.Max, new Vector3(0.0f, 10.0f, 10.0f), new Vector3(5.0f, 15.0f, 15.0f), new Vector3(10.0f, 0.0f, 0.0f) ); Assert.IsTrue(impactTime.HasValue); Assert.AreEqual(0.5f, impactTime.Value); }
public void TestCheckContact() { Assert.IsTrue( AabbAabbCollider.CheckContact( testBox.Min, testBox.Max, new Vector3(14.0f, 14.0f, 14.0f), new Vector3(16.0f, 16.0f, 16.0f) ), "Fully enclosed box is detected to intersect with test box" ); Assert.IsTrue( AabbAabbCollider.CheckContact( testBox.Min, testBox.Max, new Vector3(5.0f, 5.0f, 5.0f), new Vector3(25.0f, 25.0f, 25.0f) ), "Fully containing box is detected to intersect with test box" ); Assert.IsFalse( AabbAabbCollider.CheckContact( testBox.Min, testBox.Max, new Vector3(5.0f, 5.0f, 5.0f), new Vector3(10.0f - Specifications.MaximumDeviation, 25.0f, 25.0f) ), "Close miss of axis aligned box on X axis to left side is properly handled" ); Assert.IsFalse( AabbAabbCollider.CheckContact( testBox.Min, testBox.Max, new Vector3(20.0f + Specifications.MaximumDeviation, 5.0f, 5.0f), new Vector3(25.0f, 25.0f, 25.0f) ), "Close miss of axis aligned box on X axis to right side is properly handled" ); Assert.IsFalse( AabbAabbCollider.CheckContact( testBox.Min, testBox.Max, new Vector3(5.0f, 5.0f, 5.0f), new Vector3(25.0f, 10.0f - Specifications.MaximumDeviation, 25.0f) ), "Close miss of axis aligned box on Y axis to left side is properly handled" ); Assert.IsFalse( AabbAabbCollider.CheckContact( testBox.Min, testBox.Max, new Vector3(5.0f, 20.0f + Specifications.MaximumDeviation, 5.0f), new Vector3(25.0f, 25.0f, 25.0f) ), "Close miss of axis aligned box on Y axis to right side is properly handled" ); Assert.IsFalse( AabbAabbCollider.CheckContact( testBox.Min, testBox.Max, new Vector3(5.0f, 5.0f, 5.0f), new Vector3(25.0f, 25.0f, 10.0f - Specifications.MaximumDeviation) ), "Close miss of axis aligned box on Z axis to left side is properly handled" ); Assert.IsFalse( AabbAabbCollider.CheckContact( testBox.Min, testBox.Max, new Vector3(5.0f, 5.0f, 20.0f + Specifications.MaximumDeviation), new Vector3(25.0f, 25.0f, 25.0f) ), "Close miss of axis aligned box on Z axis to right side is properly handled" ); }