mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-09 20:08:57 +03:00
Moved nav mesh generation button onto navmeshVolume component.
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -7,11 +7,13 @@ namespace Nuake
|
||||
struct NavMeshVolumeComponent
|
||||
{
|
||||
Vector3 VolumeSize = { 1.0f, 1.0f, 1.0f };
|
||||
bool OnlyIncludeMapGeometry = true;
|
||||
|
||||
json Serialize()
|
||||
{
|
||||
BEGIN_SERIALIZE();
|
||||
SERIALIZE_VEC3(VolumeSize);
|
||||
SERIALIZE_VAL(OnlyIncludeMapGeometry);
|
||||
END_SERIALIZE();
|
||||
}
|
||||
|
||||
@@ -22,6 +24,11 @@ namespace Nuake
|
||||
DESERIALIZE_VEC3(j["VolumeSize"], VolumeSize);
|
||||
}
|
||||
|
||||
if (j.contains("OnlyIncludeMapGeometry"))
|
||||
{
|
||||
DESERIALIZE_VAL(OnlyIncludeMapGeometry);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user