From 1ef49ad2134b03134c4a57cff202d194a39e9984 Mon Sep 17 00:00:00 2001 From: tangent Date: Sat, 15 Aug 2026 02:24:34 -0600 Subject: [PATCH] remove C library dependency --- simplex.lua | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/simplex.lua b/simplex.lua index f2e52a7..2e90a8d 100644 --- a/simplex.lua +++ b/simplex.lua @@ -9,7 +9,6 @@ local table = table local tonumber = tonumber local ipairs = ipairs local error = error -local bit = require("bit") local simplex = {} @@ -137,8 +136,8 @@ function simplex.Noise2D(xin, yin) local y2 = y0 - 1.0 + 2.0 * G2; -- Work out the hashed gradient indices of the three simplex corners - local ii = bit.band(i , 255) - local jj = bit.band(j , 255) + local ii = math.floor(i % 255) + local jj = math.floor(j % 255) local gi0 = perm[ii+perm[jj]] % 12; local gi1 = perm[ii+i1+perm[jj+j1]] % 12; local gi2 = perm[ii+1+perm[jj+1]] % 12; @@ -250,9 +249,9 @@ function simplex.Noise3D(xin, yin, zin) local z3 = z0 - 1.0 + 3.0*G3; -- Work out the hashed gradient indices of the four simplex corners - local ii = bit.band(i , 255) - local jj = bit.band(j , 255) - local kk = bit.band(k , 255) + local ii = math.floor(i % 255) + local jj = math.floor(j % 255) + local kk = math.floor(k % 255) local gi0 = perm[ii+perm[jj+perm[kk]]] % 12; local gi1 = perm[ii+i1+perm[jj+j1+perm[kk+k1]]] % 12; @@ -394,10 +393,10 @@ function simplex.Noise4D(x,y,z,w) local w4 = w0 - 1.0 + 4.0*G4; -- Work out the hashed gradient indices of the five simplex corners - local ii = bit.band(i , 255) - local jj = bit.band(j , 255) - local kk = bit.band(k , 255) - local ll = bit.band(l , 255) + local ii = math.floor(i % 255) + local jj = math.floor(j % 255) + local kk = math.floor(k % 255) + local ll = math.floor(l % 255) local gi0 = perm[ii+perm[jj+perm[kk+perm[ll]]]] % 32; local gi1 = perm[ii+i1+perm[jj+j1+perm[kk+k1+perm[ll+l1]]]] % 32; local gi2 = perm[ii+i2+perm[jj+j2+perm[kk+k2+perm[ll+l2]]]] % 32;