From 89ffa9ea09da478852ebe24f2ae2348c6b145edd Mon Sep 17 00:00:00 2001
From: miepzerino <o.skotnik@gmail.com>
Date: Sun, 06 Apr 2025 16:22:53 +0000
Subject: [PATCH] #48 added perlinNoise cache

---
 Assets/Scripts/Jobs/GenerateGroundJob.cs |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/Assets/Scripts/Jobs/GenerateGroundJob.cs b/Assets/Scripts/Jobs/GenerateGroundJob.cs
index ce435a5..1b679aa 100644
--- a/Assets/Scripts/Jobs/GenerateGroundJob.cs
+++ b/Assets/Scripts/Jobs/GenerateGroundJob.cs
@@ -22,6 +22,7 @@
 
     [WriteOnly]
     public NativeArray<bool> groundTiles;
+    [ReadOnly] public NativeArray<float> perlinNoiseCache;
 
     public void Execute(int index)
     {
@@ -33,11 +34,7 @@
             groundTiles[index] = false;
             return;
         }
-
-        float xPerlin = ((float)x / maxWidth) * scale + offsetX;
-        float yPerlin = ((float)math.abs(y) / groundDepth) * scale + offsetY;
-        float perlinNoise = noise.cnoise(new float2(xPerlin, yPerlin));
-
-        groundTiles[index] = perlinNoise <= 0.7f;
+        
+        groundTiles[index] = perlinNoiseCache[x * groundDepth + Mathf.Abs(y)] <= 0.7f;
     }
 }

--
Gitblit v1.9.3