diff --git a/include/omath/pathfinding/Astar.h b/include/omath/pathfinding/Astar.h index 0525679..64bfc88 100644 --- a/include/omath/pathfinding/Astar.h +++ b/include/omath/pathfinding/Astar.h @@ -10,7 +10,7 @@ namespace omath::pathfinding { - class Astar + class Astar final { public: [[nodiscard]] diff --git a/include/omath/pathfinding/NavigationMesh.h b/include/omath/pathfinding/NavigationMesh.h index 7b4ffa6..11e08bb 100644 --- a/include/omath/pathfinding/NavigationMesh.h +++ b/include/omath/pathfinding/NavigationMesh.h @@ -12,19 +12,12 @@ namespace omath::pathfinding { - struct NavigationVertex - { - Vector3 origin; - std::vector connections; - }; - - class NavigationMesh final { public: [[nodiscard]] - std::expected GetClossestVertex(const Vector3& point) const; + std::expected GetClosestVertex(const Vector3& point) const; [[nodiscard]] diff --git a/include/omath/prediction/Target.h b/include/omath/prediction/Target.h index bb21fb0..0332c53 100644 --- a/include/omath/prediction/Target.h +++ b/include/omath/prediction/Target.h @@ -13,7 +13,15 @@ namespace omath::prediction public: [[nodiscard]] - Vector3 PredictPosition(float time, float gravity) const; + constexpr Vector3 PredictPosition(float time, float gravity) const + { + auto predicted = m_origin + m_velocity * time; + + if (m_isAirborne) + predicted.z -= gravity * std::pow(time, 2.f) * 0.5f; + + return predicted; + } Vector3 m_origin; Vector3 m_velocity; diff --git a/source/pathfinding/Astar.cpp b/source/pathfinding/Astar.cpp index a5002e9..10a03e9 100644 --- a/source/pathfinding/Astar.cpp +++ b/source/pathfinding/Astar.cpp @@ -23,8 +23,8 @@ namespace omath::pathfinding std::unordered_map closedList; std::unordered_map openList; - const auto startVertex = navMesh.GetClossestVertex(start).value(); - const auto endVertex = navMesh.GetClossestVertex(end).value(); + const auto startVertex = navMesh.GetClosestVertex(start).value(); + const auto endVertex = navMesh.GetClosestVertex(end).value(); openList.emplace(startVertex, PathNode{std::nullopt, 0.f}); diff --git a/source/pathfinding/NavigationMesh.cpp b/source/pathfinding/NavigationMesh.cpp index 766558e..8b96248 100644 --- a/source/pathfinding/NavigationMesh.cpp +++ b/source/pathfinding/NavigationMesh.cpp @@ -7,7 +7,7 @@ #include namespace omath::pathfinding { - std::expected NavigationMesh::GetClossestVertex(const Vector3 &point) const + std::expected NavigationMesh::GetClosestVertex(const Vector3 &point) const { const auto res = std::ranges::min_element(m_verTextMap, [&point](const auto& a, const auto& b) diff --git a/source/prediction/Target.cpp b/source/prediction/Target.cpp index 64c58a1..3b4c2da 100644 --- a/source/prediction/Target.cpp +++ b/source/prediction/Target.cpp @@ -3,18 +3,9 @@ // #include "omath/prediction/Target.h" -#include namespace omath::prediction { - Vector3 Target::PredictPosition(const float time, const float gravity) const - { - auto predicted = m_origin + m_velocity * time; - if (m_isAirborne) - predicted.z -= gravity * std::pow(time, 2.f) * 0.5f; - - return predicted; - } }