#include <simgear/math/polar3d.hxx>
#include <simgear/math/sg_geodesy.hxx>
#include <simgear/math/vector.hxx>
-#include <simgear/misc/exception.hxx>
+#include <simgear/structure/exception.hxx>
+#include <simgear/scene/model/modellib.hxx>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
#include <Main/viewer.hxx>
-#include <Model/loader.hxx>
-#include <Objects/obj.hxx>
#include "newcache.hxx"
#include "scenery.hxx"
current_bucket.make_bad();
longitude = latitude = -1000.0;
- last_longitude = last_latitude = -1000.0;
return 1;
}
// schedule a tile for loading
-void FGTileMgr::sched_tile( const SGBucket& b ) {
+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 );
// delete.) Try again later
delete e;
}
+ } else {
+ t->set_inner_ring( is_inner_ring );
}
}
|| latitude < -90.0 || latitude > 90.0 )
{
SG_LOG( SG_TERRAIN, SG_ALERT,
- "Attempting to schedule tiles for bogus latitude and" );
+ "Attempting to schedule tiles for bogus lon and lat = ("
+ << longitude << "," << latitude << ")" );
SG_LOG( SG_TERRAIN, SG_ALERT,
- "longitude. This is a FATAL error. Exiting!" );
+ "This is a FATAL error. Exiting!" );
exit(-1);
}
xrange = (int)(vis / tile_width) + 1;
yrange = (int)(vis / tile_height) + 1;
- if ( xrange < 1 ) { xrange /= 1; }
+ if ( xrange < 1 ) { xrange = 1; }
if ( yrange < 1 ) { yrange = 1; }
// 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;
cout << "max cache size = " << tile_cache.get_max_cache_size()
<< " current cache size = " << tile_cache.get_size() << endl;
*/
+ // 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 );
+ sched_tile( b, true );
int x, y;
for ( y = -1; y <= 1; ++y ) {
if ( x != 0 || y != 0 ) {
b = sgBucketOffset( longitude, latitude, x, y );
- sched_tile( b );
+ sched_tile( b, true );
}
}
}
for ( y = -yrange; y <= yrange; ++y ) {
if ( x < -1 || x > 1 || y < -1 || y > 1 ) {
SGBucket b = sgBucketOffset( longitude, latitude, x, y );
- sched_tile( b );
+ sched_tile( b, false );
}
}
}
try
{
ssgEntity *obj_model =
- globals->get_model_loader()->load_model(dm->get_model_path());
+ globals->get_model_lib()->load_model( ".",
+ dm->get_model_path(),
+ globals->get_props(),
+ globals->get_sim_time_sec() );
if ( obj_model != NULL ) {
dm->get_obj_trans()->addKid( obj_model );
}
#endif
e->add_ssg_nodes( globals->get_scenery()->get_terrain_branch(),
globals->get_scenery()->get_gnd_lights_root(),
+ globals->get_scenery()->get_vasi_lights_root(),
globals->get_scenery()->get_rwy_lights_root(),
globals->get_scenery()->get_taxi_lights_root() );
// cout << "Adding ssg nodes for "
// disk.
int FGTileMgr::update( double visibility_meters )
{
- FGLocation *location = globals->get_current_view()->getFGLocation();
+ SGLocation *location = globals->get_current_view()->getSGLocation();
sgdVec3 abs_pos_vector;
sgdCopyVec3( abs_pos_vector,
globals->get_current_view()->get_absolute_view_pos() );
}
-int FGTileMgr::update( FGLocation *location, double visibility_meters,
+int FGTileMgr::update( SGLocation *location, double visibility_meters,
sgdVec3 abs_pos_vector )
{
longitude = location->getLongitude_deg();
latitude = location->getLatitude_deg();
+ // add 1.0m to the max altitude to give a little leeway to the
+ // ground reaction code.
+ altitude_m = location->getAltitudeASL_ft() * SG_FEET_TO_METER + 1.0;
+
+ // if current altitude is apparently not initialized, set max
+ // altitude to something big.
+ if ( altitude_m < -1000 ) {
+ altitude_m = 10000;
+ }
// SG_LOG( SG_TERRAIN, SG_DEBUG, "FGTileMgr::update() for "
// << longitude << " " << latatitude );
current_bucket.set_bucket( longitude, latitude );
// SG_LOG( SG_TERRAIN, SG_DEBUG, "Updating tile list for "
// << current_bucket );
+ fgSetInt( "/environment/current-tile-id", current_bucket.gen_index() );
// set global scenery center from current tile center
current_tile = tile_cache.get_tile( current_bucket );
// save bucket...
previous_bucket = current_bucket;
- // no reason to update this if we haven't moved...
- if ( longitude != last_longitude || latitude != last_latitude ) {
- // update current elevation...
- if ( updateCurrentElevAtPos( abs_pos_vector,
- location->get_tile_center() ) )
- {
- last_longitude = longitude;
- last_latitude = latitude;
- }
- }
+ updateCurrentElevAtPos( abs_pos_vector, altitude_m,
+ location->get_tile_center() );
return 1;
}
}
-int FGTileMgr::updateCurrentElevAtPos(sgdVec3 abs_pos_vector, Point3D center) {
-
+int FGTileMgr::updateCurrentElevAtPos( sgdVec3 abs_pos_vector,
+ double max_alt_m,
+ Point3D center)
+{
sgdVec3 sc;
sgdSetVec3( sc, center[0], center[1], center[2]);
// scenery center has been properly defined so any hit should
// be valid (and not just luck)
hit = fgCurrentElev(abs_pos_vector,
+ max_alt_m,
sc,
+ // uncomment next paramater to fly under
+ // bridges and a slightly faster algorithm
+ // but you won't be able to land on aircraft carriers
// current_tile->get_terra_transform(),
&hit_list,
&hit_elev,
}
-void FGTileMgr::prep_ssg_nodes( FGLocation *location, float vis ) {
+void FGTileMgr::prep_ssg_nodes( SGLocation *location, float vis ) {
// traverse the potentially viewable tile list and update range
// selector and transform