Now only drawing navmesh if selected + properly serialized

This commit is contained in:
Antoine Pilote
2024-08-05 23:48:41 -04:00
parent 67b5a94613
commit ca1d17e058
8 changed files with 47 additions and 34 deletions
+1 -7
View File
@@ -278,15 +278,9 @@ namespace Nuake {
Logger::Log("Could not init Detour navmesh query", "NavManager", CRITICAL);
}
Ref<NavMesh> navMesh = CreateRef<NavMesh>(m_DetourNavMesh, m_DetourNavQuery);
const std::string& deserializedNavMesh = navMesh->Serialize().dump(4);
Logger::Log(deserializedNavMesh, "debug", VERBOSE);
Ref<NavMesh> navMesh2 = CreateRef<NavMesh>();
navMesh->Deserialize(json::parse(deserializedNavMesh));
m_Meshes.clear();
Ref<NavMesh> navMesh = CreateRef<NavMesh>(m_DetourNavMesh, m_DetourNavQuery);
return navMesh;
}
+7
View File
@@ -21,6 +21,13 @@ namespace Nuake {
json Serialize() override;
bool Deserialize(const json& j) override;
bool IsValid() const
{
return m_DetourNavMesh != nullptr && m_DetourNavQuery != nullptr;
}
dtNavMesh* GetNavMesh() const { return m_DetourNavMesh; }
private:
const dtMeshTile* GetTile(int i) const;
@@ -1,6 +1,7 @@
#pragma once
#include "../Entities/Entity.h"
#include "Engine.h"
#include <src/AI/NavMesh.h>
namespace Nuake
{
@@ -25,12 +26,14 @@ namespace Nuake
float DetailSampleDistance = 2.0f;
float DetailsampleMaxError = 1.0f;
Ref<NavMesh> NavMeshData;
json Serialize()
{
BEGIN_SERIALIZE();
SERIALIZE_VEC3(VolumeSize);
SERIALIZE_VAL(OnlyIncludeMapGeometry);
SERIALIZE_OBJECT(NavMeshData);
// Generation config
END_SERIALIZE();
}
@@ -47,6 +50,12 @@ namespace Nuake
DESERIALIZE_VAL(OnlyIncludeMapGeometry);
}
if (j.contains("NavMeshData"))
{
NavMeshData = CreateRef<NavMesh>();
NavMeshData->Deserialize(j["NavMeshData"]);
}
return true;
}
};