fix lighting settings based chunk meshes rebuilding

This commit is contained in:
MihailRis 2026-11-04 12:43:42 +03:00
parent 482f6d4a18
commit c641a18d32
2 changed files with 19 additions and 2 deletions

View file

@ -89,9 +89,25 @@ LevelScreen::LevelScreen(
resetChunks(false);
frontend->getContentGfxCache().refresh();
}));
keepAlive(settings.graphics.shadowsQuality.observe([=](int quality) {
auto graphics = &settings.graphics;
auto shadowsMeshing = std::make_shared<bool>(
graphics->shadowsQuality.get() > 0 && graphics->advancedRender.get()
);
auto updateShadowsMeshing = [=]() {
bool enabled =
graphics->shadowsQuality.get() > 0 && graphics->advancedRender.get();
if (enabled == *shadowsMeshing) {
return;
}
*shadowsMeshing = enabled;
resetChunks(false);
frontend->getContentGfxCache().refresh();
};
keepAlive(settings.graphics.shadowsQuality.observe([=](int) {
updateShadowsMeshing();
}));
keepAlive(settings.graphics.advancedRender.observe([=](bool) {
updateShadowsMeshing();
}));
keepAlive(settings.camera.fov.observe([=](double value) {
player->fpCamera->setFov(glm::radians(value));

View file

@ -696,7 +696,8 @@ SortingMeshData BlocksRenderer::renderTranslucent(
void BlocksRenderer::build(
const Chunk* chunk, const VoxelsRenderVolume& volume
) {
directionalLightFactor = settings.graphics.shadowsQuality.get() > 0.0f
directionalLightFactor = settings.graphics.shadowsQuality.get() > 0 &&
settings.graphics.advancedRender.get()
? 0.0f
: DEFAULT_DIRECTIONAL_LIGHT_FACTOR;