added some sanity checks

This commit is contained in:
k-a-z-u
2018-07-10 17:27:18 +02:00
parent 19d9ce3961
commit dd9116086d
3 changed files with 23 additions and 0 deletions

View File

@@ -339,6 +339,13 @@ namespace Ray3D {
const std::string& name = foo->file;
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.rotated_deg( Point3(foo->rot.x, foo->rot.y, foo->rot.z) );
obs = obs.translated(foo->pos + Point3(0,0,fpos.z1));

View File

@@ -89,6 +89,14 @@ namespace Ray3D {
return res;
}
/** perform sanity checks */
bool isValid() const {
for (const Triangle3& t : triangles) {
if (!t.isValid()) {return false;}
}
return true;
}
};
}