From: <pat...@us...> - 2012-10-26 21:30:20
|
Revision: 1282 http://ggt.svn.sourceforge.net/ggt/?rev=1282&view=rev Author: patrickh Date: 2012-10-26 21:30:13 +0000 (Fri, 26 Oct 2012) Log Message: ----------- Speed up isInVolume() for the Sphere/Point case. Submitted by Paul Martz. Modified Paths: -------------- trunk/gmtl/Containment.h Modified: trunk/gmtl/Containment.h =================================================================== --- trunk/gmtl/Containment.h 2012-10-26 21:24:52 UTC (rev 1281) +++ trunk/gmtl/Containment.h 2012-10-26 21:30:13 UTC (rev 1282) @@ -45,7 +45,8 @@ // the sphere to the point has a magnitude less than or equal to the radius // of the sphere. // |pt - center| <= radius - return ( length(gmtl::Vec<DATA_TYPE,3>(pt - container.mCenter)) <= container.mRadius ); + // Compare squares to avoid sqrt() call. + return ( lengthSquared(gmtl::Vec<DATA_TYPE,3>(pt - container.mCenter)) <= ( container.mRadius * container.mRadius ) ); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |