Refactor and enhance math and utility libraries
Some checks failed
Publish NuGet Packages / publish (push) Failing after 3m12s

Refactored `sincos` usage across `quaternion` and `random` to use `out` parameters for improved performance. Enhanced `random` struct with updated random direction generation methods.

Added new benchmarks in `MathematicsBenchmark` for vector operations, including SIMD-based `f4` struct. Downgraded target framework to `net9.0` for compatibility.

Introduced `ReadOnlyUnsafeCollection` for low-level memory management. Added utility methods in `CollectionUtility` for span creation and optimized list operations.

Renamed `MemoryUtilities` to `MemoryUtility` and updated all references. Enhanced `ObjectPool` with `Rent` and `TryRent` methods. Enabled `AllowUnsafeBlocks` and AOT compatibility in project configuration.

Performed general code cleanup, including removal of unused methods, improved formatting, and alignment with modern coding practices.
This commit is contained in:
2025-11-04 14:53:01 +09:00
parent 081103372f
commit 49e1171781
38 changed files with 5149 additions and 1259 deletions

View File

@@ -642,7 +642,7 @@ public struct random
public float2 NextFloat2Direction()
{
var angle = NextFloat() * PI * 2.0f;
var (s, c) = sincos(angle);
sincos(angle, out var s, out var c);
return float2(c, s);
}
@@ -652,7 +652,7 @@ public struct random
public double2 NextDouble2Direction()
{
var angle = NextDouble() * PI_DBL * 2.0;
var (s, c) = sincos(angle);
sincos(angle, out var s, out var c);
return double2(c, s);
}
@@ -665,7 +665,7 @@ public struct random
var z = rnd.x * 2.0f - 1.0f;
var r = sqrt(max(1.0f - z * z, 0.0f));
var angle = rnd.y * PI * 2.0f;
var (s, c) = sincos(angle);
sincos(angle, out var s, out var c);
return float3(c * r, s * r, z);
}
@@ -678,7 +678,7 @@ public struct random
var z = rnd.x * 2.0 - 1.0;
var r = sqrt(max(1.0 - z * z, 0.0));
var angle = rnd.y * PI_DBL * 2.0;
var (s, c) = sincos(angle);
sincos(angle, out var s, out var c);
return double3(c * r, s * r, z);
}
@@ -694,7 +694,7 @@ public struct random
var i = sqrt(1.0f - u1);
var j = sqrt(u1);
var (sin_theta_rho, cos_theta_rho) = sincos(theta_rho);
sincos(theta_rho, out var sin_theta_rho, out var cos_theta_rho);
var q = quaternion(i * sin_theta_rho.x, i * cos_theta_rho.x, j * sin_theta_rho.y, j * cos_theta_rho.y);
return quaternion(select(q.value, -q.value, q.value.w < 0.0f));