1
0
Fork 0

Create a top-level branch in each tile for random objects with the

name "random-objects".

Put the random objects for each tile inside a top-level
ssgRangeSelector with a maximum range of 20km.  This saves a lot of
range tests for distant tiles, and gives about a 10% framerate boost
on my card at 1000ft AGL (possibly more on faster cards).
This commit is contained in:
david 2002-07-27 14:29:57 +00:00
parent f1eddc9bf4
commit 43d89cb8d6

View file

@ -1427,7 +1427,7 @@ bool fgBinObjLoad( const string& path, const bool is_base,
} }
geometry->setName( (char *)path.c_str() ); geometry->setName( (char *)path.c_str() );
if ( is_base ) { if ( is_base ) {
// reference point (center offset/bounding sphere) // reference point (center offset/bounding sphere)
*center = obj.get_gbs_center(); *center = obj.get_gbs_center();
@ -1481,6 +1481,19 @@ bool fgBinObjLoad( const string& path, const bool is_base,
} }
} }
// Put all randomly-placed objects under a separate branch
// (actually an ssgRangeSelector) named "random-models".
ssgBranch * random_object_branch = 0;
if (use_random_objects) {
float ranges[] = {0, 20000}; // Maximum 20km range for random objects
ssgRangeSelector * object_lod = new ssgRangeSelector;
object_lod->setRanges(ranges, 2);
object_lod->setName("random-models");
geometry->addKid(object_lod);
random_object_branch = new ssgBranch;
object_lod->addKid(random_object_branch);
}
// generate triangles // generate triangles
string_list tri_materials = obj.get_tri_materials(); string_list tri_materials = obj.get_tri_materials();
group_list tris_v = obj.get_tris_v(); group_list tris_v = obj.get_tris_v();
@ -1497,7 +1510,8 @@ bool fgBinObjLoad( const string& path, const bool is_base,
is_base, ground_lights ); is_base, ground_lights );
if (use_random_objects) if (use_random_objects)
gen_random_surface_objects(leaf, geometry, center, material); gen_random_surface_objects(leaf, random_object_branch,
center, material);
geometry->addKid( leaf ); geometry->addKid( leaf );
} }
@ -1517,7 +1531,8 @@ bool fgBinObjLoad( const string& path, const bool is_base,
is_base, ground_lights ); is_base, ground_lights );
if (use_random_objects) if (use_random_objects)
gen_random_surface_objects(leaf, geometry, center, material); gen_random_surface_objects(leaf, random_object_branch,
center, material);
geometry->addKid( leaf ); geometry->addKid( leaf );
} }
@ -1536,7 +1551,8 @@ bool fgBinObjLoad( const string& path, const bool is_base,
vertex_index, normal_index, tex_index, vertex_index, normal_index, tex_index,
is_base, ground_lights ); is_base, ground_lights );
if (use_random_objects) if (use_random_objects)
gen_random_surface_objects(leaf, geometry, center, material); gen_random_surface_objects(leaf, random_object_branch,
center, material);
geometry->addKid( leaf ); geometry->addKid( leaf );
} }