From 05f626e9fbcccb24a66147e7cc6b437942b9a220 Mon Sep 17 00:00:00 2001 From: ehofman Date: Mon, 18 Jul 2005 16:58:22 +0000 Subject: [PATCH] Harald JOHSEN: Changes ======= - shadowvolume.cxx, renderer.cxx : - reduced the polygon offset a bit to eliminate some artifact ; - changed again the cleanup code for objects inside a tile because it could crash on rare occasion ; - the culling of shadow casters has been rewritten to traverse the scene graph, it should be a bit faster when there is a lot of objects ; - the range selector was not correctly handled, sometimes the wrong LOD was casting shadows. - added the option to display aircraft's transparent objects after the shadows, this will reduce the problem of shadows being hidden by the transparent object (propeller disk, rotor, etc). A side effect is that aircraft's transparent objects won't receive shadows anymore. This is usually a good thing except when the aircraft use a 'transparent' texture where it should not. A transparent texture in the plib context is a texture with an alpha channel or a material with alpha <= 0.99. - model.cxx, animation.cxx, shadowvolume.cxx : - added an optional under the animation - tower.cxx - correct a rare bug where all occurences of the aircraft are not deleted from the departure list causing a crash in FGTower::CheckDepartureList function. --- src/ATC/tower.cxx | 1 + src/Main/renderer.cxx | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ATC/tower.cxx b/src/ATC/tower.cxx index 1271e920a..11d076ebc 100644 --- a/src/ATC/tower.cxx +++ b/src/ATC/tower.cxx @@ -2154,6 +2154,7 @@ void FGTower::RemovePlane(string ID) { if((*twrItr)->plane.callsign == ID) { t = *twrItr; twrItr = depList.erase(twrItr); + twrItr--; depListItr = depList.begin(); } } diff --git a/src/Main/renderer.cxx b/src/Main/renderer.cxx index d8f6e8c30..fe79a0425 100644 --- a/src/Main/renderer.cxx +++ b/src/Main/renderer.cxx @@ -175,7 +175,7 @@ FGRenderer::build_states( void ) { menus->disable( GL_TEXTURE_2D ); menus->enable( GL_BLEND ); - shadows = new SGShadowVolume; + shadows = new SGShadowVolume( globals->get_scenery()->get_scene_graph() ); shadows->init( fgGetNode("/sim/rendering", true) ); shadows->addOccluder( globals->get_scenery()->get_aircraft_branch(), SGShadowVolume::occluderTypeAircraft ); @@ -701,6 +701,7 @@ FGRenderer::update( bool refresh_camera_settings ) { bool is_internal = globals->get_current_view()->getInternal(); // draw before ac because ac internal rendering clear the depth buffer + globals->get_aircraft_model()->select( true ); if( is_internal ) shadows->endOfFrame(); @@ -715,11 +716,19 @@ FGRenderer::update( bool refresh_camera_settings ) { // the aircraft in the global scenegraph // Otherwise, it just enables the aircraft: The scenegraph // must be drawn again to see the plane. + ssgBranch *branch = globals->get_scenery()->get_aircraft_branch(); + // in external view the shadows are drawn before the transparent parts of the ac + if( ! is_internal ) + branch->setTravCallback( SSG_CALLBACK_POSTTRAV, SGShadowVolume::ACpostTravCB); ssgCullAndDraw( globals->get_scenery()->get_scene_graph() ); + branch->setTravCallback( SSG_CALLBACK_POSTTRAV, 0); FGTileMgr::set_tile_filter( true ); sgSetModelFilter( true ); globals->get_aircraft_model()->select( true ); } + // in 'external' view the ac can be culled, so shadows have not been draw in the + // posttrav callback, this would be a rare case if the getInternal was acting + // as expected (ie in internal view, getExternal returns false) if( !is_internal ) shadows->endOfFrame();