From 439c47d3991a69d0aadb0ff2b4c9d6ec05ba708a Mon Sep 17 00:00:00 2001 From: RaveYard <29225776+MrRaveYard@users.noreply.github.com> Date: Thu, 14 Sep 2023 20:50:33 +0200 Subject: [PATCH] Enforce ZDRay limit on default sampledistance when loading LIGHTMAP to avoid surface size mismatches. --- src/maploader/maploader.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/maploader/maploader.cpp b/src/maploader/maploader.cpp index 938de75bba..ddf0a03d64 100644 --- a/src/maploader/maploader.cpp +++ b/src/maploader/maploader.cpp @@ -2963,17 +2963,20 @@ void MapLoader::InitLevelMesh(MapData* map) } } } - - // Last chance to make up our mind whether to use lightmaps or not - if (!Level->lightmaps) + + if (map->Size(ML_LIGHTMAP)) { - if (map->Size(ML_LIGHTMAP)) + // Arbitrary ZDRay limit. This will break lightmap lump loading if not enforced. + Level->LightmapSampleDistance = Level->LightmapSampleDistance < 8 ? 8 : Level->LightmapSampleDistance; + + if (!Level->lightmaps) // We are unfortunately missing ZDRayInfo { - Level->lightmaps = true; Printf(PRINT_HIGH, "InitLevelMesh: The level contains LIGHTMAP, but no ZDRayInfo thing was detected in the level.\n"); } - - Level->lightmaps = *genlightmaps; + } + else + { + Level->lightmaps = Level->lightmaps || *genlightmaps; // Allow lightmapping in non-lightmapped levels. } // Levelmesh and lightmap binding/loading