+
+
+void
+FGTileEntry::disconnect_ssg_nodes()
+{
+ SG_LOG( SG_TERRAIN, SG_DEBUG, "disconnecting ssg nodes" );
+
+ if ( ! loaded ) {
+ SG_LOG( SG_TERRAIN, SG_DEBUG, "removing a not-fully loaded tile!" );
+ } else {
+ SG_LOG( SG_TERRAIN, SG_DEBUG, "removing a fully loaded tile! terra_transform = " << terra_transform.get() );
+ }
+
+ // Unregister that one at the scenery manager
+ globals->get_scenery()->unregister_placement_transform(terra_transform.get());
+
+ // find the terrain branch parent
+ int pcount = terra_transform->getNumParents();
+ if ( pcount > 0 ) {
+ // find the first parent (should only be one)
+ osg::Group *parent = terra_transform->getParent( 0 ) ;
+ if( parent ) {
+ // disconnect the tile (we previously ref()'d it so it
+ // won't get freed now)
+ parent->removeChild( terra_transform.get() );
+ } else {
+ SG_LOG( SG_TERRAIN, SG_ALERT,
+ "parent pointer is NULL! Dying" );
+ exit(-1);
+ }
+ } else {
+ SG_LOG( SG_TERRAIN, SG_ALERT,
+ "Parent count is zero for an ssg tile! Dying" );
+ exit(-1);
+ }
+
+ // find the ground lighting branch
+ if ( gnd_lights_transform.get() ) {
+ // Unregister that one at the scenery manager
+ globals->get_scenery()->unregister_placement_transform(gnd_lights_transform.get());
+ pcount = gnd_lights_transform->getNumParents();
+ if ( pcount > 0 ) {
+ // find the first parent (should only be one)
+ osg::Group *parent = gnd_lights_transform->getParent( 0 ) ;
+ if( parent ) {
+ // disconnect the light branch (we previously ref()'d
+ // it so it won't get freed now)
+ parent->removeChild( gnd_lights_transform.get() );
+ } else {
+ SG_LOG( SG_TERRAIN, SG_ALERT,
+ "parent pointer is NULL! Dying" );
+ exit(-1);
+ }
+ } else {
+ SG_LOG( SG_TERRAIN, SG_ALERT,
+ "Parent count is zero for an ssg light tile! Dying" );
+ exit(-1);
+ }
+ }
+
+ // find the vasi lighting branch
+ if ( vasi_lights_transform.get() ) {
+ // Unregister that one at the scenery manager
+ globals->get_scenery()->unregister_placement_transform(vasi_lights_transform.get());
+ pcount = vasi_lights_transform->getNumParents();
+ if ( pcount > 0 ) {
+ // find the first parent (should only be one)
+ osg::Group *parent = vasi_lights_transform->getParent( 0 ) ;
+ if( parent ) {
+ // disconnect the light branch (we previously ref()'d
+ // it so it won't get freed now)
+ parent->removeChild( vasi_lights_transform.get() );
+ } else {
+ SG_LOG( SG_TERRAIN, SG_ALERT,
+ "parent pointer is NULL! Dying" );
+ exit(-1);
+ }
+ } else {
+ SG_LOG( SG_TERRAIN, SG_ALERT,
+ "Parent count is zero for an ssg light tile! Dying" );
+ exit(-1);
+ }
+ }
+
+ // find the runway lighting branch
+ if ( rwy_lights_transform.get() ) {
+ // Unregister that one at the scenery manager
+ globals->get_scenery()->unregister_placement_transform(rwy_lights_transform.get());
+ pcount = rwy_lights_transform->getNumParents();
+ if ( pcount > 0 ) {
+ // find the first parent (should only be one)
+ osg::Group *parent = rwy_lights_transform->getParent( 0 ) ;
+ if( parent ) {
+ // disconnect the light branch (we previously ref()'d
+ // it so it won't get freed now)
+ parent->removeChild( rwy_lights_transform.get() );
+ } else {
+ SG_LOG( SG_TERRAIN, SG_ALERT,
+ "parent pointer is NULL! Dying" );
+ exit(-1);
+ }
+ } else {
+ SG_LOG( SG_TERRAIN, SG_ALERT,
+ "Parent count is zero for an ssg light tile! Dying" );
+ exit(-1);
+ }
+ }
+
+ // find the taxi lighting branch
+ if ( taxi_lights_transform.get() ) {
+ // Unregister that one at the scenery manager
+ globals->get_scenery()->unregister_placement_transform(taxi_lights_transform.get());
+ pcount = taxi_lights_transform->getNumParents();
+ if ( pcount > 0 ) {
+ // find the first parent (should only be one)
+ osg::Group *parent = taxi_lights_transform->getParent( 0 ) ;
+ if( parent ) {
+ // disconnect the light branch (we previously ref()'d
+ // it so it won't get freed now)
+ parent->removeChild( taxi_lights_transform.get() );
+ } else {
+ SG_LOG( SG_TERRAIN, SG_ALERT,
+ "parent pointer is NULL! Dying" );
+ exit(-1);
+ }
+ } else {
+ SG_LOG( SG_TERRAIN, SG_ALERT,
+ "Parent count is zero for an ssg light tile! Dying" );
+ exit(-1);
+ }
+ }
+}