mirror of
git://repo.or.cz/rocks.git
synced 2025-01-04 07:10:28 +01:00
Vein gen cleanup and experimental ores in veins.
This commit is contained in:
parent
64e01a2aab
commit
7c7b7715bc
@ -1,26 +1,5 @@
|
|||||||
-- experimental fast vein generator
|
-- experimental fast vein generator
|
||||||
|
|
||||||
local function draw_sphere(data,area,pos,radius,with)
|
|
||||||
local rsq=radius^2
|
|
||||||
radius=radius+2
|
|
||||||
for x=-radius, radius do
|
|
||||||
for y=-radius, radius do
|
|
||||||
for z=-radius, radius do
|
|
||||||
if (x^2)+(y^2)+(z^2)<=rsq then
|
|
||||||
data[area:index(x+pos.x,y+pos.y,z+pos.z)]=with
|
|
||||||
end
|
|
||||||
end end end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function line(data,area,A,B,with)
|
|
||||||
local length=vector.distance(A,B)
|
|
||||||
local step=1/length
|
|
||||||
for t=0, 1, step do
|
|
||||||
local p=vector.add(vector.multiply(A,(1-t)), vector.multiply(B,t) )
|
|
||||||
p=vector.round(p)
|
|
||||||
data[area:index(p.x,p.y,p.z)]=with
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
rocksl.genvein=function(minp,maxp,pr,vm,area)
|
rocksl.genvein=function(minp,maxp,pr,vm,area)
|
||||||
local t1 = os.clock()
|
local t1 = os.clock()
|
||||||
@ -30,23 +9,37 @@ rocksl.genvein=function(minp,maxp,pr,vm,area)
|
|||||||
local chunksize = chunksizer + 1
|
local chunksize = chunksizer + 1
|
||||||
local pmapsize = {x = chunksize, y = chunksize, z = chunksize}
|
local pmapsize = {x = chunksize, y = chunksize, z = chunksize}
|
||||||
local minpxz = {x = minp.x, y = minp.z}
|
local minpxz = {x = minp.x, y = minp.z}
|
||||||
local c_sample=minetest.get_content_id("default:mese")
|
local c_sample=minetest.get_content_id("default:stone")
|
||||||
|
local c_sample_ore=minetest.get_content_id("default:mese")
|
||||||
|
|
||||||
|
|
||||||
local pointA=vector.new(pr:next(0,chunksizer)+minp.x,pr:next(0,chunksizer)+minp.y,pr:next(0,chunksizer)+minp.z)
|
local A=vector.new(pr:next(0,chunksizer)+minp.x,pr:next(0,chunksizer)+minp.y,pr:next(0,chunksizer)+minp.z)
|
||||||
local pointB=vector.new(pr:next(0,chunksizer)+minp.x,pr:next(0,chunksizer)+minp.y,pr:next(0,chunksizer)+minp.z)
|
local B=vector.new(pr:next(0,chunksizer)+minp.x,pr:next(0,chunksizer)+minp.y,pr:next(0,chunksizer)+minp.z)
|
||||||
local pointC=vector.new(pr:next(0,chunksizer)+minp.x,pr:next(0,chunksizer)+minp.y,pr:next(0,chunksizer)+minp.z)
|
local C=vector.new(pr:next(0,chunksizer)+minp.x,pr:next(0,chunksizer)+minp.y,pr:next(0,chunksizer)+minp.z)
|
||||||
local pointB2=vector.new(pr:next(0,chunksizer)+minp.x,pr:next(0,chunksizer)+minp.y,pr:next(0,chunksizer)+minp.z)
|
local D=vector.new(pr:next(0,chunksizer)+minp.x,pr:next(0,chunksizer)+minp.y,pr:next(0,chunksizer)+minp.z)
|
||||||
local l1=vector.distance(pointA,pointB)+vector.distance(pointB,pointC)
|
local l1=vector.distance(A,C)+vector.distance(C,B)
|
||||||
local l2=1/(vector.distance(pointA,pointB2)+vector.distance(pointB2,pointC))
|
local l2=vector.distance(A,D)+vector.distance(D,B)
|
||||||
local step=1.3/math.max(l1,l2)
|
local step=1.4/math.max(l1,l2)
|
||||||
|
print("step="..step.." l1="..l1.." l2="..l2)
|
||||||
|
local scarcity=6
|
||||||
|
local ocn=pr:next(0,scarcity)+(scarcity/2)
|
||||||
for t=0, 1, step do
|
for t=0, 1, step do
|
||||||
local p
|
local P=vector.multiply(A,(1-t)^2)
|
||||||
p=vector.multiply(pointA,(1-t)^2)
|
P=vector.add(P, vector.multiply(B,t*t) )
|
||||||
p=vector.add(p, vector.multiply(pointC,t*t) )
|
local Q=vector.add(P, vector.multiply(D,2*t*(1-t)) )
|
||||||
p=vector.add(p, vector.multiply(pointB,2*t*(1-t)) )
|
P=vector.add(P, vector.multiply(C,2*t*(1-t)) )
|
||||||
local p2=vector.add(p, vector.multiply(pointB2,2*t*(1-t)) )
|
local step2=1/vector.distance(P,Q)
|
||||||
line(data,area,p,p2,c_sample)
|
for u=0, 1, step2 do
|
||||||
|
local R=vector.add(vector.multiply(P,(1-u)), vector.multiply(Q,u) )
|
||||||
|
local di=area:indexp(vector.round(R))
|
||||||
|
if ocn<1 then
|
||||||
|
data[di]=c_sample_ore
|
||||||
|
ocn=pr:next(0,scarcity)+(scarcity/2)
|
||||||
|
else
|
||||||
|
data[di]=c_sample
|
||||||
|
ocn=ocn-1
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
vm:set_data(data)
|
vm:set_data(data)
|
||||||
|
Loading…
Reference in New Issue
Block a user