| | | 1 | | //======================================================================= |
| | | 2 | | // ColliderShapeSnapshot2D.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 System; |
| | | 10 | | using System.Runtime.CompilerServices; |
| | | 11 | | |
| | | 12 | | namespace Gravitas.Colliders; |
| | | 13 | | |
| | | 14 | | internal readonly struct ColliderShapeSnapshot2D : IEquatable<ColliderShapeSnapshot2D> |
| | | 15 | | { |
| | | 16 | | public ColliderShapeSnapshot2D( |
| | | 17 | | Vector2d center, |
| | | 18 | | Fixed64 rotation, |
| | | 19 | | Vector2d ownerScale, |
| | | 20 | | Vector2d partScale, |
| | | 21 | | Vector2d localOffset, |
| | | 22 | | uint shapeVersion, |
| | | 23 | | Fixed64 mixedSlabCenterY, |
| | | 24 | | Fixed64 mixedHalfThickness) |
| | | 25 | | { |
| | 21060 | 26 | | Center = center; |
| | 21060 | 27 | | Rotation = rotation; |
| | 21060 | 28 | | OwnerScale = ownerScale; |
| | 21060 | 29 | | PartScale = partScale; |
| | 21060 | 30 | | LocalOffset = localOffset; |
| | 21060 | 31 | | ShapeVersion = shapeVersion; |
| | 21060 | 32 | | MixedSlabCenterY = mixedSlabCenterY; |
| | 21060 | 33 | | MixedHalfThickness = mixedHalfThickness; |
| | 21060 | 34 | | } |
| | | 35 | | |
| | | 36 | | public Vector2d Center { get; } |
| | | 37 | | |
| | | 38 | | public Fixed64 Rotation { get; } |
| | | 39 | | |
| | | 40 | | public Vector2d OwnerScale { get; } |
| | | 41 | | |
| | | 42 | | public Vector2d PartScale { get; } |
| | | 43 | | |
| | | 44 | | public Vector2d LocalOffset { get; } |
| | | 45 | | |
| | | 46 | | public uint ShapeVersion { get; } |
| | | 47 | | |
| | | 48 | | public Fixed64 MixedSlabCenterY { get; } |
| | | 49 | | |
| | | 50 | | public Fixed64 MixedHalfThickness { get; } |
| | | 51 | | |
| | | 52 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 53 | | public bool Equals(ColliderShapeSnapshot2D other) => |
| | 14585 | 54 | | Center == other.Center |
| | 14585 | 55 | | && Rotation == other.Rotation |
| | 14585 | 56 | | && OwnerScale == other.OwnerScale |
| | 14585 | 57 | | && PartScale == other.PartScale |
| | 14585 | 58 | | && LocalOffset == other.LocalOffset |
| | 14585 | 59 | | && ShapeVersion == other.ShapeVersion |
| | 14585 | 60 | | && MixedSlabCenterY == other.MixedSlabCenterY |
| | 14585 | 61 | | && MixedHalfThickness == other.MixedHalfThickness; |
| | | 62 | | |
| | | 63 | | public override bool Equals(object? obj) => |
| | 4 | 64 | | obj is ColliderShapeSnapshot2D other && Equals(other); |
| | | 65 | | |
| | | 66 | | public override int GetHashCode() |
| | | 67 | | { |
| | | 68 | | unchecked |
| | | 69 | | { |
| | 2 | 70 | | int hash = 17; |
| | 2 | 71 | | hash = hash * 31 + Center.X.GetHashCode(); |
| | 2 | 72 | | hash = hash * 31 + Center.Y.GetHashCode(); |
| | 2 | 73 | | hash = hash * 31 + Rotation.GetHashCode(); |
| | 2 | 74 | | hash = hash * 31 + OwnerScale.X.GetHashCode(); |
| | 2 | 75 | | hash = hash * 31 + OwnerScale.Y.GetHashCode(); |
| | 2 | 76 | | hash = hash * 31 + PartScale.X.GetHashCode(); |
| | 2 | 77 | | hash = hash * 31 + PartScale.Y.GetHashCode(); |
| | 2 | 78 | | hash = hash * 31 + LocalOffset.X.GetHashCode(); |
| | 2 | 79 | | hash = hash * 31 + LocalOffset.Y.GetHashCode(); |
| | 2 | 80 | | hash = hash * 31 + ShapeVersion.GetHashCode(); |
| | 2 | 81 | | hash = hash * 31 + MixedSlabCenterY.GetHashCode(); |
| | 2 | 82 | | hash = hash * 31 + MixedHalfThickness.GetHashCode(); |
| | 2 | 83 | | return hash; |
| | | 84 | | } |
| | | 85 | | } |
| | | 86 | | } |