fix block positions rounded to float in ray casts and routes

iendpoint of block.raycast, entities.raycast and world.raycast and
nodes of a pathfinding route are integer block positions, but they were
pushed to Lua through glm::vec3. An odd coordinate above 16.7M came
back as a neighbour block.
This commit is contained in:
ostermine 2026-11-12 01:19:22 +03:00
parent 56ab3de514
commit ebd506de09
3 changed files with 3 additions and 3 deletions

View file

@ -598,7 +598,7 @@ static int l_raycast(lua::State* L) {
lua::pushnumber(L, glm::distance(start, end));
lua::setfield(L, "length");
lua::pushvec3(L, iend);
lua::pushvec(L, iend);
lua::setfield(L, "iendpoint");
lua::pushinteger(L, voxel->id);

View file

@ -184,7 +184,7 @@ static int l_push_ray(
lua::pushnumber(L, ray ? ray->distance : glm::distance(start, end));
lua::setfield(L, "length");
lua::pushvec3(L, iend);
lua::pushvec(L, iend);
lua::setfield(L, "iendpoint");
lua::pushinteger(L, block);

View file

@ -36,7 +36,7 @@ static int l_is_enabled(lua::State* L) {
static int push_route(lua::State* L, const voxels::Route& route) {
lua::createtable(L, route.nodes.size(), 1);
for (int i = 0; i < route.nodes.size(); i++) {
lua::pushvec3(L, route.nodes[i].pos);
lua::pushvec(L, route.nodes[i].pos);
lua::rawseti(L, i + 1);
}
lua::pushinteger(L, route.totalVisited);