From a5005deba7a4b299ef953c458532397abeba01a4 Mon Sep 17 00:00:00 2001 From: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> Date: Wed, 22 Dec 2021 16:57:36 -0800 Subject: [PATCH] Removes BoundingSphere from Gems/EMotionFX Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> --- .../Code/MCore/Source/BoundingSphere.cpp | 106 ------------------ .../Code/MCore/Source/BoundingSphere.h | 26 ----- Gems/EMotionFX/Code/MCore/mcore_files.cmake | 1 - 3 files changed, 133 deletions(-) delete mode 100644 Gems/EMotionFX/Code/MCore/Source/BoundingSphere.cpp diff --git a/Gems/EMotionFX/Code/MCore/Source/BoundingSphere.cpp b/Gems/EMotionFX/Code/MCore/Source/BoundingSphere.cpp deleted file mode 100644 index 376052563f..0000000000 --- a/Gems/EMotionFX/Code/MCore/Source/BoundingSphere.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -// include required headers -#include "BoundingSphere.h" -#include "AABB.h" - - -namespace MCore -{ - // encapsulate a point in the sphere - void BoundingSphere::Encapsulate(const AZ::Vector3& v) - { - // calculate the squared distance from the center to the point - const AZ::Vector3 diff = v - m_center; - const float dist = diff.Dot(diff); - - // if the current sphere doesn't contain the point, grow the sphere so that it contains the point - if (dist > m_radiusSq) - { - const AZ::Vector3 diff2 = diff.GetNormalized() * m_radius; - const AZ::Vector3 delta = 0.5f * (diff - diff2); - m_center += delta; - // TODO: KB- Was a 'safe' function, is there an AZ equivalent? - float length = delta.GetLengthSq(); - if (length >= FLT_EPSILON) - { - m_radius += sqrtf(length); - } - else - { - m_radius = 0.0f; - } - m_radiusSq = m_radius * m_radius; - } - } - - - // check if the sphere intersects with a given AABB - bool BoundingSphere::Intersects(const AABB& b) const - { - float distance = 0.0f; - - for (int32_t t = 0; t < 3; ++t) - { - const AZ::Vector3& minVec = b.GetMin(); - if (m_center.GetElement(t) < minVec.GetElement(t)) - { - distance += (m_center.GetElement(t) - minVec.GetElement(t)) * (m_center.GetElement(t) - minVec.GetElement(t)); - if (distance > m_radiusSq) - { - return false; - } - } - else - { - const AZ::Vector3& maxVec = b.GetMax(); - if (m_center.GetElement(t) > maxVec.GetElement(t)) - { - distance += (m_center.GetElement(t) - maxVec.GetElement(t)) * (m_center.GetElement(t) - maxVec.GetElement(t)); - if (distance > m_radiusSq) - { - return false; - } - } - } - } - - return true; - } - - - // check if the sphere completely contains a given AABB - bool BoundingSphere::Contains(const AABB& b) const - { - float distance = 0.0f; - for (int32_t t = 0; t < 3; ++t) - { - const AZ::Vector3& maxVec = b.GetMax(); - if (m_center.GetElement(t) < maxVec.GetElement(t)) - { - distance += (m_center.GetElement(t) - maxVec.GetElement(t)) * (m_center.GetElement(t) - maxVec.GetElement(t)); - } - else - { - const AZ::Vector3& minVec = b.GetMin(); - if (m_center.GetElement(t) > minVec.GetElement(t)) - { - distance += (m_center.GetElement(t) - minVec.GetElement(t)) * (m_center.GetElement(t) - minVec.GetElement(t)); - } - } - - if (distance > m_radiusSq) - { - return false; - } - } - - return true; - } -} // namespace MCore diff --git a/Gems/EMotionFX/Code/MCore/Source/BoundingSphere.h b/Gems/EMotionFX/Code/MCore/Source/BoundingSphere.h index 1687f72799..ec63bb4b5d 100644 --- a/Gems/EMotionFX/Code/MCore/Source/BoundingSphere.h +++ b/Gems/EMotionFX/Code/MCore/Source/BoundingSphere.h @@ -108,32 +108,6 @@ namespace MCore */ MCORE_INLINE bool Intersects(const BoundingSphere& s) const { return ((m_center - s.m_center).GetLengthSq() <= (m_radiusSq + s.m_radiusSq)); } - /** - * Encapsulate a given 3D point with this sphere. - * Automatically adjust the center and radius of the sphere after 'adding' the given point to the sphere. - * Note that you should only use this method when the center of the bounding sphere isnt exactly known yet. - * This encapsulation method will adjust the center of the sphere as well. If the center of the sphere is known upfront and it is - * known upfront as well that this center point won't change, you should use the Encapsulate() method instead. - * @param v The vector representing the 3D point to use in the encapsulation. - */ - void Encapsulate(const AZ::Vector3& v); - - /** - * Checks if this sphere completely contains a given Axis Aligned Bounding Box (AABB). - * Note that the border of the sphere is counted as 'inside'. - * @param 'b' The box to perform the test with. - * @result Returns true when 'b' is COMPLETELY inside the spheres volume, otherwise false is returned. - */ - bool Contains(const AABB& b) const; - - /** - * Checks if a given Axis Aligned Bounding Box (AABB) intersects this sphere. - * Note that the border of the sphere is counted as inside. - * @param 'b' The box to perform the test with. - * @result Returns true when 'b' is completely or partially inside the volume of this sphere. - */ - bool Intersects(const AABB& b) const; - /** * Get the radius of the sphere. * @result Returns the radius of the sphere. diff --git a/Gems/EMotionFX/Code/MCore/mcore_files.cmake b/Gems/EMotionFX/Code/MCore/mcore_files.cmake index fd4eeb23c4..d33041eaf8 100644 --- a/Gems/EMotionFX/Code/MCore/mcore_files.cmake +++ b/Gems/EMotionFX/Code/MCore/mcore_files.cmake @@ -34,7 +34,6 @@ set(FILES Source/AttributeVector3.h Source/AttributeVector4.h Source/AzCoreConversions.h - Source/BoundingSphere.cpp Source/BoundingSphere.h Source/Color.cpp Source/Color.h