1
0
Fork 0

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.)
This commit is contained in:
curt 2002-10-24 03:38:14 +00:00
parent aff9655029
commit d62b1a0a66

View file

@ -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--;