1 -- experimental fast vein generator
5 table.insert(rocks
.veins
,{
11 rocksl
.genvein
=function(minp
,maxp
,pr
,vm
,area
)
13 local data
= vm
:get_data()
15 local chunksizer
= maxp
.x
- minp
.x
+ 1
16 local chunksize
= chunksizer
+ 1
17 local pmapsize
= {x
= chunksize
, y
= chunksize
, z
= chunksize
}
18 local minpxz
= {x
= minp
.x
, y
= minp
.z
}
19 local c_sample
=minetest
.get_content_id("default:stone")
20 local c_sample_ore
=minetest
.get_content_id("default:mese")
23 local A
=vector
.new(pr
:next(0,chunksizer
)+minp
.x
,pr
:next(0,chunksizer
)+minp
.y
,pr
:next(0,chunksizer
)+minp
.z
)
24 local B
=vector
.new(pr
:next(0,chunksizer
)+minp
.x
,pr
:next(0,chunksizer
)+minp
.y
,pr
:next(0,chunksizer
)+minp
.z
)
25 local C
=vector
.new(pr
:next(0,chunksizer
)+minp
.x
,pr
:next(0,chunksizer
)+minp
.y
,pr
:next(0,chunksizer
)+minp
.z
)
26 local D
=vector
.new(pr
:next(0,chunksizer
)+minp
.x
,pr
:next(0,chunksizer
)+minp
.y
,pr
:next(0,chunksizer
)+minp
.z
)
27 local l1
=vector
.distance(A
,C
)+vector
.distance(C
,B
)
28 local l2
=vector
.distance(A
,D
)+vector
.distance(D
,B
)
29 local step
=1.4/math
.max(l1
,l2
)
30 print("step="..step
.." l1="..l1
.." l2="..l2
)
32 local ocn
=pr
:next(0,scarcity
)+(scarcity
/2)
34 local P
=vector
.multiply(A
,(1-t
)^
2)
35 P
=vector
.add(P
, vector
.multiply(B
,t
*t
) )
36 local Q
=vector
.add(P
, vector
.multiply(D
,2*t
*(1-t
)) )
37 P
=vector
.add(P
, vector
.multiply(C
,2*t
*(1-t
)) )
38 local step2
=1/vector
.distance(P
,Q
)
40 local R
=vector
.add(vector
.multiply(P
,(1-u
)), vector
.multiply(Q
,u
) )
41 local di
=area
:indexp(vector
.round(R
))
44 ocn
=pr
:next(0,scarcity
)+(scarcity
/2)
53 minetest
.log("action", "rocks/genvein/ "..math
.ceil((os
.clock() - t1
) * 1000).." ms ")