Merge pull request #1058 from MihailRis/patch-0.32.7
Some checks are pending
x86-64 AppImage / build-appimage (ubuntu-22.04) (push) Waiting to run
Build / Build (push) Waiting to run
Macos Build / build-dmg (push) Waiting to run
Windows Build (CLang) / build-windows (clang, windows-latest) (push) Waiting to run
MSVC Build / build-windows (windows-2022) (push) Waiting to run

fix world.raycast
This commit is contained in:
MihailRis 2026-10-21 19:01:41 +03:00 • committed by GitHub
commit 24ba0ff2dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 8 deletions

View file

@ -682,7 +682,7 @@ static int l_get_field(lua::State* L) {
return 0;
}
auto lx = x - cx * CHUNK_W;
auto lz = z - cz * CHUNK_W;
auto lz = z - cz * CHUNK_D;
size_t voxelIndex = vox_index(lx, y, lz);
const auto& vox = chunk->voxels[voxelIndex];
@ -751,7 +751,7 @@ static int l_set_field(lua::State* L) {
auto cx = floordiv(x, CHUNK_W);
auto cz = floordiv(z, CHUNK_D);
auto lx = x - cx * CHUNK_W;
auto lz = z - cz * CHUNK_W;
auto lz = z - cz * CHUNK_D;
auto chunk = blocks_agent::get_chunk(*level.chunks, cx, cz);
if (chunk == nullptr || y < 0 || y >= CHUNK_H) {
return 0;

View file

@ -183,7 +183,7 @@ static int l_push_ray(
lua::pushvec3(L, ray ? ray->normal : normal);
lua::setfield(L, "normal");
lua::pushnumber(L, glm::distance(start, end));
lua::pushnumber(L, ray ? ray->distance : glm::distance(start, end));
lua::setfield(L, "length");
lua::pushvec3(L, iend);
@ -306,12 +306,12 @@ static int l_world_raycast(lua::State* L) {
entityRaycast.ignoredUid = lua::tointeger(L, -1);
lua::pop(L);
}
if (lua::getfield(L, "filter_entities")) {
if (lua::getfield(L, "filter_entities", 1)) {
load_entities_filter(L, -1, filteredEntities);
blocksRaycast.filter = &filteredEntities;
entityRaycast.entitiesFilter = &filteredEntities;
lua::pop(L);
}
if (lua::getfield(L, "entities_exclusion")) {
if (lua::getfield(L, "entities_exclusion", 1)) {
entityRaycast.entityFilterExcludeMode = lua::toboolean(L, -1);
lua::pop(L);
}
@ -324,7 +324,7 @@ static int l_world_raycast(lua::State* L) {
blocksRaycast.filter = &filteredBlocks;
lua::pop(L);
}
if (lua::getfield(L, "blocks_exclusion")) {
if (lua::getfield(L, "blocks_exclusion", 1)) {
blocksRaycast.blocksFilterExcludeMode = lua::toboolean(L, -1);
lua::pop(L);
}
@ -357,7 +357,7 @@ static int l_raycast(lua::State* L) {
}
}
if (luaStackSize >= 7) {
blocksRaycast.includeNonSelectable = lua::toboolean(L, 6);
blocksRaycast.includeNonSelectable = lua::toboolean(L, 7);
}
return l_raycast(
L, start, dir, maxDistance, blocksRaycast, entityRaycast, true