From ab91bbe17afc79cf49a64596b713e09b6f81f274 Mon Sep 17 00:00:00 2001 From: david Date: Sat, 20 Jul 2002 19:23:44 +0000 Subject: [PATCH] More efficient version of get_bounding_radius from Norm Vine. --- src/Objects/obj.cxx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Objects/obj.cxx b/src/Objects/obj.cxx index 88ad034ba..d90815fcd 100644 --- a/src/Objects/obj.cxx +++ b/src/Objects/obj.cxx @@ -33,6 +33,7 @@ #include #include +#include #include #include STL_STRING @@ -571,17 +572,12 @@ DummyBSphereEntity::get_entity () * @param p3 The third point in the triangle. * @return The greatest distance any point lies from the center. */ -static float -get_bounding_radius (sgVec3 center, float *p1, float *p2, float *p3) +static inline float +get_bounding_radius( sgVec3 center, float *p1, float *p2, float *p3) { - float result = sgDistanceVec3(center, p1); - float length = sgDistanceVec3(center, p2); - if (length > result) - result = length; - length = sgDistanceVec3(center, p3); - if (length > result) - result = length; - return result; + return sqrt( SG_MAX3( sgDistanceSquaredVec3(center, p1), + sgDistanceSquaredVec3(center, p2), + sgDistanceSquaredVec3(center, p3) ) ); }