|
From: David M. <da...@me...> - 2001-06-19 20:39:19
|
David Megginson writes:
> Wolfram Kuss writes:
>
> > This leads to a hit in the intersection!! I would guess that jsb then
> > runs, since it gets the real height of the scenery. Of course my code
> > is completely temporary; For example I hardcoded lat, lon of KSJC.
> > The only reason for the code is to find the reason for the bug. I hope
> > this helps more knowledgable people than me forward. Obviously, the
> > problem is with the code for the threaded loading, although I don't
> > use threads. But it seems even then tiles that are loaded into a queue
> > and then at an possibly other time taken out of that. Obviously, not
> > one tile has been attached to the variable "terrain" when the
> > intersection test between the ray and the terrain is done.
>
> The code does attempt to run the queue once, before trying to get the
> elev, and it reports that it has loaded a tile; I wonder why it's not
> attached to "terrain".
OK, I've solved the bug. There were two problems in
FGTileMgr::update, both caused by the new threading code:
1. current_elev_ssg was invoked too early, after the load queue was
run but before the attach queue was run (i.e. the tile was loaded
but not attached to anything, so FlightGear couldn't give JSBSim
the right ground elevation) ...
2. ... but it wouldn't have mattered anyway, because the attach queue
is run only once every five iterations, starting with the fifth.
I moved the call to current_elev_ssg to the end of the method, and
changed to assign queue test so that it would run on the first
iteration, and JSBSim now starts nicely on the runway.
The patch is small, so I'm including it in this message (I'll also
send the full file to Curt with my next round of changes).
Index: tilemgr.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.7/FlightGear/src/Scenery/tilemgr.cxx,v
retrieving revision 1.61
diff -c -r1.61 tilemgr.cxx
*** tilemgr.cxx 2001/06/14 20:10:29 1.61
--- tilemgr.cxx 2001/06/19 20:36:33
***************
*** 378,383 ****
--- 378,407 ----
delete dm;
}
+ // cout << "current elevation (ssg) == " << scenery.cur_elev << endl;
+
+ previous_bucket = current_bucket;
+ last_longitude = longitude;
+ last_latitude = latitude;
+
+ // activate loader thread one out of every 5 frames
+ counter_hack = (counter_hack + 1) % 5;
+ if ( counter_hack == 1 ) {
+ // Notify the tile loader that it can load another tile
+ // loader.update();
+
+ if ( !attach_queue.empty() ) {
+ #ifdef ENABLE_THREADS
+ FGTileEntry* e = attach_queue.pop();
+ #else
+ FGTileEntry* e = attach_queue.front();
+ attach_queue.pop();
+ #endif
+ e->add_ssg_nodes( terrain, ground );
+ // cout << "Adding ssg nodes for "
+ }
+ }
+
if ( scenery.center == Point3D(0.0) ) {
// initializing
cout << "initializing scenery current elevation ... " << endl;
***************
*** 412,441 ****
} else {
scenery.cur_elev = 0.0;
}
- }
-
- // cout << "current elevation (ssg) == " << scenery.cur_elev << endl;
-
- previous_bucket = current_bucket;
- last_longitude = longitude;
- last_latitude = latitude;
-
- // activate loader thread one out of every 5 frames
- counter_hack = (counter_hack + 1) % 5;
- if ( !counter_hack ) {
- // Notify the tile loader that it can load another tile
- // loader.update();
-
- if ( !attach_queue.empty() ) {
- #ifdef ENABLE_THREADS
- FGTileEntry* e = attach_queue.pop();
- #else
- FGTileEntry* e = attach_queue.front();
- attach_queue.pop();
- #endif
- e->add_ssg_nodes( terrain, ground );
- // cout << "Adding ssg nodes for "
- }
}
return 1;
--- 436,441 ----
All the best,
David
--
David Megginson
da...@me...
|