| | | 1 | | //======================================================================= |
| | | 2 | | // HeightmapLayerRegistration.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.Heightmaps; |
| | | 11 | | |
| | | 12 | | /// <summary> |
| | | 13 | | /// Context-local registration metadata for one heightmap layer. |
| | | 14 | | /// </summary> |
| | | 15 | | public sealed class HeightmapLayerRegistration |
| | | 16 | | { |
| | 40 | 17 | | internal HeightmapLayerRegistration( |
| | 40 | 18 | | HeightmapSurface surface, |
| | 40 | 19 | | Fixed64 minSelectionY, |
| | 40 | 20 | | Fixed64 maxSelectionY, |
| | 40 | 21 | | int priority, |
| | 40 | 22 | | int registrationOrder) |
| | | 23 | | { |
| | 40 | 24 | | Surface = surface; |
| | 40 | 25 | | LayerName = surface.Name; |
| | 40 | 26 | | MinSelectionY = minSelectionY; |
| | 40 | 27 | | MaxSelectionY = maxSelectionY; |
| | 40 | 28 | | Priority = priority; |
| | 40 | 29 | | RegistrationOrder = registrationOrder; |
| | 40 | 30 | | } |
| | | 31 | | |
| | | 32 | | /// <summary> |
| | | 33 | | /// Stable registered layer name. |
| | | 34 | | /// </summary> |
| | | 35 | | public string LayerName { get; } |
| | | 36 | | |
| | | 37 | | /// <summary> |
| | | 38 | | /// Compressed surface data used by this layer. |
| | | 39 | | /// </summary> |
| | | 40 | | public HeightmapSurface Surface { get; } |
| | | 41 | | |
| | | 42 | | /// <summary> |
| | | 43 | | /// Inclusive lower contact-Y bound for selecting this layer. |
| | | 44 | | /// </summary> |
| | | 45 | | public Fixed64 MinSelectionY { get; } |
| | | 46 | | |
| | | 47 | | /// <summary> |
| | | 48 | | /// Exclusive upper contact-Y bound for selecting this layer. |
| | | 49 | | /// </summary> |
| | | 50 | | public Fixed64 MaxSelectionY { get; } |
| | | 51 | | |
| | | 52 | | /// <summary> |
| | | 53 | | /// Deterministic tie-break priority for overlapping layers. |
| | | 54 | | /// </summary> |
| | | 55 | | public int Priority { get; } |
| | | 56 | | |
| | | 57 | | /// <summary> |
| | | 58 | | /// Deterministic context-local registration order. |
| | | 59 | | /// </summary> |
| | | 60 | | public int RegistrationOrder { get; } |
| | | 61 | | |
| | | 62 | | internal bool ContainsSelectionY(Fixed64 contactY) |
| | | 63 | | { |
| | 36 | 64 | | return contactY >= MinSelectionY && contactY < MaxSelectionY; |
| | | 65 | | } |
| | | 66 | | } |