Improve room-over-room support

This commit is contained in:
KP 2024-08-04 15:38:59 -05:00
parent 1f383c2800
commit 844a5d94a3
3 changed files with 48 additions and 43 deletions

View file

@ -1,45 +1,40 @@
[03:20:37 PM] Info: Starting... [03:38:05 PM] Info: Starting...
KP3D version 2 KP3D version 2
=============================== ===============================
Copyright (C) kpworld.xyz 2018-2024 Copyright (C) kpworld.xyz 2018-2024
Contact me! @kp_cftsz Contact me! @kp_cftsz
[03:20:37 PM] Info: Initializing SDL [03:38:05 PM] Info: Initializing SDL
[03:20:37 PM] Info: Initializing OpenGL [03:38:05 PM] Info: Initializing OpenGL
[03:20:37 PM] Info: OpenGL version: 4.6.0 NVIDIA 536.23 [03:38:05 PM] Info: OpenGL version: 4.6.0 NVIDIA 536.23
[03:20:37 PM] Info: Initializing GLEW [03:38:05 PM] Info: Initializing GLEW
[03:20:37 PM] Info: Initializing SDL_mixer [03:38:05 PM] Info: Initializing SDL_mixer
[03:20:37 PM] Info: Reticulating splines... [03:38:05 PM] Info: Reticulating splines...
[03:20:37 PM] Info: Ready! [03:38:05 PM] Info: Ready!
[03:20:37 PM] Info: Loading script: build-cylinder.scm [03:38:05 PM] Info: Loading script: build-cylinder.scm
[03:20:37 PM] Info: Loading script: build-stairs.scm [03:38:05 PM] Info: Loading script: build-stairs.scm
[03:20:37 PM] Info: Loading material resource: block.png [03:38:05 PM] Info: Loading material resource: block.png
[03:20:37 PM] Info: Found normal map texture: materials/block_n.png [03:38:05 PM] Info: Found normal map texture: materials/block_n.png
[03:20:37 PM] Info: Loading material resource: brick2.jpg [03:38:05 PM] Info: Loading material resource: brick2.jpg
[03:20:37 PM] Info: Found normal map texture: materials/brick2_n.jpg [03:38:05 PM] Info: Found normal map texture: materials/brick2_n.jpg
[03:20:37 PM] Info: Loading material resource: bricks.jpg [03:38:05 PM] Info: Loading material resource: bricks.jpg
[03:20:37 PM] Info: Found normal map texture: materials/bricks_n.jpg [03:38:05 PM] Info: Found normal map texture: materials/bricks_n.jpg
[03:20:37 PM] Info: Loading material resource: FLAT5_7.png [03:38:05 PM] Info: Loading material resource: FLAT5_7.png
[03:20:37 PM] Info: Found normal map texture: materials/FLAT5_7_n.png [03:38:05 PM] Info: Found normal map texture: materials/FLAT5_7_n.png
[03:20:37 PM] Info: Loading material resource: floor0.png [03:38:05 PM] Info: Loading material resource: floor0.png
[03:20:37 PM] Info: Found normal map texture: materials/floor0_n.png [03:38:05 PM] Info: Found normal map texture: materials/floor0_n.png
[03:20:37 PM] Info: Loading material resource: floor1.png [03:38:05 PM] Info: Loading material resource: floor1.png
[03:20:37 PM] Info: Found normal map texture: materials/floor1_n.png [03:38:05 PM] Info: Found normal map texture: materials/floor1_n.png
[03:20:37 PM] Info: Loading material resource: GRASS2.png [03:38:05 PM] Info: Loading material resource: GRASS2.png
[03:20:37 PM] Info: Found normal map texture: materials/GRASS2_n.png [03:38:05 PM] Info: Found normal map texture: materials/GRASS2_n.png
[03:20:37 PM] Info: Loading material resource: hardwood.jpg [03:38:05 PM] Info: Loading material resource: hardwood.jpg
[03:20:37 PM] Info: Found normal map texture: materials/hardwood_n.jpg [03:38:05 PM] Info: Found normal map texture: materials/hardwood_n.jpg
[03:20:37 PM] Info: Map init [03:38:05 PM] Info: Map init
[03:20:37 PM] Info: Finalized mesh with 49 batches [03:38:05 PM] Info: Finalized mesh with 49 batches
[03:20:41 PM] Info: Finalized mesh with 54 batches [03:38:14 PM] Info: Finalized mesh with 54 batches
[03:20:56 PM] Info: Finalized mesh with 60 batches [03:38:15 PM] Info: Finalized mesh with 54 batches
[03:21:07 PM] Info: Finalized mesh with 67 batches [03:38:18 PM] Info: Finalized mesh with 54 batches
[03:21:13 PM] Info: Finalized mesh with 75 batches [03:38:33 PM] Info: Finalized mesh with 60 batches
[03:21:19 PM] Info: Finalized mesh with 83 batches [03:38:41 PM] Info: Finalized mesh with 68 batches
[03:21:21 PM] Info: Finalized mesh with 84 batches [03:38:41 PM] Info: Finalized mesh with 68 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

View file

@ -365,6 +365,11 @@ void Map::JoinSectors(Sector& sector)
if (s.inverted) if (s.inverted)
continue; 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_a = {ld.start.x, sector.floor.base_height, ld.start.y};
Vec3 pos_b = {ld.end.x, sector.ceiling.base_height, ld.end.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. // 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(); 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) for (const auto& sp: sectors)
{ {
Sector& sector = *sp; Sector& sector = *sp;

View file

@ -864,14 +864,17 @@ void Editor::RenderUI()
} }
if (ImGui::BeginMenu("Edit")) if (ImGui::BeginMenu("Edit"))
{ {
if (ImGui::MenuItem("Undo")) { Undo(); } if (ImGui::MenuItem("Undo")) Undo();
if (ImGui::MenuItem("Redo")) { Redo(); } if (ImGui::MenuItem("Redo")) Redo();
ImGui::EndMenu(); ImGui::EndMenu();
} }
if (ImGui::BeginMenu("View")) if (ImGui::BeginMenu("View"))
{ {
ImGui::Checkbox("Info Overlay", &show_info_overlay); ImGui::Checkbox("Info Overlay", &show_info_overlay);
ImGui::Checkbox("Selection Info", &show_selection_info); 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::Checkbox("Console", &kp3d::console::open);
ImGui::EndMenu(); ImGui::EndMenu();
} }