From 1c35d89eb4c0122b1aa846d021311ad5a2426ff5 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 25 Jul 2002 17:29:08 +0000 Subject: [PATCH] Fix a problem with the culling of out-of-range random objects. When 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 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 3661968f0..fce651f52 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -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 -- 2.39.5