Set bounding sphere of RenderableModelProjection based on its geometry

This commit is contained in:
Erik Broberg
2016-08-10 17:37:30 -04:00
parent fa93a78d9f
commit 9ac5476146
3 changed files with 21 additions and 1 deletions
+15
View File
@@ -90,6 +90,21 @@ ModelGeometry::ModelGeometry(const ghoul::Dictionary& dictionary)
addProperty(_magnification);
}
double ModelGeometry::boundingRadius() const {
double maxDistSquared = 0;
double distSquared;
for (const Vertex& v : _vertices) {
distSquared = // x*x + y*y + z*z
v.location[0] * v.location[0] +
v.location[1] * v.location[1] +
v.location[2] * v.location[2];
maxDistSquared = glm::max(maxDistSquared, distSquared);
}
double maxDist = std::sqrt(maxDistSquared);
return maxDist;
}
ModelGeometry::~ModelGeometry() {
}