Further restructuring of the scenery loading code.
This commit is contained in:
parent
b9e866cfdd
commit
73b92a697d
7 changed files with 64 additions and 30 deletions
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 "
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue