]> git.mxchange.org Git - flightgear.git/commitdiff
Fix a subtle bug in the partial ssg tree deleter which was leaving some
authorcurt <curt>
Thu, 24 Oct 2002 03:38:14 +0000 (03:38 +0000)
committercurt <curt>
Thu, 24 Oct 2002 03:38:14 +0000 (03:38 +0000)
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.)

src/Scenery/tileentry.cxx

index 81336f42b18fc2a61c1fc6c93af48c079a380462..7bd728e1819b41db76d91a4bbc430ae280f1e22b 100644 (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--;