worked on 3d models within map
adjusted grid factory adjusted nav mesh factory minoor changes/fixes new helper classes refactoring
This commit is contained in:
@@ -86,6 +86,48 @@ public:
|
||||
|
||||
}
|
||||
|
||||
/** add some slight delta to prevent rounding issues */
|
||||
bool intersectsDelta(const Ray3& ray, const double delta, Point3& pos) const {
|
||||
|
||||
const Point3 e1 = p2-p1;
|
||||
const Point3 e2 = p3-p1;
|
||||
|
||||
// make delta an absolute value (independent of the triangle's size)
|
||||
// larger triangle -> smaller delta, as u,v are [0:1]
|
||||
//double deltaU = delta/e2.length();
|
||||
//double deltaV = delta/e1.length();
|
||||
|
||||
const double deltaU = delta;
|
||||
const double deltaV = delta;
|
||||
|
||||
const Point3 h = cross(ray.dir, e2);
|
||||
const double a = dot(e1, h);
|
||||
|
||||
if (a > -0.00001 && a < 0.00001) {return false;}
|
||||
|
||||
const double f = 1/a;
|
||||
|
||||
const Point3 s = ray.start - p1;
|
||||
const double u = f * dot(s,h);
|
||||
|
||||
if (u < 0.0-deltaU || u > 1.0+deltaU) {return false;}
|
||||
|
||||
const Point3 q = cross(s, e1);
|
||||
const double v = f * dot(ray.dir, q);
|
||||
|
||||
if (v < 0.0-deltaV || u + v > 1.0+deltaV) {return false;}
|
||||
const double t = f * dot(e2,q);
|
||||
|
||||
|
||||
if (t > 0.00001) {
|
||||
pos = ray.start + (ray.dir * t);
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
int rayIntersectsTriangle(float *p, float *d,
|
||||
float *v0, float *v1, float *v2) {
|
||||
|
||||
Reference in New Issue
Block a user