]> git.mxchange.org Git - flightgear.git/commitdiff
Fix a problem with the culling of out-of-range random objects. When
authordavid <david>
Thu, 25 Jul 2002 17:29:08 +0000 (17:29 +0000)
committerdavid <david>
Thu, 25 Jul 2002 17:29:08 +0000 (17:29 +0000)
the triangles containing the objects were out of the view Frustum,
they were never traversed by ssg (and thus, never culled).  Now, every
200 frames, do a pass through the whole scene graph with cull-testing
disabled and without drawing anything; that will allow random-objects
to be collected incrementally.

src/Main/main.cxx

index 3661968f06f54d6d045775652d0a641a97d78a18..fce651f522aab936e211b26f7db827aec919e21e 100644 (file)
@@ -647,6 +647,22 @@ void fgRenderFrame() {
         ssgSetNearFar( scene_nearplane, scene_farplane );
        ssgCullAndDraw( globals->get_scenery()->get_scene_graph() );
 
+       // This is a bit kludgy.  Every 200 frames, do an extra traversal
+       // of the scene graph without drawing anything and with frustum
+       // culling disabled.  This ensures that out-of-range random
+       // objects that are not in the current view frustum will still be
+       // freed properly.
+       static int counter = 0;
+       if (++counter == 200) {
+                               // We disable frustrum testing, so 
+                               // the default is fine.
+         sgFrustum f;
+         sgMat4 m;
+         ssgGetModelviewMatrix(m);
+         globals->get_scenery()->get_scene_graph()->cull(&f, m, false);
+         counter = 0;
+       }
+
        // change state for lighting here
 
        // draw lighting