//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
# include <config.h>
#endif
-#include <plib/ssg.h>
-
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/math/point3d.hxx>
#include <simgear/math/vector.hxx>
#include <simgear/structure/exception.hxx>
#include <simgear/scene/model/modellib.hxx>
-#include <simgear/scene/model/shadowvolume.hxx>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
#include <Main/viewer.hxx>
+#include <Scripting/NasalSys.hxx>
#include "newcache.hxx"
#include "scenery.hxx"
#define TEST_LAST_HIT_CACHE
-#if defined(ENABLE_THREADS) && ENABLE_THREADS
+#if defined(ENABLE_THREADS)
SGLockedQueue<FGTileEntry *> FGTileMgr::attach_queue;
SGLockedQueue<FGDeferredModel *> FGTileMgr::model_queue;
#else
bool FGTileMgr::tile_filter = true;
-extern SGShadowVolume *shadows;
-
// Constructor
FGTileMgr::FGTileMgr():
state( Start ),
}
while ( ! model_queue.empty() ) {
-#if defined(ENABLE_THREADS) && ENABLE_THREADS
+#if defined(ENABLE_THREADS)
FGDeferredModel* dm = model_queue.pop();
#else
FGDeferredModel* dm = model_queue.front();
loader.reinit();
#endif
- hit_list.clear();
-
state = Inited;
previous_bucket.make_bad();
long index = tile_cache.get_oldest_tile();
if ( index >= 0 ) {
FGTileEntry *old = tile_cache.get_tile( index );
- shadows->deleteOccluderFromTile( (ssgBranch *) old->get_terra_transform() );
+ // OSGFIXME
+// shadows->deleteOccluderFromTile( (ssgBranch *) old->get_terra_transform() );
old->disconnect_ssg_nodes();
delete_queue.push( old );
tile_cache.clear_entry( index );
// schedule a needed buckets for loading
-void FGTileMgr::schedule_needed( double vis, SGBucket curr_bucket) {
+void FGTileMgr::schedule_needed( double vis, const SGBucket& curr_bucket) {
// sanity check (unfortunately needed!)
if ( longitude < -180.0 || longitude > 180.0
|| latitude < -90.0 || latitude > 90.0 )
SG_LOG( SG_TERRAIN, SG_ALERT,
"Attempting to schedule tiles for bogus lon and lat = ("
<< longitude << "," << latitude << ")" );
+ return; // FIXME
SG_LOG( SG_TERRAIN, SG_ALERT,
"This is a FATAL error. Exiting!" );
- exit(-1);
+ exit(-1);
}
SG_LOG( SG_TERRAIN, SG_INFO,
// cout << "loading next model ..." << endl;
// load the next tile in the queue
-#if defined(ENABLE_THREADS) && ENABLE_THREADS
+#if defined(ENABLE_THREADS)
FGDeferredModel* dm = model_queue.pop();
#else
FGDeferredModel* dm = model_queue.front();
// tile cache
FGTileEntry *t = tile_cache.get_tile( dm->get_bucket() );
if ( t != NULL ) {
- ssgTexturePath( (char *)(dm->get_texture_path().c_str()) );
+ //OSGFIXME
+// ssgTexturePath( (char *)(dm->get_texture_path().c_str()) );
try {
- ssgEntity *obj_model =
+ osg::Node *obj_model =
globals->get_model_lib()->load_model( ".",
dm->get_model_path(),
globals->get_props(),
- globals->get_sim_time_sec() );
+ globals->get_sim_time_sec(),
+ dm->get_cache_state(),
+ new FGNasalModelData );
if ( obj_model != NULL ) {
- dm->get_obj_trans()->addKid( obj_model );
- shadows->addOccluder( (ssgBranch *) obj_model->getParent(0),
- SGShadowVolume::occluderTypeTileObject,
- (ssgBranch *) dm->get_tile()->get_terra_transform());
+ dm->get_obj_trans()->addChild( obj_model );
+ //OSGFIXME
+// shadows->addOccluder( (ssgBranch *) obj_model->getParent(0),
+// SGShadowVolume::occluderTypeTileObject,
+// (ssgBranch *) dm->get_tile()->get_terra_transform());
}
- } catch (const sg_exception& exc) {
- SG_LOG( SG_ALL, SG_ALERT, exc.getMessage() );
+ } catch (const sg_io_exception& exc) {
+ string m(exc.getMessage());
+ m += " ";
+ m += exc.getLocation().asString();
+ SG_LOG( SG_ALL, SG_ALERT, m );
+ } catch (const sg_exception& exc) { // XXX may be redundant
+ SG_LOG( SG_ALL, SG_ALERT, exc.getMessage());
}
dm->get_tile()->dec_pending_models();
loader.update();
if ( !attach_queue.empty() ) {
-#if defined(ENABLE_THREADS) && ENABLE_THREADS
+#if defined(ENABLE_THREADS)
FGTileEntry* e = attach_queue.pop();
#else
FGTileEntry* e = attach_queue.front();
// get real serious and agressively free up some tiles so
// we don't explode our memory usage.
- SG_LOG( SG_TERRAIN, SG_WARN,
+ SG_LOG( SG_TERRAIN, SG_ALERT,
"Warning: catching up on tile delete queue" );
}
// traverse the potentially viewable tile list and update range
// selector and transform
- Point3D center = location->get_tile_center();
- if (center == Point3D(0.0))
- return;
float *up = location->get_world_up();
FGTileEntry *e;
tile_cache.reset_traversal();
+ const double *vp = location->get_absolute_view_pos();
+ Point3D viewpos(vp[0], vp[1], vp[2]);
while ( ! tile_cache.at_end() ) {
// cout << "processing a tile" << endl;
if ( (e = tile_cache.get_current()) ) {
- e->prep_ssg_node( center, up, vis);
+ e->prep_ssg_node( viewpos, up, vis);
} else {
SG_LOG(SG_INPUT, SG_ALERT, "warning ... empty tile in cache");
}
bool FGTileMgr::scenery_available(double lat, double lon, double range_m)
{
// sanity check (unfortunately needed!)
- if ( lon < -180.0 || lon > 180.0 || lat < -90.0 || lat > 90.0 )
+ if ( lon <= -180.0 || lon >= 180.0 || lat <= -90.0 || lat >= 90.0 )
return false;
SGBucket bucket(lon, lat);