Moved nav mesh generation button onto navmeshVolume component.

This commit is contained in:
Antoine Pilote
2024-07-24 21:14:23 -04:00
parent 493a1c076f
commit 7b1d930b9f
2 changed files with 48 additions and 0 deletions

View File

@@ -48,6 +48,26 @@ public:
ImGui::PopStyleColor();
}
ImGui::TableNextColumn();
{
CompononentPropertyName("Only include map");
ImGui::TableNextColumn();
Vector3 volumeSize = component.VolumeSize;
UI::CheckBox("##onlyIncludeMapGeo", component.OnlyIncludeMapGeometry);
ImGui::TableNextColumn();
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0));
std::string resetLabel = std::string(ICON_FA_UNDO) + "##ResetOnlyIncludeGeo";
if (ImGui::Button(resetLabel.c_str()))
{
component.OnlyIncludeMapGeometry = true;
}
ImGui::PopStyleColor();
}
ImGui::TableNextColumn();
{
CompononentPropertyName("Generate");
@@ -55,7 +75,28 @@ public:
if (UI::SecondaryButton("Generate"))
{
if (component.OnlyIncludeMapGeometry)
{
auto view = Engine::GetCurrentScene()->m_Registry.view<TransformComponent, QuakeMapComponent>();
for (auto e : view)
{
auto [transform, map] = view.get<TransformComponent, QuakeMapComponent>(e);
for (auto& b : map.m_Brushes)
{
if (b.HasComponent<ModelComponent>())
{
TransformComponent& transformComponent = b.GetComponent<TransformComponent>();
for (auto& mesh : b.GetComponent<ModelComponent>().ModelResource->GetMeshes())
{
Nuake::NavManager::Get().PushMesh(mesh, transformComponent.GetGlobalTransform());
}
}
}
NavManager::Get().BuildNavMesh();
}
}
}
ImGui::TableNextColumn();