some refactorings/fixes
worked on nav-mesh stuff new tests
This commit is contained in:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user