From 844a5d94a32dc343c3e06ddf0d7f1ab107b915f3 Mon Sep 17 00:00:00 2001 From: KP Date: Sun, 4 Aug 2024 15:38:59 -0500 Subject: [PATCH] Improve room-over-room support --- Data/sandbox-log.txt | 73 +++++++++++++++++++---------------------- KP3Dii/src/KP3D_Map.cpp | 11 +++++-- Sandbox/src/Editor.cpp | 7 ++-- 3 files changed, 48 insertions(+), 43 deletions(-) diff --git a/Data/sandbox-log.txt b/Data/sandbox-log.txt index 806d1ca..69b9315 100644 --- a/Data/sandbox-log.txt +++ b/Data/sandbox-log.txt @@ -1,45 +1,40 @@ -[03:20:37 PM] Info: Starting... +[03:38:05 PM] Info: Starting... KP3D version 2 =============================== Copyright (C) kpworld.xyz 2018-2024 Contact me! @kp_cftsz -[03:20:37 PM] Info: Initializing SDL -[03:20:37 PM] Info: Initializing OpenGL -[03:20:37 PM] Info: OpenGL version: 4.6.0 NVIDIA 536.23 -[03:20:37 PM] Info: Initializing GLEW -[03:20:37 PM] Info: Initializing SDL_mixer -[03:20:37 PM] Info: Reticulating splines... -[03:20:37 PM] Info: Ready! -[03:20:37 PM] Info: Loading script: build-cylinder.scm -[03:20:37 PM] Info: Loading script: build-stairs.scm -[03:20:37 PM] Info: Loading material resource: block.png -[03:20:37 PM] Info: Found normal map texture: materials/block_n.png -[03:20:37 PM] Info: Loading material resource: brick2.jpg -[03:20:37 PM] Info: Found normal map texture: materials/brick2_n.jpg -[03:20:37 PM] Info: Loading material resource: bricks.jpg -[03:20:37 PM] Info: Found normal map texture: materials/bricks_n.jpg -[03:20:37 PM] Info: Loading material resource: FLAT5_7.png -[03:20:37 PM] Info: Found normal map texture: materials/FLAT5_7_n.png -[03:20:37 PM] Info: Loading material resource: floor0.png -[03:20:37 PM] Info: Found normal map texture: materials/floor0_n.png -[03:20:37 PM] Info: Loading material resource: floor1.png -[03:20:37 PM] Info: Found normal map texture: materials/floor1_n.png -[03:20:37 PM] Info: Loading material resource: GRASS2.png -[03:20:37 PM] Info: Found normal map texture: materials/GRASS2_n.png -[03:20:37 PM] Info: Loading material resource: hardwood.jpg -[03:20:37 PM] Info: Found normal map texture: materials/hardwood_n.jpg -[03:20:37 PM] Info: Map init -[03:20:37 PM] Info: Finalized mesh with 49 batches -[03:20:41 PM] Info: Finalized mesh with 54 batches -[03:20:56 PM] Info: Finalized mesh with 60 batches -[03:21:07 PM] Info: Finalized mesh with 67 batches -[03:21:13 PM] Info: Finalized mesh with 75 batches -[03:21:19 PM] Info: Finalized mesh with 83 batches -[03:21:21 PM] Info: Finalized mesh with 84 batches -[03:21:36 PM] Info: Finalized mesh with 91 batches -[03:21:37 PM] Info: Finalized mesh with 92 batches -[03:21:47 PM] Info: Finalized mesh with 99 batches -[03:21:49 PM] Info: Finalized mesh with 107 batches -[03:21:49 PM] Info: Finalized mesh with 108 batches +[03:38:05 PM] Info: Initializing SDL +[03:38:05 PM] Info: Initializing OpenGL +[03:38:05 PM] Info: OpenGL version: 4.6.0 NVIDIA 536.23 +[03:38:05 PM] Info: Initializing GLEW +[03:38:05 PM] Info: Initializing SDL_mixer +[03:38:05 PM] Info: Reticulating splines... +[03:38:05 PM] Info: Ready! +[03:38:05 PM] Info: Loading script: build-cylinder.scm +[03:38:05 PM] Info: Loading script: build-stairs.scm +[03:38:05 PM] Info: Loading material resource: block.png +[03:38:05 PM] Info: Found normal map texture: materials/block_n.png +[03:38:05 PM] Info: Loading material resource: brick2.jpg +[03:38:05 PM] Info: Found normal map texture: materials/brick2_n.jpg +[03:38:05 PM] Info: Loading material resource: bricks.jpg +[03:38:05 PM] Info: Found normal map texture: materials/bricks_n.jpg +[03:38:05 PM] Info: Loading material resource: FLAT5_7.png +[03:38:05 PM] Info: Found normal map texture: materials/FLAT5_7_n.png +[03:38:05 PM] Info: Loading material resource: floor0.png +[03:38:05 PM] Info: Found normal map texture: materials/floor0_n.png +[03:38:05 PM] Info: Loading material resource: floor1.png +[03:38:05 PM] Info: Found normal map texture: materials/floor1_n.png +[03:38:05 PM] Info: Loading material resource: GRASS2.png +[03:38:05 PM] Info: Found normal map texture: materials/GRASS2_n.png +[03:38:05 PM] Info: Loading material resource: hardwood.jpg +[03:38:05 PM] Info: Found normal map texture: materials/hardwood_n.jpg +[03:38:05 PM] Info: Map init +[03:38:05 PM] Info: Finalized mesh with 49 batches +[03:38:14 PM] Info: Finalized mesh with 54 batches +[03:38:15 PM] Info: Finalized mesh with 54 batches +[03:38:18 PM] Info: Finalized mesh with 54 batches +[03:38:33 PM] Info: Finalized mesh with 60 batches +[03:38:41 PM] Info: Finalized mesh with 68 batches +[03:38:41 PM] Info: Finalized mesh with 68 batches diff --git a/KP3Dii/src/KP3D_Map.cpp b/KP3Dii/src/KP3D_Map.cpp index de088b9..711b432 100644 --- a/KP3Dii/src/KP3D_Map.cpp +++ b/KP3Dii/src/KP3D_Map.cpp @@ -365,6 +365,11 @@ void Map::JoinSectors(Sector& sector) if (s.inverted) continue; + if (s.floor.base_height >= sector.ceiling.base_height) + continue; + if (sector.floor.base_height >= s.ceiling.base_height) + continue; + Vec3 pos_a = {ld.start.x, sector.floor.base_height, ld.start.y}; Vec3 pos_b = {ld.end.x, sector.ceiling.base_height, ld.end.y}; @@ -657,9 +662,11 @@ void Map::Rebuild(NormalGenType gen_normals) } // Now perform the process of "parenting" sectors; this essentially takes in our flat list of sectors and creates a hierarchy. - std::sort(sectors.begin(), sectors.end(), [](const auto& a, const auto& b) { return a->area < b->area; }); + // Note: For better room-over-room support we should consider changing this to also consider floor/ceiling heights, otherwise + // it'll break. + std::sort(sectors.begin(), sectors.end(), [](const auto& a, const auto& b) { return a->floor.base_height < b->ceiling.base_height && a->area < b->area; }); SanitizeSectors(); - std::sort(sectors.begin(), sectors.end(), [](const auto& a, const auto& b) { return a->area < b->area; }); + std::sort(sectors.begin(), sectors.end(), [](const auto& a, const auto& b) { return a->floor.base_height < b->ceiling.base_height && a->area < b->area; }); for (const auto& sp: sectors) { Sector& sector = *sp; diff --git a/Sandbox/src/Editor.cpp b/Sandbox/src/Editor.cpp index d1bd054..26c4a14 100644 --- a/Sandbox/src/Editor.cpp +++ b/Sandbox/src/Editor.cpp @@ -864,14 +864,17 @@ void Editor::RenderUI() } if (ImGui::BeginMenu("Edit")) { - if (ImGui::MenuItem("Undo")) { Undo(); } - if (ImGui::MenuItem("Redo")) { Redo(); } + if (ImGui::MenuItem("Undo")) Undo(); + if (ImGui::MenuItem("Redo")) Redo(); ImGui::EndMenu(); } if (ImGui::BeginMenu("View")) { ImGui::Checkbox("Info Overlay", &show_info_overlay); ImGui::Checkbox("Selection Info", &show_selection_info); + ImGui::Separator(); + ImGui::Checkbox("Wireframe", &sandbox->map.render_wireframe); + ImGui::Separator(); ImGui::Checkbox("Console", &kp3d::console::open); ImGui::EndMenu(); }