log indexing time
parent
be3bfe70ff
commit
bff38b461b
|
@ -6,3 +6,42 @@ planetoidgen.register_planet({
|
|||
airshell = true,
|
||||
airshell_radius = 10
|
||||
})
|
||||
|
||||
planetoidgen.register_planet({
|
||||
pos = { x=-2500, y=7500, z=-2500 },
|
||||
name = "my-planet 2",
|
||||
type = "class-m",
|
||||
radius = 500,
|
||||
airshell = true,
|
||||
airshell_radius = 100
|
||||
})
|
||||
|
||||
-- unnamed system
|
||||
planetoidgen.register_planet({
|
||||
pos = { x = 9000, y = 9500, z = 5000 },
|
||||
radius = 400, type = "sun", name = "system-2 sun"
|
||||
})
|
||||
planetoidgen.register_planet({
|
||||
pos = { x = 9000, y = 9500, z = 6000 },
|
||||
radius = 300, type = "class-p", name = "system-2 top", airshell = true
|
||||
})
|
||||
planetoidgen.register_planet({
|
||||
pos = { x = 9866, y = 9500, z = 5500 },
|
||||
radius = 300, type = "class-m", name = "system-2 top-right", airshell = true
|
||||
})
|
||||
planetoidgen.register_planet({
|
||||
pos = { x = 9866, y = 9500, z = 4500 },
|
||||
radius = 300, type = "class-m", name = "system-2 bottom-right", airshell = true
|
||||
})
|
||||
planetoidgen.register_planet({
|
||||
pos = { x = 9000, y = 9500, z = 4000 },
|
||||
radius = 300, type = "class-h", name = "system-2 bottom desert", airshell = true
|
||||
})
|
||||
planetoidgen.register_planet({
|
||||
pos = { x = 8134, y = 9500, z = 4500 },
|
||||
radius = 300, type = "class-m", name = "system-2 bottom-left", airshell = true
|
||||
})
|
||||
planetoidgen.register_planet({
|
||||
pos = { x = 8134, y = 9500, z = 5500 },
|
||||
radius = 300, type = "class-m", name = "system-2 top-left", airshell = true
|
||||
})
|
||||
|
|
|
@ -7,6 +7,9 @@ local index = {}
|
|||
|
||||
-- generates the spatial index for a single planet
|
||||
function planetoidgen.generate_index(planet)
|
||||
local t0 = minetest.get_us_time()
|
||||
local count = 0
|
||||
|
||||
local radius = planet.radius + (planet.airshell_radius or planetoidgen.default_air_shell_radius)
|
||||
local min_mapblock = vector.round(vector.divide(vector.subtract(planet.pos, radius), 16))
|
||||
local max_mapblock = vector.round(vector.divide(vector.add(planet.pos, radius), 16))
|
||||
|
@ -30,11 +33,19 @@ function planetoidgen.generate_index(planet)
|
|||
-- mapblock is in the planet sphere, add to index
|
||||
local hash = minetest.hash_node_position(mapblock_pos)
|
||||
index[hash] = planet
|
||||
count = count + 1
|
||||
end
|
||||
|
||||
end --z
|
||||
end --y
|
||||
end --x
|
||||
|
||||
local t1 = minetest.get_us_time()
|
||||
local micros = t1 -t0
|
||||
|
||||
minetest.log("action", "[planetoidgen] indexing for planet at " .. minetest.pos_to_string(planet.pos) ..
|
||||
" took " .. micros .. " us and populated " .. count .. " mapblocks")
|
||||
|
||||
end
|
||||
|
||||
function planetoidgen.get_planet_at_pos(pos)
|
||||
|
|
Loading…
Reference in New Issue