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 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-14 18:01:54 +02:00
commit e308c19e4c
5 changed files with 10 additions and 16 deletions

View file

@ -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
{

View file

@ -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];
}

View file

@ -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
{

View file

@ -1,6 +1,4 @@
using Unity.Mathematics;
using UnityEngine;
using static Unity.Mathematics.math;
public class SlimeTestSpawner : MonoBehaviour
{

View file

@ -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