mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Add Lua API function to resolve node/collision/selection boxes (#13964)
This commit is contained in:
parent
4859cf44ce
commit
f2b99332d9
13 changed files with 159 additions and 28 deletions
|
@ -364,20 +364,20 @@ aabb3f read_aabb3f(lua_State *L, int index, f32 scale)
|
|||
return box;
|
||||
}
|
||||
|
||||
void push_aabb3f(lua_State *L, aabb3f box)
|
||||
void push_aabb3f(lua_State *L, aabb3f box, f32 divisor)
|
||||
{
|
||||
lua_createtable(L, 6, 0);
|
||||
lua_pushnumber(L, box.MinEdge.X);
|
||||
lua_pushnumber(L, box.MinEdge.X / divisor);
|
||||
lua_rawseti(L, -2, 1);
|
||||
lua_pushnumber(L, box.MinEdge.Y);
|
||||
lua_pushnumber(L, box.MinEdge.Y / divisor);
|
||||
lua_rawseti(L, -2, 2);
|
||||
lua_pushnumber(L, box.MinEdge.Z);
|
||||
lua_pushnumber(L, box.MinEdge.Z / divisor);
|
||||
lua_rawseti(L, -2, 3);
|
||||
lua_pushnumber(L, box.MaxEdge.X);
|
||||
lua_pushnumber(L, box.MaxEdge.X / divisor);
|
||||
lua_rawseti(L, -2, 4);
|
||||
lua_pushnumber(L, box.MaxEdge.Y);
|
||||
lua_pushnumber(L, box.MaxEdge.Y / divisor);
|
||||
lua_rawseti(L, -2, 5);
|
||||
lua_pushnumber(L, box.MaxEdge.Z);
|
||||
lua_pushnumber(L, box.MaxEdge.Z / divisor);
|
||||
lua_rawseti(L, -2, 6);
|
||||
}
|
||||
|
||||
|
@ -409,6 +409,16 @@ std::vector<aabb3f> read_aabb3f_vector(lua_State *L, int index, f32 scale)
|
|||
return boxes;
|
||||
}
|
||||
|
||||
void push_aabb3f_vector(lua_State *L, const std::vector<aabb3f> &boxes, f32 divisor)
|
||||
{
|
||||
lua_createtable(L, boxes.size(), 0);
|
||||
int i = 1;
|
||||
for (const aabb3f &box : boxes) {
|
||||
push_aabb3f(L, box, divisor);
|
||||
lua_rawseti(L, -2, i++);
|
||||
}
|
||||
}
|
||||
|
||||
size_t read_stringlist(lua_State *L, int index, std::vector<std::string> *result)
|
||||
{
|
||||
if (index < 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue