mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
improved code added unit test
This commit is contained in:
@@ -1,4 +1,26 @@
|
||||
//
|
||||
// Created by Vlad on 28.07.2024.
|
||||
//
|
||||
#include "omath/pathfinding/NavigationMesh.h"
|
||||
#include "omath/pathfinding/NavigationMesh.h"
|
||||
|
||||
namespace omath::pathfinding
|
||||
{
|
||||
std::expected<Vector3, std::string> NavigationMesh::GetClossestVertex(const Vector3 &point) const
|
||||
{
|
||||
const auto res = std::ranges::min_element(m_verTextMap,
|
||||
[&point](const auto& a, const auto& b)
|
||||
{
|
||||
return a.first.DistTo(point) < b.first.DistTo(point);
|
||||
});
|
||||
|
||||
if (res == m_verTextMap.cend())
|
||||
return std::unexpected("Failed to get clossest point");
|
||||
|
||||
return res->first;
|
||||
}
|
||||
|
||||
const std::vector<Vector3>& NavigationMesh::GetNeighbors(const Vector3 &vertex) const
|
||||
{
|
||||
return m_verTextMap.at(vertex);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user