Skip to content

Commit 25c6f3e

Browse files
committed
update: added messagepack-csharp serialization support
- Added serialization support to bound structs
1 parent e669770 commit 25c6f3e

30 files changed

+984
-294
lines changed

.assets/scripts/set-version-and-build.ps1

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,35 @@ Set-Location $solutionDir
1414
Ensure-GitVersion-Environment
1515

1616
# Build the project with the version information applied
17-
Build-Project -Configuration $BuildType
17+
Build-Project -Configuration $BuildType
18+
19+
# Output directory
20+
$releaseDir = Join-Path $solutionDir "src\$solutionDir\bin\Release"
21+
22+
# Ensure release directory exists
23+
if (Test-Path $releaseDir) {
24+
Get-ChildItem -Path $releaseDir -Directory | ForEach-Object {
25+
$targetDir = $_.FullName
26+
$frameworkName = $_.Name
27+
28+
# Construct final archive name
29+
$zipFileName = "${solutionDir}-v${GitVersion_FullSemVer}-${frameworkName}-release.zip"
30+
$zipPath = Join-Path $releaseDir $zipFileName
31+
32+
Write-Host "Creating archive: $zipPath"
33+
34+
if (Test-Path $zipPath) {
35+
Remove-Item $zipPath -Force
36+
}
37+
38+
Compress-Archive -Path "$targetDir\*" -DestinationPath $zipPath -Force
39+
40+
if (Test-Path $zipPath) {
41+
Write-Host "✔ Archive created for $frameworkName"
42+
} else {
43+
Write-Warning "⚠ Failed to create archive for $frameworkName"
44+
}
45+
}
46+
} else {
47+
Write-Warning "⚠ Release directory not found: $releaseDir"
48+
}

.assets/scripts/utilities.ps1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
function Get-SolutionDirectory {
2-
param ([string]$StartPath = $(Get-Location))
2+
param (
3+
[string]$StartPath = $(Get-Location),
4+
[string]$SolutionPath = "FixedMathSharp.sln"
5+
)
36

47
$currentPath = $StartPath
58
while ($true) {
6-
if (Test-Path (Join-Path $currentPath "FixedMathSharp.sln")) {
9+
if (Test-Path (Join-Path $currentPath $SolutionPath)) {
710
return $currentPath
811
}
912
$parent = [System.IO.Directory]::GetParent($currentPath)

CONTRIBUTING.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Contributing
2+
3+
When contributing to this repository, please first discuss the change you wish to make via issue,
4+
email, or any other method with the owners of this repository before making a change.
5+
6+
Please note we have a code of conduct, please follow it in all your interactions with the project.
7+
8+
## Pull Request Process
9+
10+
1. Ensure any install or build dependencies are removed before the end of the layer when doing a
11+
build.
12+
2. Update the README.md with details of changes to the interface, this includes new environment
13+
variables, exposed ports, useful file locations and container parameters.
14+
3. Increase the version numbers in any examples files and the README.md to the new version that this
15+
Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
16+
4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
17+
do not have permission to do that, you may request the second reviewer to merge it for you.
18+
19+
## Code of Conduct
20+
21+
### Our Pledge
22+
23+
In the interest of fostering an open and welcoming environment, we as
24+
contributors and maintainers pledge to making participation in our project and
25+
our community a harassment-free experience for everyone, regardless of age, body
26+
size, disability, ethnicity, gender identity and expression, level of experience,
27+
nationality, personal appearance, race, religion, or sexual identity and
28+
orientation.
29+
30+
### Our Standards
31+
32+
Examples of behavior that contributes to creating a positive environment
33+
include:
34+
35+
* Using welcoming and inclusive language
36+
* Being respectful of differing viewpoints and experiences
37+
* Gracefully accepting constructive criticism
38+
* Focusing on what is best for the community
39+
* Showing empathy towards other community members
40+
41+
Examples of unacceptable behavior by participants include:
42+
43+
* The use of sexualized language or imagery and unwelcome sexual attention or
44+
advances
45+
* Trolling, insulting/derogatory comments, and personal or political attacks
46+
* Public or private harassment
47+
* Publishing others' private information, such as a physical or electronic
48+
address, without explicit permission
49+
* Other conduct which could reasonably be considered inappropriate in a
50+
professional setting
51+
52+
### Our Responsibilities
53+
54+
Project maintainers are responsible for clarifying the standards of acceptable
55+
behavior and are expected to take appropriate and fair corrective action in
56+
response to any instances of unacceptable behavior.
57+
58+
Project maintainers have the right and responsibility to remove, edit, or
59+
reject comments, commits, code, wiki edits, issues, and other contributions
60+
that are not aligned to this Code of Conduct, or to ban temporarily or
61+
permanently any contributor for other behaviors that they deem inappropriate,
62+
threatening, offensive, or harmful.
63+
64+
### Scope
65+
66+
This Code of Conduct applies both within project spaces and in public spaces
67+
when an individual is representing the project or its community. Examples of
68+
representing a project or community include using an official project e-mail
69+
address, posting via an official social media account, or acting as an appointed
70+
representative at an online or offline event. Representation of a project may be
71+
further defined and clarified by project maintainers.
72+
73+
### Enforcement
74+
75+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
76+
reported by contacting the project team at `[email protected]`. All
77+
complaints will be reviewed and investigated and will result in a response that
78+
is deemed necessary and appropriate to the circumstances. The project team is
79+
obligated to maintain confidentiality with regard to the reporter of an incident.
80+
Further details of specific enforcement policies may be posted separately.
81+
82+
Project maintainers who do not follow or enforce the Code of Conduct in good
83+
faith may face temporary or permanent repercussions as determined by other
84+
members of the project's leadership.
85+
86+
### Attribution
87+
88+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
89+
available at [http://contributor-covenant.org/version/1/4][version]
90+
91+
[homepage]: http://contributor-covenant.org
92+
[version]: http://contributor-covenant.org/version/1/4/

README.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Ideal for simulations, games, and physics engines requiring reliable arithmetic
2020
- **Bounding Shapes:** Includes `IBound` structs `BoundingBox`, `BoundingSphere`, and `BoundingArea` for lightweight spatial calculations.
2121
- **Advanced Math Functions:** Includes trigonometry and common math utilities.
2222
- **Framework Agnostic:** Works with **.NET, Unity, and other game engines**.
23+
- **Full Serialization Support:** Out-of-the-box round-trip serialization via BinaryFormatter (for .NET Framework 4.8+), System.Text.Json (for .NET 8+), and MessagePack across all serializable structs.
2324

2425
---
2526

@@ -115,15 +116,11 @@ Console.WriteLine(sinValue); // Output: ~0.707
115116
- **`IBound` Interface:** Standard interface for bounding shapes `BoundingBox`, `BoundingArea`, and `BoundingSphere`, each offering intersection, containment, and projection logic.
116117
- **`FixedMath` Static Class:** Provides common math and trigonometric functions using fixed-point math.
117118
- **`Fixed4x4` and `Fixed3x3`:** Support matrix operations for transformations.
118-
- **`FixedMathSharp.Editor`:** Extensions for seamless integration with Unity, including property drawers and type conversions.
119119

120120
### Fixed64 Struct
121121

122-
**Fixed64** is the core data type representing fixed-point numbers. It
123-
provides various mathematical operations, including addition,
124-
subtraction, multiplication, division, and more. The struct guarantees
125-
deterministic behavior by using integer-based arithmetic with a
126-
configurable `SHIFT_AMOUNT`.
122+
**Fixed64** is the core data type representing fixed-point numbers. It provides various mathematical operations, including addition, subtraction, multiplication, division, and more.
123+
The struct guarantees deterministic behavior by using integer-based arithmetic with a configurable `SHIFT_AMOUNT`.
127124

128125
---
129126

@@ -138,13 +135,12 @@ FixedMathSharp is optimized for high-performance deterministic calculations:
138135

139136
## 🧪 Testing and Validation
140137

141-
Unit tests are used extensively to validate the correctness of mathematical
142-
operations. Special **fuzzy comparisons** are employed where small precision
143-
discrepancies might occur, mimicking floating-point behavior.
138+
Unit tests are used extensively to validate the correctness of mathematical operations.
139+
Special **fuzzy comparisons** are employed where small precision discrepancies might occur, mimicking floating-point behavior.
144140

145141
To run the tests:
146142
```bash
147-
dotnet test --configuration Release
143+
dotnet test --configuration debug
148144
```
149145

150146
---
@@ -158,10 +154,13 @@ dotnet test --configuration Release
158154

159155
---
160156

157+
## 🤝 Contributing
158+
159+
We welcome contributions! Please see our [CONTRIBUTING](https://github.com/mrdav30/FixedMathSharp/blob/main/CONTRIBUTING.md) guide for details on how to propose changes, report issues, and interact with the community.
160+
161161
## 📄 License
162162

163-
This project is licensed under the MIT License - see the `LICENSE` file
164-
for details.
163+
This project is licensed under the MIT License - see the [LICENSE](https://github.com/mrdav30/FixedMathSharp/blob/main/LICENSE.md) for details.
165164

166165
---
167166

src/FixedMathSharp/Bounds/BoundingArea.cs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using MessagePack;
2+
using System;
23
using System.Runtime.CompilerServices;
34

45
namespace FixedMathSharp
@@ -17,18 +18,21 @@ namespace FixedMathSharp
1718
/// </remarks>
1819

1920
[Serializable]
21+
[MessagePackObject]
2022
public struct BoundingArea : IBound, IEquatable<BoundingArea>
2123
{
2224
#region Fields
2325

2426
/// <summary>
2527
/// One of the corner points of the bounding area.
2628
/// </summary>
29+
[Key(0)]
2730
public Vector3d Corner1;
2831

2932
/// <summary>
3033
/// The opposite corner point of the bounding area.
3134
/// </summary>
35+
[Key(1)]
3236
public Vector3d Corner2;
3337

3438
#endregion
@@ -64,48 +68,59 @@ public BoundingArea(Vector3d corner1, Vector3d corner2)
6468
/// <summary>
6569
/// The minimum corner of the bounding box.
6670
/// </summary>
71+
[IgnoreMember]
6772
public Vector3d Min
6873
{
6974
[MethodImpl(MethodImplOptions.AggressiveInlining)]
70-
get => new Vector3d(MinX, MinY, MinZ);
75+
get => new(MinX, MinY, MinZ);
7176
}
7277

7378
/// <summary>
7479
/// The maximum corner of the bounding box.
7580
/// </summary>
81+
[IgnoreMember]
7682
public Vector3d Max
7783
{
7884
[MethodImpl(MethodImplOptions.AggressiveInlining)]
79-
get => new Vector3d(MaxX, MaxY, MaxZ);
85+
get => new(MaxX, MaxY, MaxZ);
8086
}
8187

88+
[IgnoreMember]
8289
public Fixed64 MinX
8390
{
8491
[MethodImpl(MethodImplOptions.AggressiveInlining)]
8592
get => Corner1.x < Corner2.x ? Corner1.x : Corner2.x;
8693
}
94+
95+
[IgnoreMember]
8796
public Fixed64 MaxX
8897
{
8998
[MethodImpl(MethodImplOptions.AggressiveInlining)]
9099
get => Corner1.x > Corner2.x ? Corner1.x : Corner2.x;
91100
}
92101

102+
[IgnoreMember]
93103
public Fixed64 MinY
94104
{
95105
[MethodImpl(MethodImplOptions.AggressiveInlining)]
96106
get => Corner1.y < Corner2.y ? Corner1.y : Corner2.y;
97107
}
108+
109+
[IgnoreMember]
98110
public Fixed64 MaxY
99111
{
100112
[MethodImpl(MethodImplOptions.AggressiveInlining)]
101113
get => Corner1.y > Corner2.y ? Corner1.y : Corner2.y;
102114
}
103115

116+
[IgnoreMember]
104117
public Fixed64 MinZ
105118
{
106119
[MethodImpl(MethodImplOptions.AggressiveInlining)]
107120
get => Corner1.z < Corner2.z ? Corner1.z : Corner2.z;
108121
}
122+
123+
[IgnoreMember]
109124
public Fixed64 MaxZ
110125
{
111126
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -115,6 +130,7 @@ public Fixed64 MaxZ
115130
/// <summary>
116131
/// Calculates the width (X-axis) of the bounding area.
117132
/// </summary>
133+
[IgnoreMember]
118134
public Fixed64 Width
119135
{
120136
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -124,6 +140,7 @@ public Fixed64 Width
124140
/// <summary>
125141
/// Calculates the height (Y-axis) of the bounding area.
126142
/// </summary>
143+
[IgnoreMember]
127144
public Fixed64 Height
128145
{
129146
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -133,6 +150,7 @@ public Fixed64 Height
133150
/// <summary>
134151
/// Calculates the depth (Z-axis) of the bounding area.
135152
/// </summary>
153+
[IgnoreMember]
136154
public Fixed64 Depth
137155
{
138156
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -203,7 +221,7 @@ public Vector3d ProjectPoint(Vector3d point)
203221
#region Equality and HashCode Overrides
204222

205223
[MethodImpl(MethodImplOptions.AggressiveInlining)]
206-
public override bool Equals(object obj) => obj is BoundingArea other && Equals(other);
224+
public override bool Equals(object? obj) => obj is BoundingArea other && Equals(other);
207225

208226
[MethodImpl(MethodImplOptions.AggressiveInlining)]
209227
public bool Equals(BoundingArea other) => Corner1.Equals(other.Corner1) && Corner2.Equals(other.Corner2);

0 commit comments

Comments
 (0)