#include <Debug/logstream.hxx>
#include <Airports/genapt.hxx>
#include <Bucket/newbucket.hxx>
+#include <Clouds/cloudobj.hxx>
#include <Main/options.hxx>
#include <Main/views.hxx>
#include <Misc/fgpath.hxx>
<< tile_cache.size() );
FGTileEntry e;
e.mark_unused();
- e.vtlist = NULL;
- e.vnlist = NULL;
- e.tclist = NULL;
+ e.vec3_ptrs.clear();
+ e.vec2_ptrs.clear();
+ e.index_ptrs.clear();
FG_LOG( FG_TERRAIN, FG_DEBUG, " size of tile = "
<< sizeof( e ) );
// cout << "FILL IN CACHE ENTRY = " << index << endl;
tile_cache[index].center = Point3D( 0.0 );
- if ( (tile_cache[index].vtlist != NULL) ||
- (tile_cache[index].vnlist != NULL) ||
- (tile_cache[index].tclist != NULL) )
+ if ( tile_cache[index].vec3_ptrs.size() ||
+ tile_cache[index].vec2_ptrs.size() ||
+ tile_cache[index].index_ptrs.size() )
{
FG_LOG( FG_TERRAIN, FG_ALERT,
"Attempting to overwrite existing or"
<< " not properly freed leaf data." );
exit(-1);
}
- // Force some values in case the tile fails to load (i.e. fill
- // doesn't exist)
- // tile_cache[index].vtlist = NULL;
- // tile_cache[index].vnlist = NULL;
- // tile_cache[index].tclist = NULL;
// Load the appropriate data file and build tile fragment list
FGPath tile_path( current_options.get_fg_root() );
tile_cache[index].range_ptr = new ssgRangeSelector;
ssgBranch *new_tile = fgObjLoad( tile_path.str(), &tile_cache[index] );
+ if ( current_options.get_clouds() ) {
+ ssgLeaf *cloud_layer = fgGenCloudLayer( &tile_cache[index],
+ current_options.get_clouds_asl() );
+ new_tile -> addKid( cloud_layer );
+ }
+
if ( new_tile != NULL ) {
tile_cache[index].range_ptr->addKid( new_tile );
}
// Constructor
FGTileEntry::FGTileEntry ( void )
: ncount(0),
- state(Unused),
- vtlist(NULL),
- vnlist(NULL),
- tclist(NULL)
+ state(Unused)
{
nodes.clear();
}
// Step through the fragment list, deleting the display list, then the
// fragment, until the list is empty. Also delete the arrays used by
// ssg as well as the whole ssg branch
-void
-FGTileEntry::free_tile()
-{
+void FGTileEntry::free_tile() {
+ int i;
FG_LOG( FG_TERRAIN, FG_DEBUG,
"FREEING TILE = (" << tile_bucket << ")" );
// delete the ssg structures
FG_LOG( FG_TERRAIN, FG_DEBUG,
- " deleting vertex, normal, and texture coordinate arrays" );
- FG_LOG( FG_TERRAIN, FG_DEBUG,
- " deleting vertex array" );
- if ( vtlist != NULL ) {
- delete vtlist;
- vtlist = NULL;
- }
- FG_LOG( FG_TERRAIN, FG_DEBUG,
- " deleting normal array" );
- if ( vnlist != NULL ) {
- delete vnlist;
- vnlist = NULL;
+ " deleting (leaf data) vertex, normal, and "
+ << " texture coordinate arrays" );
+
+ for ( i = 0; i < (int)vec3_ptrs.size(); ++i ) {
+ delete vec3_ptrs[i];
}
- FG_LOG( FG_TERRAIN, FG_DEBUG,
- " deleting texture coordinate array" );
- if ( tclist != NULL ) {
- delete tclist;
- tclist = NULL;
+ vec3_ptrs.clear();
+
+ for ( i = 0; i < (int)vec2_ptrs.size(); ++i ) {
+ delete vec2_ptrs[i];
}
- for ( int i = 0; i < (int)free_ptrs.size(); ++i ) {
- delete free_ptrs[i];
+ vec2_ptrs.clear();
+
+ for ( i = 0; i < (int)index_ptrs.size(); ++i ) {
+ delete index_ptrs[i];
}
- free_ptrs.clear();
+ index_ptrs.clear();
// delete the ssg branch
typedef container::iterator FragmentIterator;
typedef container::const_iterator FragmentConstIterator;
- typedef vector < unsigned short * > free_list;
+ typedef vector < sgVec3 * > free_vec3_list;
+ typedef vector < sgVec2 * > free_vec2_list;
+ typedef vector < unsigned short * > free_index_list;
public:
// node list (the per fragment face lists reference this node list)
container fragment_list;
// ssg related structures
- sgVec3 *vtlist;
- sgVec3 *vnlist;
- sgVec2 *tclist;
- free_list free_ptrs; // list of pointers to free when tile
- // entry goes away
+ // sgVec3 *vtlist;
+ // sgVec3 *vnlist;
+ // sgVec2 *tclist;
+
+ // list of pointers to memory chunks that need to be freed when
+ // tile entry goes away
+ free_vec3_list vec3_ptrs;
+ free_vec2_list vec2_ptrs;
+ free_index_list index_ptrs;
// ssg tree structure for this tile is as follows:
// ssgRoot(scene)