be more defensive in FBXGeometry::convexHullContains

This commit is contained in:
Seth Alves 2016-03-22 11:24:12 -07:00
parent f57332e4be
commit 47fb85eaeb

View file

@ -78,10 +78,14 @@ bool FBXGeometry::convexHullContains(const glm::vec3& point) const {
auto checkEachPrimitive = [=](FBXMesh& mesh, QVector<int> indices, int primitiveSize) -> bool {
// Check whether the point is "behind" all the primitives.
int verticesSize = mesh.vertices.size();
for (int j = 0;
j < indices.size() - 2; // -2 in case the vertices aren't the right size -- we access j + 2 below
j += primitiveSize) {
if (!isPointBehindTrianglesPlane(point,
if (indices[j] < verticesSize &&
indices[j + 1] < verticesSize &&
indices[j + 2] < verticesSize &&
!isPointBehindTrianglesPlane(point,
mesh.vertices[indices[j]],
mesh.vertices[indices[j + 1]],
mesh.vertices[indices[j + 2]])) {