added some sanity checks
This commit is contained in:
@@ -136,6 +136,14 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** perform some sanity checks */
|
||||||
|
bool isValid() const {
|
||||||
|
if (p1 == p2) {return false;}
|
||||||
|
if (p1 == p3) {return false;}
|
||||||
|
if (p2 == p3) {return false;}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
int rayIntersectsTriangle(float *p, float *d,
|
int rayIntersectsTriangle(float *p, float *d,
|
||||||
float *v0, float *v1, float *v2) {
|
float *v0, float *v1, float *v2) {
|
||||||
|
|||||||
@@ -339,6 +339,13 @@ namespace Ray3D {
|
|||||||
|
|
||||||
const std::string& name = foo->file;
|
const std::string& name = foo->file;
|
||||||
Obstacle3D obs = OBJPool::get().getObject(name);
|
Obstacle3D obs = OBJPool::get().getObject(name);
|
||||||
|
|
||||||
|
// perform sanity checks
|
||||||
|
if (!obs.isValid()) {
|
||||||
|
throw std::runtime_error("invalid obstacle-data detected");
|
||||||
|
}
|
||||||
|
|
||||||
|
// apply scaling/rotation/translation
|
||||||
obs = obs.scaled(foo->scale);
|
obs = obs.scaled(foo->scale);
|
||||||
obs = obs.rotated_deg( Point3(foo->rot.x, foo->rot.y, foo->rot.z) );
|
obs = obs.rotated_deg( Point3(foo->rot.x, foo->rot.y, foo->rot.z) );
|
||||||
obs = obs.translated(foo->pos + Point3(0,0,fpos.z1));
|
obs = obs.translated(foo->pos + Point3(0,0,fpos.z1));
|
||||||
|
|||||||
@@ -89,6 +89,14 @@ namespace Ray3D {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** perform sanity checks */
|
||||||
|
bool isValid() const {
|
||||||
|
for (const Triangle3& t : triangles) {
|
||||||
|
if (!t.isValid()) {return false;}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user