Skip to content

Commit 2411a77

Browse files
committed
Namespace change, added support for netstandard2.1
1 parent 6032b3c commit 2411a77

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+620
-319
lines changed

Hexa.NET.Math/AudioOrientation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#if !MINIMAL
2-
namespace HexaEngine.Mathematics
2+
namespace Hexa.NET.Mathematics
33
{
44
using System.Numerics;
55

Hexa.NET.Math/BezierCurve.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
namespace HexaEngine.Mathematics
1+
namespace Hexa.NET.Mathematics
22
{
3+
#if NET8_0_OR_GREATER
34
using System.Numerics;
45
using System.Runtime.CompilerServices;
56

@@ -49,4 +50,5 @@ public readonly Vector2 ComputePoint(float t)
4950
return point;
5051
}
5152
}
53+
#endif
5254
}

Hexa.NET.Math/BezierTable.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
namespace HexaEngine.Mathematics
1+
namespace Hexa.NET.Mathematics
22
{
3+
#if NET8_0_OR_GREATER
34
using System.Numerics;
45
using System.Runtime.InteropServices;
56

@@ -132,4 +133,5 @@ public void Release()
132133
k = null;
133134
}
134135
}
136+
#endif
135137
}

Hexa.NET.Math/BoundingBox.cs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace HexaEngine.Mathematics
1+
namespace Hexa.NET.Mathematics
22
{
33
using System.Numerics;
44
using System.Runtime.CompilerServices;
@@ -239,8 +239,14 @@ public readonly Vector3[] GetCorners()
239239
/// <returns>An array of points representing the eight corners of the bounding box.</returns>
240240
public readonly void GetCorners(Vector3[] corners)
241241
{
242+
#if NET8_0_OR_GREATER
242243
ArgumentNullException.ThrowIfNull(corners);
243-
244+
#else
245+
if (corners == null)
246+
{
247+
throw new ArgumentNullException(nameof(corners));
248+
}
249+
#endif
244250
if (corners.Length < CornerCount)
245251
{
246252
throw new ArgumentOutOfRangeException(nameof(corners), $"GetCorners need at least {CornerCount} elements to copy corners.");
@@ -328,8 +334,8 @@ public readonly ContainmentType Contains(in BoundingBox box)
328334
return ContainmentType.Disjoint;
329335
}
330336

331-
if (Min.X <= box.Min.X && (box.Max.X <= Max.X &&
332-
Min.Y <= box.Min.Y && box.Max.Y <= Max.Y) &&
337+
if (Min.X <= box.Min.X && box.Max.X <= Max.X &&
338+
Min.Y <= box.Min.Y && box.Max.Y <= Max.Y &&
333339
Min.Z <= box.Min.Z && box.Max.Z <= Max.Z)
334340
{
335341
return ContainmentType.Contains;
@@ -353,9 +359,9 @@ public readonly ContainmentType Contains(in BoundingSphere sphere)
353359
return ContainmentType.Disjoint;
354360
}
355361

356-
if (((Min.X + sphere.Radius <= sphere.Center.X) && (sphere.Center.X <= Max.X - sphere.Radius) && (Max.X - Min.X > sphere.Radius)) &&
357-
((Min.Y + sphere.Radius <= sphere.Center.Y) && (sphere.Center.Y <= Max.Y - sphere.Radius) && (Max.Y - Min.Y > sphere.Radius)) &&
358-
((Min.Z + sphere.Radius <= sphere.Center.Z) && (sphere.Center.Z <= Max.Z - sphere.Radius) && (Max.Z - Min.Z > sphere.Radius)))
362+
if (Min.X + sphere.Radius <= sphere.Center.X && sphere.Center.X <= Max.X - sphere.Radius && Max.X - Min.X > sphere.Radius &&
363+
Min.Y + sphere.Radius <= sphere.Center.Y && sphere.Center.Y <= Max.Y - sphere.Radius && Max.Y - Min.Y > sphere.Radius &&
364+
Min.Z + sphere.Radius <= sphere.Center.Z && sphere.Center.Z <= Max.Z - sphere.Radius && Max.Z - Min.Z > sphere.Radius)
359365
{
360366
return ContainmentType.Contains;
361367
}
@@ -520,12 +526,12 @@ public readonly PlaneIntersectionType Intersects(in Plane plane)
520526
Vector3 min;
521527
Vector3 max;
522528

523-
max.X = (plane.Normal.X >= 0.0f) ? Min.X : Max.X;
524-
max.Y = (plane.Normal.Y >= 0.0f) ? Min.Y : Max.Y;
525-
max.Z = (plane.Normal.Z >= 0.0f) ? Min.Z : Max.Z;
526-
min.X = (plane.Normal.X >= 0.0f) ? Max.X : Min.X;
527-
min.Y = (plane.Normal.Y >= 0.0f) ? Max.Y : Min.Y;
528-
min.Z = (plane.Normal.Z >= 0.0f) ? Max.Z : Min.Z;
529+
max.X = plane.Normal.X >= 0.0f ? Min.X : Max.X;
530+
max.Y = plane.Normal.Y >= 0.0f ? Min.Y : Max.Y;
531+
max.Z = plane.Normal.Z >= 0.0f ? Min.Z : Max.Z;
532+
min.X = plane.Normal.X >= 0.0f ? Max.X : Min.X;
533+
min.Y = plane.Normal.Y >= 0.0f ? Max.Y : Min.Y;
534+
min.Z = plane.Normal.Z >= 0.0f ? Max.Z : Min.Z;
529535

530536
float distance = Vector3.Dot(plane.Normal, max);
531537

Hexa.NET.Math/BoundingBoxHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace HexaEngine.Mathematics
1+
namespace Hexa.NET.Mathematics
22
{
33
using System.Numerics;
44

Hexa.NET.Math/BoundingFrustum.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace HexaEngine.Mathematics
1+
namespace Hexa.NET.Mathematics
22
{
33
using System.Numerics;
44
using System.Runtime.CompilerServices;
@@ -157,8 +157,14 @@ public bool Intersects(BoundingSphere sphere)
157157
/// <returns>An array of points representing the eight corners of the bounding frustum.</returns>
158158
public void GetCorners(Vector3[] corners)
159159
{
160+
#if NET8_0_OR_GREATER
160161
ArgumentNullException.ThrowIfNull(corners);
161-
162+
#else
163+
if (corners is null)
164+
{
165+
throw new ArgumentNullException(nameof(corners));
166+
}
167+
#endif
162168
if (corners.Length < CornerCount)
163169
{
164170
throw new ArgumentOutOfRangeException(nameof(corners), $"GetCorners need at least {CornerCount} elements to copy corners.");

Hexa.NET.Math/BoundingSphere.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace HexaEngine.Mathematics
1+
namespace Hexa.NET.Mathematics
22
{
33
using System.Numerics;
44
using System.Runtime.CompilerServices;
@@ -99,9 +99,9 @@ public static void Transform(in BoundingSphere sphere, in Matrix4x4 transform, o
9999
Vector3 center = Vector3.Transform(sphere.Center, transform);
100100

101101
float majorAxisLengthSquared = Math.Max(
102-
(transform.M11 * transform.M11) + (transform.M12 * transform.M12) + (transform.M13 * transform.M13), Math.Max(
103-
(transform.M21 * transform.M21) + (transform.M22 * transform.M22) + (transform.M23 * transform.M23),
104-
(transform.M31 * transform.M31) + (transform.M32 * transform.M32) + (transform.M33 * transform.M33)));
102+
transform.M11 * transform.M11 + transform.M12 * transform.M12 + transform.M13 * transform.M13, Math.Max(
103+
transform.M21 * transform.M21 + transform.M22 * transform.M22 + transform.M23 * transform.M23,
104+
transform.M31 * transform.M31 + transform.M32 * transform.M32 + transform.M33 * transform.M33));
105105

106106
float radius = sphere.Radius * (float)Math.Sqrt(majorAxisLengthSquared);
107107
result = new BoundingSphere(center, radius);
@@ -169,7 +169,7 @@ public ContainmentType Contains(in BoundingSphere sphere)
169169
Vector3 m = Vector3.Subtract(ray.Position, Center);
170170

171171
float b = Vector3.Dot(m, ray.Direction);
172-
float c = Vector3.Dot(m, m) - (Radius * Radius);
172+
float c = Vector3.Dot(m, m) - Radius * Radius;
173173

174174
if (c > 0f && b > 0f)
175175
{

Hexa.NET.Math/CSMHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#if !MINIMAL
22

3-
namespace HexaEngine.Mathematics
3+
namespace Hexa.NET.Mathematics
44
{
55
using System;
66
using System.Numerics;

Hexa.NET.Math/CameraTransform.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#if !MINIMAL
2-
namespace HexaEngine.Mathematics
2+
namespace Hexa.NET.Mathematics
33
{
44
using System.Numerics;
55

Hexa.NET.Math/Color.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace HexaEngine.Mathematics
1+
namespace Hexa.NET.Mathematics
22
{
33
using System;
44
using System.Numerics;
@@ -77,9 +77,9 @@ public Color(byte r, byte g, byte b, byte a)
7777
/// <param name="color">The unsigned integer representation of the color.</param>
7878
public Color(uint color)
7979
{
80-
R = (float)((color >> 24) & 0xff) / byte.MaxValue;
81-
G = (float)((color >> 16) & 0xff) / byte.MaxValue;
82-
B = (float)((color >> 8) & 0xff) / byte.MaxValue;
80+
R = (float)(color >> 24 & 0xff) / byte.MaxValue;
81+
G = (float)(color >> 16 & 0xff) / byte.MaxValue;
82+
B = (float)(color >> 8 & 0xff) / byte.MaxValue;
8383
A = (float)(color & 0xff) / byte.MaxValue;
8484
}
8585

@@ -110,9 +110,9 @@ public Color(Color32 color)
110110

111111
public static Color FromABGR(uint color)
112112
{
113-
var a = (float)((color >> 24) & 0xff) / byte.MaxValue;
114-
var b = (float)((color >> 16) & 0xff) / byte.MaxValue;
115-
var g = (float)((color >> 8) & 0xff) / byte.MaxValue;
113+
var a = (float)(color >> 24 & 0xff) / byte.MaxValue;
114+
var b = (float)(color >> 16 & 0xff) / byte.MaxValue;
115+
var g = (float)(color >> 8 & 0xff) / byte.MaxValue;
116116
var r = (float)(color & 0xff) / byte.MaxValue;
117117
return new Color(r, g, b, a);
118118
}
@@ -128,7 +128,7 @@ public readonly uint ToUIntRGBA()
128128
byte g = (byte)(col.G * byte.MaxValue);
129129
byte b = (byte)(col.B * byte.MaxValue);
130130
byte a = (byte)(col.A * byte.MaxValue);
131-
return ((uint)r << 24) | ((uint)g << 16) | ((uint)b << 8) | a;
131+
return (uint)r << 24 | (uint)g << 16 | (uint)b << 8 | a;
132132
}
133133

134134
/// <summary>
@@ -142,7 +142,7 @@ public readonly uint ToUIntABGR()
142142
byte g = (byte)(col.G * byte.MaxValue);
143143
byte b = (byte)(col.B * byte.MaxValue);
144144
byte a = (byte)(col.A * byte.MaxValue);
145-
return ((uint)a << 24) | ((uint)b << 16) | ((uint)g << 8) | r;
145+
return (uint)a << 24 | (uint)b << 16 | (uint)g << 8 | r;
146146
}
147147

148148
/// <summary>
@@ -170,7 +170,7 @@ public readonly ColorHSVA ToHSVA()
170170
{
171171
if (max == R)
172172
{
173-
hue = (G - B) / delta + ((G < B) ? 6 : 0);
173+
hue = (G - B) / delta + (G < B ? 6 : 0);
174174
}
175175
else if (max == G)
176176
{
@@ -184,7 +184,7 @@ public readonly ColorHSVA ToHSVA()
184184
hue /= 6;
185185
}
186186

187-
float saturation = (max != 0) ? delta / max : 0;
187+
float saturation = max != 0 ? delta / max : 0;
188188
float value = max;
189189

190190
return new ColorHSVA(hue, saturation, value, A);

Hexa.NET.Math/Color32.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace HexaEngine.Mathematics
1+
namespace Hexa.NET.Mathematics
22
{
33
using System;
44
using System.Numerics;
@@ -65,10 +65,10 @@ public Color32(float r, float g, float b, float a)
6565
/// <returns>The 32-bit unsigned integer representation of the color.</returns>
6666
public Color32(uint color)
6767
{
68-
R = (byte)((color >> 24) & 0xff);
69-
G = (byte)((color >> 16) & 0xff);
70-
B = (byte)((color >> 8) & 0xff);
71-
A = (byte)((color) & 0xff);
68+
R = (byte)(color >> 24 & 0xff);
69+
G = (byte)(color >> 16 & 0xff);
70+
B = (byte)(color >> 8 & 0xff);
71+
A = (byte)(color & 0xff);
7272
}
7373

7474
/// <summary>
@@ -103,7 +103,7 @@ public Color32(Color color)
103103
/// <returns>The 32-bit unsigned integer representation of the color.</returns>
104104
public readonly uint ToUInt()
105105
{
106-
return ((uint)R << 24) | ((uint)G << 16) | ((uint)B << 8) | A;
106+
return (uint)R << 24 | (uint)G << 16 | (uint)B << 8 | A;
107107
}
108108

109109
/// <summary>

Hexa.NET.Math/ColorHSLA.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace HexaEngine.Mathematics
1+
namespace Hexa.NET.Mathematics
22
{
33
using System;
44
using System.Numerics;

Hexa.NET.Math/ColorHSVA.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace HexaEngine.Mathematics
1+
namespace Hexa.NET.Mathematics
22
{
33
using System.Numerics;
44

Hexa.NET.Math/Colors.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace HexaEngine.Mathematics
1+
namespace Hexa.NET.Mathematics
22
{
33
/// <summary>
44
/// <see cref="Colors" /> defines standard colors using names and RGB values from https://www.w3.org/TR/css-color-3 .

Hexa.NET.Math/ContainmentType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace HexaEngine.Mathematics
1+
namespace Hexa.NET.Mathematics
22
{
33
/// <summary>
44
/// Defines how the bounding volumes intersects or contain one another.

Hexa.NET.Math/Curve.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Fair use of code, this code section is trivial to the rest.
66
*/
77

8-
namespace HexaEngine.Mathematics
8+
namespace Hexa.NET.Mathematics
99
{
1010
using System.Runtime.Serialization;
1111
using System.Text.Json.Serialization;

Hexa.NET.Math/CurvePoint.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace HexaEngine.Mathematics
1+
namespace Hexa.NET.Mathematics
22
{
33
using System.Numerics;
44

Hexa.NET.Math/CurvePointType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace HexaEngine.Mathematics
1+
namespace Hexa.NET.Mathematics
22
{
33
public enum CurvePointType
44
{

Hexa.NET.Math/CurveType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace HexaEngine.Mathematics
1+
namespace Hexa.NET.Mathematics
22
{
33
public enum CurveType
44
{

Hexa.NET.Math/DPSMHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#if !MINIMAL
2-
namespace HexaEngine.Mathematics
2+
namespace Hexa.NET.Mathematics
33
{
44
using System.Numerics;
55

Hexa.NET.Math/EllipseF.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace HexaEngine.Mathematics
1+
namespace Hexa.NET.Mathematics
22
{
33
using System;
44
using System.Numerics;

Hexa.NET.Math/Endianness.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace HexaEngine.Mathematics
1+
namespace Hexa.NET.Mathematics
22
{
33
/// <summary>
44
/// Specifies the byte order or endianness of data storage or communication.

Hexa.NET.Math/Hexa.NET.Math.csproj

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFrameworks>net8.0;netstandard2.1</TargetFrameworks>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
8+
<Configurations>Debug;Release;Minimal</Configurations>
9+
<RootNamespace>Hexa.NET.Mathematicsematics</RootNamespace>
10+
<LangVersion>12</LangVersion>
11+
</PropertyGroup>
12+
13+
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
14+
<IsAotCompatible>true</IsAotCompatible>
815
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
916
<EnableSingleFileAnalyzer>true</EnableSingleFileAnalyzer>
1017
<EnableAotAnalyzer>true</EnableAotAnalyzer>
11-
<IsAotCompatible>true</IsAotCompatible>
12-
<Configurations>Debug;Release;Minimal</Configurations>
1318
</PropertyGroup>
1419

1520
<PropertyGroup>
@@ -27,15 +32,20 @@
2732
</PropertyGroup>
2833

2934
<PropertyGroup Condition="'$(Configuration)' != 'Minimal'">
30-
<PackageVersion>1.0.0-full</PackageVersion>
35+
<PackageVersion>2.0.0-full</PackageVersion>
3136
</PropertyGroup>
3237

3338
<PropertyGroup Condition="'$(Configuration)' == 'Minimal'">
34-
<PackageVersion>1.0.0-minimal</PackageVersion>
39+
<PackageVersion>2.0.0-minimal</PackageVersion>
3540
</PropertyGroup>
3641

3742
<ItemGroup>
3843
<Content Include="../LICENSE.txt" Pack="true" PackagePath="\" />
3944
<Content Include="../README.md" Pack="true" PackagePath="\" />
4045
</ItemGroup>
46+
47+
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
48+
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
49+
<PackageReference Include="System.Text.Json" Version="8.0.4" />
50+
</ItemGroup>
4151
</Project>

Hexa.NET.Math/IReadOnlyTransform.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#if !MINIMAL
2-
namespace HexaEngine.Mathematics
2+
namespace Hexa.NET.Mathematics
33
{
44
using System.Numerics;
55

0 commit comments

Comments
 (0)