1
0
mirror of git://repo.or.cz/rocks.git synced 2024-12-29 12:20:35 +01:00

Vein stuff.

This commit is contained in:
Tomáš Brada 2015-07-03 21:26:19 +02:00
parent 90718a30ee
commit f9d6fbdcea
2 changed files with 16 additions and 14 deletions

View File

@ -15,7 +15,7 @@ l.OnInit={}
l.ToResolve={} l.ToResolve={}
local includes={ local includes={
"pipes" --,"veins" "pipes","veins"
} }
minetest.register_on_generated(function(minp,maxp,seed) minetest.register_on_generated(function(minp,maxp,seed)

View File

@ -41,7 +41,7 @@ local sample_vein_def={
depositgen.register_vein(sample_vein_def) depositgen.register_vein(sample_vein_def)
end end
rocksl.genvein=function(minp,maxp,pr,vm,area) local function generate(minp,maxp,pr,vm,area)
local t1 = os.clock() local t1 = os.clock()
local data = vm:get_data() local data = vm:get_data()
@ -49,9 +49,10 @@ 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:stone")
local c_sample_ore=minetest.get_content_id("default:mese")
for _,descr in pairs(regs) do
local num = math.floor( (chunksize/descr.scarcity) + (pr:next(0,99)/100) )
for vc=1, num do
local A=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 B=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)
@ -59,8 +60,7 @@ rocksl.genvein=function(minp,maxp,pr,vm,area)
local D=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(A,C)+vector.distance(C,B) local l1=vector.distance(A,C)+vector.distance(C,B)
local l2=vector.distance(A,D)+vector.distance(D,B) local l2=vector.distance(A,D)+vector.distance(D,B)
local step=1.4/math.max(l1,l2) local step=2/math.max(l1,l2)
print("step="..step.." l1="..l1.." l2="..l2)
local scarcity=6 local scarcity=6
local ocn=pr:next(0,scarcity)+(scarcity/2) local ocn=pr:next(0,scarcity)+(scarcity/2)
for t=0, 1, step do for t=0, 1, step do
@ -71,17 +71,19 @@ rocksl.genvein=function(minp,maxp,pr,vm,area)
local step2=1/vector.distance(P,Q) local step2=1/vector.distance(P,Q)
for u=0, 1, step2 do for u=0, 1, step2 do
local R=vector.add(vector.multiply(P,(1-u)), vector.multiply(Q,u) ) local R=vector.add(vector.multiply(P,(1-u)), vector.multiply(Q,u) )
--<brush>
local di=area:indexp(vector.round(R)) local di=area:indexp(vector.round(R))
if ocn<1 then if data[di] then
data[di]=c_sample_ore data[di]=descr.content.id
ocn=pr:next(0,scarcity)+(scarcity/2)
else
data[di]=c_sample
ocn=ocn-1
end end
--</brush>
end end
end end
end
end
vm:set_data(data) vm:set_data(data)
minetest.log("action", "rocks/genvein/ "..math.ceil((os.clock() - t1) * 1000).." ms ") print("vein "..math.ceil((os.clock() - t1) * 1000).." ms ")
end end
table.insert(depositgen.l.OnGenerate,generate)