Merge branch 'main' into dev

This commit is contained in:
MihailRis 2026-10-27 13:03:13 +03:00
commit 575bfb28e0
14 changed files with 95 additions and 31 deletions

View file

@ -124,7 +124,7 @@ static int l_set(lua::State* L) {
auto chunksController = controller->getChunksController();
if (chunksController == nullptr) {
return 1;
return 0;
}
if (chunksController->lighting) {
Lighting& lighting = *chunksController->lighting;
@ -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