| | | 1 | | //======================================================================= |
| | | 2 | | // GjkResult.cs |
| | | 3 | | //======================================================================= |
| | | 4 | | // MIT License, Copyright (c) 2026-present David Oravsky (mrdav30) |
| | | 5 | | // See LICENSE file in the project root for full license information. |
| | | 6 | | //======================================================================= |
| | | 7 | | |
| | | 8 | | using FixedMathSharp; |
| | | 9 | | using FixedMathSharp.Geometry; |
| | | 10 | | |
| | | 11 | | namespace Gravitas.Queries; |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Carries GJK intersection or separation evidence, including witnesses on both shapes. |
| | | 15 | | /// </summary> |
| | | 16 | | internal readonly struct GjkResult |
| | | 17 | | { |
| | | 18 | | public GjkResult( |
| | | 19 | | bool intersects, |
| | | 20 | | Fixed64 distance, |
| | | 21 | | FixedPointAnchor pointA, |
| | | 22 | | FixedPointAnchor pointB, |
| | | 23 | | Vector3d normal) |
| | | 24 | | { |
| | 4692 | 25 | | Intersects = intersects; |
| | 4692 | 26 | | Distance = distance; |
| | 4692 | 27 | | PointA = pointA; |
| | 4692 | 28 | | PointB = pointB; |
| | 4692 | 29 | | Normal = normal; |
| | 4692 | 30 | | } |
| | | 31 | | |
| | | 32 | | public bool Intersects { get; } |
| | | 33 | | |
| | | 34 | | public Fixed64 Distance { get; } |
| | | 35 | | |
| | | 36 | | public FixedPointAnchor PointA { get; } |
| | | 37 | | |
| | | 38 | | public FixedPointAnchor PointB { get; } |
| | | 39 | | |
| | | 40 | | public Vector3d Normal { get; } |
| | | 41 | | |
| | | 42 | | public static GjkResult CreateIntersection( |
| | | 43 | | FixedPointAnchor pointA, |
| | | 44 | | FixedPointAnchor pointB) => |
| | 3634 | 45 | | new(true, Fixed64.Zero, pointA, pointB, Vector3d.Zero); |
| | | 46 | | } |