From cea97aa317389b538c345725c810bea44762c75b Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 17 Mar 2016 10:55:24 -0700 Subject: [PATCH 1/2] fix FBXGeometry::convexHullContains crash --- libraries/fbx/src/FBXReader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fbx/src/FBXReader.cpp b/libraries/fbx/src/FBXReader.cpp index a63cf78393..223a633365 100644 --- a/libraries/fbx/src/FBXReader.cpp +++ b/libraries/fbx/src/FBXReader.cpp @@ -76,7 +76,7 @@ bool FBXGeometry::convexHullContains(const glm::vec3& point) const { auto checkEachPrimitive = [=](FBXMesh& mesh, QVector indices, int primitiveSize) -> bool { // Check whether the point is "behind" all the primitives. - for (int j = 0; j < indices.size(); j += primitiveSize) { + for (int j = 0; j < indices.size() - 2; j += primitiveSize) { if (!isPointBehindTrianglesPlane(point, mesh.vertices[indices[j]], mesh.vertices[indices[j + 1]], From 87dbec8974ca4cecc61fc7d0f67f07b658deffb9 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 17 Mar 2016 14:43:00 -0700 Subject: [PATCH 2/2] add comment --- libraries/fbx/src/FBXReader.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/fbx/src/FBXReader.cpp b/libraries/fbx/src/FBXReader.cpp index 223a633365..cf11706ede 100644 --- a/libraries/fbx/src/FBXReader.cpp +++ b/libraries/fbx/src/FBXReader.cpp @@ -76,7 +76,9 @@ bool FBXGeometry::convexHullContains(const glm::vec3& point) const { auto checkEachPrimitive = [=](FBXMesh& mesh, QVector indices, int primitiveSize) -> bool { // Check whether the point is "behind" all the primitives. - for (int j = 0; j < indices.size() - 2; j += primitiveSize) { + 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, mesh.vertices[indices[j]], mesh.vertices[indices[j + 1]],