| | | 1 | | //======================================================================= |
| | | 2 | | // NavigationNodeState.cs |
| | | 3 | | //======================================================================= |
| | | 4 | | // MIT License, Copyright (c) 2024-present David Oravsky (mrdav30) |
| | | 5 | | // See LICENSE file in the project root for full license information. |
| | | 6 | | //======================================================================= |
| | | 7 | | |
| | | 8 | | using FixedMathSharp; |
| | | 9 | | |
| | | 10 | | namespace Trailblazer.Pathing; |
| | | 11 | | |
| | | 12 | | /// <summary>Exposes effective semantic and mirrored physical state for one snapshot node.</summary> |
| | | 13 | | internal readonly struct NavigationNodeState |
| | | 14 | | { |
| | | 15 | | internal NavigationNodeState( |
| | | 16 | | NavigationCell cell, |
| | | 17 | | bool isPresent, |
| | | 18 | | byte obstacleCount, |
| | | 19 | | Vector3d center, |
| | | 20 | | Vector3d footAnchor) |
| | | 21 | | { |
| | 963809 | 22 | | Cell = cell; |
| | 963809 | 23 | | IsPresent = isPresent; |
| | 963809 | 24 | | ObstacleCount = obstacleCount; |
| | 963809 | 25 | | Center = center; |
| | 963809 | 26 | | FootAnchor = footAnchor; |
| | 963809 | 27 | | } |
| | | 28 | | |
| | | 29 | | internal NavigationCell Cell { get; } |
| | | 30 | | |
| | | 31 | | internal bool IsPresent { get; } |
| | | 32 | | |
| | 1 | 33 | | internal bool IsBlocked => ObstacleCount > 0; |
| | | 34 | | |
| | | 35 | | internal byte ObstacleCount { get; } |
| | | 36 | | |
| | | 37 | | internal Vector3d Center { get; } |
| | | 38 | | |
| | | 39 | | internal Vector3d FootAnchor { get; } |
| | | 40 | | |
| | | 41 | | internal bool TryGetCenteredVolumeFootAnchor( |
| | | 42 | | Fixed64 bodyHeight, |
| | | 43 | | out Vector3d footAnchor) |
| | | 44 | | { |
| | 6211 | 45 | | if (bodyHeight <= Fixed64.Zero |
| | 6211 | 46 | | || !Fixed64.TryMultiplyAdd( |
| | 6211 | 47 | | bodyHeight, |
| | 6211 | 48 | | -Fixed64.Half, |
| | 6211 | 49 | | Center.Y, |
| | 6211 | 50 | | out Fixed64 footY)) |
| | | 51 | | { |
| | 9 | 52 | | footAnchor = default; |
| | 9 | 53 | | return false; |
| | | 54 | | } |
| | | 55 | | |
| | 6202 | 56 | | footAnchor = new Vector3d(Center.X, footY, Center.Z); |
| | 6202 | 57 | | return true; |
| | | 58 | | } |
| | | 59 | | } |