| | | 1 | | //======================================================================= |
| | | 2 | | // QueryDetection2D.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 System; |
| | | 9 | | using FixedMathSharp; |
| | | 10 | | using FixedMathSharp.Geometry; |
| | | 11 | | using Gravitas.Colliders; |
| | | 12 | | using Gravitas.CollisionHandling; |
| | | 13 | | |
| | | 14 | | namespace Gravitas.Queries; |
| | | 15 | | |
| | | 16 | | /// <summary> |
| | | 17 | | /// Deterministic pure 2D shape checks used by query services. |
| | | 18 | | /// </summary> |
| | | 19 | | /// <content>Owns overlap, raycast and circle-sweep detection for pure 2D shapes.</content> |
| | | 20 | | internal static partial class QueryDetection2D |
| | | 21 | | { |
| | | 22 | | internal static bool TryOverlapCircle( |
| | | 23 | | Vector2d center, |
| | | 24 | | Fixed64 radius, |
| | | 25 | | LSCollider2D collider, |
| | | 26 | | out Physics2DHit hit) |
| | | 27 | | { |
| | 23891 | 28 | | ChronicleGuard.ThrowIfArgument(radius < Fixed64.Zero, nameof(radius), "2D query radius cannot be negative."); |
| | | 29 | | |
| | 23891 | 30 | | if (collider is LSCompoundCollider2D compound) |
| | 8 | 31 | | return TryOverlapCircleCompound(center, radius, compound, out hit); |
| | 23883 | 32 | | if (collider is LSCircleCollider2D circle) |
| | 21855 | 33 | | return TryOverlapCircleCenteredCapsule( |
| | 21855 | 34 | | center, |
| | 21855 | 35 | | radius, |
| | 21855 | 36 | | circle.Center, |
| | 21855 | 37 | | circle.Rotation, |
| | 21855 | 38 | | Fixed64.Zero, |
| | 21855 | 39 | | circle.ScaledRadius, |
| | 21855 | 40 | | Vector2d.Right, |
| | 21855 | 41 | | circle, |
| | 21855 | 42 | | out hit); |
| | 2028 | 43 | | if (collider is LSCapsuleCollider2D capsule) |
| | 410 | 44 | | return TryOverlapCircleCenteredCapsule( |
| | 410 | 45 | | center, |
| | 410 | 46 | | radius, |
| | 410 | 47 | | capsule.Center, |
| | 410 | 48 | | capsule.Rotation, |
| | 410 | 49 | | capsule.AxisLength, |
| | 410 | 50 | | capsule.ScaledRadius, |
| | 410 | 51 | | capsule.WorldAxis.RotatedRight, |
| | 410 | 52 | | capsule, |
| | 410 | 53 | | out hit); |
| | 1618 | 54 | | if (collider is not IConvexVertexSource2D) |
| | | 55 | | { |
| | 2 | 56 | | hit = default; |
| | 2 | 57 | | return false; |
| | | 58 | | } |
| | | 59 | | |
| | 1616 | 60 | | Span<Vector2d> scratch = stackalloc Vector2d[4]; |
| | 1616 | 61 | | ReadOnlySpan<Vector2d> vertexOffsets = |
| | 1616 | 62 | | GetConvexVertexOffsets(collider, scratch); |
| | 1616 | 63 | | if (!FixedConvex2dRelations.TryGetCircleContact( |
| | 1616 | 64 | | center, |
| | 1616 | 65 | | Fixed64.Zero, |
| | 1616 | 66 | | radius, |
| | 1616 | 67 | | collider.Center, |
| | 1616 | 68 | | collider.ConvexRotation, |
| | 1616 | 69 | | vertexOffsets, |
| | 1616 | 70 | | out _, |
| | 1616 | 71 | | out FixedPointAnchor2d contactAnchor, |
| | 1616 | 72 | | out Vector2d circleToColliderNormal, |
| | 1616 | 73 | | out Fixed64 depth, |
| | 1616 | 74 | | out _)) |
| | | 75 | | { |
| | 428 | 76 | | hit = default; |
| | 428 | 77 | | return false; |
| | | 78 | | } |
| | | 79 | | |
| | 1188 | 80 | | bool containsCenter = FixedConvex2dRelations.ContainsPoint( |
| | 1188 | 81 | | center, |
| | 1188 | 82 | | collider.Center, |
| | 1188 | 83 | | collider.ConvexRotation, |
| | 1188 | 84 | | vertexOffsets); |
| | 1188 | 85 | | Fixed64 distance = Fixed64.Zero; |
| | 1188 | 86 | | Vector2d normal = -circleToColliderNormal; |
| | 1188 | 87 | | if (!containsCenter) |
| | 901 | 88 | | distance = radius - depth; |
| | | 89 | | |
| | 1188 | 90 | | hit = new Physics2DHit( |
| | 1188 | 91 | | collider, |
| | 1188 | 92 | | new ContactAnchor2D(contactAnchor), |
| | 1188 | 93 | | normal, |
| | 1188 | 94 | | distance); |
| | 1188 | 95 | | return true; |
| | | 96 | | } |
| | | 97 | | |
| | | 98 | | private static bool TryOverlapCircleCenteredCapsule( |
| | | 99 | | Vector2d queryCenter, |
| | | 100 | | Fixed64 queryRadius, |
| | | 101 | | Vector2d targetCenter, |
| | | 102 | | Fixed64 targetRotation, |
| | | 103 | | Fixed64 targetAxisLength, |
| | | 104 | | Fixed64 targetRadius, |
| | | 105 | | Vector2d targetFallbackNormal, |
| | | 106 | | LSCollider2D target, |
| | | 107 | | out Physics2DHit hit) |
| | | 108 | | { |
| | 22265 | 109 | | if (!FixedSegment2d.TryGetCenteredCapsulesContact( |
| | 22265 | 110 | | queryCenter, |
| | 22265 | 111 | | Fixed64.Zero, |
| | 22265 | 112 | | Fixed64.Zero, |
| | 22265 | 113 | | queryRadius, |
| | 22265 | 114 | | targetCenter, |
| | 22265 | 115 | | targetRotation, |
| | 22265 | 116 | | targetAxisLength, |
| | 22265 | 117 | | targetRadius, |
| | 22265 | 118 | | -targetFallbackNormal, |
| | 22265 | 119 | | out FixedContactAnchors2d contact)) |
| | | 120 | | { |
| | 7408 | 121 | | hit = default; |
| | 7408 | 122 | | return false; |
| | | 123 | | } |
| | | 124 | | |
| | 14857 | 125 | | Fixed64 distance = FixedSegment2d.GetDistanceToCenteredCapsule( |
| | 14857 | 126 | | queryCenter, |
| | 14857 | 127 | | targetCenter, |
| | 14857 | 128 | | targetRotation, |
| | 14857 | 129 | | targetAxisLength, |
| | 14857 | 130 | | targetRadius); |
| | | 131 | | |
| | 14857 | 132 | | hit = new Physics2DHit( |
| | 14857 | 133 | | target, |
| | 14857 | 134 | | new ContactAnchor2D(contact.SecondAnchor), |
| | 14857 | 135 | | -contact.Normal, |
| | 14857 | 136 | | distance); |
| | 14857 | 137 | | return true; |
| | | 138 | | } |
| | | 139 | | |
| | | 140 | | internal static bool TryOverlapPolygon( |
| | | 141 | | ReadOnlySpan<Vector2d> vertices, |
| | | 142 | | Vector2d center, |
| | | 143 | | LSCollider2D collider, |
| | | 144 | | out Physics2DHit hit) |
| | | 145 | | { |
| | 7802 | 146 | | return TryOverlapConvexArea(center, vertices, collider, out hit); |
| | | 147 | | } |
| | | 148 | | |
| | | 149 | | internal static Vector2d ValidateAabbSize(Vector2d size) |
| | | 150 | | { |
| | 1691 | 151 | | ChronicleGuard.ThrowIfArgument( |
| | 1691 | 152 | | size.X <= Fixed64.Zero || size.Y <= Fixed64.Zero, |
| | 1691 | 153 | | nameof(size), |
| | 1691 | 154 | | "2D AABB query size components must be greater than zero."); |
| | 1689 | 155 | | Vector2d halfExtents = size * Fixed64.Half; |
| | 1689 | 156 | | ColliderGeometryPolicy.ValidateReach(halfExtents, nameof(size)); |
| | 1686 | 157 | | return halfExtents; |
| | | 158 | | } |
| | | 159 | | |
| | | 160 | | internal static void ValidateConvexQueryPolygon(ReadOnlySpan<Vector2d> vertices) |
| | | 161 | | { |
| | 34 | 162 | | ChronicleGuard.ThrowIfArgument(vertices.Length < 3, nameof(vertices), "2D polygon query must contain at least th |
| | 34 | 163 | | ChronicleGuard.ThrowIfArgument( |
| | 34 | 164 | | !FixedConvex2dRelations.IsStrictlyConvex(vertices), |
| | 34 | 165 | | nameof(vertices), |
| | 34 | 166 | | "2D polygon query vertices must form a strictly convex boundary."); |
| | 34 | 167 | | ColliderGeometryPolicy.ValidateWorldPolygonReach(vertices); |
| | 19 | 168 | | } |
| | | 169 | | |
| | | 170 | | internal static Vector2d CalculateAverageCenter(ReadOnlySpan<Vector2d> vertices) => |
| | 16 | 171 | | Vector2d.GetAverage(vertices); |
| | | 172 | | |
| | | 173 | | internal static bool TryRaycast(Vector2d start, Vector2d end, LSCollider2D collider, out Physics2DHit hit) |
| | | 174 | | { |
| | 380 | 175 | | if (!Vector2d.TrySubtract(end, start, out Vector2d segment)) |
| | | 176 | | { |
| | 1 | 177 | | hit = default; |
| | 1 | 178 | | return false; |
| | | 179 | | } |
| | | 180 | | |
| | 379 | 181 | | if (segment == Vector2d.Zero || !SegmentBoundsOverlap(start, end, collider)) |
| | | 182 | | { |
| | 33 | 183 | | hit = default; |
| | 33 | 184 | | return false; |
| | | 185 | | } |
| | | 186 | | |
| | 346 | 187 | | if (!Vector2d.TryGetMagnitude(segment, out Fixed64 segmentLength)) |
| | | 188 | | { |
| | 1 | 189 | | hit = default; |
| | 1 | 190 | | return false; |
| | | 191 | | } |
| | | 192 | | |
| | 345 | 193 | | return TryRaycastPrepared(start, end, segment, segmentLength, collider, out hit); |
| | | 194 | | } |
| | | 195 | | |
| | | 196 | | // The caller has admitted the exact endpoint difference and its positive, |
| | | 197 | | // representable length. Keep shape bounds checks local to each compound part. |
| | | 198 | | internal static bool TryRaycast( |
| | | 199 | | Vector2d start, Vector2d end, Vector2d segment, Fixed64 segmentLength, |
| | | 200 | | LSCollider2D collider, out Physics2DHit hit) |
| | | 201 | | { |
| | 18212 | 202 | | if (!SegmentBoundsOverlap(start, end, collider)) |
| | | 203 | | { |
| | 432 | 204 | | hit = default; |
| | 432 | 205 | | return false; |
| | | 206 | | } |
| | | 207 | | |
| | 17780 | 208 | | return TryRaycastPrepared(start, end, segment, segmentLength, collider, out hit); |
| | | 209 | | } |
| | | 210 | | |
| | | 211 | | private static bool TryRaycastPrepared( |
| | | 212 | | Vector2d start, Vector2d end, Vector2d segment, Fixed64 segmentLength, |
| | | 213 | | LSCollider2D collider, out Physics2DHit hit) |
| | | 214 | | { |
| | 18125 | 215 | | if (collider is LSCompoundCollider2D compound) |
| | 437 | 216 | | return TryRaycastCompound(start, end, segment, segmentLength, compound, out hit); |
| | | 217 | | |
| | 17688 | 218 | | if (ContainsPointExact(collider, start)) |
| | | 219 | | { |
| | | 220 | | // A contained ray has no entry normal. Reuse point/shape geometry |
| | | 221 | | // to describe an actual separating surface without contact anchors, |
| | | 222 | | // while retaining the ray's zero-distance/start-point contract. |
| | 2264 | 223 | | if (!TryGetContainedRayNormal(start, collider, out Vector2d normal)) |
| | | 224 | | { |
| | 1 | 225 | | hit = default; |
| | 1 | 226 | | return false; |
| | | 227 | | } |
| | 2263 | 228 | | hit = new Physics2DHit( |
| | 2263 | 229 | | collider, |
| | 2263 | 230 | | start, |
| | 2263 | 231 | | normal, |
| | 2263 | 232 | | Fixed64.Zero); |
| | 2263 | 233 | | return true; |
| | | 234 | | } |
| | | 235 | | |
| | 15424 | 236 | | if (collider is LSCircleCollider2D circle) |
| | 14090 | 237 | | return TryRaycastCircle(start, end, segmentLength, circle, out hit); |
| | 1334 | 238 | | if (collider is LSCapsuleCollider2D capsule) |
| | 275 | 239 | | return TryRaycastCapsule(start, end, segmentLength, capsule, out hit); |
| | 1059 | 240 | | if (collider is not LSAABBoxCollider2D |
| | 1059 | 241 | | && collider is not LSPolygonCollider2D) |
| | | 242 | | { |
| | 8 | 243 | | hit = default; |
| | 8 | 244 | | return false; |
| | | 245 | | } |
| | | 246 | | |
| | 1051 | 247 | | return TryRaycastConvex(start, segment, segmentLength, collider, out hit); |
| | | 248 | | } |
| | | 249 | | |
| | | 250 | | internal static bool TrySweepCircle( |
| | | 251 | | Vector2d start, |
| | | 252 | | Vector2d end, |
| | | 253 | | Fixed64 radius, |
| | | 254 | | LSCollider2D collider, |
| | | 255 | | out Physics2DHit hit) |
| | | 256 | | { |
| | 129 | 257 | | if (!Vector2d.TrySubtract(end, start, out Vector2d segment)) |
| | | 258 | | { |
| | 1 | 259 | | hit = default; |
| | 1 | 260 | | return false; |
| | | 261 | | } |
| | | 262 | | |
| | 128 | 263 | | if (segment == Vector2d.Zero || !SweepBoundsOverlap(start, end, radius, collider)) |
| | | 264 | | { |
| | 71 | 265 | | hit = default; |
| | 71 | 266 | | return false; |
| | | 267 | | } |
| | | 268 | | |
| | 57 | 269 | | if (!Vector2d.TryGetMagnitude(segment, out Fixed64 segmentLength) |
| | 57 | 270 | | || segmentLength <= Fixed64.Epsilon) |
| | | 271 | | { |
| | 4 | 272 | | hit = default; |
| | 4 | 273 | | return false; |
| | | 274 | | } |
| | | 275 | | |
| | 53 | 276 | | return TrySweepCirclePrepared(start, end, segment, segmentLength, radius, collider, out hit); |
| | | 277 | | } |
| | | 278 | | |
| | | 279 | | // Generic sweeps admit travel greater than Epsilon. Authored support queries |
| | | 280 | | // retain their separate distance domain and stationary-contact semantics. |
| | | 281 | | internal static bool TrySweepCircle( |
| | | 282 | | Vector2d start, Vector2d end, Vector2d segment, Fixed64 segmentLength, |
| | | 283 | | Fixed64 radius, LSCollider2D collider, out Physics2DHit hit) |
| | | 284 | | { |
| | 9248 | 285 | | if (!SweepBoundsOverlap(start, end, radius, collider)) |
| | | 286 | | { |
| | 32 | 287 | | hit = default; |
| | 32 | 288 | | return false; |
| | | 289 | | } |
| | | 290 | | |
| | 9216 | 291 | | return TrySweepCirclePrepared(start, end, segment, segmentLength, radius, collider, out hit); |
| | | 292 | | } |
| | | 293 | | |
| | | 294 | | private static bool TrySweepCirclePrepared( |
| | | 295 | | Vector2d start, Vector2d end, Vector2d segment, Fixed64 segmentLength, |
| | | 296 | | Fixed64 radius, LSCollider2D collider, out Physics2DHit hit) |
| | | 297 | | { |
| | 9269 | 298 | | if (collider is LSCompoundCollider2D compound) |
| | 27 | 299 | | return TrySweepCircleCompound(start, end, segment, segmentLength, radius, compound, out hit); |
| | | 300 | | |
| | 9242 | 301 | | if (TryOverlapCircle(start, radius, collider, out Physics2DHit overlapHit)) |
| | | 302 | | { |
| | 1440 | 303 | | hit = new Physics2DHit(collider, overlapHit.Anchor, overlapHit.Normal, Fixed64.Zero); |
| | 1440 | 304 | | return true; |
| | | 305 | | } |
| | | 306 | | |
| | 7802 | 307 | | if (collider is LSCircleCollider2D circle) |
| | 7125 | 308 | | return TrySweepCircleCircle(start, end, segmentLength, radius, circle, out hit); |
| | 677 | 309 | | if (collider is LSCapsuleCollider2D capsule) |
| | 274 | 310 | | return TrySweepCircleCapsule(start, end, segmentLength, radius, capsule, out hit); |
| | 403 | 311 | | if (collider is not LSAABBoxCollider2D |
| | 403 | 312 | | && collider is not LSPolygonCollider2D) |
| | | 313 | | { |
| | 1 | 314 | | hit = default; |
| | 1 | 315 | | return false; |
| | | 316 | | } |
| | | 317 | | |
| | 402 | 318 | | return TrySweepCircleConvex(start, segment, segmentLength, radius, collider, out hit, |
| | 402 | 319 | | authoredDisplacement: true); |
| | | 320 | | } |
| | | 321 | | |
| | | 322 | | internal static bool TrySweepMoverShape( |
| | | 323 | | LSCollider2D mover, |
| | | 324 | | Vector2d displacement, |
| | | 325 | | LSCollider2D target, |
| | | 326 | | out Physics2DHit hit) |
| | | 327 | | { |
| | 795 | 328 | | ChronicleGuard.ThrowIfNull(mover, nameof(mover)); |
| | 795 | 329 | | ChronicleGuard.ThrowIfNull(target, nameof(target)); |
| | | 330 | | |
| | 795 | 331 | | if (!Vector2d.TryGetMagnitude(displacement, out Fixed64 displacementLength) |
| | 795 | 332 | | || displacementLength <= Fixed64.Epsilon) |
| | | 333 | | { |
| | 2 | 334 | | hit = default; |
| | 2 | 335 | | return false; |
| | | 336 | | } |
| | | 337 | | |
| | 793 | 338 | | if (mover is LSCompoundCollider2D moverCompound) |
| | 4 | 339 | | return TrySweepMoverCompound(moverCompound, displacement, target, out hit); |
| | | 340 | | |
| | 789 | 341 | | if (target is LSCompoundCollider2D targetCompound) |
| | 3 | 342 | | return TrySweepMoverAgainstCompound(mover, displacement, targetCompound, out hit); |
| | | 343 | | |
| | 786 | 344 | | if (mover is LSCircleCollider2D circle) |
| | | 345 | | { |
| | 211 | 346 | | if (!Vector2d.TryAdd( |
| | 211 | 347 | | circle.Center, |
| | 211 | 348 | | displacement, |
| | 211 | 349 | | out Vector2d end)) |
| | | 350 | | { |
| | 1 | 351 | | hit = default; |
| | 1 | 352 | | return false; |
| | | 353 | | } |
| | | 354 | | |
| | 210 | 355 | | return TrySweepCircle( |
| | 210 | 356 | | circle.Center, |
| | 210 | 357 | | end, |
| | 210 | 358 | | displacement, |
| | 210 | 359 | | displacementLength, |
| | 210 | 360 | | circle.ScaledRadius, |
| | 210 | 361 | | target, |
| | 210 | 362 | | out hit); |
| | | 363 | | } |
| | 575 | 364 | | if (mover is LSCapsuleCollider2D moverCapsule) |
| | 291 | 365 | | return TrySweepCapsuleMover( |
| | 291 | 366 | | moverCapsule, |
| | 291 | 367 | | displacement, |
| | 291 | 368 | | displacementLength, |
| | 291 | 369 | | target, |
| | 291 | 370 | | out hit); |
| | | 371 | | |
| | 284 | 372 | | if (target is LSCircleCollider2D targetCircle) |
| | 41 | 373 | | return TrySweepConvexMoverAgainstCircle(mover, displacement, targetCircle, out hit); |
| | 243 | 374 | | if (target is LSCapsuleCollider2D targetCapsule) |
| | 4 | 375 | | return TrySweepConvexMoverAgainstCapsule( |
| | 4 | 376 | | mover, |
| | 4 | 377 | | displacement, |
| | 4 | 378 | | displacementLength, |
| | 4 | 379 | | targetCapsule, |
| | 4 | 380 | | out hit); |
| | | 381 | | |
| | 239 | 382 | | return TrySweepConvexMoverAgainstConvex( |
| | 239 | 383 | | mover, |
| | 239 | 384 | | displacement, |
| | 239 | 385 | | displacementLength, |
| | 239 | 386 | | target, |
| | 239 | 387 | | out hit); |
| | | 388 | | } |
| | | 389 | | |
| | | 390 | | private static bool TryRaycastCircle( |
| | | 391 | | Vector2d start, |
| | | 392 | | Vector2d end, |
| | | 393 | | Fixed64 segmentLength, |
| | | 394 | | LSCircleCollider2D circle, |
| | | 395 | | out Physics2DHit hit) |
| | | 396 | | { |
| | 14090 | 397 | | var query = new FixedSegment2d(start, end); |
| | 14090 | 398 | | if (!query.TryGetCircleIntersectionDistanceInterval( |
| | 14090 | 399 | | new FixedBoundCircle(circle.Center, circle.ScaledRadius), |
| | 14090 | 400 | | segmentLength, |
| | 14090 | 401 | | out Fixed64 distance, |
| | 14090 | 402 | | out _)) |
| | | 403 | | { |
| | 6 | 404 | | hit = default; |
| | 6 | 405 | | return false; |
| | | 406 | | } |
| | | 407 | | |
| | 14084 | 408 | | Vector2d point = query.GetPointAtDistance(distance, segmentLength); |
| | 14084 | 409 | | Vector2d normal = Vector2d.GetDirection(circle.Center, point); |
| | 14084 | 410 | | hit = new Physics2DHit( |
| | 14084 | 411 | | circle, |
| | 14084 | 412 | | new ContactAnchor2D( |
| | 14084 | 413 | | circle.Center, |
| | 14084 | 414 | | normal * circle.ScaledRadius), |
| | 14084 | 415 | | normal, |
| | 14084 | 416 | | distance); |
| | 14084 | 417 | | return true; |
| | | 418 | | } |
| | | 419 | | |
| | | 420 | | private static bool TrySweepCircleCircle( |
| | | 421 | | Vector2d start, |
| | | 422 | | Vector2d end, |
| | | 423 | | Fixed64 segmentLength, |
| | | 424 | | Fixed64 radius, |
| | | 425 | | LSCircleCollider2D circle, |
| | | 426 | | out Physics2DHit hit) |
| | | 427 | | { |
| | 7128 | 428 | | var query = new FixedSegment2d(start, end); |
| | 7128 | 429 | | if (!query.TryGetCircleIntersectionDistanceInterval( |
| | 7128 | 430 | | new FixedBoundCircle(circle.Center, circle.ScaledRadius), |
| | 7128 | 431 | | radius, |
| | 7128 | 432 | | segmentLength, |
| | 7128 | 433 | | out Fixed64 distance, |
| | 7128 | 434 | | out _, |
| | 7128 | 435 | | out _, |
| | 7128 | 436 | | out _)) |
| | | 437 | | { |
| | 13 | 438 | | hit = default; |
| | 13 | 439 | | return false; |
| | | 440 | | } |
| | | 441 | | |
| | 7115 | 442 | | Vector2d sweptCenter = query.GetPointAtDistance(distance, segmentLength); |
| | 7115 | 443 | | Vector2d normal = Vector2d.GetDirection(circle.Center, sweptCenter); |
| | 7115 | 444 | | hit = new Physics2DHit( |
| | 7115 | 445 | | circle, |
| | 7115 | 446 | | new ContactAnchor2D( |
| | 7115 | 447 | | circle.Center, |
| | 7115 | 448 | | normal * circle.ScaledRadius), |
| | 7115 | 449 | | normal, |
| | 7115 | 450 | | distance); |
| | 7115 | 451 | | return true; |
| | | 452 | | } |
| | | 453 | | |
| | | 454 | | private static bool TryRaycastCapsule( |
| | | 455 | | Vector2d start, |
| | | 456 | | Vector2d end, |
| | | 457 | | Fixed64 segmentLength, |
| | | 458 | | LSCapsuleCollider2D capsule, |
| | | 459 | | out Physics2DHit hit) |
| | | 460 | | { |
| | 275 | 461 | | var query = new FixedSegment2d(start, end); |
| | 275 | 462 | | if (!query.TryGetCapsuleIntersectionDistanceInterval( |
| | 275 | 463 | | capsule.Center, |
| | 275 | 464 | | capsule.Rotation, |
| | 275 | 465 | | capsule.AxisLength, |
| | 275 | 466 | | capsule.ScaledRadius, |
| | 275 | 467 | | Fixed64.Zero, |
| | 275 | 468 | | segmentLength, |
| | 275 | 469 | | out Fixed64 distance, |
| | 275 | 470 | | out _, |
| | 275 | 471 | | out _, |
| | 275 | 472 | | out _)) |
| | | 473 | | { |
| | 3 | 474 | | hit = default; |
| | 3 | 475 | | return false; |
| | | 476 | | } |
| | | 477 | | |
| | 272 | 478 | | Vector2d pointOnRay = query.GetPointAtDistance(distance, segmentLength); |
| | 272 | 479 | | Vector2d normal = capsule.GetNormalFromCenteredAxis(pointOnRay); |
| | 272 | 480 | | hit = new Physics2DHit( |
| | 272 | 481 | | capsule, |
| | 272 | 482 | | ContactAnchor2D.FromWorldPoint(pointOnRay), |
| | 272 | 483 | | normal, |
| | 272 | 484 | | distance); |
| | 272 | 485 | | return true; |
| | | 486 | | } |
| | | 487 | | |
| | | 488 | | private static bool TrySweepCircleCapsule( |
| | | 489 | | Vector2d start, |
| | | 490 | | Vector2d end, |
| | | 491 | | Fixed64 segmentLength, |
| | | 492 | | Fixed64 radius, |
| | | 493 | | LSCapsuleCollider2D capsule, |
| | | 494 | | out Physics2DHit hit) |
| | | 495 | | { |
| | 277 | 496 | | var query = new FixedSegment2d(start, end); |
| | 277 | 497 | | if (!query.TryGetCapsuleIntersectionDistanceInterval( |
| | 277 | 498 | | capsule.Center, |
| | 277 | 499 | | capsule.Rotation, |
| | 277 | 500 | | capsule.AxisLength, |
| | 277 | 501 | | capsule.ScaledRadius, |
| | 277 | 502 | | radius, |
| | 277 | 503 | | segmentLength, |
| | 277 | 504 | | out Fixed64 distance, |
| | 277 | 505 | | out _, |
| | 277 | 506 | | out _, |
| | 277 | 507 | | out _)) |
| | | 508 | | { |
| | 2 | 509 | | hit = default; |
| | 2 | 510 | | return false; |
| | | 511 | | } |
| | | 512 | | |
| | 275 | 513 | | Vector2d sweptCenter = query.GetPointAtDistance(distance, segmentLength); |
| | 275 | 514 | | Vector2d normal = capsule.GetNormalFromCenteredAxis(sweptCenter); |
| | 275 | 515 | | bool hasPoint = TryOffsetPoint( |
| | 275 | 516 | | sweptCenter, |
| | 275 | 517 | | -normal, |
| | 275 | 518 | | radius, |
| | 275 | 519 | | out Vector2d point); |
| | | 520 | | |
| | 275 | 521 | | hit = new Physics2DHit( |
| | 275 | 522 | | capsule, |
| | 275 | 523 | | hasPoint |
| | 275 | 524 | | ? ContactAnchor2D.FromWorldPoint(point) |
| | 275 | 525 | | : new ContactAnchor2D( |
| | 275 | 526 | | sweptCenter, |
| | 275 | 527 | | -normal * radius), |
| | 275 | 528 | | normal, |
| | 275 | 529 | | distance); |
| | 275 | 530 | | return true; |
| | | 531 | | } |
| | | 532 | | |
| | | 533 | | private static bool TryOverlapCircleCompound( |
| | | 534 | | Vector2d center, |
| | | 535 | | Fixed64 radius, |
| | | 536 | | LSCompoundCollider2D compound, |
| | | 537 | | out Physics2DHit hit) |
| | | 538 | | { |
| | 8 | 539 | | bool found = false; |
| | 8 | 540 | | Physics2DHit best = default; |
| | | 541 | | |
| | 48 | 542 | | for (int i = 0; i < compound.PartCount; i++) |
| | | 543 | | { |
| | 16 | 544 | | LSCollider2D part = compound.GetPartCollider(i); |
| | 16 | 545 | | if (!TryOverlapCircle(center, radius, part, out Physics2DHit candidate)) |
| | | 546 | | continue; |
| | | 547 | | |
| | 10 | 548 | | TryKeepEarlierHit(candidate, ref found, ref best); |
| | | 549 | | } |
| | | 550 | | |
| | 8 | 551 | | if (!found) |
| | | 552 | | { |
| | 3 | 553 | | hit = default; |
| | 3 | 554 | | return false; |
| | | 555 | | } |
| | | 556 | | |
| | 5 | 557 | | hit = new Physics2DHit(compound, best.Anchor, best.Normal, best.Distance); |
| | 5 | 558 | | return true; |
| | | 559 | | } |
| | | 560 | | |
| | | 561 | | private static bool TryOverlapConvexArea( |
| | | 562 | | Vector2d center, |
| | | 563 | | ReadOnlySpan<Vector2d> vertices, |
| | | 564 | | LSCollider2D collider, |
| | | 565 | | out Physics2DHit hit) |
| | | 566 | | { |
| | 7806 | 567 | | if (collider is LSCompoundCollider2D compound) |
| | 2 | 568 | | return TryOverlapConvexAreaCompound(center, vertices, compound, out hit); |
| | | 569 | | |
| | 7804 | 570 | | return collider switch |
| | 7804 | 571 | | { |
| | 7804 | 572 | | LSCircleCollider2D circle => |
| | 7506 | 573 | | TryOverlapConvexAreaCircle(center, vertices, circle, out hit), |
| | 7804 | 574 | | LSCapsuleCollider2D capsule => |
| | 137 | 575 | | TryOverlapConvexAreaCapsule(center, vertices, capsule, out hit), |
| | 161 | 576 | | _ => TryOverlapConvexAreaConvex(center, vertices, collider, out hit) |
| | 7804 | 577 | | }; |
| | | 578 | | } |
| | | 579 | | |
| | | 580 | | private static bool TryOverlapConvexAreaCompound( |
| | | 581 | | Vector2d center, |
| | | 582 | | ReadOnlySpan<Vector2d> vertices, |
| | | 583 | | LSCompoundCollider2D compound, |
| | | 584 | | out Physics2DHit hit) |
| | | 585 | | { |
| | 2 | 586 | | bool found = false; |
| | 2 | 587 | | Physics2DHit best = default; |
| | 12 | 588 | | for (int i = 0; i < compound.PartCount; i++) |
| | | 589 | | { |
| | 4 | 590 | | LSCollider2D part = compound.GetPartCollider(i); |
| | 4 | 591 | | if (!TryOverlapConvexArea(center, vertices, part, out Physics2DHit candidate)) |
| | | 592 | | continue; |
| | | 593 | | |
| | 2 | 594 | | TryKeepEarlierHit(candidate, ref found, ref best); |
| | | 595 | | } |
| | | 596 | | |
| | 2 | 597 | | if (!found) |
| | | 598 | | { |
| | 1 | 599 | | hit = default; |
| | 1 | 600 | | return false; |
| | | 601 | | } |
| | | 602 | | |
| | 1 | 603 | | hit = new Physics2DHit(compound, best.Anchor, best.Normal, best.Distance); |
| | 1 | 604 | | return true; |
| | | 605 | | } |
| | | 606 | | |
| | | 607 | | private static bool TryOverlapConvexAreaCircle( |
| | | 608 | | Vector2d center, |
| | | 609 | | ReadOnlySpan<Vector2d> vertices, |
| | | 610 | | LSCircleCollider2D circle, |
| | | 611 | | out Physics2DHit hit) |
| | | 612 | | { |
| | 7506 | 613 | | if (!FixedConvex2dRelations.TryGetCircleContact( |
| | 7506 | 614 | | circle.Center, |
| | 7506 | 615 | | circle.Rotation, |
| | 7506 | 616 | | circle.ScaledRadius, |
| | 7506 | 617 | | Vector2d.Zero, |
| | 7506 | 618 | | Fixed64.Zero, |
| | 7506 | 619 | | vertices, |
| | 7506 | 620 | | out _, |
| | 7506 | 621 | | out _, |
| | 7506 | 622 | | out _, |
| | 7506 | 623 | | out _, |
| | 7506 | 624 | | out _)) |
| | | 625 | | { |
| | 8 | 626 | | hit = default; |
| | 8 | 627 | | return false; |
| | | 628 | | } |
| | | 629 | | |
| | 7498 | 630 | | return TryBuildCenteredCapsuleAreaHit( |
| | 7498 | 631 | | center, |
| | 7498 | 632 | | circle.Center, |
| | 7498 | 633 | | circle.Rotation, |
| | 7498 | 634 | | Fixed64.Zero, |
| | 7498 | 635 | | circle.ScaledRadius, |
| | 7498 | 636 | | circle, |
| | 7498 | 637 | | out hit); |
| | | 638 | | } |
| | | 639 | | |
| | | 640 | | private static bool TryOverlapConvexAreaCapsule( |
| | | 641 | | Vector2d center, |
| | | 642 | | ReadOnlySpan<Vector2d> vertices, |
| | | 643 | | LSCapsuleCollider2D capsule, |
| | | 644 | | out Physics2DHit hit) |
| | | 645 | | { |
| | 137 | 646 | | if (!FixedSegment2d.TryGetCenteredCapsuleConvexMinimumTranslation( |
| | 137 | 647 | | capsule.Center, |
| | 137 | 648 | | capsule.Rotation, |
| | 137 | 649 | | capsule.AxisLength, |
| | 137 | 650 | | capsule.ScaledRadius, |
| | 137 | 651 | | Vector2d.Zero, |
| | 137 | 652 | | vertices, |
| | 137 | 653 | | out _, |
| | 137 | 654 | | out _)) |
| | | 655 | | { |
| | 3 | 656 | | hit = default; |
| | 3 | 657 | | return false; |
| | | 658 | | } |
| | | 659 | | |
| | 134 | 660 | | return TryBuildCenteredCapsuleAreaHit( |
| | 134 | 661 | | center, |
| | 134 | 662 | | capsule.Center, |
| | 134 | 663 | | capsule.Rotation, |
| | 134 | 664 | | capsule.AxisLength, |
| | 134 | 665 | | capsule.ScaledRadius, |
| | 134 | 666 | | capsule, |
| | 134 | 667 | | out hit); |
| | | 668 | | } |
| | | 669 | | |
| | | 670 | | private static bool TryOverlapConvexAreaConvex( |
| | | 671 | | Vector2d center, |
| | | 672 | | ReadOnlySpan<Vector2d> vertices, |
| | | 673 | | LSCollider2D collider, |
| | | 674 | | out Physics2DHit hit) |
| | | 675 | | { |
| | 161 | 676 | | Span<Vector2d> targetScratch = stackalloc Vector2d[4]; |
| | 161 | 677 | | ReadOnlySpan<Vector2d> targetOffsets = |
| | 161 | 678 | | GetConvexVertexOffsets(collider, targetScratch); |
| | 161 | 679 | | Span<FixedPointAnchor2d> queryContacts = |
| | 161 | 680 | | stackalloc FixedPointAnchor2d[2]; |
| | 161 | 681 | | Span<FixedPointAnchor2d> targetContacts = |
| | 161 | 682 | | stackalloc FixedPointAnchor2d[2]; |
| | 161 | 683 | | if (!FixedConvex2dRelations.TryGetConvexContacts( |
| | 161 | 684 | | Vector2d.Zero, |
| | 161 | 685 | | Fixed64.Zero, |
| | 161 | 686 | | vertices, |
| | 161 | 687 | | collider.Center, |
| | 161 | 688 | | collider.ConvexRotation, |
| | 161 | 689 | | targetOffsets, |
| | 161 | 690 | | queryContacts, |
| | 161 | 691 | | targetContacts, |
| | 161 | 692 | | out _, |
| | 161 | 693 | | out _, |
| | 161 | 694 | | out _, |
| | 161 | 695 | | out _)) |
| | | 696 | | { |
| | 9 | 697 | | hit = default; |
| | 9 | 698 | | return false; |
| | | 699 | | } |
| | | 700 | | |
| | 152 | 701 | | return TryBuildConvexAreaHit( |
| | 152 | 702 | | center, |
| | 152 | 703 | | collider, |
| | 152 | 704 | | targetOffsets, |
| | 152 | 705 | | out hit); |
| | | 706 | | } |
| | | 707 | | |
| | | 708 | | private static bool TryBuildCenteredCapsuleAreaHit( |
| | | 709 | | Vector2d queryCenter, |
| | | 710 | | Vector2d targetCenter, |
| | | 711 | | Fixed64 targetRotation, |
| | | 712 | | Fixed64 targetAxisLength, |
| | | 713 | | Fixed64 targetRadius, |
| | | 714 | | LSCollider2D target, |
| | | 715 | | out Physics2DHit hit) |
| | | 716 | | { |
| | 7632 | 717 | | bool containsCenter = FixedSegment2d.ContainsPointInCenteredCapsule( |
| | 7632 | 718 | | queryCenter, |
| | 7632 | 719 | | targetCenter, |
| | 7632 | 720 | | targetRotation, |
| | 7632 | 721 | | targetAxisLength, |
| | 7632 | 722 | | targetRadius, |
| | 7632 | 723 | | Fixed64.Zero); |
| | 7632 | 724 | | if (containsCenter) |
| | | 725 | | { |
| | 844 | 726 | | hit = new Physics2DHit( |
| | 844 | 727 | | target, |
| | 844 | 728 | | ContactAnchor2D.FromWorldPoint(queryCenter), |
| | 844 | 729 | | ResolveQueryFallbackNormal(queryCenter, targetCenter), |
| | 844 | 730 | | Fixed64.Zero); |
| | 844 | 731 | | return true; |
| | | 732 | | } |
| | | 733 | | |
| | 6788 | 734 | | Vector2d normal = FixedSegment2d.GetDirectionFromCenteredAxis( |
| | 6788 | 735 | | queryCenter, |
| | 6788 | 736 | | targetCenter, |
| | 6788 | 737 | | targetRotation, |
| | 6788 | 738 | | targetAxisLength); |
| | | 739 | | |
| | 6788 | 740 | | hit = new Physics2DHit( |
| | 6788 | 741 | | target, |
| | 6788 | 742 | | new ContactAnchor2D( |
| | 6788 | 743 | | GetCenteredCapsuleSurfaceAnchor( |
| | 6788 | 744 | | queryCenter, |
| | 6788 | 745 | | targetCenter, |
| | 6788 | 746 | | targetRotation, |
| | 6788 | 747 | | targetAxisLength, |
| | 6788 | 748 | | targetRadius, |
| | 6788 | 749 | | normal)), |
| | 6788 | 750 | | normal, |
| | 6788 | 751 | | FixedSegment2d.GetDistanceToCenteredCapsule( |
| | 6788 | 752 | | queryCenter, |
| | 6788 | 753 | | targetCenter, |
| | 6788 | 754 | | targetRotation, |
| | 6788 | 755 | | targetAxisLength, |
| | 6788 | 756 | | targetRadius)); |
| | 6788 | 757 | | return true; |
| | | 758 | | } |
| | | 759 | | |
| | | 760 | | private static FixedPointAnchor2d GetCenteredCapsuleSurfaceAnchor( |
| | | 761 | | Vector2d point, |
| | | 762 | | Vector2d center, |
| | | 763 | | Fixed64 rotation, |
| | | 764 | | Fixed64 axisLength, |
| | | 765 | | Fixed64 radius, |
| | | 766 | | Vector2d worldNormal) |
| | | 767 | | { |
| | | 768 | | // A unit rotation preserves the admitted normalized direction. |
| | 6788 | 769 | | _ = Vector2d.TryRotate( |
| | 6788 | 770 | | worldNormal, |
| | 6788 | 771 | | -rotation, |
| | 6788 | 772 | | out Vector2d localNormal); |
| | 6788 | 773 | | return FixedSegment2d.GetSurfaceAnchorOnCenteredCapsule( |
| | 6788 | 774 | | point, |
| | 6788 | 775 | | center, |
| | 6788 | 776 | | rotation, |
| | 6788 | 777 | | Vector2d.Forward, |
| | 6788 | 778 | | axisLength, |
| | 6788 | 779 | | radius, |
| | 6788 | 780 | | localNormal.Normalized); |
| | | 781 | | } |
| | | 782 | | |
| | | 783 | | private static bool TryBuildConvexAreaHit( |
| | | 784 | | Vector2d queryCenter, |
| | | 785 | | LSCollider2D target, |
| | | 786 | | ReadOnlySpan<Vector2d> targetVertexOffsets, |
| | | 787 | | out Physics2DHit hit) |
| | | 788 | | { |
| | 152 | 789 | | if (FixedConvex2dRelations.ContainsPoint( |
| | 152 | 790 | | queryCenter, |
| | 152 | 791 | | target.Center, |
| | 152 | 792 | | target.ConvexRotation, |
| | 152 | 793 | | targetVertexOffsets)) |
| | | 794 | | { |
| | 16 | 795 | | hit = new Physics2DHit( |
| | 16 | 796 | | target, |
| | 16 | 797 | | ContactAnchor2D.FromWorldPoint(queryCenter), |
| | 16 | 798 | | ResolveQueryFallbackNormal(queryCenter, target.Center), |
| | 16 | 799 | | Fixed64.Zero); |
| | 16 | 800 | | return true; |
| | | 801 | | } |
| | | 802 | | |
| | 136 | 803 | | FixedPointAnchor2d targetAnchor = |
| | 136 | 804 | | FixedConvex2dRelations.GetClosestPointAnchor( |
| | 136 | 805 | | queryCenter, |
| | 136 | 806 | | target.Center, |
| | 136 | 807 | | target.ConvexRotation, |
| | 136 | 808 | | targetVertexOffsets); |
| | | 809 | | |
| | 136 | 810 | | var anchor = new ContactAnchor2D(targetAnchor); |
| | 136 | 811 | | if (!anchor.TryGetOffsetFrom(queryCenter, out Vector2d centerToTarget) |
| | 136 | 812 | | || !Vector2d.TryGetMagnitude(centerToTarget, out Fixed64 distance)) |
| | | 813 | | { |
| | 2 | 814 | | hit = default; |
| | 2 | 815 | | return false; |
| | | 816 | | } |
| | | 817 | | |
| | 134 | 818 | | Vector2d normal = -centerToTarget / distance; |
| | 134 | 819 | | hit = new Physics2DHit(target, anchor, normal, distance); |
| | 134 | 820 | | return true; |
| | | 821 | | } |
| | | 822 | | |
| | | 823 | | private static bool TryRaycastConvex( |
| | | 824 | | Vector2d start, |
| | | 825 | | Vector2d direction, |
| | | 826 | | Fixed64 segmentLength, |
| | | 827 | | LSCollider2D collider, |
| | | 828 | | out Physics2DHit hit) |
| | | 829 | | { |
| | 1051 | 830 | | Span<Vector2d> scratch = stackalloc Vector2d[4]; |
| | 1051 | 831 | | ReadOnlySpan<Vector2d> vertexOffsets = |
| | 1051 | 832 | | GetConvexVertexOffsets(collider, scratch); |
| | 1051 | 833 | | if (!FixedConvex2dRelations.TryGetSweptCenteredCapsuleFirstDistanceCore( |
| | 1051 | 834 | | start, |
| | 1051 | 835 | | Vector2d.Right, |
| | 1051 | 836 | | Fixed64.Zero, |
| | 1051 | 837 | | Fixed64.Zero, |
| | 1051 | 838 | | direction, |
| | 1051 | 839 | | segmentLength, |
| | 1051 | 840 | | collider.Center, |
| | 1051 | 841 | | collider.ConvexRotation, |
| | 1051 | 842 | | vertexOffsets, |
| | 1051 | 843 | | out Fixed64 distance, |
| | 1051 | 844 | | out Vector2d normal, |
| | 1051 | 845 | | out Vector2d contactOffset, |
| | 1051 | 846 | | authoredDisplacement: true)) |
| | | 847 | | { |
| | 1 | 848 | | hit = default; |
| | 1 | 849 | | return false; |
| | | 850 | | } |
| | | 851 | | |
| | 1050 | 852 | | hit = new Physics2DHit( |
| | 1050 | 853 | | collider, |
| | 1050 | 854 | | new ContactAnchor2D(new FixedPointAnchor2d(collider.Center, collider.ConvexRotation, contactOffset)), |
| | 1050 | 855 | | normal, |
| | 1050 | 856 | | distance); |
| | 1050 | 857 | | return true; |
| | | 858 | | } |
| | | 859 | | |
| | | 860 | | private static bool TrySweepCircleConvex( |
| | | 861 | | Vector2d start, |
| | | 862 | | Vector2d direction, |
| | | 863 | | Fixed64 segmentLength, |
| | | 864 | | Fixed64 radius, |
| | | 865 | | LSCollider2D collider, |
| | | 866 | | out Physics2DHit hit, |
| | | 867 | | bool authoredDisplacement = false) |
| | | 868 | | { |
| | 419 | 869 | | Span<Vector2d> scratch = stackalloc Vector2d[4]; |
| | 419 | 870 | | ReadOnlySpan<Vector2d> vertexOffsets = |
| | 419 | 871 | | GetConvexVertexOffsets(collider, scratch); |
| | 419 | 872 | | if (!FixedConvex2dRelations.TryGetSweptCenteredCapsuleFirstDistanceCore( |
| | 419 | 873 | | start, |
| | 419 | 874 | | Vector2d.Right, |
| | 419 | 875 | | Fixed64.Zero, |
| | 419 | 876 | | radius, |
| | 419 | 877 | | direction, |
| | 419 | 878 | | segmentLength, |
| | 419 | 879 | | collider.Center, |
| | 419 | 880 | | collider.ConvexRotation, |
| | 419 | 881 | | vertexOffsets, |
| | 419 | 882 | | out Fixed64 distance, |
| | 419 | 883 | | out Vector2d normal, |
| | 419 | 884 | | out Vector2d contactOffset, |
| | 419 | 885 | | authoredDisplacement)) |
| | | 886 | | { |
| | 65 | 887 | | hit = default; |
| | 65 | 888 | | return false; |
| | | 889 | | } |
| | | 890 | | |
| | 354 | 891 | | hit = new Physics2DHit( |
| | 354 | 892 | | collider, |
| | 354 | 893 | | new ContactAnchor2D(new FixedPointAnchor2d(collider.Center, collider.ConvexRotation, contactOffset)), |
| | 354 | 894 | | normal, |
| | 354 | 895 | | distance); |
| | 354 | 896 | | return true; |
| | | 897 | | } |
| | | 898 | | |
| | | 899 | | private static bool TrySweepConvexMoverAgainstCircle( |
| | | 900 | | LSCollider2D mover, |
| | | 901 | | Vector2d displacement, |
| | | 902 | | LSCircleCollider2D target, |
| | | 903 | | out Physics2DHit hit) |
| | | 904 | | { |
| | 41 | 905 | | if (CollisionDetection2D.TryCollide(mover, target, out Contact2D overlap)) |
| | | 906 | | { |
| | 2 | 907 | | Vector2d normal = -overlap.Normal; |
| | 2 | 908 | | hit = new Physics2DHit( |
| | 2 | 909 | | target, |
| | 2 | 910 | | overlap.AnchorB, |
| | 2 | 911 | | normal, |
| | 2 | 912 | | Fixed64.Zero); |
| | 2 | 913 | | return true; |
| | | 914 | | } |
| | | 915 | | |
| | 39 | 916 | | if (!TrySweepCircle( |
| | 39 | 917 | | target.Center, |
| | 39 | 918 | | target.Center - displacement, |
| | 39 | 919 | | target.ScaledRadius, |
| | 39 | 920 | | mover, |
| | 39 | 921 | | out Physics2DHit reverseHit)) |
| | | 922 | | { |
| | 35 | 923 | | hit = default; |
| | 35 | 924 | | return false; |
| | | 925 | | } |
| | | 926 | | |
| | 4 | 927 | | Vector2d hitNormal = -reverseHit.Normal; |
| | 4 | 928 | | hit = new Physics2DHit( |
| | 4 | 929 | | target, |
| | 4 | 930 | | new ContactAnchor2D( |
| | 4 | 931 | | target.Center, |
| | 4 | 932 | | hitNormal * target.ScaledRadius), |
| | 4 | 933 | | hitNormal, |
| | 4 | 934 | | reverseHit.Distance); |
| | 4 | 935 | | return true; |
| | | 936 | | } |
| | | 937 | | |
| | | 938 | | } |