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);

0 commit comments

Comments
 (0)