mirror of
https://github.com/minetest/minetest.git
synced 2025-07-05 01:10:22 +02:00
Raycast: export exact pointing location (#6304)
* Return intersection point in node coordinates. * Clarify 'intersection_point' documentation
This commit is contained in:
committed by
SmallJoker
parent
798724efea
commit
325bf68041
@ -1757,7 +1757,8 @@ void read_json_value(lua_State *L, Json::Value &root, int index, u8 recursion)
|
||||
lua_pop(L, 1); // Pop value
|
||||
}
|
||||
|
||||
void push_pointed_thing(lua_State *L, const PointedThing &pointed, bool csm)
|
||||
void push_pointed_thing(lua_State *L, const PointedThing &pointed, bool csm,
|
||||
bool hitpoint)
|
||||
{
|
||||
lua_newtable(L);
|
||||
if (pointed.type == POINTEDTHING_NODE) {
|
||||
@ -1782,6 +1783,14 @@ void push_pointed_thing(lua_State *L, const PointedThing &pointed, bool csm)
|
||||
lua_pushstring(L, "nothing");
|
||||
lua_setfield(L, -2, "type");
|
||||
}
|
||||
if (hitpoint && (pointed.type != POINTEDTHING_NOTHING)) {
|
||||
push_v3f(L, pointed.intersection_point / BS); // convert to node coords
|
||||
lua_setfield(L, -2, "intersection_point");
|
||||
push_v3s16(L, pointed.intersection_normal);
|
||||
lua_setfield(L, -2, "intersection_normal");
|
||||
lua_pushinteger(L, pointed.box_id + 1); // change to Lua array index
|
||||
lua_setfield(L, -2, "box_id");
|
||||
}
|
||||
}
|
||||
|
||||
void push_objectRef(lua_State *L, const u16 id)
|
||||
|
Reference in New Issue
Block a user