Saved Navigation Data as Asset and load on scene load #439
|
@ -29,6 +29,7 @@
|
||||||
#include "Physics/System/SHPhysicsDebugDrawSystem.h"
|
#include "Physics/System/SHPhysicsDebugDrawSystem.h"
|
||||||
#include "Camera/SHCameraSystem.h"
|
#include "Camera/SHCameraSystem.h"
|
||||||
#include "Tools/Utilities/SHClipboardUtilities.h"
|
#include "Tools/Utilities/SHClipboardUtilities.h"
|
||||||
|
#include <Navigation/SHNavigationSystem.h>
|
||||||
|
|
||||||
const std::string LAYOUT_FOLDER_PATH{ std::string(ASSET_ROOT) + "/Editor/Layouts" };
|
const std::string LAYOUT_FOLDER_PATH{ std::string(ASSET_ROOT) + "/Editor/Layouts" };
|
||||||
|
|
||||||
|
@ -93,6 +94,7 @@ namespace SHADE
|
||||||
DrawLayoutMenu();
|
DrawLayoutMenu();
|
||||||
DrawApplicationConfig();
|
DrawApplicationConfig();
|
||||||
DrawPhysicsSettings();
|
DrawPhysicsSettings();
|
||||||
|
DrawNavMenu();
|
||||||
|
|
||||||
std::string const sceneName{std::format("Current Scene: {}",SHSceneManager::GetSceneName().data())};
|
std::string const sceneName{std::format("Current Scene: {}",SHSceneManager::GetSceneName().data())};
|
||||||
auto const size = ImGui::CalcTextSize(sceneName.data());
|
auto const size = ImGui::CalcTextSize(sceneName.data());
|
||||||
|
@ -418,6 +420,38 @@ namespace SHADE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHEditorMenuBar::DrawNavMenu() noexcept
|
||||||
|
{
|
||||||
|
ImGui::SetNextWindowSize({ 400.0f, 0.0f });
|
||||||
|
if (ImGui::BeginMenu("Nav"))
|
||||||
|
{
|
||||||
|
if (auto navSystem = SHSystemManager::GetSystem<SHNavigationSystem>())
|
||||||
|
{
|
||||||
|
if (SHEditorWidgets::DragN<float, 3>("Origin", { "X", "Y", "Z" }, {&navSystem->origin_editor.x, &navSystem->origin_editor .y, &navSystem->origin_editor.z}))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
if (SHEditorWidgets::DragN<float, 3>("Size", { "X", "Y", "Z" }, { &navSystem->size_editor.x, &navSystem->size_editor.y, &navSystem->size_editor.z }))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::DragScalar("Col", ImGuiDataType_U16, &navSystem->numCols_editor)) {}
|
||||||
|
if(ImGui::DragScalar("Row", ImGuiDataType_U16, &navSystem->numRows_editor)){}
|
||||||
|
|
||||||
|
if (ImGui::Button("Generate"))
|
||||||
|
{
|
||||||
|
navSystem->Clear();
|
||||||
|
navSystem->GenerateNavigationGridData();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ namespace SHADE
|
||||||
void DrawLayoutMenu() noexcept;
|
void DrawLayoutMenu() noexcept;
|
||||||
void DrawApplicationConfig() noexcept;
|
void DrawApplicationConfig() noexcept;
|
||||||
void DrawPhysicsSettings() noexcept;
|
void DrawPhysicsSettings() noexcept;
|
||||||
|
void DrawNavMenu() noexcept;
|
||||||
|
|
||||||
float menuBarHeight = 20.0f;
|
float menuBarHeight = 20.0f;
|
||||||
std::vector<std::filesystem::path> layoutPaths;
|
std::vector<std::filesystem::path> layoutPaths;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include "Editor/SHEditor.h"
|
#include "Editor/SHEditor.h"
|
||||||
#include "Scene/SHSceneManager.h"
|
#include "Scene/SHSceneManager.h"
|
||||||
#include "Graphics/MiddleEnd/Interface/SHDebugDrawSystem.h"
|
#include "Graphics/MiddleEnd/Interface/SHDebugDrawSystem.h"
|
||||||
|
#include "Assets/SHAssetManager.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
|
@ -82,6 +82,21 @@ namespace SHADE
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SHNavigationSystem::Clear() noexcept
|
||||||
|
{
|
||||||
|
numRows = 0;
|
||||||
|
numCols = 0;
|
||||||
|
origin = SHVec3{ 0.0f };
|
||||||
|
size = SHVec3{ 0.0f };
|
||||||
|
navigationGrid.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHNavigationSystem::SaveToFile(std::string const& name) noexcept
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
SHVec3 SHNavigationSystem::GetGridWorldPos(NavigationGridIndex index) noexcept
|
SHVec3 SHNavigationSystem::GetGridWorldPos(NavigationGridIndex index) noexcept
|
||||||
{
|
{
|
||||||
SHVec3 result{0.0f};
|
SHVec3 result{0.0f};
|
||||||
|
@ -164,6 +179,11 @@ namespace SHADE
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SHNavigationSystem::GenerateNavigationGridData() noexcept
|
||||||
|
{
|
||||||
|
GenerateNavigationGridData(origin_editor, size_editor, numRows_editor, numCols_editor);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void SHNavigationSystem::NavigationSystemGenerateRoutine::Execute(double dt) noexcept
|
void SHNavigationSystem::NavigationSystemGenerateRoutine::Execute(double dt) noexcept
|
||||||
|
|
|
@ -61,8 +61,22 @@ namespace SHADE
|
||||||
virtual void Init();
|
virtual void Init();
|
||||||
virtual void Exit();
|
virtual void Exit();
|
||||||
|
|
||||||
|
|
||||||
|
//Number of subdivision on the x axis
|
||||||
|
uint16_t numRows_editor{ 0 };
|
||||||
|
//Number of subdivision on the z axis
|
||||||
|
uint16_t numCols_editor{ 0 };
|
||||||
|
|
||||||
|
//The center of the navigation area.
|
||||||
|
SHVec3 origin_editor{ 0.0f };
|
||||||
|
|
||||||
|
//Size of the navigation area
|
||||||
|
SHVec3 size_editor{ 0.0f };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void GenerateNavigationGridData(SHVec3 origin, SHVec3 size, uint16_t numRow, uint16_t numCol) noexcept;
|
void GenerateNavigationGridData(SHVec3 origin, SHVec3 size, uint16_t numRow, uint16_t numCol) noexcept;
|
||||||
|
void GenerateNavigationGridData() noexcept;
|
||||||
void GeneratePath(SHNavigationComponent& comp) noexcept;
|
void GeneratePath(SHNavigationComponent& comp) noexcept;
|
||||||
|
|
||||||
bool GetNavigationData(uint16_t row, uint16_t col) noexcept;
|
bool GetNavigationData(uint16_t row, uint16_t col) noexcept;
|
||||||
|
@ -70,8 +84,9 @@ namespace SHADE
|
||||||
|
|
||||||
|
|
||||||
NavigationGridIndex GetNavigationGridIndex(SHVec3 const& worldPosition) noexcept;
|
NavigationGridIndex GetNavigationGridIndex(SHVec3 const& worldPosition) noexcept;
|
||||||
|
void Clear() noexcept;
|
||||||
|
|
||||||
|
void SaveToFile(std::string const& name) noexcept;
|
||||||
|
|
||||||
class SH_API NavigationSystemGenerateRoutine final: public SHSystemRoutine
|
class SH_API NavigationSystemGenerateRoutine final: public SHSystemRoutine
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue