]> git.mxchange.org Git - flightgear.git/commitdiff
Further restructuring of the scenery loading code.
authorcurt <curt>
Sun, 3 Mar 2002 23:20:55 +0000 (23:20 +0000)
committercurt <curt>
Sun, 3 Mar 2002 23:20:55 +0000 (23:20 +0000)
src/Main/main.cxx
src/Objects/obj.cxx
src/Scenery/hitlist.cxx
src/Scenery/newcache.cxx
src/Scenery/tileentry.cxx
src/Scenery/tileentry.hxx
src/Scenery/tilemgr.cxx

index 2912e5442b1d7b919e8ffe4055703ae4a3dc4588..4d8d1243ea03b8bfdbc5565382381082c51fb9c1 100644 (file)
@@ -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;
index 3b2b61f93ad2a741d52ccb96bdef3a42f277fcd8..769000d2e3643a5934f001b6794721f3ac9e9e09 100644 (file)
@@ -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
index fac8ae5c23b5a6c43b7db8ae5a5158c10ec1a73a..02fe978e3f0cf31238a5c1f48c7d366cab268ca3 100644 (file)
@@ -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;
index aca6fe0a042621d419a992b11f9b2ad59daf318c..d5d07a9b2135a88adc1bc25f12a3819623ac0bd5 100644 (file)
@@ -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();
 }
 
 
index adc92e04ee01158ff70dc5c6c465d09248b66473..aa701539a0020d9c994aa9c9c8e4bc6966b29025 100644 (file)
@@ -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
 
index 0abcebaab0651d2407c4e8feb6f9201e80f7c1b1..56b173ce07b199e7c33d0864e1d11270adbb25ec 100644 (file)
@@ -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
index 0b7b22968667fad54bd5c381fed3e818a6450765..4b6cffc7400c8ab19d27c29974c58ac529193f68 100644 (file)
@@ -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 "
     }