[prev in list] [next in list] [prev in thread] [next in thread]
List: flightgear-cvs
Subject: [Flightgear-cvslogs] CVS: source/src/Scenery newcache.cxx, 1.2,
From: "Curtis L. Olson" <curt () flightgear ! org>
Date: 2003-12-30 15:12:08
Message-ID: E1AbLXU-0001BB-00 () baron ! me ! umn ! edu
[Download RAW message or body]
Update of /var/cvs/FlightGear-0.9/source/src/Scenery
In directory baron:/tmp/cvs-serv4523
Modified Files:
newcache.cxx newcache.hxx tileentry.cxx tileentry.hxx
tilemgr.cxx tilemgr.hxx
Log Message:
Add a small optimization to reduce the amount of vasi computation that is
done every frame.
Index: newcache.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Scenery/newcache.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** newcache.cxx 10 Dec 2002 20:50:52 -0000 1.2
--- newcache.cxx 30 Dec 2003 15:12:04 -0000 1.3
***************
*** 208,211 ****
--- 208,225 ----
+ // Clear the inner ring flag for all tiles in the cache so that the
+ // external tile scheduler can flag the inner ring correctly.
+ void FGNewCache::clear_inner_ring_flags() {
+ tile_map_iterator current = tile_cache.begin();
+ tile_map_iterator end = tile_cache.end();
+
+ for ( ; current != end; ++current ) {
+ FGTileEntry *e = current->second;
+ if ( e->is_loaded() && (e->get_pending_models() == 0) ) {
+ e->set_inner_ring( false );
+ }
+ }
+ }
+
// Clear a cache entry, note that the cache only holds pointers
// and this does not free the object which is pointed to.
Index: newcache.hxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Scenery/newcache.hxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** newcache.hxx 10 Dec 2002 20:50:52 -0000 1.2
--- newcache.hxx 30 Dec 2003 15:12:04 -0000 1.3
***************
*** 86,89 ****
--- 86,93 ----
long get_oldest_tile();
+ // Clear the inner ring flag for all tiles in the cache so that
+ // the external tile scheduler can flag the inner ring correctly.
+ void clear_inner_ring_flags();
+
// Clear a cache entry, note that the cache only holds pointers
// and this does not free the object which is pointed to.
***************
*** 93,99 ****
void clear_cache();
- // Fill in a tile cache entry with real data for the specified bucket
- // void fill_in( const SGBucket& b );
-
// Return a pointer to the specified tile cache entry
inline FGTileEntry *get_tile( const long tile_index ) {
--- 97,100 ----
Index: tileentry.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Scenery/tileentry.cxx,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -r1.33 -r1.34
*** tileentry.cxx 30 Dec 2003 07:04:40 -0000 1.33
--- tileentry.cxx 30 Dec 2003 15:12:04 -0000 1.34
***************
*** 73,76 ****
--- 73,77 ----
loaded(false),
pending_models(0),
+ is_inner_ring(false),
free_tracker(0)
{
***************
*** 494,500 ****
}
! if ( vasi_lights_transform ) {
// now we need to traverse the list of vasi lights and update
! // their coloring
for ( int i = 0; i < vasi_lights_transform->getNumKids(); ++i ) {
// cout << "vasi root = " << i << endl;
--- 495,503 ----
}
! if ( vasi_lights_transform && is_inner_ring ) {
// now we need to traverse the list of vasi lights and update
! // their coloring (but only for the inner ring, no point in
! // doing this extra work for tiles that are relatively far
! // away.)
for ( int i = 0; i < vasi_lights_transform->getNumKids(); ++i ) {
// cout << "vasi root = " << i << endl;
Index: tileentry.hxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Scenery/tileentry.hxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** tileentry.hxx 24 Sep 2003 19:59:25 -0000 1.9
--- tileentry.hxx 30 Dec 2003 15:12:04 -0000 1.10
***************
*** 169,174 ****
double timestamp;
! // this variable tracks the status of the incremental memory freeing.
enum {
NODES = 0x01,
--- 169,185 ----
double timestamp;
+ /**
+ * this value is used by the tile scheduler/loader to mark which
+ * tiles are in the primary ring (i.e. the current tile or the
+ * surrounding eight.) Other routines then can use this as an
+ * optimization and not do some operation to tiles outside of this
+ * inner ring. (For instance vasi color updating)
+ */
+ bool is_inner_ring;
! /**
! * this variable tracks the status of the incremental memory
! * freeing.
! */
enum {
NODES = 0x01,
***************
*** 261,268 ****
inline ssgTransform *get_terra_transform() { return terra_transform; }
- void set_timestamp(double time_ms) { timestamp = time_ms; }
-
inline double get_timestamp() const { return timestamp; }
};
--- 272,280 ----
inline ssgTransform *get_terra_transform() { return terra_transform; }
inline double get_timestamp() const { return timestamp; }
+ inline void set_timestamp( double time_ms ) { timestamp = time_ms; }
+ inline bool get_inner_ring() const { return is_inner_ring; }
+ inline void set_inner_ring( bool val ) { is_inner_ring = val; }
};
Index: tilemgr.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Scenery/tilemgr.cxx,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -r1.30 -r1.31
*** tilemgr.cxx 30 Dec 2003 05:57:25 -0000 1.30
--- tilemgr.cxx 30 Dec 2003 15:12:04 -0000 1.31
***************
*** 115,119 ****
// schedule a tile for loading
! void FGTileMgr::sched_tile( const SGBucket& b ) {
// see if tile already exists in the cache
FGTileEntry *t = tile_cache.get_tile( b );
--- 115,119 ----
// schedule a tile for loading
! void FGTileMgr::sched_tile( const SGBucket& b, const bool is_inner_ring ) {
// see if tile already exists in the cache
FGTileEntry *t = tile_cache.get_tile( b );
***************
*** 146,149 ****
--- 146,151 ----
delete e;
}
+ } else {
+ t->set_inner_ring( is_inner_ring );
}
}
***************
*** 181,185 ****
// note * 2 at end doubles cache size (for fdm and viewer)
tile_cache.set_max_cache_size( (2*xrange + 2) * (2*yrange + 2) * 2 );
-
/*
cout << "xrange = " << xrange << " yrange = " << yrange << endl;
--- 183,186 ----
***************
*** 188,196 ****
*/
SGBucket b;
// schedule center tile first so it can be loaded first
b = sgBucketOffset( longitude, latitude, 0, 0 );
! sched_tile( b );
int x, y;
--- 189,203 ----
*/
+ // clear the inner ring flags so we can set them below. This
+ // prevents us from having "true" entries we aren't able to find
+ // to get rid of if we teleport a long ways away from the current
+ // location.
+ tile_cache.clear_inner_ring_flags();
+
SGBucket b;
// schedule center tile first so it can be loaded first
b = sgBucketOffset( longitude, latitude, 0, 0 );
! sched_tile( b, true );
int x, y;
***************
*** 201,205 ****
if ( x != 0 || y != 0 ) {
b = sgBucketOffset( longitude, latitude, x, y );
! sched_tile( b );
}
}
--- 208,212 ----
if ( x != 0 || y != 0 ) {
b = sgBucketOffset( longitude, latitude, x, y );
! sched_tile( b, true );
}
}
***************
*** 211,215 ****
if ( x < -1 || x > 1 || y < -1 || y > 1 ) {
SGBucket b = sgBucketOffset( longitude, latitude, x, y );
! sched_tile( b );
}
}
--- 218,222 ----
if ( x < -1 || x > 1 || y < -1 || y > 1 ) {
SGBucket b = sgBucketOffset( longitude, latitude, x, y );
! sched_tile( b, false );
}
}
Index: tilemgr.hxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Scenery/tilemgr.hxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** tilemgr.hxx 30 Dec 2003 05:57:25 -0000 1.9
--- tilemgr.hxx 30 Dec 2003 15:12:04 -0000 1.10
***************
*** 78,89 ****
// schedule a tile for loading
! void sched_tile( const SGBucket& b );
// schedule a needed buckets for loading
void schedule_needed(double visibility_meters, SGBucket curr_bucket);
- // see comment at prep_ssg_nodes()
- void prep_ssg_node( int idx );
-
FGHitList hit_list;
--- 78,86 ----
// schedule a tile for loading
! void sched_tile( const SGBucket& b, const bool is_inner_ring );
// schedule a needed buckets for loading
void schedule_needed(double visibility_meters, SGBucket curr_bucket);
FGHitList hit_list;
_______________________________________________
Flightgear-cvslogs mailing list
Flightgear-cvslogs@flightgear.org
http://mail.flightgear.org/mailman/listinfo/flightgear-cvslogs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic