Implement partial node spawning check

This commit is contained in:
teknomunk 2024-06-24 08:53:20 -05:00
parent fa09b65010
commit 4d58f63485

@ -572,15 +572,20 @@ local function has_room(self,pos)
local processed = {} local processed = {}
for x = p1.x,p2.x do for x = p1.x,p2.x do
for z = p1.z,p2.z do for z = p1.z,p2.z do
local node = minetest.get_node(vector.new(x,p2.y,z)) or { name = "ignore" } local test_pos = vector.new(x,p2.y,z)
if not processed[node.name] then local node = minetest.get_node(test_pos) or { name = "ignore" }
local nodedef = minetest.registered_nodes local cache_name = string.format("%s-%d", node.name, node.param2)
if not processed[cache_name] then
-- Calculate node bounding box and select the lowest y value
local boxes = minetest.get_node_boxes("collision_box", test_pos, node)
for i = 1,#boxes do
local box = boxes[i]
local y_test = box[2] + 0.5
if y_test < top_layer_height then top_layer_height = y_test end
-- TODO: calculate node bounding box and select the lowest y value local y_test = box[5] + 0.5
local lowest_y = 0 if y_test < top_layer_height then top_layer_height = y_test end
top_layer_height = math.min(lowest_y, top_layer_height) end
processed[node.name] = true
end end
end end
end end