fix chunk meshes refresh in some cases

This commit is contained in:
MihailRis 2026-03-16 19:24:50 +03:00
parent 6cccb3876b
commit 9e6ff82e88
2 changed files with 3 additions and 2 deletions

View file

@ -126,12 +126,12 @@ const ChunkMesh* ChunksRenderer::render(
const std::shared_ptr<Chunk>& chunk, bool important, bool lowPriority const std::shared_ptr<Chunk>& chunk, bool important, bool lowPriority
) { ) {
glm::ivec2 key(chunk->x, chunk->z); glm::ivec2 key(chunk->x, chunk->z);
chunk->flags.modified = false;
if (important) { if (important) {
ChunkMesh mesh {}; ChunkMesh mesh {};
auto voxelsBuffer = prepareVoxelsVolume(*chunk); auto voxelsBuffer = prepareVoxelsVolume(*chunk);
mesh = renderer->render(chunk.get(), *voxelsBuffer); mesh = renderer->render(chunk.get(), *voxelsBuffer);
meshes[key] = std::move(mesh); meshes[key] = std::move(mesh);
chunk->flags.modified = false;
return &meshes[key]; return &meshes[key];
} }
if (inwork.find(key) != inwork.end() || if (inwork.find(key) != inwork.end() ||
@ -140,6 +140,7 @@ const ChunkMesh* ChunksRenderer::render(
lowPriority)) { lowPriority)) {
return nullptr; return nullptr;
} }
chunk->flags.modified = false;
enqueuedInFrame++; enqueuedInFrame++;
auto voxelsBuffer = prepareVoxelsVolume(*chunk); auto voxelsBuffer = prepareVoxelsVolume(*chunk);
threadPool.enqueueJob({chunk, std::move(voxelsBuffer)}); threadPool.enqueueJob({chunk, std::move(voxelsBuffer)});

View file

@ -100,7 +100,7 @@ static int l_seek_origin(lua::State* L) {
auto z = lua::tointeger(L, 3); auto z = lua::tointeger(L, 3);
const auto& level = require_level(); const auto& level = require_level();
const auto& vox = blocks_agent::require(*level.chunks, x, y, z); const auto& vox = blocks_agent::require(*level.chunks, x, y, z);
auto& def = indices->blocks.require(vox.id); const auto& def = indices->blocks.require(vox.id);
return lua::pushivec_stack( return lua::pushivec_stack(
L, blocks_agent::seek_origin(*level.chunks, {x, y, z}, def, vox.state) L, blocks_agent::seek_origin(*level.chunks, {x, y, z}, def, vox.state)
); );