| | | 1 | | #if !NET8_0_OR_GREATER |
| | | 2 | | using System; |
| | | 3 | | using SwiftCollections; |
| | | 4 | | #endif |
| | | 5 | | |
| | | 6 | | using FixedMathSharp; |
| | | 7 | | |
| | | 8 | | namespace GridForge; |
| | | 9 | | |
| | | 10 | | /// <summary> |
| | | 11 | | /// Exact identity key for a grid's snapped bounds. |
| | | 12 | | /// </summary> |
| | | 13 | | #if NET8_0_OR_GREATER |
| | 2 | 14 | | public readonly record struct BoundsKey(Vector3d BoundsMin, Vector3d BoundsMax); |
| | | 15 | | #endif |
| | | 16 | | |
| | | 17 | | #if !NET8_0_OR_GREATER |
| | | 18 | | public readonly struct BoundsKey : IEquatable<BoundsKey> |
| | | 19 | | { |
| | | 20 | | /// <summary> |
| | | 21 | | /// The minimum bounds of the key. |
| | | 22 | | /// </summary> |
| | | 23 | | public Vector3d BoundsMin { get; } |
| | | 24 | | |
| | | 25 | | /// <summary> |
| | | 26 | | /// The maximum bounds of the key. |
| | | 27 | | /// </summary> |
| | | 28 | | public Vector3d BoundsMax { get; } |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// Initializes a new instance of the BoundsKey class with the specified minimum and maximum coordinates. |
| | | 32 | | /// </summary> |
| | | 33 | | /// <remarks> |
| | | 34 | | /// Use this constructor to define the spatial limits of a bounding box by specifying its lower |
| | | 35 | | /// and upper corners. |
| | | 36 | | /// </remarks> |
| | | 37 | | /// <param name="boundsMin">The minimum corner of the bounding box, represented as a Vector3d.</param> |
| | | 38 | | /// <param name="boundsMax">The maximum corner of the bounding box, represented as a Vector3d.</param> |
| | | 39 | | public BoundsKey(Vector3d boundsMin, Vector3d boundsMax) |
| | | 40 | | { |
| | | 41 | | BoundsMin = boundsMin; |
| | | 42 | | BoundsMax = boundsMax; |
| | | 43 | | } |
| | | 44 | | |
| | | 45 | | /// <inheritdoc /> |
| | | 46 | | public override bool Equals(object obj) |
| | | 47 | | { |
| | | 48 | | return obj is BoundsKey other && Equals(other); |
| | | 49 | | } |
| | | 50 | | |
| | | 51 | | /// <inheritdoc /> |
| | | 52 | | public bool Equals(BoundsKey other) => |
| | | 53 | | BoundsMin.Equals(other.BoundsMin) && BoundsMax.Equals(other.BoundsMax); |
| | | 54 | | |
| | | 55 | | /// <inheritdoc /> |
| | | 56 | | public override int GetHashCode() => SwiftHashTools.CombineHashCodes(BoundsMin, BoundsMax); |
| | | 57 | | } |
| | | 58 | | #endif |