From 51bf54c7039440089e4180264ba04b7236d723a5 Mon Sep 17 00:00:00 2001 From: HifiExperiments Date: Fri, 12 Feb 2021 12:27:35 -0800 Subject: [PATCH] fix EntityItem::contains sphere case --- libraries/entities/src/EntityItem.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 9d3947ab56..e3112c1265 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -1764,8 +1764,7 @@ bool EntityItem::contains(const glm::vec3& point) const { // therefore we must do math using an unscaled localPoint relative to sphere center glm::vec3 dimensions = getScaledDimensions(); glm::vec3 localPoint = point - (getWorldPosition() + getWorldOrientation() * (dimensions * (ENTITY_ITEM_DEFAULT_REGISTRATION_POINT - getRegistrationPoint()) + getPivot())); - const float HALF_SQUARED = 0.25f; - return glm::length2(localPoint) < HALF_SQUARED * glm::length2(dimensions); + return glm::length2(localPoint) < glm::length2(0.5f * glm::max(dimensions.x, glm::max(dimensions.y, dimensions.z))); } // we transform into the "normalized entity-frame" where the bounding box is centered on the origin