protected bool IsOverlapingOnAxis(Vector3[] colliderAVerts, Vector3[] colliderBVerts, Vector3 axis) { JSegment segmentA = JMeshCollider.GetMeshSegmentOnAxis(colliderAVerts, axis); JSegment segmentB = JMeshCollider.GetMeshSegmentOnAxis(colliderBVerts, axis); return(JSegment.IsOverlapping(segmentA, segmentB)); }
private float FindPenetrationDepth(Vector3[] colliderAVertices, Vector3[] colliderBVertices, Vector3 axis, out bool flipNormals) // 😏 { JSegment segmentA = JMeshCollider.GetMeshSegmentOnAxis(colliderAVertices, axis.normalized); JSegment segmentB = JMeshCollider.GetMeshSegmentOnAxis(colliderBVertices, axis.normalized); flipNormals = (segmentB.Min < segmentA.Min); if (!JSegment.IsOverlapping(segmentA, segmentB)) { return(0); } float minSegment = Mathf.Min(segmentA.Min, segmentB.Min); float maxSegment = Mathf.Max(segmentA.Max, segmentB.Max); float length = maxSegment - minSegment; return((segmentA.Length + segmentB.Length) - length); }