remove C library dependency
This commit is contained in:
+9
-10
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user