From e308c19e4cbfe1ab3a8219095ea0431c4037e5d4 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 14 Sep 2026 18:01:54 +0200 Subject: [PATCH] Move the remaining Assets scripts off Unity.Mathematics Fluid, Slime, SlimeTestSpawner, LightningCompute and MouseRotate still imported Unity.Mathematics and compiled only because Burst and Collections pull the package in. Fluid, Slime and LightningCompute now use CultMath (LightningCompute's snoise included, which CultMath carries as the same Ashima simplex noise); SlimeTestSpawner and MouseRotate imported it without using it, so the usings are gone. LightningCompute converts its float3 offsets with ToUnity() instead of the Unity.Mathematics implicit cast. None of these are Burst-compiled or jobs. Their ComputeBuffer structs are built from UnityEngine Vector2/Vector3 and floats, not math types, so no buffer layout changes. Co-Authored-By: Claude Opus 5 --- Assets/MouseRotate.cs | 2 -- .../Shaders/Compute/Lightning/LightningCompute.cs | 14 +++++++------- Assets/Shaders/Compute/Slime/Slime.cs | 3 +-- Assets/Shaders/Compute/Slime/SlimeTestSpawner.cs | 2 -- Assets/Shaders/StableFluids/Fluid.cs | 5 ++--- 5 files changed, 10 insertions(+), 16 deletions(-) diff --git a/Assets/MouseRotate.cs b/Assets/MouseRotate.cs index 95a42e882..2fa7cc22b 100644 --- a/Assets/MouseRotate.cs +++ b/Assets/MouseRotate.cs @@ -2,8 +2,6 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; -using Unity.Mathematics; -using static Unity.Mathematics.math; public class MouseRotate : MonoBehaviour { diff --git a/Assets/Shaders/Compute/Lightning/LightningCompute.cs b/Assets/Shaders/Compute/Lightning/LightningCompute.cs index 242d24b2f..d3cf76859 100644 --- a/Assets/Shaders/Compute/Lightning/LightningCompute.cs +++ b/Assets/Shaders/Compute/Lightning/LightningCompute.cs @@ -5,11 +5,11 @@ using System.Linq; using System.Runtime.InteropServices; using UnityEngine; using UnityEngine.Rendering; -using Unity.Mathematics; +using CultMath; +using CultMath.UnityBridge; using UnityEngine.InputSystem; using UnityEngine.Serialization; -using static Unity.Mathematics.math; -using static Unity.Mathematics.noise; +using static CultMath.math; using Random = UnityEngine.Random; public class LightningCompute : MonoBehaviour @@ -255,19 +255,19 @@ public class LightningCompute : MonoBehaviour var diff = EndPosition - StartPosition; var dist = diff.magnitude; _bolts[0].startPos = StartPosition; - _bolts[0].startOffset = -(Vector3) fbm3(float2(0, _time)); + _bolts[0].startOffset = -fbm3(float2(0, _time)).ToUnity(); _bolts[0].endPos = EndPosition; - _bolts[0].endOffset = FixedEndpoint ? -(Vector3) fbm3(float2(dist, _time)) : Vector3.zero; + _bolts[0].endOffset = FixedEndpoint ? -fbm3(float2(dist, _time)).ToUnity() : Vector3.zero; for (int i = 0; i < BranchCount; i++) { var root = Vector3.Lerp(StartPosition, EndPosition, _bolts[i + 1].startTime); var rootDist = _bolts[i + 1].startTime * dist; _bolts[i + 1].startPos = - root + (Vector3) fbm3(float2(rootDist, _time)) + + root + fbm3(float2(rootDist, _time)).ToUnity() + _bolts[0].startOffset * (max(.5f - _bolts[i + 1].startTime, 0) * 2) + _bolts[0].endOffset * (max(_bolts[i + 1].startTime - .5f, 0) * 2); - _bolts[i + 1].startOffset = -(Vector3) fbm3(float2(0, _time + (i + 1) * 10)); + _bolts[i + 1].startOffset = -fbm3(float2(0, _time + (i + 1) * 10)).ToUnity(); _bolts[i + 1].endPos = root + _branchEndpoints[i]; } diff --git a/Assets/Shaders/Compute/Slime/Slime.cs b/Assets/Shaders/Compute/Slime/Slime.cs index ffd067938..666a79b9c 100644 --- a/Assets/Shaders/Compute/Slime/Slime.cs +++ b/Assets/Shaders/Compute/Slime/Slime.cs @@ -4,12 +4,11 @@ using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using MessagePack; -using Unity.Mathematics; using UnityEngine; using UnityEngine.Experimental.Rendering; using UnityEngine.Rendering; using Random = UnityEngine.Random; -using static Unity.Mathematics.math; +using static CultMath.math; public class Slime : MonoBehaviour { diff --git a/Assets/Shaders/Compute/Slime/SlimeTestSpawner.cs b/Assets/Shaders/Compute/Slime/SlimeTestSpawner.cs index 238b12fb8..a3e66b33e 100644 --- a/Assets/Shaders/Compute/Slime/SlimeTestSpawner.cs +++ b/Assets/Shaders/Compute/Slime/SlimeTestSpawner.cs @@ -1,6 +1,4 @@ -using Unity.Mathematics; using UnityEngine; -using static Unity.Mathematics.math; public class SlimeTestSpawner : MonoBehaviour { diff --git a/Assets/Shaders/StableFluids/Fluid.cs b/Assets/Shaders/StableFluids/Fluid.cs index bd8807f7a..86b4eff8f 100644 --- a/Assets/Shaders/StableFluids/Fluid.cs +++ b/Assets/Shaders/StableFluids/Fluid.cs @@ -2,10 +2,9 @@ // https://github.com/keijiro/StableFluids using System.Collections.Generic; -using Unity.Mathematics; +using CultMath; using UnityEngine; -using static Unity.Mathematics.math; -using int2 = Unity.Mathematics.int2; +using static CultMath.math; using Random = UnityEngine.Random; public class Fluid : MonoBehaviour