I totally misunderstood sgFrustum. This patch should put it right,
and also adds an optimization to avoid traversing anything closer than 1000m.
This commit is contained in:
parent
27158525a9
commit
0178c65981
1 changed files with 11 additions and 21 deletions
|
@ -648,33 +648,23 @@ void fgRenderFrame() {
|
||||||
ssgCullAndDraw( globals->get_scenery()->get_scene_graph() );
|
ssgCullAndDraw( globals->get_scenery()->get_scene_graph() );
|
||||||
|
|
||||||
// This is a bit kludgy. Every 200 frames, do an extra
|
// This is a bit kludgy. Every 200 frames, do an extra
|
||||||
// traversal of the scene graph without drawing anything and
|
// traversal of the scene graph without drawing anything, but
|
||||||
// the frustum set to a different 25% of the full range of
|
// with the field-of-view set to 360x360 degrees. This
|
||||||
// view. This ensures that out-of-range random objects that
|
// ensures that out-of-range random objects that are not in
|
||||||
// are not in the current view frustum will still be freed
|
// the current view frustum will still be freed properly.
|
||||||
// properly.
|
|
||||||
static int counter = 0;
|
static int counter = 0;
|
||||||
counter++;
|
counter++;
|
||||||
if (counter % 200 == 0) {
|
if (counter == 200) {
|
||||||
sgFrustum f;
|
sgFrustum f;
|
||||||
switch (counter) {
|
f.setFOV(360, 360);
|
||||||
case 200:
|
// No need to put the near plane too close;
|
||||||
f.setFrustum(SG_180, SG_ZERO, SG_90, SG_ZERO, 0, 500000000);
|
// this way, at least the aircraft can be
|
||||||
break;
|
// culled.
|
||||||
case 400:
|
f.setNearFar(1000, 1000000);
|
||||||
f.setFrustum(SG_ZERO, SG_180, SG_90, SG_ZERO, 0, 500000000);
|
|
||||||
break;
|
|
||||||
case 600:
|
|
||||||
f.setFrustum(SG_180, SG_ZERO, SG_ZERO, SG_90, 0, 500000000);
|
|
||||||
break;
|
|
||||||
case 800:
|
|
||||||
f.setFrustum(SG_ZERO, SG_180, SG_ZERO, SG_90, 0, 500000000);
|
|
||||||
counter = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
sgMat4 m;
|
sgMat4 m;
|
||||||
ssgGetModelviewMatrix(m);
|
ssgGetModelviewMatrix(m);
|
||||||
globals->get_scenery()->get_scene_graph()->cull(&f, m, true);
|
globals->get_scenery()->get_scene_graph()->cull(&f, m, true);
|
||||||
|
counter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// change state for lighting here
|
// change state for lighting here
|
||||||
|
|
Loading…
Add table
Reference in a new issue