1
0
Fork 0

More efficient version of get_bounding_radius from Norm Vine.

This commit is contained in:
david 2002-07-20 19:23:44 +00:00
parent d6f9038a25
commit ab91bbe17a

View file

@ -33,6 +33,7 @@
#include <string.h> #include <string.h>
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <simgear/sg_inlines.h>
#include <simgear/io/sg_binobj.hxx> #include <simgear/io/sg_binobj.hxx>
#include STL_STRING #include STL_STRING
@ -571,17 +572,12 @@ DummyBSphereEntity::get_entity ()
* @param p3 The third point in the triangle. * @param p3 The third point in the triangle.
* @return The greatest distance any point lies from the center. * @return The greatest distance any point lies from the center.
*/ */
static float static inline float
get_bounding_radius (sgVec3 center, float *p1, float *p2, float *p3) get_bounding_radius( sgVec3 center, float *p1, float *p2, float *p3)
{ {
float result = sgDistanceVec3(center, p1); return sqrt( SG_MAX3( sgDistanceSquaredVec3(center, p1),
float length = sgDistanceVec3(center, p2); sgDistanceSquaredVec3(center, p2),
if (length > result) sgDistanceSquaredVec3(center, p3) ) );
result = length;
length = sgDistanceVec3(center, p3);
if (length > result)
result = length;
return result;
} }