Update of /cvsroot/plib/plib/src/ssg
In directory sc8-pr-cvs1:/tmp/cvs-serv10645
Modified Files:
ssgEntity.cxx
Log Message:
John Fay's optimizations to the Line of Sight code
----------------------------------------------------------------------
Index: ssgEntity.cxx
===================================================================
RCS file: /cvsroot/plib/plib/src/ssg/ssgEntity.cxx,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- ssgEntity.cxx 29 Nov 2002 19:39:48 -0000 1.23
+++ ssgEntity.cxx 21 May 2003 23:41:59 -0000 1.24
@@ -302,13 +302,14 @@
ssgCullResult ssgEntity::hot_test ( sgVec3 s, sgMat4 m, int test_needed )
{
+ /* Height-Off-Terrain Test */
stats_hot_test++ ;
if ( !test_needed )
-{
-stats_hot_triv_accept++ ;
+ {
+ stats_hot_triv_accept++ ;
[...85 lines suppressed...]
-stats_los_straddle++ ;
+ /* Calculate the distance from the line to the center of the sphere */
+ sgVec3 oc ;
+ sgSubVec3 ( oc, p1, center ) ;
+
+ float dmin2 = sgSquare ( oc[0] ) + sgSquare ( oc[1] ) + sgSquare ( oc[2] )
+ - sgSquare ( oc[0] * s[0] + oc[1] * s[1] + oc[2] * s[2] ) /
+ ( sgSquare ( s[0] ) + sgSquare ( s[1] ) + sgSquare ( s[2] ) ) ;
+
+ /* Compare minimum distance squared with sphere radius squared */
+ if ( dmin2 > sgSquare ( tmp.getRadius () ) )
+ {
+ stats_los_radius_reject++;
+ return SSG_OUTSIDE;
+ }
+
+ stats_los_straddle++ ;
return SSG_STRADDLE ;
}
|