summaryrefslogtreecommitdiff
path: root/indra/llmath/llsphere.cpp
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2024-10-17 16:56:21 +0300
committerGitHub <noreply@github.com>2024-10-17 16:56:21 +0300
commit0ef7a9b39cf72da1211039ab22bdf8f9f6a2c984 (patch)
tree6f51ef179497265b5bff2a355471ae5dc9643ad2 /indra/llmath/llsphere.cpp
parent9e24b300d02e5627ea0d304d412cb683ec2de3a4 (diff)
parentd3d349ae0f17a72481f30b9354b9367b1cd3b639 (diff)
Merge pull request #2856 from secondlife/marchcat/c-develop
Develop → Maint C sync
Diffstat (limited to 'indra/llmath/llsphere.cpp')
-rw-r--r--indra/llmath/llsphere.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/indra/llmath/llsphere.cpp b/indra/llmath/llsphere.cpp
index 75f9ef1772..5f48764455 100644
--- a/indra/llmath/llsphere.cpp
+++ b/indra/llmath/llsphere.cpp
@@ -69,18 +69,18 @@ F32 LLSphere::getRadius() const
return mRadius;
}
-// returns 'TRUE' if this sphere completely contains other_sphere
-BOOL LLSphere::contains(const LLSphere& other_sphere) const
+// returns 'true' if this sphere completely contains other_sphere
+bool LLSphere::contains(const LLSphere& other_sphere) const
{
F32 separation = (mCenter - other_sphere.mCenter).length();
- return (mRadius >= separation + other_sphere.mRadius) ? TRUE : FALSE;
+ return mRadius >= separation + other_sphere.mRadius;
}
-// returns 'TRUE' if this sphere completely contains other_sphere
-BOOL LLSphere::overlaps(const LLSphere& other_sphere) const
+// returns 'true' if this sphere completely contains other_sphere
+bool LLSphere::overlaps(const LLSphere& other_sphere) const
{
F32 separation = (mCenter - other_sphere.mCenter).length();
- return (separation <= mRadius + other_sphere.mRadius) ? TRUE : FALSE;
+ return mRadius >= separation - other_sphere.mRadius;
}
// returns overlap
@@ -93,9 +93,8 @@ F32 LLSphere::getOverlap(const LLSphere& other_sphere) const
bool LLSphere::operator==(const LLSphere& rhs) const
{
- // TODO? -- use approximate equality for centers?
- return (mRadius == rhs.mRadius
- && mCenter == rhs.mCenter);
+ return fabs(mRadius - rhs.mRadius) <= FLT_EPSILON &&
+ (mCenter - rhs.mCenter).length() <= FLT_EPSILON;
}
std::ostream& operator<<( std::ostream& output_stream, const LLSphere& sphere)
@@ -186,7 +185,7 @@ LLSphere LLSphere::getBoundingSphere(const std::vector<LLSphere>& sphere_list)
// TODO -- improve the accuracy for small collections of spheres
LLSphere bounding_sphere( LLVector3(0.f, 0.f, 0.f), 0.f );
- S32 sphere_count = sphere_list.size();
+ auto sphere_count = sphere_list.size();
if (1 == sphere_count)
{
// trivial case -- single sphere