From 840d17fb1f57a48b6b66602710ec7278524eaa84 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 4 Jan 2026 01:40:54 +0000 Subject: [PATCH 1/4] Initial plan From 8cd83260cea9bf21932c7d84a8ca9d2df108855d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 4 Jan 2026 01:45:08 +0000 Subject: [PATCH 2/4] fix(TerrainShadows): clear heightmap cache when entering worldspace without heightmap - Clear cachedHeightmap, texHeightMap, and texShadowHeight when: - No worldspace is active - Current worldspace has no heightmap - Worldspace has interior-like flags (kNoSky or kFixedDimensions) - Add debug UI info showing interior-like flag, cached heightmap, and ready state - Prevents stale heightmap data from previous worldspace causing broken shadows in Markarth and similar locations Co-authored-by: alandtse <7086117+alandtse@users.noreply.github.com> --- src/Features/TerrainShadows.cpp | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/Features/TerrainShadows.cpp b/src/Features/TerrainShadows.cpp index b115b56a38..319c28ae97 100644 --- a/src/Features/TerrainShadows.cpp +++ b/src/Features/TerrainShadows.cpp @@ -27,16 +27,21 @@ void TerrainShadows::DrawSettings() if (ImGui::CollapsingHeader("Debug")) { std::string curr_worldspace = "N/A"; std::string curr_worldspace_name = "N/A"; + bool isInteriorLike = false; auto tes = RE::TES::GetSingleton(); if (tes) { auto worldspace = tes->GetRuntimeData2().worldSpace; if (worldspace) { curr_worldspace = worldspace->GetFormEditorID(); curr_worldspace_name = worldspace->GetName(); + isInteriorLike = worldspace->flags.any(RE::TESWorldSpace::Flag::kNoSky, RE::TESWorldSpace::Flag::kFixedDimensions); } } ImGui::Text(fmt::format("Current worldspace: {} ({})", curr_worldspace, curr_worldspace_name).c_str()); ImGui::Text(fmt::format("Has height map: {}", heightmaps.contains(curr_worldspace)).c_str()); + ImGui::Text(fmt::format("Interior-like worldspace: {}", isInteriorLike).c_str()); + ImGui::Text(fmt::format("Cached heightmap: {}", cachedHeightmap ? cachedHeightmap->worldspace : "none").c_str()); + ImGui::Text(fmt::format("Heightmap ready: {}", IsHeightMapReady()).c_str()); ImGui::Separator(); @@ -201,11 +206,33 @@ void TerrainShadows::LoadHeightmap() if (!tes) return; auto worldspace = tes->GetRuntimeData2().worldSpace; - if (!worldspace) + if (!worldspace) { + // No worldspace, clear cache + if (cachedHeightmap) { + logger::debug("Clearing heightmap cache - no worldspace"); + cachedHeightmap = nullptr; + texHeightMap.reset(); + texShadowHeight.reset(); + } return; + } std::string worldspace_name = worldspace->GetFormEditorID(); - if (!heightmaps.contains(worldspace_name)) // no height map for that, but we don't remove cache + + // Check for interior-like worldspaces (those with kNoSky or kFixedDimensions flags) + // These should not use terrain shadows even if a heightmap exists + bool isInteriorLike = worldspace->flags.any(RE::TESWorldSpace::Flag::kNoSky, RE::TESWorldSpace::Flag::kFixedDimensions); + + if (!heightmaps.contains(worldspace_name) || isInteriorLike) { + // No heightmap for this worldspace or it's an interior-like space + // Clear the cache to prevent using stale data from previous worldspace + if (cachedHeightmap) { + logger::debug("Clearing heightmap cache - no heightmap for worldspace {} (interior-like: {})", worldspace_name, isInteriorLike); + cachedHeightmap = nullptr; + texHeightMap.reset(); + texShadowHeight.reset(); + } return; + } if (cachedHeightmap && cachedHeightmap->worldspace == worldspace_name) // already cached return; From c938adf37cfaf3ff03e8f82bcbac886de1903635 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 4 Jan 2026 01:46:05 +0000 Subject: [PATCH 3/4] docs: finalize terrain shadows Markarth fix Co-authored-by: alandtse <7086117+alandtse@users.noreply.github.com> --- _codeql_detected_source_root | 1 + 1 file changed, 1 insertion(+) create mode 120000 _codeql_detected_source_root diff --git a/_codeql_detected_source_root b/_codeql_detected_source_root new file mode 120000 index 0000000000..945c9b46d6 --- /dev/null +++ b/_codeql_detected_source_root @@ -0,0 +1 @@ +. \ No newline at end of file From f818845da351a85a9e781a69f6afc8b3da86c180 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 4 Jan 2026 02:23:14 +0000 Subject: [PATCH 4/4] chore: remove extraneous CodeQL file and update .gitignore - Remove _codeql_detected_source_root symlink created during security scan - Add _codeql_detected_source_root to .gitignore to prevent future commits Co-authored-by: alandtse <7086117+alandtse@users.noreply.github.com> --- .gitignore | 3 +++ _codeql_detected_source_root | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) delete mode 120000 _codeql_detected_source_root diff --git a/.gitignore b/.gitignore index 645dcc62d5..e75ab471ce 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,6 @@ tests/shaders/build/ tests/shaders/*.exe tests/shaders/*.pdb tests/shaders/Shaders/ + +# CodeQL artifacts +_codeql_detected_source_root diff --git a/_codeql_detected_source_root b/_codeql_detected_source_root deleted file mode 120000 index 945c9b46d6..0000000000 --- a/_codeql_detected_source_root +++ /dev/null @@ -1 +0,0 @@ -. \ No newline at end of file