From: david Date: Sat, 20 Jul 2002 19:23:44 +0000 (+0000) Subject: More efficient version of get_bounding_radius from Norm Vine. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ab91bbe17afc79cf49a64596b713e09b6f81f274;p=flightgear.git More efficient version of get_bounding_radius from Norm Vine. --- 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) ) ); }