From 4265b0d29b0d04c42116322ec6a45ba80ad7ef29 Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Wed, 24 Jul 2024 23:19:34 -0400 Subject: [PATCH] Added all navmesh settings to the editor UI --- .../src/ComponentsPanel/NavMeshVolumePanel.h | 285 +++++++++++++++++- 1 file changed, 277 insertions(+), 8 deletions(-) diff --git a/Editor/src/ComponentsPanel/NavMeshVolumePanel.h b/Editor/src/ComponentsPanel/NavMeshVolumePanel.h index 9843f452..ce6acc32 100644 --- a/Editor/src/ComponentsPanel/NavMeshVolumePanel.h +++ b/Editor/src/ComponentsPanel/NavMeshVolumePanel.h @@ -68,6 +68,273 @@ public: ImGui::PopStyleColor(); } + + ImGui::TableNextColumn(); + { + CompononentPropertyName("Cell Size"); + ImGui::TableNextColumn(); + + UI::FloatSlider("##cellsize", component.CellSize, 0.01f); + + ImGui::TableNextColumn(); + + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetLabel = std::string(ICON_FA_UNDO) + "##resetcellsize"; + if (ImGui::Button(resetLabel.c_str())) + { + component.CellSize = 0.2f; + } + + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + CompononentPropertyName("Cell Height"); + ImGui::TableNextColumn(); + + UI::FloatSlider("##cellHeight", component.CellHeight, 0.01f); + + ImGui::TableNextColumn(); + + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetLabel = std::string(ICON_FA_UNDO) + "##resetcellheight"; + if (ImGui::Button(resetLabel.c_str())) + { + component.CellHeight = 0.2f; + } + + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + CompononentPropertyName("Tile Size"); + ImGui::TableNextColumn(); + + UI::FloatSlider("##tilesize", component.TileSize, 0.01f); + + ImGui::TableNextColumn(); + + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetLabel = std::string(ICON_FA_UNDO) + "##resettilesize"; + if (ImGui::Button(resetLabel.c_str())) + { + component.TileSize = 10.0f; + } + + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + CompononentPropertyName("Walkable Slope Angle"); + ImGui::TableNextColumn(); + + UI::FloatSlider("##walkableslopeAngle", component.WalkableSlopeAngle, 1.0f); + + ImGui::TableNextColumn(); + + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetLabel = std::string(ICON_FA_UNDO) + "##resetwalkableslopeangle"; + if (ImGui::Button(resetLabel.c_str())) + { + component.WalkableSlopeAngle = 45.0f; + } + + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + CompononentPropertyName("Walkable Height"); + ImGui::TableNextColumn(); + + UI::FloatSlider("##WalkableHeight", component.WalkableHeight, 0.1f); + + ImGui::TableNextColumn(); + + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetLabel = std::string(ICON_FA_UNDO) + "##resetWalkableHeight"; + if (ImGui::Button(resetLabel.c_str())) + { + component.WalkableHeight = 1.0f; + } + + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + CompononentPropertyName("Walkable Radius"); + ImGui::TableNextColumn(); + + UI::FloatSlider("##WalkableRadius", component.WalkableRadius, 0.1f); + + ImGui::TableNextColumn(); + + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetLabel = std::string(ICON_FA_UNDO) + "##resetWalkableRadius"; + if (ImGui::Button(resetLabel.c_str())) + { + component.WalkableRadius = 1.0f; + } + + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + CompononentPropertyName("Walkable Climb"); + ImGui::TableNextColumn(); + + UI::FloatSlider("##WalkableClimb", component.WalkableClimb, 0.1f); + + ImGui::TableNextColumn(); + + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetLabel = std::string(ICON_FA_UNDO) + "##resetWalkableClimb"; + if (ImGui::Button(resetLabel.c_str())) + { + component.WalkableClimb = 1.0f; + } + + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + CompononentPropertyName("Max Simplification Error"); + ImGui::TableNextColumn(); + + UI::FloatSlider("##MaxSimplificationError", component.MaxSimplificationError, 0.1f); + + ImGui::TableNextColumn(); + + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetLabel = std::string(ICON_FA_UNDO) + "##resetMaxSimplificationError"; + if (ImGui::Button(resetLabel.c_str())) + { + component.MaxSimplificationError = 1.3f; + } + + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + CompononentPropertyName("Min Region Area"); + ImGui::TableNextColumn(); + + UI::FloatSlider("##MinRegionArea", component.MinRegionArea, 0.1f); + + ImGui::TableNextColumn(); + + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetLabel = std::string(ICON_FA_UNDO) + "##resetMinRegionArea"; + if (ImGui::Button(resetLabel.c_str())) + { + component.MinRegionArea = 4.f; + } + + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + CompononentPropertyName("Merge Region Area"); + ImGui::TableNextColumn(); + + UI::FloatSlider("##MergeRegionArea", component.MergeRegionArea, 0.1f); + + ImGui::TableNextColumn(); + + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetLabel = std::string(ICON_FA_UNDO) + "##resetMergeRegionArea"; + if (ImGui::Button(resetLabel.c_str())) + { + component.MergeRegionArea = 10.f; + } + + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + CompononentPropertyName("Max Edge Length"); + ImGui::TableNextColumn(); + + UI::FloatSlider("##MaxEdgeLength", component.MaxEdgeLength, 0.1f); + + ImGui::TableNextColumn(); + + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetLabel = std::string(ICON_FA_UNDO) + "##resetMaxEdgeLength"; + if (ImGui::Button(resetLabel.c_str())) + { + component.MaxEdgeLength = 12.f; + } + + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + CompononentPropertyName("MaxVertsPerPoly"); + ImGui::TableNextColumn(); + + UI::FloatSlider("##MaxVertsPerPoly", component.MaxVertsPerPoly, 2.f); + + ImGui::TableNextColumn(); + + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetLabel = std::string(ICON_FA_UNDO) + "##resetMaxVertsPerPoly"; + if (ImGui::Button(resetLabel.c_str())) + { + component.MaxVertsPerPoly = 6.f; + } + + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + CompononentPropertyName("Detail Sample Distance"); + ImGui::TableNextColumn(); + + UI::FloatSlider("##DetailSampleDistance", component.DetailSampleDistance, 0.1f); + + ImGui::TableNextColumn(); + + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetLabel = std::string(ICON_FA_UNDO) + "##resetDetailSampleDistance"; + if (ImGui::Button(resetLabel.c_str())) + { + component.DetailSampleDistance = 2.f; + } + + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + CompononentPropertyName("Detail Sample Max Error"); + ImGui::TableNextColumn(); + + UI::FloatSlider("##DetailsampleMaxError", component.DetailsampleMaxError, 0.1f); + + ImGui::TableNextColumn(); + + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetLabel = std::string(ICON_FA_UNDO) + "##resetDetailsampleMaxError"; + if (ImGui::Button(resetLabel.c_str())) + { + component.DetailsampleMaxError = 1.f; + } + + ImGui::PopStyleColor(); + } + ImGui::TableNextColumn(); { CompononentPropertyName("Generate"); @@ -82,16 +349,18 @@ public: for (auto e : view) { auto [transform, map] = view.get(e); - - for (auto& b : map.m_Brushes) + for (auto& brush : map.m_Brushes) { - if (b.HasComponent()) + if (!brush.HasComponent()) { - TransformComponent& transformComponent = b.GetComponent(); - for (auto& mesh : b.GetComponent().ModelResource->GetMeshes()) - { - Nuake::NavManager::Get().PushMesh(mesh, transformComponent.GetGlobalTransform()); - } + continue; + } + + auto& transformComponent = brush.GetComponent(); + auto& modelComponent = brush.GetComponent(); + for (auto& mesh : modelComponent.ModelResource->GetMeshes()) + { + Nuake::NavManager::Get().PushMesh(mesh, transformComponent.GetGlobalTransform()); } }