From 4771fa5f278316a60e589f5adcf6f6bcf940e59e Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 15 Jan 2019 09:17:48 -0800 Subject: [PATCH] fix zones using FBX models with non-trivial mesh.modelTransform --- libraries/hfm/src/hfm/HFM.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/hfm/src/hfm/HFM.cpp b/libraries/hfm/src/hfm/HFM.cpp index b9e630456d..e247984bbf 100644 --- a/libraries/hfm/src/hfm/HFM.cpp +++ b/libraries/hfm/src/hfm/HFM.cpp @@ -205,6 +205,8 @@ bool HFMModel::convexHullContains(const glm::vec3& point) const { auto checkEachPrimitive = [=](HFMMesh& mesh, QVector indices, int primitiveSize) -> bool { // Check whether the point is "behind" all the primitives. + // But first must transform from model-frame into mesh-frame + glm::vec3 transformedPoint = glm::vec3(glm::inverse(mesh.modelTransform) * glm::vec4(point, 1.0f)); 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 @@ -212,7 +214,7 @@ bool HFMModel::convexHullContains(const glm::vec3& point) const { if (indices[j] < verticesSize && indices[j + 1] < verticesSize && indices[j + 2] < verticesSize && - !isPointBehindTrianglesPlane(point, + !isPointBehindTrianglesPlane(transformedPoint, mesh.vertices[indices[j]], mesh.vertices[indices[j + 1]], mesh.vertices[indices[j + 2]])) {