public void DrawHullCollision(GameObject a, GameObject b, RigidTransform t1, NativeHull hull1, RigidTransform t2, NativeHull hull2) { var collision = HullCollision.GetDebugCollisionInfo(t1, hull1, t2, hull2); if (collision.IsColliding) { if (DrawIntersection) // Visualize all faces of the intersection { HullIntersection.DrawNativeHullHullIntersection(t1, hull1, t2, hull2); } if (DrawContact || LogContact) // Visualize the minimal contact calcluation for physics { //var manifold = HullOperations.GetContact.Invoke(t1, hull1, t2, hull2); var sw1 = System.Diagnostics.Stopwatch.StartNew(); var tmp = new NativeManifold(Allocator.Persistent); var normalResult = HullIntersection.NativeHullHullContact(ref tmp, t1, hull1, t2, hull2); sw1.Stop(); tmp.Dispose(); var sw2 = System.Diagnostics.Stopwatch.StartNew(); var burstResult = HullOperations.TryGetContact.Invoke(out NativeManifold manifold, t1, hull1, t2, hull2); sw2.Stop(); if (LogContact) { Debug.Log($"GetContact between '{a.name}'/'{b.name}' took: {sw1.Elapsed.TotalMilliseconds:N4}ms (Normal), {sw2.Elapsed.TotalMilliseconds:N4}ms (Burst)"); } if (DrawContact && burstResult) { // Do something with manifold HullDrawingUtility.DebugDrawManifold(manifold); //var points = manifold.Points; for (int i = 0; i < manifold.Length; i++) { var point = manifold[i]; DebugDrawer.DrawSphere(point.Position, 0.02f); DebugDrawer.DrawArrow(point.Position, manifold.Normal * 0.2f); var penentrationPoint = point.Position + manifold.Normal * point.Distance; DebugDrawer.DrawLabel(penentrationPoint, $"{point.Distance:N2}"); HullDrawingUtility.DrawEdge(point.Id.FeaturePair.InEdge1, t1, hull1); HullDrawingUtility.DrawEdge(point.Id.FeaturePair.OutEdge1, t1, hull1); HullDrawingUtility.DrawEdge(point.Id.FeaturePair.InEdge2, t1, hull1); HullDrawingUtility.DrawEdge(point.Id.FeaturePair.OutEdge2, t1, hull1); HullDrawingUtility.DrawEdge(point.Id.FeaturePair.InEdge1, t2, hull2); HullDrawingUtility.DrawEdge(point.Id.FeaturePair.OutEdge1, t2, hull2); HullDrawingUtility.DrawEdge(point.Id.FeaturePair.InEdge2, t2, hull2); HullDrawingUtility.DrawEdge(point.Id.FeaturePair.OutEdge2, t2, hull2); DebugDrawer.DrawDottedLine(point.Position, penentrationPoint); } manifold.Dispose(); } } if (DrawIsCollided) { DebugDrawer.DrawSphere(t1.pos, 0.1f, UnityColors.GhostDodgerBlue); DebugDrawer.DrawSphere(t2.pos, 0.1f, UnityColors.GhostDodgerBlue); } } if (DrawClosestFace) { var color1 = collision.Face1.Distance > 0 ? UnityColors.Red.ToOpacity(0.3f) : UnityColors.Yellow.ToOpacity(0.3f); HullDrawingUtility.DrawFaceWithOutline(collision.Face1.Index, t1, hull1, color1, UnityColors.Black); var color2 = collision.Face2.Distance > 0 ? UnityColors.Red.ToOpacity(0.3f) : UnityColors.Yellow.ToOpacity(0.3f); HullDrawingUtility.DrawFaceWithOutline(collision.Face2.Index, t2, hull2, color2, UnityColors.Black); } }