Skip to content

Commit cdceb0a

Browse files
committed
update: drop MessagePack support in favor of MemoryPack
+semver: breaking
1 parent 17cea2f commit cdceb0a

31 files changed

Lines changed: 287 additions & 546 deletions

src/FixedMathSharp/Bounds/BoundingArea.cs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using MessagePack;
1+
using MemoryPack;
22
using System;
33
using System.Runtime.CompilerServices;
44

@@ -18,21 +18,21 @@ namespace FixedMathSharp
1818
/// </remarks>
1919

2020
[Serializable]
21-
[MessagePackObject]
22-
public struct BoundingArea : IBound, IEquatable<BoundingArea>
21+
[MemoryPackable]
22+
public partial struct BoundingArea : IBound, IEquatable<BoundingArea>
2323
{
2424
#region Fields
2525

2626
/// <summary>
2727
/// One of the corner points of the bounding area.
2828
/// </summary>
29-
[Key(0)]
29+
[MemoryPackOrder(0)]
3030
public Vector3d Corner1;
3131

3232
/// <summary>
3333
/// The opposite corner point of the bounding area.
3434
/// </summary>
35-
[Key(1)]
35+
[MemoryPackOrder(1)]
3636
public Vector3d Corner2;
3737

3838
#endregion
@@ -68,7 +68,7 @@ public BoundingArea(Vector3d corner1, Vector3d corner2)
6868
/// <summary>
6969
/// The minimum corner of the bounding box.
7070
/// </summary>
71-
[IgnoreMember]
71+
[MemoryPackIgnore]
7272
public Vector3d Min
7373
{
7474
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -78,49 +78,49 @@ public Vector3d Min
7878
/// <summary>
7979
/// The maximum corner of the bounding box.
8080
/// </summary>
81-
[IgnoreMember]
81+
[MemoryPackIgnore]
8282
public Vector3d Max
8383
{
8484
[MethodImpl(MethodImplOptions.AggressiveInlining)]
8585
get => new(MaxX, MaxY, MaxZ);
8686
}
8787

88-
[IgnoreMember]
88+
[MemoryPackIgnore]
8989
public Fixed64 MinX
9090
{
9191
[MethodImpl(MethodImplOptions.AggressiveInlining)]
9292
get => Corner1.x < Corner2.x ? Corner1.x : Corner2.x;
9393
}
9494

95-
[IgnoreMember]
95+
[MemoryPackIgnore]
9696
public Fixed64 MaxX
9797
{
9898
[MethodImpl(MethodImplOptions.AggressiveInlining)]
9999
get => Corner1.x > Corner2.x ? Corner1.x : Corner2.x;
100100
}
101101

102-
[IgnoreMember]
102+
[MemoryPackIgnore]
103103
public Fixed64 MinY
104104
{
105105
[MethodImpl(MethodImplOptions.AggressiveInlining)]
106106
get => Corner1.y < Corner2.y ? Corner1.y : Corner2.y;
107107
}
108108

109-
[IgnoreMember]
109+
[MemoryPackIgnore]
110110
public Fixed64 MaxY
111111
{
112112
[MethodImpl(MethodImplOptions.AggressiveInlining)]
113113
get => Corner1.y > Corner2.y ? Corner1.y : Corner2.y;
114114
}
115115

116-
[IgnoreMember]
116+
[MemoryPackIgnore]
117117
public Fixed64 MinZ
118118
{
119119
[MethodImpl(MethodImplOptions.AggressiveInlining)]
120120
get => Corner1.z < Corner2.z ? Corner1.z : Corner2.z;
121121
}
122122

123-
[IgnoreMember]
123+
[MemoryPackIgnore]
124124
public Fixed64 MaxZ
125125
{
126126
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -130,7 +130,7 @@ public Fixed64 MaxZ
130130
/// <summary>
131131
/// Calculates the width (X-axis) of the bounding area.
132132
/// </summary>
133-
[IgnoreMember]
133+
[MemoryPackIgnore]
134134
public Fixed64 Width
135135
{
136136
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -140,7 +140,7 @@ public Fixed64 Width
140140
/// <summary>
141141
/// Calculates the height (Y-axis) of the bounding area.
142142
/// </summary>
143-
[IgnoreMember]
143+
[MemoryPackIgnore]
144144
public Fixed64 Height
145145
{
146146
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -150,7 +150,7 @@ public Fixed64 Height
150150
/// <summary>
151151
/// Calculates the depth (Z-axis) of the bounding area.
152152
/// </summary>
153-
[IgnoreMember]
153+
[MemoryPackIgnore]
154154
public Fixed64 Depth
155155
{
156156
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -163,8 +163,8 @@ public Fixed64 Depth
163163
public bool Contains(Vector3d point)
164164
{
165165
// Check if the point is within the bounds of the area (including boundaries)
166-
return point.x >= MinX && point.x <= MaxX
167-
&& point.y >= MinY && point.y <= MaxY
166+
return point.x >= MinX && point.x <= MaxX
167+
&& point.y >= MinY && point.y <= MaxY
168168
&& point.z >= MinZ && point.z <= MaxZ;
169169
}
170170

@@ -208,7 +208,8 @@ public bool Intersects(IBound other)
208208
return Vector3d.SqrDistance(sphere.Center, this.ProjectPointWithinBounds(sphere.Center)) <= sphere.SqrRadius;
209209

210210
default: return false; // Default case for unknown or unsupported types
211-
};
211+
}
212+
;
212213
}
213214

214215
/// <summary>

0 commit comments

Comments
 (0)