Moved ommented code to seperate file
This should help to de-clutter the main init file. If cubic noise is added, then these functions are essential, which is why they are not removedmaster
parent
32d31426c9
commit
5fede9f5c6
47
init.lua
47
init.lua
|
@ -270,50 +270,6 @@ local blockfiller_2d = function(blockdata,blocksize,table,tablesize,blockstart)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--intended for optimisation, will later be used for cubic noise instead
|
|
||||||
--[[
|
|
||||||
local solidblockfiller_2d = function(blockvalue,blocksize,table,tablesize,blockstart)
|
|
||||||
local tableit = blockstart
|
|
||||||
local zbuf = tablesize.x - blocksize.x
|
|
||||||
local x,z = 1,1
|
|
||||||
local blocklength = blocksize.x*blocksize.z
|
|
||||||
for i=1,blocklength do
|
|
||||||
if x > blocksize.x then
|
|
||||||
x = 1
|
|
||||||
z = z + 1
|
|
||||||
tableit = tableit + zbuf
|
|
||||||
end
|
|
||||||
table[tableit] = blockvalue
|
|
||||||
tableit = tableit + 1
|
|
||||||
x = x + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--for 2d use (x,y) rather than (x,0,z)
|
|
||||||
local solidblockfiller = function(blockvalue,blocksize,table,tablesize,blockstart)
|
|
||||||
local tableit = blockstart
|
|
||||||
local ybuf,zbuf = tablesize.x - blocksize.x,(tablesize.y - blocksize.y)*tablesize.x
|
|
||||||
local x,y,z = 1,1,1
|
|
||||||
local blocklength = blocksize.x*blocksize.y*(blocksize.z or 1)
|
|
||||||
for i=1,blocklength do
|
|
||||||
if x > blocksize.x then
|
|
||||||
x = 1
|
|
||||||
y = y + 1
|
|
||||||
tableit = tableit + ybuf
|
|
||||||
end
|
|
||||||
if y > blocksize.y then
|
|
||||||
y = 1
|
|
||||||
z = z + 1
|
|
||||||
tableit = tableit + zbuf
|
|
||||||
end
|
|
||||||
table[tableit] = blockvalue
|
|
||||||
tableit = tableit + 1
|
|
||||||
x = x + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
--]]
|
|
||||||
|
|
||||||
--Copy of the code in find_closest
|
--Copy of the code in find_closest
|
||||||
--This should be used in any non-critical code
|
--This should be used in any non-critical code
|
||||||
local get_dist = function(a,b,geo,dims)
|
local get_dist = function(a,b,geo,dims)
|
||||||
|
@ -390,8 +346,8 @@ local generate_points = function(sector,seed,layer)
|
||||||
local dims = layer.dimensions
|
local dims = layer.dimensions
|
||||||
local dist = layer.point_distribution
|
local dist = layer.point_distribution
|
||||||
local seen = {}
|
local seen = {}
|
||||||
|
--Distribution is completely user defined
|
||||||
local num = prand:next(dist.random_min,dist.random_max)
|
local num = prand:next(dist.random_min,dist.random_max)
|
||||||
--This is the new distribution method - very manual, but is flexible
|
|
||||||
local set = false
|
local set = false
|
||||||
for i=#dist,1,-1 do
|
for i=#dist,1,-1 do
|
||||||
if num <= dist[i] then
|
if num <= dist[i] then
|
||||||
|
@ -406,7 +362,6 @@ local generate_points = function(sector,seed,layer)
|
||||||
num = 1
|
num = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
while num > 0 do
|
while num > 0 do
|
||||||
--The points are aligned to 0.1 of a block
|
--The points are aligned to 0.1 of a block
|
||||||
--This used to be to 1 block, but having multiple points at
|
--This used to be to 1 block, but having multiple points at
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
--[[
|
||||||
|
--This file is inteded for placing unused code which may be useful
|
||||||
|
--for later work.
|
||||||
|
--
|
||||||
|
--This file will not be maintained in any way, other than having functions
|
||||||
|
--added and removed.
|
||||||
|
--
|
||||||
|
--]]
|
||||||
|
|
||||||
|
--intended for optimisation, will later be used for cubic noise instead
|
||||||
|
--[[
|
||||||
|
local solidblockfiller_2d = function(blockvalue,blocksize,table,tablesize,blockstart)
|
||||||
|
local tableit = blockstart
|
||||||
|
local zbuf = tablesize.x - blocksize.x
|
||||||
|
local x,z = 1,1
|
||||||
|
local blocklength = blocksize.x*blocksize.z
|
||||||
|
for i=1,blocklength do
|
||||||
|
if x > blocksize.x then
|
||||||
|
x = 1
|
||||||
|
z = z + 1
|
||||||
|
tableit = tableit + zbuf
|
||||||
|
end
|
||||||
|
table[tableit] = blockvalue
|
||||||
|
tableit = tableit + 1
|
||||||
|
x = x + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--for 2d use (x,y) rather than (x,0,z)
|
||||||
|
local solidblockfiller = function(blockvalue,blocksize,table,tablesize,blockstart)
|
||||||
|
local tableit = blockstart
|
||||||
|
local ybuf,zbuf = tablesize.x - blocksize.x,(tablesize.y - blocksize.y)*tablesize.x
|
||||||
|
local x,y,z = 1,1,1
|
||||||
|
local blocklength = blocksize.x*blocksize.y*(blocksize.z or 1)
|
||||||
|
for i=1,blocklength do
|
||||||
|
if x > blocksize.x then
|
||||||
|
x = 1
|
||||||
|
y = y + 1
|
||||||
|
tableit = tableit + ybuf
|
||||||
|
end
|
||||||
|
if y > blocksize.y then
|
||||||
|
y = 1
|
||||||
|
z = z + 1
|
||||||
|
tableit = tableit + zbuf
|
||||||
|
end
|
||||||
|
table[tableit] = blockvalue
|
||||||
|
tableit = tableit + 1
|
||||||
|
x = x + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
--]]
|
Loading…
Reference in New Issue