From 73b92a697d023daf128110ac96ec0d630155b6b1 Mon Sep 17 00:00:00 2001 From: curt Date: Sun, 3 Mar 2002 23:20:55 +0000 Subject: [PATCH] Further restructuring of the scenery loading code. --- src/Main/main.cxx | 33 +++++++++++++++++++-------------- src/Objects/obj.cxx | 17 ++++++++++++++--- src/Scenery/hitlist.cxx | 4 ++-- src/Scenery/newcache.cxx | 4 ++-- src/Scenery/tileentry.cxx | 23 ++++++++++++++++++----- src/Scenery/tileentry.hxx | 4 +++- src/Scenery/tilemgr.cxx | 9 ++++++--- 7 files changed, 64 insertions(+), 30 deletions(-) diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 2912e5442..4d8d1243e 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -173,11 +173,12 @@ void fgReshape( int width, int height ); // ssg variables ssgRoot *scene = NULL; -ssgBranch *terrain = NULL; +ssgBranch *terrain_branch = NULL; +ssgBranch *gnd_lights_branch = NULL; +ssgBranch *rwy_lights_branch = NULL; ssgRoot *lighting = NULL; -ssgBranch *ground = NULL; -ssgBranch *airport = NULL; +// ssgBranch *airport = NULL; #ifdef FG_NETWORK_OLK ssgSelector *fgd_sel = NULL; @@ -1552,18 +1553,22 @@ int mainLoop( int argc, char **argv ) { globals->set_mag( magvar ); // Terrain branch - terrain = new ssgBranch; - terrain->setName( "Terrain" ); - scene->addKid( terrain ); + terrain_branch = new ssgBranch; + terrain_branch->setName( "Terrain" ); + scene->addKid( terrain_branch ); // Lighting - ground = new ssgBranch; - ground->setName( "Ground Lighting" ); - lighting->addKid( ground ); + gnd_lights_branch = new ssgBranch; + gnd_lights_branch->setName( "Ground Lighting" ); + lighting->addKid( gnd_lights_branch ); - airport = new ssgBranch; - airport->setName( "Airport Lighting" ); - lighting->addKid( airport ); + rwy_lights_branch = new ssgBranch; + rwy_lights_branch->setName( "Runway Lighting" ); + lighting->addKid( rwy_lights_branch ); + + // airport = new ssgBranch; + // airport->setName( "Airport Lighting" ); + // lighting->addKid( airport ); // ADA fgLoadDCS(); @@ -1812,7 +1817,7 @@ void fgLoadDCS(void) { //dummy_tile->lightmaps_sequence->setTraversalMaskBits( SSGTRAV_HOT ); lightpoints_transform->addKid( dummy_tile->lightmaps_sequence ); lightpoints_transform->ref(); - ground->addKid( lightpoints_transform ); + gnd_lights_branch->addKid( lightpoints_transform ); } } //if in1 } //if objc @@ -1826,7 +1831,7 @@ void fgLoadDCS(void) { SG_LOG ( SG_TERRAIN, SG_ALERT, "Finished object processing." ); - terrain->addKid( ship_sel ); //add selector node to root node + terrain_branch->addKid( ship_sel ); //add selector node to root node } return; diff --git a/src/Objects/obj.cxx b/src/Objects/obj.cxx index 3b2b61f93..769000d2e 100644 --- a/src/Objects/obj.cxx +++ b/src/Objects/obj.cxx @@ -930,18 +930,25 @@ bool fgBinObjLoad( const string& path, const bool is_base, point_list normals = obj.get_normals(); point_list texcoords = obj.get_texcoords(); - string material; + string material, tmp_mat; int_list vertex_index; int_list tex_index; int i; + bool is_lighting = false; // generate points string_list pt_materials = obj.get_pt_materials(); group_list pts_v = obj.get_pts_v(); for ( i = 0; i < (int)pts_v.size(); ++i ) { cout << "pts_v.size() = " << pts_v.size() << endl; - material = pt_materials[i]; + tmp_mat = pt_materials[i]; + if ( tmp_mat.substr(0, 3) == "RWY" ) { + material = "LIGHTS"; + is_lighting = true; + } else { + material = tmp_mat; + } vertex_index = pts_v[i]; tex_index.clear(); ssgLeaf *leaf = gen_leaf( path, GL_POINTS, material, @@ -949,7 +956,11 @@ bool fgBinObjLoad( const string& path, const bool is_base, vertex_index, tex_index, false, ground_lights ); - geometry->addKid( leaf ); + if ( is_lighting ) { + rwy_lights->addKid( leaf ); + } else { + geometry->addKid( leaf ); + } } // generate triangles diff --git a/src/Scenery/hitlist.cxx b/src/Scenery/hitlist.cxx index fac8ae5c2..02fe978e3 100644 --- a/src/Scenery/hitlist.cxx +++ b/src/Scenery/hitlist.cxx @@ -27,7 +27,7 @@ #include "hitlist.hxx" -extern ssgBranch *terrain; +extern ssgBranch *terrain_branch; #if 0 // check to see if the intersection point is @@ -558,7 +558,7 @@ bool fgCurrentElev( sgdVec3 abs_view_pos, sgdVec3 scenery_center, sgdCopyVec3(orig, view_pos ); sgdCopyVec3(dir, abs_view_pos ); - hit_list->Intersect( terrain, orig, dir ); + hit_list->Intersect( terrain_branch, orig, dir ); int this_hit=0; Point3D geoc; diff --git a/src/Scenery/newcache.cxx b/src/Scenery/newcache.cxx index aca6fe0a0..d5d07a9b2 100644 --- a/src/Scenery/newcache.cxx +++ b/src/Scenery/newcache.cxx @@ -183,7 +183,7 @@ bool FGNewCache::make_space() { // Clear all completely loaded tiles (ignores partially loaded tiles) void FGNewCache::clear_cache() { // This is a hack that should really get cleaned up at some point - extern ssgBranch *terrain; + extern ssgBranch *terrain_branch; tile_map_iterator current = tile_cache.begin(); tile_map_iterator end = tile_cache.end(); @@ -199,7 +199,7 @@ void FGNewCache::clear_cache() { } // and ... just in case we missed something ... - terrain->removeAllKids(); + terrain_branch->removeAllKids(); } diff --git a/src/Scenery/tileentry.cxx b/src/Scenery/tileentry.cxx index adc92e04e..aa701539a 100644 --- a/src/Scenery/tileentry.cxx +++ b/src/Scenery/tileentry.cxx @@ -1029,6 +1029,10 @@ FGTileEntry::load( const SGPath& base, bool is_base ) ssgBranch* new_tile = new ssgBranch; + // runway lights + rwy_lights_transform = NULL; + rwy_lights_range = NULL; + // Check for master .stg (scene terra gear) file SGPath stg_name = basename; stg_name.concat( ".stg" ); @@ -1382,12 +1386,14 @@ FGTileEntry::load( const SGPath& base, bool is_base ) void -FGTileEntry::add_ssg_nodes( ssgBranch* terrain, ssgBranch* ground ) +FGTileEntry::add_ssg_nodes( ssgBranch* terrain_branch, + ssgBranch* gnd_lights_branch, + ssgBranch* rwy_lights_branch ) { // bump up the ref count so we can remove this later without // having ssg try to free the memory. terra_transform->ref(); - terrain->addKid( terra_transform ); + terrain_branch->addKid( terra_transform ); SG_LOG( SG_TERRAIN, SG_DEBUG, "connected a tile into scene graph. terra_transform = " @@ -1395,11 +1401,18 @@ FGTileEntry::add_ssg_nodes( ssgBranch* terrain, ssgBranch* ground ) SG_LOG( SG_TERRAIN, SG_DEBUG, "num parents now = " << terra_transform->getNumParents() ); - if ( gnd_lights_transform != 0 ) { + if ( gnd_lights_transform != NULL ) { // bump up the ref count so we can remove this later without // having ssg try to free the memory. gnd_lights_transform->ref(); - ground->addKid( gnd_lights_transform ); + gnd_lights_branch->addKid( gnd_lights_transform ); + } + + if ( rwy_lights_transform != NULL ) { + // bump up the ref count so we can remove this later without + // having ssg try to free the memory. + rwy_lights_transform->ref(); + rwy_lights_branch->addKid( rwy_lights_transform ); } // ADA @@ -1407,7 +1420,7 @@ FGTileEntry::add_ssg_nodes( ssgBranch* terrain, ssgBranch* ground ) // bump up the ref count so we can remove this later without // having ssg try to free the memory. lightmaps_transform->ref(); - ground->addKid( lightmaps_transform ); + gnd_lights_branch->addKid( lightmaps_transform ); } // ADA diff --git a/src/Scenery/tileentry.hxx b/src/Scenery/tileentry.hxx index 0abcebaab..56b173ce0 100644 --- a/src/Scenery/tileentry.hxx +++ b/src/Scenery/tileentry.hxx @@ -255,7 +255,9 @@ public: /** * Add terrain mesh and ground lighting to scene graph. */ - void add_ssg_nodes( ssgBranch* terrain, ssgBranch* ground ); + void add_ssg_nodes( ssgBranch* terrain_branch, + ssgBranch* gnd_lights_branch, + ssgBranch* rwy_lights_branch ); /** * disconnect terrain mesh and ground lighting nodes from scene diff --git a/src/Scenery/tilemgr.cxx b/src/Scenery/tilemgr.cxx index 0b7b22968..4b6cffc74 100644 --- a/src/Scenery/tilemgr.cxx +++ b/src/Scenery/tilemgr.cxx @@ -52,8 +52,9 @@ #define TEST_LAST_HIT_CACHE extern ssgRoot *scene; -extern ssgBranch *terrain; -extern ssgBranch *ground; +extern ssgBranch *terrain_branch; // branch that holds world geometry +extern ssgBranch *gnd_lights_branch; // branch that holds ground lighting +extern ssgBranch *rwy_lights_branch; // branch that holds runway lighting // the tile manager FGTileMgr global_tile_mgr; @@ -333,7 +334,9 @@ int FGTileMgr::update( double lon, double lat ) { FGTileEntry* e = attach_queue.front(); attach_queue.pop(); #endif - e->add_ssg_nodes( terrain, ground ); + e->add_ssg_nodes( terrain_branch, + gnd_lights_branch, + rwy_lights_branch ); // cout << "Adding ssg nodes for " } -- 2.39.5