From: curt Date: Thu, 24 Oct 2002 03:38:14 +0000 (+0000) Subject: Fix a subtle bug in the partial ssg tree deleter which was leaving some X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d62b1a0a668abdd5dd552e5d1a50e5bc6e3a451c;p=flightgear.git Fix a subtle bug in the partial ssg tree deleter which was leaving some parts of the tree left over at the end which the failsafe was catching, but this could impose a huge framerate hit if the missed portion of the tree was large enough (and it very often was.) --- diff --git a/src/Scenery/tileentry.cxx b/src/Scenery/tileentry.cxx index 81336f42b..7bd728e18 100644 --- a/src/Scenery/tileentry.cxx +++ b/src/Scenery/tileentry.cxx @@ -687,13 +687,22 @@ ssgBranch* FGTileEntry::gen_runway_lights( ssgVertexArray *points,ssgVertexArray // is intended to spread the load of freeing a complex tile out over // several frames. static int fgPartialFreeSSGtree( ssgBranch *b, int n ) { - // ssgDeRefDelete( b ); - // return 0; +#if 0 + // for testing: we could call the following two lines and replace + // the functionality of this entire function and everything will + // get properly freed, but it will happen all at once and could + // cause a huge frame rate hit. + ssgDeRefDelete( b ); + return 0; +#endif int num_deletes = 0; if ( n > 0 ) { // we still have some delete budget left + if ( b->getNumKids() > 100 ) { + cout << "large family = " << b->getNumKids() << endl; + } for ( int i = 0; i < b->getNumKids(); ++i ) { ssgEntity *kid = b->getKid(i); if ( kid->isAKindOf( ssgTypeBranch() ) && kid->getRef() <= 1 ) { @@ -704,8 +713,10 @@ static int fgPartialFreeSSGtree( ssgBranch *b, int n ) { break; } } - // remove the kid if it is now empty - if ( kid->getNumKids() == 0 ) { + // remove the kid if (a) it is now empty -or- (b) it's ref + // count is > zero at which point we don't care if it's + // empty, we don't want to touch it's contents. + if ( kid->getNumKids() == 0 || kid->getRef() > 1 ) { b->removeKid( kid ); num_deletes++; n--;