]> git.mxchange.org Git - flightgear.git/commitdiff
More efficient version of get_bounding_radius from Norm Vine.
authordavid <david>
Sat, 20 Jul 2002 19:23:44 +0000 (19:23 +0000)
committerdavid <david>
Sat, 20 Jul 2002 19:23:44 +0000 (19:23 +0000)
src/Objects/obj.cxx

index 88ad034badf73d4c3245f8c8f186f22a9b41aaae..d90815fcdf9e64d94d7b31dc3fd305fd806c34ed 100644 (file)
@@ -33,6 +33,7 @@
 #include <string.h>
 
 #include <simgear/compiler.h>
+#include <simgear/sg_inlines.h>
 #include <simgear/io/sg_binobj.hxx>
 
 #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_radiussgVec3 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) ) );
 }