From bda72025af1ea7dd49a5bfe71a8894f3a5e1662e Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 23 Apr 2015 16:40:40 +0200 Subject: [PATCH] Check mesh extend before going through triangles --- libraries/entities/src/EntityItem.cpp | 2 +- libraries/fbx/src/FBXReader.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index ea012922b8..7c47dadd2f 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -1060,7 +1060,7 @@ float EntityItem::getRadius() const { return 0.5f * glm::length(_dimensions); } -bool EntityItem::contains(const glm::vec3 &point) const { +bool EntityItem::contains(const glm::vec3& point) const { switch (getShapeType()) { case SHAPE_TYPE_BOX: { // Transform point to be in a space where the box is a 1m cube centered on the origin. diff --git a/libraries/fbx/src/FBXReader.cpp b/libraries/fbx/src/FBXReader.cpp index 95cd99852f..1c89ee4067 100644 --- a/libraries/fbx/src/FBXReader.cpp +++ b/libraries/fbx/src/FBXReader.cpp @@ -127,6 +127,10 @@ Extents FBXGeometry::getUnscaledMeshExtents() const { // TODO: Move to model::Mesh when Sam's ready bool FBXGeometry::convexHullContains(const glm::vec3& point) const { + if (!getUnscaledMeshExtents().containsPoint(point)) { + return false; + } + auto checkEachPrimitive = [=](FBXMesh& mesh, QVector indices, int primitiveSize) -> bool { // Check whether the point is "behind" all the primitives. for (unsigned int j = 0; j < indices.size(); j += primitiveSize) {