diff --git a/include/omath/pathfinding/NavigationMesh.h b/include/omath/pathfinding/NavigationMesh.h index 6143eff..7b4ffa6 100644 --- a/include/omath/pathfinding/NavigationMesh.h +++ b/include/omath/pathfinding/NavigationMesh.h @@ -30,6 +30,8 @@ namespace omath::pathfinding [[nodiscard]] const std::vector& GetNeighbors(const Vector3& vertex) const; + [[nodiscard]] + bool Empty() const; [[nodiscard]] std::vector Serialize() const; void Deserialize(const std::vector& raw); diff --git a/source/pathfinding/Astar.cpp b/source/pathfinding/Astar.cpp index 06f2090..a5002e9 100644 --- a/source/pathfinding/Astar.cpp +++ b/source/pathfinding/Astar.cpp @@ -6,6 +6,7 @@ #include #include #include +#include namespace omath::pathfinding diff --git a/source/pathfinding/NavigationMesh.cpp b/source/pathfinding/NavigationMesh.cpp index b09e33d..766558e 100644 --- a/source/pathfinding/NavigationMesh.cpp +++ b/source/pathfinding/NavigationMesh.cpp @@ -4,7 +4,7 @@ #include "omath/pathfinding/NavigationMesh.h" #include - +#include namespace omath::pathfinding { std::expected NavigationMesh::GetClossestVertex(const Vector3 &point) const @@ -26,6 +26,11 @@ namespace omath::pathfinding return m_verTextMap.at(vertex); } + bool NavigationMesh::Empty() const + { + return m_verTextMap.empty(); + } + std::vector NavigationMesh::Serialize() const { auto dumpToVector =[](const T& t, std::vector& vec){ @@ -58,7 +63,7 @@ namespace omath::pathfinding { throw std::runtime_error("Deserialize: Invalid input data size."); } - std::memcpy(&value, vec.data() + offset, sizeof(value)); + std::copy_n(vec.data() + offset, sizeof(value), (uint8_t*)&value); offset += sizeof(value); };