[Plib-cvs] plib/src/ssg ssgBranch.cxx,1.21,1.22
Brought to you by:
sjbaker
From: Curtis O. <cu...@us...> - 2002-10-26 19:19:28
|
Update of /cvsroot/plib/plib/src/ssg In directory usw-pr-cvs1:/tmp/cvs-serv31554 Modified Files: ssgBranch.cxx Log Message: There are two removeKid() functions, one by index and one by *kid_ptr. The removeKid(index) function is just a wrapper that looks up the kid pointer and calls removeKid(kid_ptr *) However removeKid(by kid pointer *) always does a linear search to find the kid index again. This patch simply reverses which is the wrapper and which is the actual deleting function. I assert that it makes more sense to have removeKid(index) do the actual delete because it already knows the index and can do the delete directly. removeKid(kid_ptr *) can be the wrapper which searches for an appropriate index and calls removeKid(index) Index: ssgBranch.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/ssg/ssgBranch.cxx,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- ssgBranch.cxx 2 Sep 2002 06:05:47 -0000 1.21 +++ ssgBranch.cxx 26 Oct 2002 19:19:25 -0000 1.22 @@ -92,25 +92,25 @@ { ssgEntity *k = kids.getEntity ( n ) ; - if ( k != NULL ) - removeKid ( k ) ; + if ( k != NULL ) { + k -> removeParent ( this ) ; + kids.removeEntity ( n ) ; + dirtyBSphere () ; + } } void ssgBranch::removeKid ( ssgEntity *entity ) { - entity -> removeParent ( this ) ; - kids.removeEntity ( entity ) ; - dirtyBSphere () ; + removeKid( searchForKid( entity ) ); } void ssgBranch::removeAllKids (void) { - ssgEntity *k ; - - while ( ( k = getKid ( 0 ) ) != NULL ) + for ( int k = getNumKids() - 1; k >= 0; --k ) { removeKid ( k ) ; + } } |