1
0
Fork 0
Commit graph

203 commits

Author SHA1 Message Date
timoore
616b2bf4f6 Use the OSG DatabasePager instead of FGTileLoader
Make an OSG file reader for .stg files.

New class flightgear::SceneryPager, which is a subclass
osg::DatabasePager to handle explicit delete requests.

Modify FGNewCache, FGTileEntry, and FGTileManager to use
SceneryPager. Mostly this involved removing the queues that talked to
FGTileLoader.

Calculate accurate tile timestamps from the time they are traversed in
the cull stage (which means that they are visible) instead of updating
them periodically.

Replace tile entry transform and range node with one LOD node
2007-12-14 22:51:56 +00:00
timoore
a76f3863bf Move to loading tiles and their submodels only by name.
Some cleanup in tileentry.cxx, but mostly code to implement loading of tiles
and their models without reference to FGTileEntry or SGBucket structures.
Also, don't do deferred model loading; load them when the tile is loaded.
2007-11-29 23:59:14 +00:00
mfranz
5abe6dffdb degrade "Warning: catching up on tile delete queue" from SG_ALERT to SG_WARN.
* it says it's a warning (while in fact it's just saying what it's doing)
* the user can't do much here (yes, flying slower, but it doesn't say that :-)
* scrolling those countless messages in the terminal puts stress on the CPU
  in a time when it's apparently already struggling
2007-06-24 08:30:55 +00:00
frohlich
16a2bb0118 Modified Files:
src/ATC/AIPlane.cxx src/ATC/ATC.cxx src/ATC/ATCDialog.cxx
	src/ATC/ATCmgr.cxx src/ATC/Makefile.am src/ATC/approach.cxx
	src/ATC/atis.cxx src/ATC/ground.cxx src/ATC/tower.cxx
	src/GUI/mouse.cxx src/Main/Makefile.am src/Main/fg_init.cxx
	src/Main/fg_props.cxx src/Main/globals.cxx
	src/Main/globals.hxx src/Main/main.cxx src/Main/renderer.cxx
	src/Model/acmodel.cxx src/Scenery/scenery.cxx
	src/Scenery/scenery.hxx src/Scenery/tilemgr.cxx
	src/Scenery/tilemgr.hxx
Removed Files:
	src/ATC/ATCdisplay.cxx src/ATC/ATCdisplay.hxx:
	Remove unused functions and the disabled ATC display.
2007-05-09 20:41:08 +00:00
frohlich
b51292d9db Modified Files:
src/FDM/groundcache.cxx src/Main/fg_commands.cxx
	src/Main/main.cxx src/Main/renderer.cxx
	src/Scenery/FGTileLoader.cxx src/Scenery/scenery.cxx
	src/Scenery/scenery.hxx src/Scenery/tileentry.cxx
	src/Scenery/tileentry.hxx src/Scenery/tilemgr.cxx
	src/Scenery/tilemgr.hxx: Simplify scenegraph structure.
2007-05-08 06:12:26 +00:00
frohlich
b0f9d24f9d Modified Files:
configure.ac src/AIModel/AIAircraft.cxx src/AIModel/AIBase.cxx
 	src/AIModel/AIBase.hxx src/AIModel/AICarrier.cxx
 	src/AIModel/AICarrier.hxx src/AIModel/AIManager.cxx
 	src/AIModel/AIManager.hxx src/ATC/AIEntity.cxx
 	src/ATC/AIEntity.hxx src/ATC/AIMgr.cxx src/ATC/AIMgr.hxx
 	src/ATC/ATCdisplay.cxx src/ATC/ATCdisplay.hxx
 	src/Cockpit/cockpit.cxx src/Cockpit/cockpit.hxx
 	src/Cockpit/hud.cxx src/Cockpit/hud.hxx
 	src/Cockpit/hud_rwy.cxx src/Cockpit/panel.cxx
 	src/Cockpit/panel.hxx src/Cockpit/built_in/FGMagRibbon.cxx
 	src/Cockpit/built_in/FGMagRibbon.hxx src/FDM/flight.cxx
 	src/FDM/groundcache.cxx src/FDM/groundcache.hxx
 	src/GUI/gui_funcs.cxx src/Input/input.cxx
 	src/Instrumentation/od_gauge.cxx
 	src/Instrumentation/od_gauge.hxx
 	src/Instrumentation/render_area_2d.cxx
 	src/Instrumentation/render_area_2d.hxx
 	src/Instrumentation/wxradar.cxx
 	src/Instrumentation/wxradar.hxx
 	src/Instrumentation/HUD/HUD.cxx
 	src/Instrumentation/HUD/HUD.hxx
 	src/Instrumentation/HUD/HUD_runway.cxx src/Main/Makefile.am
 	src/Main/main.cxx src/Main/renderer.cxx src/Main/renderer.hxx
 	src/Main/viewmgr.cxx src/Model/acmodel.cxx
 	src/Model/acmodel.hxx src/Model/model_panel.cxx
 	src/Model/model_panel.hxx src/Model/modelmgr.cxx
 	src/Model/modelmgr.hxx src/Model/panelnode.cxx
 	src/Model/panelnode.hxx src/Navaids/awynet.cxx
 	src/Scenery/Makefile.am src/Scenery/hitlist.cxx
 	src/Scenery/hitlist.hxx src/Scenery/newcache.cxx
 	src/Scenery/scenery.cxx src/Scenery/scenery.hxx
 	src/Scenery/tileentry.cxx src/Scenery/tileentry.hxx
 	src/Scenery/tilemgr.cxx src/Scripting/NasalSys.cxx
 	src/Scripting/NasalSys.hxx src/Time/light.cxx
	Big BLOB on the way to OSG.
2006-10-29 19:30:21 +00:00
mfranz
5656526d83 as the "Attempting to schedule tiles for bogus lon and lat = (-1000,0)"
bug happens now on a regular basis, and just ignoring it doesn't seem to
cause any harm, just return after it, rather than abort.
2006-08-19 07:30:52 +00:00
frohlich
d11ec8c8e7 Don't bail out for lon == 180 or lat == 90 2006-06-15 08:55:42 +00:00
frohlich
292ad8f5af Remove unused variable 2006-03-20 18:16:09 +00:00
mfranz
2796f3f4a5 NasalSys.[ch]xx:
implement FGNasalModelData class for execution of XML <load> and <unload>
  scripts. modelLoaded() is called by the model loader, and the destructor
  on branch removal.

modelmgr.cxx:
tilemgr.cxx:
tileentry.[ch]xx:
  make scenery and custom objects run their Nasal scripts on loading
  and unloading. Let OBJECT_STATIC object not be cached.
2006-03-09 09:04:03 +00:00
mfranz
c9813d1b5d new FSF address 2006-02-21 01:16:04 +00:00
ehofman
90a149ffa3 Vassilii Khachaturov:
* in some cases more specific sg exception types were used in place
  of the more generic one, e.g., sg_io_exception instead of sg_exception
  when the context of the error was an IO error
* in some cases, the error message was made more specific
* minor style fix for exception rethrowing --- using throw; whenever
  a re-throw is made; sometimes optimizing away the exception symbol name
  in the catch handler at all
* more specific catch handlers added in some places -- e.g.,
  an sg_io_exception caught ahead of sg_exception
2005-12-11 13:37:06 +00:00
curt
e807c7f95c A long, long time ago, a bug was inadvertently introduced into the threaded
metar fetcher.  Effectively this caused the metar thread and the main
thread to both attempt to fetch weather data.  This could lead to long pauses
when the main thread decided to fetch the weather, and introduced a race
condition that could cause a segfault/crash.

Investigating this issue, I discovered that even longer ago, someone confused
#defines and #ifdef symbols with C/C++ variables.  If I #define XYZ 0 it is
defined so #ifdef XYZ is true, not false like a variable.  Our thread
detection made this mistake and there were follow up patches to work around
it.

So I fixed the configure script (ahhh, reading the autoconf manual is highly
recommended excercise for people editing the configure.ac file.)  I also
discovered that we were hardwiring with_threads=yes with no way via configure
options to disable threads from the build so I fixed that.

Then I patched up the #ifdef's scattered through the code to match the
configure script changes, oh and by the way, I stumbled upon a past typo
that led to the race condition in the metar fetching thread and fixed that.
2005-11-22 17:02:31 +00:00
ehofman
b24dbb3f8b Alex Romosan:
I tried to make sure accessor functions which return by reference act
on const objects. also replaced some iterators with const_iterator
and a few return/pass by reference that were missed the first time
around.
2005-10-26 09:03:49 +00:00
ehofman
fad67bda10 Mathias Frhlihlich:
There was a patch from Manuel Masing a few months ago which cleaned up
SGLocation's way depending on input values. That means that with that patch
SGLocation does no longer have calls with unneeded input arguments.
I took his patch and integrated that into flightgear and made maximum use of
that changes.


Erik Hofman:
Remove some duplicate code that was moved to simgear/compiler.h
2005-09-05 13:25:09 +00:00
ehofman
7b824755ee Mathias Frhlich:
I have prepared a patch that:
- Introduces a FGTileMgr::scenery_available method which asks the tilemanager
  if scenery for a given range around a lat/lon pair is already loaded and make
  use of that method at some -9999 meter checks.
- Introduces a FGScenery::get_elevation_m method which queries the altitude at
  a given position. In constrast to the groundcache functions this is the best
  choice if you ask for one *single* altitude value. Make use of that thing in
  AI/ATC classes and for the current views ground level. At the current views
  part the groundcache is reused if possible.
- The computation of the 'current groundlevel' is no longer done on the
  tilemanagers update since the required functions are now better seperated.

Alltogether it eliminates somehow redundant terrain level computations which
are now superseeded by that more finegrained functions and the existence of
the groundcache. Additionally it introduces an api to commonly required
functions which was very complex to do prevously.
2005-08-14 12:57:12 +00:00
ehofman
f2cf76171f Harald JOHNSEN:
Changes
=======

New volumetric shadows for FlightGear.

There is now two new checkboxes in the rendering dialog to enable/disable shadows
for the user aircraft and for static scenery objects (ie those defined in the .stg files).
AI and random objects are not handled for the moment.


known bugs
==========
- ghost objects
2005-06-26 17:21:18 +00:00
mfranz
61b5efb772 The "catching up on tile delete queue" doesn't justify an ALERT message.
It happens regularly during normal operation (ufo!) and only informs about
unfortunate, but known and deliberate behavior. The user can't do anything
about it, anyway. And finally: flooding the console with this message does
only *add* to fgfs' sluggish performance and makes every other message
go unnoticed.
2005-05-22 17:14:15 +00:00
ehofman
4c10ef139c Mathias:
I have done a patch to eliminate the jitter of 3D-objects near the viewpoint
(for example 3D cockpit objects).
The problem is the roundoff accuracy of the float values used in the
scenegraph together with the transforms of the eyepoint relative to the
scenery center.

The solution will be to move the scenery center near the view point.
This way floats relative accuracy is enough to show a stable picture.

To get that right I have introduced a transform node for the scenegraph which
is responsible for that shift and uses double values as long as possible.
The scenery subsystem now has a list of all those transforms required to place
objects in the world and will tell all those transforms that the scenery
center has changed when the set_scenery_center() of the scenery subsystem is
called.
The problem was not solvable by SGModelPlacement and SGLocation, since not all
objects, especially the scenery, are placed using these classes.

The first approach was to have the scenery center exactly at the eyepoint.
This works well for the cockpit.
But then the ground jitters a bit below the aircraft. With our default views
you can't see that, but that F-18 has a camera view below the left engine
intake with the nose gear and the ground in its field of view, here I could
see that.
Having the scenery center constant will still have this roundoff problems, but
like it is now too, the roundoff error here is exactly the same in each
frame, so you will not notice any jitter.

The real solution is now to keep the scenery center constant as long as it is
in a ball of 30m radius around the view point. If the scenery center is
outside this ball, just put it at the view point.

As a sideeffect of now beeing able to switch the scenery center in the whole
scenegraph with one function call, I was able to remove a one half of a
problem when switching views, where the scenery center was far off for one or
two frames past switching from one view to the next. Also included is a fix
to the other half of this problem, where the view position was not yet copied
into a view when it is switched (at least under glut). This was responsible
for the 'Error: ...' messages of the cloud subsystem when views were
switched.
2005-04-29 14:38:24 +00:00
ehofman
7159e318e1 Mathias Frhlich:
I have now split out the ground cache functions into src/FDM/groundcache.[ch]xx
Attached are the two files and the patch to integrate that cache into
FGInterface.

The code is nowhere used at the moment, the fdm's need to be updated to use
that ground cache. The JSBSim-dropin.tar.gz from Martins ftp server does this
for example.

The carrier's scenegraph is not yet processed to be visible for ground
intersection testing. So the only benefit up to now is that the api is set
up. Using this I can put the changes to make JSBSim work with that into
JSBSim's cvs. Also I aim to provide Andy a patch to make use of that with
YASim.
2004-11-22 10:10:33 +00:00
curt
d05121ef46 Fix my mailing address by replacing it with my web page. 2004-11-19 22:10:41 +00:00
curt
cc3d0221ea Make a subtle change to tile loading/unloading policy in order to make the tile
paging system much more robust when position change is very rapid and sporadic.

Recall that we must load 3d models in the main render thread because model
loading can trigger opengl calls (i.e. with texture loading) and all opengl
calls *must* happen in the main render thread.

To accomplish this we load the base tile in the pager thread and build a work
queue of external models that need to be loaded.  We never allow a tile to be
paged out of the tile cache until all it's pending model loads are complete.

However, when changing position very rapidly, we can quickly create a huge
backlog of pending model loads because we are changing positions faster than we
can load the associated models for the existing tiles.  The end result is
that tiles that are long out of range can't be removed because there is still
a huge backlog of pending model load requests and memory blows up.

This change being committed allows the tile paging system to remove tiles
if they are out of range, even when there are pending models to load.  The
model loading code in the render thread can now check to see if the tile
exists and discard any model load request for tiles that no longer exist.

This situation should never occur in normal operation, but could occur in
"contrived" situations where an external script was rapidly changing
the simulator position to then be able to query FG terrain height, and doing
this for a large number of points that are distributed across a large area.
2004-09-15 15:52:05 +00:00
ehofman
9d972d86bf Jim Wilson: This patch prevents FDM execution until intial scenery load completes making
midair starts in the KSFO area possible again.
2004-07-22 16:42:14 +00:00
ehofman
56f085b6f1 Melchior FRANZ:
Remove an unused test, counter_hack is initialized to 0 and the test never reaches the increment section but instead will always call loader.update();
2004-06-13 18:47:55 +00:00
andy
7ceb85d454 Changes to get FlightGear (well, the src directory at least) to
configure and compile out-of-the-box on a MinGW target:

Use -lSDL instead of -lglut32 on windows builds when --enable-sdl
is set.

Link against alut.dll in addition to openal32.dll.

Replace BSD bcopy() with ANSI C memmove() in a few places.  This is
simpler than trying to abstract it out as a platform dependency in a
header file; bcopy() has never been standard.

The ENABLE_THREADS handling has changed to be set to 0 when threads
are not in use.  This breaks expressions like #ifdef ENABLE_THREADS.
Replace with a slightly more complicated expression.  It might have
been better to fix the configure.ac script, but I didn't know how and
this whole setting is likely to go away soon anyway.

The MinGW C runtime actually does include snprintf, so only MSVC
builds (and not all WIN32 ones) need _snprintf in JSBSim/FGState.cpp

Building on a platform with no glut at all exposed some spots where
plib/pu.h was being included without a toolkit setting (it defaults to
glut).  Include fg_os.hxx first.

And when still using glut, glut.h has a bizarre dependency on a
_WCHAR_T_DEFINED symbol.  It it's not defined, it tries to redefine
(!!) wchar_t to disasterous effect.
2004-04-30 00:52:11 +00:00
ehofman
7902c04905 Plib is willing callbacks to return 0, 1 or 2 and not simply a boolean 2004-04-02 19:49:51 +00:00
ehofman
b34f0711c4 Frederic Bouvier:
Add a static function that will be installed as a callback to
  cull or not the terrain leaves in tiles.
  Add a function to set the filter.
2004-04-02 14:42:42 +00:00
ehofman
cf96deac29 Frederic Bouvier:
The message 'Alert: catching up on tile delete queue'
comes from the fact that 48 tiles are scheduled and
added to the cache at startup before the plane location
is initialized. My proposed patch is to initialize
SGLocation with an invalid position and detect this
fact before scheduling tiles. I prefer to do that
rather than testing for lon and lat being 0,0 because
it is a valid position and someone could want to fly
near Accra.
2004-03-20 22:42:41 +00:00
curt
a1a68b9c93 Various preparations for the next release. 2004-03-18 02:37:01 +00:00
curt
72f2c5c4f4 Fix a type ... 2004-01-26 22:44:27 +00:00
curt
492d5fbd8d Fix a small mistake in the scene graph arrangement for vasi lights. 2004-01-11 19:45:29 +00:00
curt
461baef128 Add a small optimization to reduce the amount of vasi computation that is
done every frame.
2003-12-30 15:12:04 +00:00
curt
3d7f467c61 First stab at correct vasi/papi coloring. This is still rough and doesn't
account for variation in lighting alignment, but it's more useful than the
previous attempt which was based on a misunderstanding of how environment
mapping worked.
2003-12-30 05:57:25 +00:00
david
e95e9bbf4e Oops -- checked in last version with a small typo. 2003-11-24 18:00:48 +00:00
david
d296e5a7df Use proper logging facility, and lower the priority of some of the
logging messages.  This is part of an effort to make FlightGear a bit
quieter during normal operations.
2003-11-24 17:45:35 +00:00
curt
f6fad7f000 Tweaks and massages to the ground intersection code. Most of the changes
are cosmetic, but we now have a combination of code that seems to work
very robustly.  I was able to land the yf23 at about 130 kts on the lower
level of the bay bridge and then taxi the entire length.
2003-11-21 22:00:46 +00:00
curt
ca6067cbc0 With this patch, you can fly under bridges, then turn around and land on
them lengthwise.
2003-11-21 04:41:01 +00:00
curt
905b48c55c Sort VASI lights into their own tree so we can control them separately
from the rest of the runway lighting.  VASI/PAPI lights are generally
always on.  Also, the red/white VASI coloring has never worked right.
This is also a step towards fixing that problem.
2003-09-24 19:59:25 +00:00
ehofman
980012e168 Move FGEventMgr and FGSubsystemMgr over to SimGear, add SGEventMgr to FlightGear's globals structre and some small code cleanups 2003-09-24 17:20:55 +00:00
ehofman
7249aaea33 Frederic Bouvier:
This patch is there to correct a problem that prevent to load static objects when specifying a relative fg-root or a different, relative, fg-scenery. It appears that there is a mix between fg-root, fg-scenery and PLIB's model-dir.
It has been reported on the list that users are not able to see the buildings, especially those running the win32 builds because they run 'runfgfs.bat' that set FG_ROOT=./DATA.

I decided not to use model-dir because it just add confusion and to build a valid path earlier.
2003-09-13 11:47:30 +00:00
curt
b23183f018 Put the id of the tile we are flying over into the property tree for
convenience of debugging.
2003-08-28 20:52:34 +00:00
ehofman
c745a8f956 Add a comment on how to enable an alternative HOT algorithm that enables one to fly underneath static objects 2003-08-18 09:34:12 +00:00
curt
b749638fd6 Move low level "tg" object loader code over to SimGear. 2003-05-28 21:01:55 +00:00
curt
6200c3cb62 Changes to track updates to SimGear. 2003-05-15 21:35:51 +00:00
curt
3c7bdc31d9 Cosmetic changes for new code moved into simgear to make the naming scheme
better follow simgear conventions.
2003-05-13 03:18:42 +00:00
curt
56db994994 Moved src/Model/loader.[ch]xx and src/Model/model.[ch]xx to
simgear/scene/model/
2003-05-09 20:40:59 +00:00
curt
198b88ca9b This is step "1" of probably "many" in the process of separating out the
scene management code and organizing it within simgear.  My strategy is
to identify the code I want to move, and break it's direct flightgear
dependencies.  Then it will be free to move over into the simgear package.

- Moved some property specific code into simgear/props/
- Split out the condition code from fgfs/src/Main/fg_props and put it
  in it's own source file in simgear/props/
- Created a scene subdirectory for scenery, model, and material property
  related code.
- Moved location.[ch]xx into simgear/scene/model/
- The location and condition code had dependencies on flightgear's global
  state (all the globals-> stuff, the flightgear property tree, etc.)  SimGear
  code can't depend on it so that data has to be passed as parameters to the
  functions/methods/constructors.
- This need to pass data as function parameters had a dramatic cascading
  effect throughout the FlightGear code.
2003-05-06 23:54:17 +00:00
curt
2e90248df8 Make error message slightly more informative. 2003-03-21 20:39:59 +00:00
curt
53083bf9fb Another tilemgr fix from Jim W. 2003-02-11 15:50:53 +00:00
curt
0fe90a83dd Fix a bug in tile manager updating when switching from one view to the next. 2003-02-10 15:34:18 +00:00
curt
43e48070fe - Some refactoring of the configure.ac script.
- Better Mac OS X support (they put glut.h in GLUT/glut.h) :-(
2002-12-10 20:50:48 +00:00
curt
28243f40ca White space cleanups. 2002-12-07 02:26:50 +00:00
curt
1feedec8d1 - Change the global_tile_mgr to a globals->get_tile_mgr() which is
dynamically created at run time.
- Further clean ups to the FGTileMgr class interface.
2002-12-06 22:29:46 +00:00
curt
a6ce9a5b2a A small amount of additional massaging of tile manager update() interface. 2002-11-30 14:22:00 +00:00
curt
bcf9fa3695 Massaging the FGTileMgr->update() interface towards using FGLocation. 2002-11-30 03:05:34 +00:00
curt
95109cec57 Split out tile load/free queue processing into a separate routine. 2002-11-30 02:21:04 +00:00
curt
89874fd5f5 Make tile_mgr->prep_ssg_nodes() use an FGLocation object. 2002-11-28 01:08:25 +00:00
curt
dbf997a2d3 Put taxiway lights in their own scene graph so we can adjust their brightness
(or fog punch through) independently from the ground or runway lighting.
2002-11-01 21:56:48 +00:00
curt
7df3da668c Fix a bug in ground elevation measuring for the first frame after we cross
a tile boundary.  (Potentially imposes a slight performance penalty, but
getting the correct answer needs to be higher priority than getting the
wrong answer really quickly.)
2002-10-17 15:54:31 +00:00
curt
c162577340 Begin work on rendering runway lights using environment maps. The basics
are now working.  A runway light is defined by a point and a direction.  The
point and direction are combined with the local up vector to create a small
triangle orthogonal to the direction.  The two ficticous corners of the
triangle are given an alpha value of zero, the orignal corner is given an
alpha of one.  The triangle is drawn in glPolygonMode(GL_FRONT, GL_POINT)
mode which means only the corner points are drawn, and since two have alpha=0
only the original point is drawn.  This is a long way to go to draw a point,
but it ensures that the point is only visible within 90 degrees of the light
direction, behind the light it is not visible.  This is still a long way
to get to drawing a point, but we use an environement map, with the direction
vector as the normal to mimic a light that is brightest when viewed head
on and dimmest when viewed perpendicularly or disappears when viewed from
behind.

- warning, there is a bug in how the current runway light direction vector
  is calculated which will adversely effect runway lighting.  The airports
  should be regenerated in order to fix this problem.
2002-10-06 03:53:19 +00:00
curt
7b01068d9c Bernie Bright:
fgLoad3DModel() throws an exception if it fails to load the requested model.
This causes FGTileMgr::update(...) to exit.  So I've added a try/catch block
to catch the exception and display an error message instead.
2002-09-23 14:23:17 +00:00
david
0ebe8ec8f0 Removed the FG3DModel class and replaced it with fgLoad3DModel.
Animations are now contained within the scene graph itself and are
updated whenever the graph is traversed -- that saves time by not
updating animations not currently in sight, and it allows animations
to be used for static objects and random objects as well.

Added new FGModelLoader and FGTextureLoader classes.  These are intern
tables for models, to guarantee (mostly) that no model is loaded more
than once.  FGTextureLoader is not yet used anywhere, but
FGModelLoader is now in place everywhere that ssgLoad* used to be
used (thus adding the ability to use animations).

In the future, FGModelLoader will add some interesting functionality,
including the ability to reload 3D models on the fly.
2002-08-07 01:34:49 +00:00
curt
2619106044 Fix tile cache resizing bug (which could lead to thrashing.) 2002-08-01 06:15:59 +00:00
curt
b3c5a8fb95 Various tweaks, enhancements, and optimizations surrounding tile paging
(specifically freeing tiles when we need to remove them from the tile cache.)
2002-07-29 05:07:38 +00:00
curt
27158525a9 Restructure the way tile freeing is handled. When a tile is removed from
the tile cache it's ssg elements are disconnected from the main ssg scene
graph, and then the tile is thrown on the end of a delete queue.  The
tilemgr->update() routine runs every frame.  It looks at this queue and if
it is non-empty, it incrementally frees the compents of the first tile
on the queue.  When the tile is completely free it is removed from the queue.

The amount of time to free the memory for even a single tile can be quite
substantial, especially with the increased overhead of dynamic/random
ground objects.  This change allows the system to spread the work of freeing
tile memory out over many frames so you don't get a noticable single frame
hit or stutter.
2002-07-25 23:59:04 +00:00
curt
96d499f4f1 Restructuring how tiles are freed to allow us to eventually spread the task
out over multiple frames.
2002-07-25 21:57:58 +00:00
curt
8ae364a220 Jim Wilson:
This is a small fix for what turned out to be a major bug.  Ground elevation
was calculated incorrectly when distant from one of the view locations. This
resulted in several problems including bizarre gear trimming, mid air
"crashes" (as in thinking we hit the ground) and so on when close to or on the
ground.

Unfortunately it does require a second ssg traversal when in tower view
(only), but the increased load isn't all that noticable.  For the time being
this really is the best solution.  In a future update I will be eliminating
the unecessary per frame traversals for the static views (without having to
maintain multiple ssgRoots).

When we go to multiple FDM instances we will perhaps need to put the ssg
traversal and ground elevation queries for the FDMs into an event timer that
updates the FDMs ground elevation in a round robin fashion (maybe every 1/n
seconds where n is the number of FDM instances running).
2002-05-20 16:13:37 +00:00
curt
b1674cb506 From: "Jim Wilson" <jimw@kelcomaine.com>
This is a new improved patch for the previous tile manager fixes.

Rather than building dependencies between FGlocation or the viewer or fdm with
tilemgr what I ended up doing was linking the pieces together in the Mainloop
in main.cxx.  You'll see what I mean...it's been commented fairly well.  More
than likely we should move that chunk somewhere...just not sure where yet.

The changes seem clean now. As I get more ideas there could be some further
improvement in organizing the update in tilemgr.  You'll note that I left an
override in there for the tilemgr::update() function to preserve earlier
functionality if someone needs it (e.g. usage independent of an fdm or
viewer), not to mention there are a few places in flightgear that call it
directly that have not been changed to the new interface (and may not need to be).

The code has been optimized to avoid duplicate traversals and seems to run
generally quite well.  Note that there can be a short delay reloading tiles
that have been dropped from static views.  We could call the tile scheduler on
a view switch, but it's not a big deal and at the moment I'd like to get this
in so people can try it and comment on it as it is.

Everything has been resycned with CVS tonight and I've included the
description submitted earlier (below).

Best,

Jim

Changes synced with CVS approx 20:30EDT 2002-05-09 (after this evenings updates).

Files:
http://www.spiderbark.com/fgfs/viewer-update-20020516.tar.gz
 or
http://www.spiderbark.com/fgfs/viewer-update-20020516.diffs.gz

Description:
In a nutshell, these patches begin to take what was one value for ground
elevation and calculate ground elevation values seperately for the FDM and the
viewer (eye position).  Several outstanding view related bugs have been fixed.

With the introduction of the new viewer code a lot of that Flight Gear code
broke related to use of a global variable called "scenery.cur_elev".

Therefore the ground_elevation and other associated items (like the current
tile bucket) is maintained per FDM instance and per View.  Each of these has a
"point" or location that can be identified.  See changes to FGLocation class
and main.cxx.

Most of the problems related to the new viewer in terms of sky, ground and
runway lights, and tower views are fixed.

There are four minor problems remaining.  1) The sun/moon spins when you pan
the "lookat" tower view only (view #3).  2) Under stress (esp. magic carpet
full speed with max visibility), there is a memory leak in the tile caching
that was not introduced with these changes.  3) I have not tested these
changes or made corrections to the ADA or External FDM interfaces.  4) The
change view function doesn't call the time/light update (not a problem unless
a tower is very far away).

Details:
FDM/flight.cxx, flight.hxx - FGInterface ties to FGAircraftModel so that it's
 location data can be accessed for runway (ground elevation under aircraft)
 elevation.

FDM/larsim.cxx, larcsim.hxx - gets runway elevation from FGInterface now.
Commented out function that is causing a namespace conflict, hasn't been
called with recent code anyway.

FDM/JSBSim/JSBSim.cxx, YASim/YASim.cxx - gets runway elevation from
FGInterface now.

Scenery/newcache.cxx, newcache.hxx - changed caching scheme to time based
(oldest tiles discard).

Scenery/tileentry.cxx, tileentry.hxx - added place to record time, changed
rendering to reference viewer altitude in order to fix a problem with ground
and runway lights.

Scenery/tilemgr.cxx, tilemgr.hxx - Modified update() to accept values for
multiple locations.   Refresh function added in  order to periodically make
the tiles current for a non-moving view (like a tower).

Main/fg_init.cxx - register event for making tiles current in a non-moving
view (like a tower).

Main/location.hxx - added support for current ground elevation data.

Main/main.cxx - added second tilemgr call for fdm, fixed places where viewer
position data was required for correct sky rendering.

Main/options.cxx - fixed segfault reported by Curtis when using --view-offset
command line parameter.

Main/viewer.cxx, viewer.hxx - removed fudging of view position. Fixed numerous
bugs that were causing eye and target values to get mixed up.
2002-05-17 17:25:28 +00:00
curt
92a58f6555 Consolodating scenery structures in scenery.hxx. 2002-05-14 05:49:47 +00:00
curt
47825dcbae Moved "scenery" from being declaried in scenery.cxx to being declared
in globals.hxx.
2002-05-14 05:22:52 +00:00
david
c5f6293f17 Fix for vanishing-model problem: models are drawn in the same scene
graph as the terrain, except for internal cockpit view.  The SSG
scene-graph variables (except for the lighting root -- I'll get that
later) are now held in globals.hxx.

FGModelMgr::draw() is obsolete; I'll remove it in a future revision.
2002-04-13 21:36:22 +00:00
david
6e5d22789b Patches from Norm Vine to improve framerate and add a new
#ifdef'ed-out mode for syncing fullscreen with user settings in
Windows.
2002-04-07 15:24:32 +00:00
david
4d4cd16012 Major viewer-code overhaul from Jim Wilson:
Description:

This update includes the new viewer interface as proposed by David M. and
a first pass at cleaning up the viewer/view manager code by Jim W.

Note that I have dropped Main/viewer_lookat.?xx and Main/viewer_rph.?xx and
modified the Makefile.am accordingly.


Detail of work:

Overall:
The code reads a little easier.  There are still some unnecessary bits in
there and I'd like to supplement the comments in the viewer.hxx with a tiny
bit on each interface group and what the groupings mean (similar but briefer
than what you emailed me the other day).  I tried not to mess up the style,
but there is an occasional inconsistency.  In general I wouldn't call it done
(especially since there's no tower yet! :)), but I'd like to get this out
there so others can comment, and test.

In Viewer:
The interface as you suggested has been implemented.  Basically everything
seems to work as it did visually.  There is no difference that I can see in
performance, although some things might be a tiny bit faster.

I've merged the lookat and rph (pilot view) code into the recalc for the
viewer.  There is still some redundancy between the two, but a lot has been
removed.  In some cases I've taken some code that we'd likely want to inline
anyway and left it in there in duplicate.  You'll see that the code for both
looks a little cleaner.  I need to take a closer look at the rotations in
particular.  I've cleaned up a little there, but I suspect more can be done
to streamline this.

The external declaration to the Quat_mat in mouse.cxx has been removed.  IMHO
the quat doesn't serve any intrinsic purpose in mouse.cxx, but I'm not about
to rip it out.  It would seem that there more conventional ways to get
spherical data that are just as fast.  In any case all the viewer was pulling
from the quat matrix was the pitch value so I modified mouse.cxx to output to
our pitchOffset input and that works fine.

I've changed the native values to degrees from radians where appropriate.
This required a conversion from degrees to radians in a couple modules that
access the interface.  Perhaps we should add interface calls that do the
conversion,  e.g. a getHeadingOffset_rad() to go along with the
getHeadingOffset_deg().

On the view_offset (now headingOffset) thing there are two entry points
because of the ability to instantly switch views or to scroll to a new view
angle (by hitting the numeric keys for example).   This leaves an anomaly in
the interface which should be resolved by adding "goal" settings to the
interface, e.g. a setGoalHeadingOffset_deg(), setGoalPitchOffset_deg(), etc.

Other than these two issues, the next step here will be to look at some
further optimizations, and to write support code for a tower view.  That
should be fairly simple at this point.  I was considering creating a
"simulated tower view" or "pedestrian view" that defaulted to a position off
to the right of whereever the plane is at the moment you switch to the tower
view.  This could be a fall back when we don't have an actual tower location
at hand (as would be the case with rural airports).

ViewManager:
Basically all I did here was neaten things up by ripping out excess crap and
made it compatible as is with the new interface.

The result is that viewmanager is now ready to be developed.  The two
preexisting views are still hardcoded into the view manager.  The next step
would be to design configuration xml (eg /sim/view[x]/config/blahblah) that
could be used to set up as many views as we want.  If we want to take the easy
way out, we might want to insist that view[0] be a pilot-view and have
viewmanager check for that.
2002-03-20 17:43:28 +00:00
curt
8138c82b58 Incorporated Norman's optimized line/geometry intersection code. 2002-03-17 00:38:24 +00:00
david
d0eaafb1e1 Patches from Tony Peden to separate property XML I/O operations into a
separate header file.  This change will help integrate properties into
JSBSim.

Also, I (David Megginson) removed most of the SimGear include
statements from globals.hxx, reducing the amount of recompilation
every time SimGear changes.  This required making minor changes to a
lot of files that were depending on the side-effects of the inclusions
in globals.hxx.
2002-03-16 00:18:38 +00:00
curt
73b92a697d Further restructuring of the scenery loading code. 2002-03-03 23:20:55 +00:00
david
2e4f836a98 General cleanups to cut cross-dependencies and speed up compilation.
Added two new properties:

  /environment/temperature-sea-level-degc
  /environment/pressure-sea-level-inhg

These are now supported in FGEnvironment as well, though they always
have the same value for now.  They need to be hooked up to the FDMs.
2002-02-22 23:37:45 +00:00
david
eaf9fa7621 Added FGEnvironmentMgr to provide information on the environment in
different locations, and hitched it into FGGlobals.  FGEnvironmentMgr
has taken over as the subsystem, while FGEnvironment is simple the
information that it returns.  I've removed current_environment
completely -- everything now uses properties or goes through
FGGlobals.  FGGlobals itself has a couple of useful methods:

  const FGEnvironment * get_environment ();
  const FGEnvironment * get_environment (double lat, double lon, double alt);

The first one returns the environment data for the plane's current
position, while the second returns the environment data for any
arbitrary location.  Currently, they both return the same information,
but that will change soon.
2002-02-22 22:51:34 +00:00
curt
0a61c0da99 Fix a big where the initial ground elevation reported could be bogus
(initialization order problem.)
2002-02-22 20:20:23 +00:00
david
71f120e3be Initial take of new environment subsystem. Configure with
--use-new-environment to active it.
2002-02-19 15:16:08 +00:00
david
3b870192f4 First steps in a weather reorganization. Note especially that
properties have been renamed from wind-(north|east|down)-fps to
wind-from-(north|east|down)-fps, and the FDMs modified appropriately.
No other changes should be visible unless FG_OLD_WEATHER is defined.
2002-02-19 01:26:44 +00:00
curt
dd8852dabe Better support for an alternate calendar time (i.e. if time/position/etc.
are being driven from an external data source.)

Akso found and fixed a bug in the simgear that caused the time to go goofy
temporarily while scenery was being loaded.
2002-02-11 23:33:20 +00:00
curt
3d1e802b84 Format tweaks. 2001-11-20 22:03:58 +00:00
curt
36de63366b I just nailed an especially annoying tile cache scheduling bug.
What was happening was that we screwed up and scheduled tiles for
(lon,lon) rather than (lon,lat) ... note the typo.  This generated
bogus tile id's which the system happily accepted, put into the tile
cache system, and attempted to load.  The problem was that these bogus
tile id's were negative where as all valid tile id's should be >= 0.

These negative tile id's up the logic used to remove tiles from the
cache.  When identifying tiles for removal, we look for the furthest
tile away from us by starting out the furthest id at -1 and if we find
something further, we update the furthest tile id.  Then at the end we
check if the furthest tile id >= 0 to see if we found anything we
could remove.  However, the furthest tile id was these bogus tiles
with negative tile id's so the system always assumed there was nothing
appropriate for removal.  This made it impossible to ever remove a
tile from the cache meaning it quickly filled up and no more tiles
could be loaded.

I fixed the one instance of scheduling tiles for a bogus location, and
added a sanity check so if it ever happens again we'll bomb with an
appropriate error message.
2001-11-12 22:05:47 +00:00
curt
e19d456716 Tweaks to get startup time, relative sun angle, sky colors, etc. to be
properly initialized.
2001-11-07 04:55:57 +00:00
curt
d0df197e1d Temporarily added some debugging output. 2001-10-29 04:40:19 +00:00
curt
2b056c8452 This set of changes touches a *lot* of files. The main goal here is to
fix startup sequence problems where we initialize the FDM before we know
the desired starting altitude.

These changes delay fdm initialization until the local tile has been loaded
and we can do a real intersection and find the true ground elevation.

In order to do this, I depend more on the property manager as glue, rather
than the FGInterface.

There are some glitches still when switching to a new airport or reseting
the sim.  I will work on addressing these, but I need to commit the changes
so far to keep in sync with other developers.
2001-10-28 16:16:30 +00:00
curt
96b88e539f Move FGControls declaration to globals.hxx 2001-07-22 19:51:16 +00:00
curt
fe82a3d31f Make the tile loader more tolerant of situations where the cache is full,
but no entries qualify for removal.  It will keep trying to schedule the
tile(s) until an entry frees up.  Entries in the cache do not qualify for
removal if they are in the process of being loaded.
2001-07-20 22:25:12 +00:00
curt
2fba4df258 Begin stubbing in some wrapper code in preparation for runway lighting. 2001-07-12 15:03:49 +00:00
curt
4b23576df1 Shuffled around and restructured the terrain elevation interesection code
to make it usable by the threaded tile loader for placing objects at ground
level at load time.
2001-07-11 15:51:21 +00:00
curt
4c8a7c3cef - fixed an initialization order bug that prevented reading correct
ground elevation at start-up
2001-06-20 22:22:26 +00:00
curt
81eb6d345d Fixed various warnings. 2001-06-14 22:10:29 +00:00
curt
35533b3a8d Test for null object after load before trying to connect it into the scene
graph (which would cause a crash.)
2001-06-01 18:04:10 +00:00
curt
d5a2533411 Fixed a bug in the tile pager / caching / management system that caused
a crash when relocating to a new airport.  Pending work from the old
area is now just completed as normal, rather than trying to empty the various
queues in their various stages when can lead to many problems in a threaded
environment.
2001-05-30 18:21:03 +00:00
curt
29d540901c Tile pager tweaks.
MSVC++ tweaks.
2001-05-21 20:44:59 +00:00
curt
34854ab2af Threaded tile paging:
- model loading deferred to primary thread
- tile removal deferred to paging thread
- other tweaks and rearrangments.

Airport signs
- first stab at some support for adding taxiway and runway signs.  This
  is non-optimal, but I'm under the gun for a demo.
2001-05-19 16:59:43 +00:00
curt
865fb56c5a Tile loading is interleaved now when not threaded. Threaded loader is
throttled to one tile per frame maximum.
2001-05-18 20:31:23 +00:00
curt
4a609646b6 Modified FlightGear/src/Scenery. The tile loader thread no longer adds
a newly loaded tile to the scene graph.  Instead it puts it in a queue
for the tile manager.  I've used your counter_hack to check the loaded
queue and add any tiles to the scene graph.  I was playing around with
the counter_hack so there might be some commented out code, etc.  I also
changed some SG_DEBUGs to SG_INFOs so I could track the tile loading.
2001-04-16 20:03:52 +00:00
curt
a29cb28e93 Tweaks to the tile pager so it waits for a signal from the main thread before
loading the next tile.  This allows the main thread to "pace" the tile loader
so it consumes fewer resources.
2001-04-14 03:11:39 +00:00