Skip to content

Commit 2df922b

Browse files
committed
chore: added missing public facing documentation, linted, and minor code cleanup
1 parent a995b02 commit 2df922b

31 files changed

Lines changed: 1828 additions & 868 deletions

src/FixedMathSharp/Bounds/BoundingArea.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ public Vector3d Max
8989
get => new(MaxX, MaxY, MaxZ);
9090
}
9191

92+
/// <summary>
93+
/// The minimum X coordinate of the bounding area.
94+
/// </summary>
9295
[JsonIgnore]
9396
[MemoryPackIgnore]
9497
public Fixed64 MinX
@@ -97,6 +100,9 @@ public Fixed64 MinX
97100
get => Corner1.x < Corner2.x ? Corner1.x : Corner2.x;
98101
}
99102

103+
/// <summary>
104+
/// Gets the greater X-coordinate value of the two corners that define the bounding area.
105+
/// </summary>
100106
[JsonIgnore]
101107
[MemoryPackIgnore]
102108
public Fixed64 MaxX
@@ -105,6 +111,9 @@ public Fixed64 MaxX
105111
get => Corner1.x > Corner2.x ? Corner1.x : Corner2.x;
106112
}
107113

114+
/// <summary>
115+
/// Gets the minimum Y-coordinate value of the bounding area defined by Corner1 and Corner2.
116+
/// </summary>
108117
[JsonIgnore]
109118
[MemoryPackIgnore]
110119
public Fixed64 MinY
@@ -113,6 +122,9 @@ public Fixed64 MinY
113122
get => Corner1.y < Corner2.y ? Corner1.y : Corner2.y;
114123
}
115124

125+
/// <summary>
126+
/// Gets the maximum Y-coordinate value of the bounding area defined by the two corners.
127+
/// </summary>
116128
[JsonIgnore]
117129
[MemoryPackIgnore]
118130
public Fixed64 MaxY
@@ -121,6 +133,9 @@ public Fixed64 MaxY
121133
get => Corner1.y > Corner2.y ? Corner1.y : Corner2.y;
122134
}
123135

136+
/// <summary>
137+
/// Gets the minimum Z coordinate value of the bounding volume.
138+
/// </summary>
124139
[JsonIgnore]
125140
[MemoryPackIgnore]
126141
public Fixed64 MinZ
@@ -129,6 +144,9 @@ public Fixed64 MinZ
129144
get => Corner1.z < Corner2.z ? Corner1.z : Corner2.z;
130145
}
131146

147+
/// <summary>
148+
/// Gets the maximum Z coordinate value between the two corners of the bounding box.
149+
/// </summary>
132150
[JsonIgnore]
133151
[MemoryPackIgnore]
134152
public Fixed64 MaxZ
@@ -290,22 +308,37 @@ private static bool OverlapsOnAllAxes(Vector3d min, Vector3d max, Vector3d other
290308

291309
#region Operators
292310

311+
/// <summary>
312+
/// Determines whether two BoundingArea instances are equal.
313+
/// </summary>
314+
/// <param name="left">The first BoundingArea to compare.</param>
315+
/// <param name="right">The second BoundingArea to compare.</param>
316+
/// <returns>true if the specified BoundingArea instances are equal; otherwise, false.</returns>
293317
[MethodImpl(MethodImplOptions.AggressiveInlining)]
294318
public static bool operator ==(BoundingArea left, BoundingArea right) => left.Equals(right);
295319

320+
/// <summary>
321+
/// Determines whether two BoundingArea instances are not equal.
322+
/// </summary>
323+
/// <param name="left">The first BoundingArea to compare.</param>
324+
/// <param name="right">The second BoundingArea to compare.</param>
325+
/// <returns>true if the specified BoundingArea instances are not equal; otherwise, false.</returns>
296326
[MethodImpl(MethodImplOptions.AggressiveInlining)]
297327
public static bool operator !=(BoundingArea left, BoundingArea right) => !left.Equals(right);
298328

299329
#endregion
300330

301331
#region Equality and HashCode Overrides
302332

333+
/// <inheritdoc/>
303334
[MethodImpl(MethodImplOptions.AggressiveInlining)]
304335
public override bool Equals(object? obj) => obj is BoundingArea other && Equals(other);
305336

337+
/// <inheritdoc/>
306338
[MethodImpl(MethodImplOptions.AggressiveInlining)]
307339
public bool Equals(BoundingArea other) => Corner1.Equals(other.Corner1) && Corner2.Equals(other.Corner2);
308340

341+
/// <inheritdoc/>
309342
[MethodImpl(MethodImplOptions.AggressiveInlining)]
310343
public override int GetHashCode()
311344
{

src/FixedMathSharp/Bounds/BoundingBox.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,31 @@ public partial struct BoundingBox : IBound, IEquatable<BoundingBox>
2323
{
2424
#region Nested Types
2525

26+
/// <summary>
27+
/// Represents the state of a three-dimensional axis-aligned bounding box using its minimum and maximum coordinates.
28+
/// </summary>
29+
/// <remarks>
30+
/// The bounding box is defined by two points: the minimum and maximum corners in 3D space. This
31+
/// structure is immutable and can be used to describe spatial boundaries for geometric computations, collision
32+
/// detection, or spatial queries.
33+
/// </remarks>
2634
[Serializable]
2735
[MemoryPackable]
2836
public readonly partial struct BoundingBoxState
2937
{
38+
/// <inheritdoc cref="BoundingBox.Min"/>
3039
[JsonInclude]
3140
[MemoryPackInclude]
3241
public readonly Vector3d Min;
3342

43+
/// <inheritdoc cref="BoundingBox.Max"/>
3444
[JsonInclude]
3545
[MemoryPackInclude]
3646
public readonly Vector3d Max;
3747

48+
/// <summary>
49+
/// Initializes a new instance of the BoundingBoxState class with the specified minimum and maximum coordinates.
50+
/// </summary>
3851
[JsonConstructor]
3952
public BoundingBoxState(Vector3d min, Vector3d max)
4053
{
@@ -73,6 +86,10 @@ public BoundingBox(Vector3d center, Vector3d size)
7386
_isDirty = true;
7487
}
7588

89+
/// <summary>
90+
/// Initializes a new instance of the BoundingBox class with the specified bounding box state.
91+
/// </summary>
92+
/// <param name="state">The state that defines the position, size, and orientation of the bounding box.</param>
7693
[JsonConstructor]
7794
[MemoryPackConstructor]
7895
public BoundingBox(BoundingBoxState state)
@@ -160,6 +177,9 @@ public Vector3d[] Vertices
160177
get => GetOrGenerateVertices();
161178
}
162179

180+
/// <summary>
181+
/// Gets or sets the current bounding box state, including its minimum and maximum coordinates.
182+
/// </summary>
163183
[JsonInclude]
164184
[MemoryPackInclude]
165185
public BoundingBoxState State
@@ -457,18 +477,28 @@ public static Vector3d FindClosestPointsBetweenBoxes(BoundingBox a, BoundingBox
457477

458478
#region Equality
459479

480+
/// <summary>
481+
/// Determines whether two BoundingBox instances are equal.
482+
/// </summary>
460483
public static bool operator ==(BoundingBox left, BoundingBox right) => left.Equals(right);
484+
485+
/// <summary>
486+
/// Determines whether two BoundingBox instances are not equal.
487+
/// </summary>
461488
public static bool operator !=(BoundingBox left, BoundingBox right) => !left.Equals(right);
462489

463490
#endregion
464491

465492
#region Equality and HashCode Overrides
466493

494+
/// <inheritdoc/>
467495
public override bool Equals(object? obj) => obj is BoundingBox other && Equals(other);
468496

497+
/// <inheritdoc/>
469498
public bool Equals(BoundingBox other)
470499
=> Min.Equals(other.Min) && Max.Equals(other.Max);
471500

501+
/// <inheritdoc/>
472502
public override int GetHashCode()
473503
{
474504
return HashCode.Combine(Min, Max);

src/FixedMathSharp/Bounds/BoundingSphere.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ public BoundingSphere(Vector3d center, Fixed64 radius)
5555

5656
#region Properties
5757

58+
/// <summary>
59+
/// Gets the coordinates of the minimum corner of the bounding box that contains the sphere.
60+
/// </summary>
61+
/// <remarks>
62+
/// The minimum corner is calculated by subtracting the radius from each component of the sphere's center.
63+
/// This property is useful for spatial queries and bounding box calculations.
64+
/// </remarks>
5865
[JsonIgnore]
5966
[MemoryPackIgnore]
6067
public Vector3d Min
@@ -63,6 +70,13 @@ public Vector3d Min
6370
get => Center - new Vector3d(Radius, Radius, Radius);
6471
}
6572

73+
/// <summary>
74+
/// Gets the coordinates of the maximum corner of the bounding box that contains the sphere.
75+
/// </summary>
76+
/// <remarks>
77+
/// The maximum corner is calculated as the center of the sphere plus the radius in each dimension.
78+
/// This property is useful for spatial queries and bounding volume calculations.
79+
/// </remarks>
6680
[JsonIgnore]
6781
[MemoryPackIgnore]
6882
public Vector3d Max
@@ -146,22 +160,31 @@ public Fixed64 DistanceToSurface(Vector3d point)
146160

147161
#region Operators
148162

163+
/// <summary>
164+
/// Determines whether two BoundingSphere instances are equal.
165+
/// </summary>
149166
[MethodImpl(MethodImplOptions.AggressiveInlining)]
150167
public static bool operator ==(BoundingSphere left, BoundingSphere right) => left.Equals(right);
151168

169+
/// <summary>
170+
/// Determines whether two BoundingSphere instances are not equal.
171+
/// </summary>
152172
[MethodImpl(MethodImplOptions.AggressiveInlining)]
153173
public static bool operator !=(BoundingSphere left, BoundingSphere right) => !left.Equals(right);
154174

155175
#endregion
156176

157177
#region Equality and HashCode Overrides
158178

179+
/// <inheritdoc/>
159180
[MethodImpl(MethodImplOptions.AggressiveInlining)]
160181
public override bool Equals(object? obj) => obj is BoundingSphere other && Equals(other);
161182

183+
/// <inheritdoc/>
162184
[MethodImpl(MethodImplOptions.AggressiveInlining)]
163185
public bool Equals(BoundingSphere other) => Center.Equals(other.Center) && Radius.Equals(other.Radius);
164186

187+
/// <inheritdoc/>
165188
[MethodImpl(MethodImplOptions.AggressiveInlining)]
166189
public override int GetHashCode()
167190
{
Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,43 @@
1-
namespace FixedMathSharp
1+
namespace FixedMathSharp;
2+
3+
/// <summary>
4+
/// Defines an axis-aligned bounding volume in three-dimensional space and provides methods for containment,
5+
/// intersection, and projection operations.
6+
/// </summary>
7+
/// <remarks>
8+
/// Implementations of this interface represent a 3D region defined by minimum and maximum coordinates.
9+
/// The interface provides methods to determine whether a point is contained within the bounds, whether two bounds
10+
/// intersect, and to project a point onto the bounds. Typical use cases include spatial queries, collision detection,
11+
/// and geometric computations in 3D environments.
12+
/// </remarks>
13+
public interface IBound
214
{
3-
public interface IBound
4-
{
5-
/// <summary>
6-
/// The minimum bounds of the IBound.
7-
/// </summary>
8-
Vector3d Min { get; }
15+
/// <summary>
16+
/// The minimum bounds of the IBound.
17+
/// </summary>
18+
Vector3d Min { get; }
919

10-
/// <summary>
11-
/// The maximum bounds of the IBound.
12-
/// </summary>
13-
Vector3d Max { get; }
20+
/// <summary>
21+
/// The maximum bounds of the IBound.
22+
/// </summary>
23+
Vector3d Max { get; }
1424

15-
/// <summary>
16-
/// Checks if a point is inside the IBound.
17-
/// </summary>
18-
/// <param name="point">The point to check.</param>
19-
/// <returns>True if the point is inside the IBound, otherwise false.</returns>
20-
bool Contains(Vector3d point);
25+
/// <summary>
26+
/// Checks if a point is inside the IBound.
27+
/// </summary>
28+
/// <param name="point">The point to check.</param>
29+
/// <returns>True if the point is inside the IBound, otherwise false.</returns>
30+
bool Contains(Vector3d point);
2131

22-
/// <summary>
23-
/// Checks if the IBound intersects with another IBound.
24-
/// </summary>
25-
/// <param name="other">The other IBound to check for intersection.</param>
26-
/// <returns>True if the IBounds intersect, otherwise false.</returns>
27-
bool Intersects(IBound other);
32+
/// <summary>
33+
/// Checks if the IBound intersects with another IBound.
34+
/// </summary>
35+
/// <param name="other">The other IBound to check for intersection.</param>
36+
/// <returns>True if the IBounds intersect, otherwise false.</returns>
37+
bool Intersects(IBound other);
2838

29-
/// <summary>
30-
/// Projects a point onto the IBound. If the point is outside the IBound, it returns the closest point on the surface.
31-
/// </summary>
32-
Vector3d ProjectPoint(Vector3d point);
33-
}
39+
/// <summary>
40+
/// Projects a point onto the IBound. If the point is outside the IBound, it returns the closest point on the surface.
41+
/// </summary>
42+
Vector3d ProjectPoint(Vector3d point);
3443
}

src/FixedMathSharp/Core/FixedMath.cs

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,74 @@ public static partial class FixedMath
1111
{
1212
#region Fields and Constants
1313

14-
public const int NUM_BITS = 64;
14+
/// <summary>
15+
/// Represents the number of bits to shift for fixed-point representation.
16+
/// </summary>
1517
public const int SHIFT_AMOUNT_I = 32;
18+
/// <summary>
19+
/// Represents the maximum value that can be produced by left-shifting 1 by SHIFT_AMOUNT_I bits and subtracting 1.
20+
/// </summary>
21+
/// <remarks>
22+
/// This constant is typically used as a bitmask to extract or limit values to the range
23+
/// defined by SHIFT_AMOUNT_I.
24+
/// The value is always non-negative and fits within a 32-bit unsigned
25+
/// integer.
26+
/// </remarks>
1627
public const uint MAX_SHIFTED_AMOUNT_UI = (uint)((1L << SHIFT_AMOUNT_I) - 1);
28+
/// <summary>
29+
/// Represents a bitmask with all bits set except for the lowest SHIFT_AMOUNT_I bits.
30+
/// </summary>
31+
/// <remarks>
32+
/// This constant is typically used to isolate or clear the lower SHIFT_AMOUNT_I bits of
33+
/// an unsigned 64-bit value.
34+
/// The value of SHIFT_AMOUNT_I determines how many least significant bits are masked out.
35+
/// </remarks>
1736
public const ulong MASK_UL = (ulong)(ulong.MaxValue << SHIFT_AMOUNT_I);
1837

19-
public const long MAX_VALUE_L = long.MaxValue; // Max possible value for Fixed64
20-
public const long MIN_VALUE_L = long.MinValue; // Min possible value for Fixed64
38+
/// <summary>
39+
/// Represents the largest possible value for a 64-bit fixed-point number.
40+
/// </summary>
41+
/// <remarks>
42+
/// Use this constant to perform comparisons or to initialize variables that require the
43+
/// maximum representable value for a 64-bit fixed-point type.
44+
/// </remarks>
45+
public const long MAX_VALUE_L = long.MaxValue;
46+
/// <summary>
47+
/// Represents the smallest possible value for a 64-bit fixed-point number.
48+
/// </summary>
49+
/// <remarks>
50+
/// Use this constant to check for underflow conditions or to initialize variables that
51+
/// require the minimum representable value for a 64-bit fixed-point type.
52+
/// </remarks>
53+
public const long MIN_VALUE_L = long.MinValue;
2154

55+
/// <summary>
56+
/// Represents the value 1 shifted left by the number of bits specified by SHIFT_AMOUNT_I.
57+
/// </summary>
2258
public const long ONE_L = 1L << SHIFT_AMOUNT_I;
2359

2460
// Precomputed scale factors only for performance-critical scenarios to avoid division at runtime
61+
62+
/// <summary>
63+
/// Represents the precomputed scale factor used for floating-point calculations.
64+
/// </summary>
65+
/// <remarks>
66+
/// This constant is intended only for converting fixed-point values to floating-point representations in performance-critical scenarios.
67+
/// </remarks>
2568
public const float SCALE_FACTOR_F = 1.0f / ONE_L;
69+
/// <summary>
70+
/// Represents the precomputed scale factor used for double-precision calculations.
71+
/// </summary>
72+
/// <remarks>
73+
/// This constant is intended only for converting fixed-point values to double-precision representations in performance-critical scenarios.
74+
/// </remarks>
2675
public const double SCALE_FACTOR_D = 1.0 / ONE_L;
76+
/// <summary>
77+
/// Represents the precomputed scale factor used for decimal calculations.
78+
/// </summary>
79+
/// <remarks>
80+
/// This constant is intended only for converting fixed-point values to decimal representations in performance-critical scenarios.
81+
/// </remarks>
2782
public const decimal SCALE_FACTOR_M = 1.0m / ONE_L;
2883

2984
/// <summary>

0 commit comments

Comments
 (0)