mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
added additional methods
This commit is contained in:
@@ -30,6 +30,8 @@ namespace omath::pathfinding
|
|||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
const std::vector<Vector3>& GetNeighbors(const Vector3& vertex) const;
|
const std::vector<Vector3>& GetNeighbors(const Vector3& vertex) const;
|
||||||
|
|
||||||
|
[[nodiscard]]
|
||||||
|
bool Empty() const;
|
||||||
[[nodiscard]] std::vector<uint8_t> Serialize() const;
|
[[nodiscard]] std::vector<uint8_t> Serialize() const;
|
||||||
void Deserialize(const std::vector<uint8_t>& raw);
|
void Deserialize(const std::vector<uint8_t>& raw);
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include <optional>
|
#include <optional>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
||||||
namespace omath::pathfinding
|
namespace omath::pathfinding
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include "omath/pathfinding/NavigationMesh.h"
|
#include "omath/pathfinding/NavigationMesh.h"
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <algorithm>
|
||||||
namespace omath::pathfinding
|
namespace omath::pathfinding
|
||||||
{
|
{
|
||||||
std::expected<Vector3, std::string> NavigationMesh::GetClossestVertex(const Vector3 &point) const
|
std::expected<Vector3, std::string> NavigationMesh::GetClossestVertex(const Vector3 &point) const
|
||||||
@@ -26,6 +26,11 @@ namespace omath::pathfinding
|
|||||||
return m_verTextMap.at(vertex);
|
return m_verTextMap.at(vertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NavigationMesh::Empty() const
|
||||||
|
{
|
||||||
|
return m_verTextMap.empty();
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<uint8_t> NavigationMesh::Serialize() const
|
std::vector<uint8_t> NavigationMesh::Serialize() const
|
||||||
{
|
{
|
||||||
auto dumpToVector =[]<typename T>(const T& t, std::vector<uint8_t>& vec){
|
auto dumpToVector =[]<typename T>(const T& t, std::vector<uint8_t>& vec){
|
||||||
@@ -58,7 +63,7 @@ namespace omath::pathfinding
|
|||||||
{
|
{
|
||||||
throw std::runtime_error("Deserialize: Invalid input data size.");
|
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);
|
offset += sizeof(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user