some refactorings/fixes

worked on nav-mesh stuff
new tests
This commit is contained in:
k-a-z-u
2018-01-24 11:27:11 +01:00
parent c9d02d440a
commit 1a1f249e9b
10 changed files with 70 additions and 264 deletions

View File

@@ -11,7 +11,9 @@
namespace NM {
/** distance/neighbor-to-the target for each of the 3 triangle edge points */
struct NavMeshTriangleDijkstra {
class NavMeshTriangleDijkstra {
public:
/** next hop towards the pedestrian's target */
struct ToTarget {
@@ -47,8 +49,12 @@ namespace NM {
ToTarget spFromP3;
/** interpolate the distance towards the garget for the given point */
template <typename T> float getDistanceToDestination(const Point3 p) const {
return T::interpolate(p, spFromP1.distance, spFromP2.distance, spFromP3.distance);
template <typename UserTriangleClass> float getDistanceToDestination(const Point3 p) const {
// this one is a little bit awkward.. normally NavMeshTriangleDijkstra should extend NavMeshTriangle..
// however, this often yields issues for user-classes, extending NavMeshTriangle more than once
StaticAssert::AinheritsB<UserTriangleClass, NavMeshTriangle>();
const UserTriangleClass* userClass = static_cast<const UserTriangleClass*>(this); // must inherit NavMeshTriangle
return userClass->interpolate(p, spFromP1.distance, spFromP2.distance, spFromP3.distance);
}
/** get the next neighbor-point/triangle for the given point */