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

@@ -185,6 +185,7 @@ namespace NM {
w = 1-u-v;
}
/** barycentric interpolation at Point p for val1@p1, val2@p2, val3@p3 */
template <typename T> T interpolate(const Point3 p, const T val1, const T val2, const T val3) const {
float u, v, w;
@@ -194,6 +195,9 @@ namespace NM {
}
/** does the triangle contain the given 3D point? */
bool contains(const Point3 p) const {
return (minZ <= p.z) && (maxZ >= p.z) && contains(p.xy());
@@ -245,6 +249,21 @@ namespace NM {
}
/** nearest point on the triangle */
Point3 toPoint3Near(const Point2 p) const {
float u, v;
getUV(p, u, v);
if (u < 0) {u = 0;}
if (u > 1) {u = 1;}
if (v < 0) {v = 0;}
if (v > 1) {v = 1;}
return getPoint(u,v);
}
/** get the triangle's size */