| | | 1 | | //======================================================================= |
| | | 2 | | // PhysicsMixedQueryRequests.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 Gravitas.Colliders; |
| | | 10 | | using Gravitas.Support; |
| | | 11 | | |
| | | 12 | | namespace Gravitas.Queries; |
| | | 13 | | |
| | | 14 | | /// <summary> |
| | | 15 | | /// Describes one mixed 3D swept-sphere query against embedded 2D slabs. |
| | | 16 | | /// </summary> |
| | | 17 | | public readonly struct PhysicsSweepSphereAgainst2DRequest |
| | | 18 | | { |
| | | 19 | | /// <summary> |
| | | 20 | | /// Creates a mixed 3D sphere sweep against embedded 2D slabs. |
| | | 21 | | /// </summary> |
| | | 22 | | public PhysicsSweepSphereAgainst2DRequest( |
| | | 23 | | Vector3d start, |
| | | 24 | | Vector3d end, |
| | | 25 | | Fixed64 radius, |
| | | 26 | | PhysicsLayerMask layerMask, |
| | | 27 | | LSCollider? excludedCollider = null, |
| | | 28 | | bool includeTriggers = true) |
| | | 29 | | { |
| | | 30 | | Start = start; |
| | | 31 | | End = end; |
| | | 32 | | Radius = radius; |
| | | 33 | | LayerMask = layerMask; |
| | | 34 | | ExcludedCollider = excludedCollider; |
| | | 35 | | IncludeTriggers = includeTriggers; |
| | | 36 | | } |
| | | 37 | | |
| | | 38 | | /// <summary> |
| | | 39 | | /// Creates a mixed 3D sphere sweep against all embedded 2D physics layers. |
| | | 40 | | /// </summary> |
| | | 41 | | public PhysicsSweepSphereAgainst2DRequest(Vector3d start, Vector3d end, Fixed64 radius) |
| | | 42 | | : this(start, end, radius, PhysicsLayerMask.All) |
| | | 43 | | { |
| | | 44 | | } |
| | | 45 | | |
| | | 46 | | /// <summary> |
| | | 47 | | /// Gets the sphere center's world-space start. |
| | | 48 | | /// </summary> |
| | | 49 | | public Vector3d Start { get; } |
| | | 50 | | |
| | | 51 | | /// <summary> |
| | | 52 | | /// Gets the sphere center's world-space end. |
| | | 53 | | /// </summary> |
| | | 54 | | public Vector3d End { get; } |
| | | 55 | | |
| | | 56 | | /// <summary> |
| | | 57 | | /// Gets the swept sphere radius. |
| | | 58 | | /// </summary> |
| | | 59 | | public Fixed64 Radius { get; } |
| | | 60 | | |
| | | 61 | | /// <summary> |
| | | 62 | | /// Gets the included 2D target layers. |
| | | 63 | | /// </summary> |
| | | 64 | | public PhysicsLayerMask LayerMask { get; } |
| | | 65 | | |
| | | 66 | | /// <summary> |
| | | 67 | | /// Gets the optional 3D source collider used for mixed-collision filtering. |
| | | 68 | | /// </summary> |
| | | 69 | | public LSCollider? ExcludedCollider { get; } |
| | | 70 | | |
| | | 71 | | /// <summary> |
| | | 72 | | /// Gets whether trigger targets are included. |
| | | 73 | | /// </summary> |
| | | 74 | | public bool IncludeTriggers { get; } |
| | | 75 | | } |
| | | 76 | | |
| | | 77 | | /// <summary> |
| | | 78 | | /// Describes one mixed 2D swept-circle query against 3D colliders. |
| | | 79 | | /// </summary> |
| | | 80 | | public readonly struct PhysicsSweepCircleAgainst3DRequest |
| | | 81 | | { |
| | | 82 | | /// <summary> |
| | | 83 | | /// Creates a mixed 2D circle-slab sweep against 3D colliders. |
| | | 84 | | /// </summary> |
| | | 85 | | public PhysicsSweepCircleAgainst3DRequest( |
| | | 86 | | Vector2d start, |
| | | 87 | | Vector2d end, |
| | | 88 | | Fixed64 radius, |
| | | 89 | | Fixed64 slabCenterY, |
| | | 90 | | Fixed64 halfThickness, |
| | | 91 | | PhysicsLayerMask layerMask, |
| | | 92 | | LSCollider2D? excludedCollider = null, |
| | | 93 | | bool includeTriggers = true) |
| | | 94 | | { |
| | 4 | 95 | | Start = start; |
| | 4 | 96 | | End = end; |
| | 4 | 97 | | Radius = radius; |
| | 4 | 98 | | SlabCenterY = slabCenterY; |
| | 4 | 99 | | HalfThickness = halfThickness; |
| | 4 | 100 | | LayerMask = layerMask; |
| | 4 | 101 | | ExcludedCollider = excludedCollider; |
| | 4 | 102 | | IncludeTriggers = includeTriggers; |
| | 4 | 103 | | } |
| | | 104 | | |
| | | 105 | | /// <summary> |
| | | 106 | | /// Creates a mixed 2D circle-slab sweep against all 3D physics layers. |
| | | 107 | | /// </summary> |
| | | 108 | | public PhysicsSweepCircleAgainst3DRequest( |
| | | 109 | | Vector2d start, |
| | | 110 | | Vector2d end, |
| | | 111 | | Fixed64 radius, |
| | | 112 | | Fixed64 slabCenterY, |
| | | 113 | | Fixed64 halfThickness) |
| | 1 | 114 | | : this(start, end, radius, slabCenterY, halfThickness, PhysicsLayerMask.All) |
| | | 115 | | { |
| | 1 | 116 | | } |
| | | 117 | | |
| | | 118 | | /// <summary> |
| | | 119 | | /// Gets the circle center's start in the X/Z plane. |
| | | 120 | | /// </summary> |
| | | 121 | | public Vector2d Start { get; } |
| | | 122 | | |
| | | 123 | | /// <summary> |
| | | 124 | | /// Gets the circle center's end in the X/Z plane. |
| | | 125 | | /// </summary> |
| | | 126 | | public Vector2d End { get; } |
| | | 127 | | |
| | | 128 | | /// <summary> |
| | | 129 | | /// Gets the swept circle radius. |
| | | 130 | | /// </summary> |
| | | 131 | | public Fixed64 Radius { get; } |
| | | 132 | | |
| | | 133 | | /// <summary> |
| | | 134 | | /// Gets the world-space Y coordinate at the center of the embedded slab. |
| | | 135 | | /// </summary> |
| | | 136 | | public Fixed64 SlabCenterY { get; } |
| | | 137 | | |
| | | 138 | | /// <summary> |
| | | 139 | | /// Gets the slab half-thickness along the Y axis. |
| | | 140 | | /// </summary> |
| | | 141 | | public Fixed64 HalfThickness { get; } |
| | | 142 | | |
| | | 143 | | /// <summary> |
| | | 144 | | /// Gets the included 3D target layers. |
| | | 145 | | /// </summary> |
| | | 146 | | public PhysicsLayerMask LayerMask { get; } |
| | | 147 | | |
| | | 148 | | /// <summary> |
| | | 149 | | /// Gets the optional 2D source collider used for mixed-collision filtering. |
| | | 150 | | /// </summary> |
| | | 151 | | public LSCollider2D? ExcludedCollider { get; } |
| | | 152 | | |
| | | 153 | | /// <summary> |
| | | 154 | | /// Gets whether trigger targets are included. |
| | | 155 | | /// </summary> |
| | | 156 | | public bool IncludeTriggers { get; } |
| | | 157 | | } |