Export get_node_active_selection_box

main
copygirl 1 year ago
parent 4c528793c3
commit 1075257bb1
  1. 9
      utility.lua

@ -8,9 +8,11 @@ local rotate_box_by_facedir = nc_extended_rotating.rotate.rotate_box_by_facedir
local DEFAULT_SELECTION_BOX = { min = vector.new(-0.5, -0.5, -0.5),
max = vector.new( 0.5, 0.5, 0.5) }
local utility = {}
-- Gets the active `selection_box` for the specified `node` which
-- has a `paramtype2` of `facedir`, based on its `param2` value.
local function get_node_active_selection_box(node)
function utility.get_node_active_selection_box(node)
local def = minetest.registered_nodes[node.name]
local box = def.selection_box and def.selection_box.fixed
-- No need to rotate the default selection box.
@ -25,15 +27,12 @@ local function get_node_active_selection_box(node)
return box
end
local utility = {}
-- Calculates the rotation vector from where a player is looking at on this node.
-- * If looking near an edge, the vector points in the direction of that edge.
-- * If looking near a corner, the vector similarly points in that direction.
-- * Otherwise, vector simply points away from the face.
function utility.rotation_vector_from_lookat(node, pointed_thing, edge_distance)
local box = get_node_active_selection_box(node)
local box = utility.get_node_active_selection_box(node)
local center = (box.min + box.max) / 2
-- Calculate bounds, single vector describing the size of the selection box.

Loading…
Cancel
Save