1
0
Fork 0

Modified Files:

src/AIModel/AIBase.cxx src/AIModel/AICarrier.cxx
	src/ATC/AIEntity.cxx src/Cockpit/hud_rwy.cxx
 	src/FDM/Makefile.am src/FDM/flight.hxx src/FDM/groundcache.cxx
	src/Instrumentation/HUD/HUD_runway.cxx src/Main/Makefile.am
	src/Main/fg_init.cxx src/Main/main.cxx src/Main/renderer.cxx
	src/Main/viewer.cxx src/Main/viewer.hxx src/Model/acmodel.cxx
	src/Model/modelmgr.cxx src/Scenery/scenery.cxx
	src/Scenery/scenery.hxx src/Scenery/tileentry.cxx
	src/Time/tmp.cxx: Remove the scenery center handling.
	Osg has double valued transforms at any relevant place.
This commit is contained in:
frohlich 2007-05-05 08:08:24 +00:00
parent f80d5676b4
commit 4fe615fff5
16 changed files with 19 additions and 198 deletions

View file

@ -76,7 +76,6 @@ FGAIBase::FGAIBase(object_type ot) :
FGAIBase::~FGAIBase() { FGAIBase::~FGAIBase() {
// Unregister that one at the scenery manager // Unregister that one at the scenery manager
if (globals->get_scenery()) { if (globals->get_scenery()) {
globals->get_scenery()->unregister_placement_transform(aip.getTransform());
globals->get_scenery()->get_scene_graph()->removeChild(aip.getSceneGraph()); globals->get_scenery()->get_scene_graph()->removeChild(aip.getSceneGraph());
} }
@ -174,8 +173,6 @@ bool FGAIBase::init(bool search_in_AI_path) {
invisible = false; invisible = false;
globals->get_scenery()->get_scene_graph()->addChild(aip.getSceneGraph()); globals->get_scenery()->get_scene_graph()->addChild(aip.getSceneGraph());
// Register that one at the scenery manager
globals->get_scenery()->register_placement_transform(aip.getTransform());
fgSetString("/ai/models/model-added", props->getPath()); fgSetString("/ai/models/model-added", props->getPath());
} else { } else {

View file

@ -271,7 +271,7 @@ void FGAICarrier::update(double dt) {
// For the flols reuse some computations done above ... // For the flols reuse some computations done above ...
// The position of the eyepoint - at least near that ... // The position of the eyepoint - at least near that ...
SGVec3d eyePos(globals->get_current_view()->get_absolute_view_pos()); SGVec3d eyePos(globals->get_current_view()->get_view_pos());
// Add the position offset of the AIModel to gain the earth // Add the position offset of the AIModel to gain the earth
// centered position // centered position
SGVec3d eyeWrtCarrier = eyePos - cartPos; SGVec3d eyeWrtCarrier = eyePos - cartPos;

View file

@ -47,8 +47,6 @@ FGAIEntity::~FGAIEntity() {
//cout << "FGAIEntity dtor called..." << endl; //cout << "FGAIEntity dtor called..." << endl;
//cout << "Removing model from scene graph..." << endl; //cout << "Removing model from scene graph..." << endl;
globals->get_scenery()->get_scene_graph()->removeChild(_aip.getSceneGraph()); globals->get_scenery()->get_scene_graph()->removeChild(_aip.getSceneGraph());
// Unregister that one at the scenery manager
globals->get_scenery()->unregister_placement_transform(_aip.getTransform());
//cout << "Done!" << endl; //cout << "Done!" << endl;
} }
@ -58,8 +56,6 @@ void FGAIEntity::SetModel(osg::Node* model) {
_aip.init(_model.get()); _aip.init(_model.get());
_aip.setVisible(false); _aip.setVisible(false);
globals->get_scenery()->get_scene_graph()->addChild(_aip.getSceneGraph()); globals->get_scenery()->get_scene_graph()->addChild(_aip.getSceneGraph());
// Register that one at the scenery manager
globals->get_scenery()->register_placement_transform(_aip.getTransform());
} }

View file

@ -207,14 +207,6 @@ void runway_instr::get_rwy_points(sgdVec3 *points3d)
geo_direct_wgs_84(alt, frontLat, frontLon, runway._heading + 90, width, &tempLat, &tempLon, &az); geo_direct_wgs_84(alt, frontLat, frontLon, runway._heading + 90, width, &tempLat, &tempLon, &az);
sgGeodToCart(tempLat * SG_DEGREES_TO_RADIANS, tempLon * SG_DEGREES_TO_RADIANS, alt, points3d[3]); sgGeodToCart(tempLat * SG_DEGREES_TO_RADIANS, tempLon * SG_DEGREES_TO_RADIANS, alt, points3d[3]);
//Get the current tile center
SGVec3d tileCenter = globals->get_scenery()->get_center();
for (int i = 0; i < 6; i++) {
points3d[i][0] -= tileCenter.x();
points3d[i][1] -= tileCenter.y();
points3d[i][2] -= tileCenter.z();
}
} }

View file

@ -145,12 +145,6 @@ public:
mGroundProperty.pivot = SGVec3d(0, 0, 0); mGroundProperty.pivot = SGVec3d(0, 0, 0);
} }
void setSceneryCenter(const SGVec3d& cntr)
{
mLocalToGlobal.makeTranslate(cntr.osg());
mGlobalToLocal.makeTranslate(-cntr.osg());
}
void updateCullMode(osg::StateSet* stateSet) void updateCullMode(osg::StateSet* stateSet)
{ {
if (!stateSet) if (!stateSet)
@ -507,7 +501,6 @@ FGGroundCache::prepare_ground_cache(double ref_time, const SGVec3d& pt,
// Walk the scene graph and extract solid ground triangles and carrier data. // Walk the scene graph and extract solid ground triangles and carrier data.
GroundCacheFillVisitor gcfv(this, down, pt, cacheRadius, wireCacheRadius); GroundCacheFillVisitor gcfv(this, down, pt, cacheRadius, wireCacheRadius);
gcfv.setSceneryCenter(globals->get_scenery()->get_center());
globals->get_scenery()->get_scene_graph()->accept(gcfv); globals->get_scenery()->get_scene_graph()->accept(gcfv);
// some stats // some stats

View file

@ -199,14 +199,6 @@ void HUD::Runway::get_rwy_points(sgdVec3 *_points3d)
geo_direct_wgs_84(alt, frontLat, frontLon, _runway._heading + 90, width, &tempLat, &tempLon, &az); geo_direct_wgs_84(alt, frontLat, frontLon, _runway._heading + 90, width, &tempLat, &tempLon, &az);
sgGeodToCart(tempLat * SG_DEGREES_TO_RADIANS, tempLon * SG_DEGREES_TO_RADIANS, alt, _points3d[3]); sgGeodToCart(tempLat * SG_DEGREES_TO_RADIANS, tempLon * SG_DEGREES_TO_RADIANS, alt, _points3d[3]);
//Get the current tile center
SGVec3d tileCenter = globals->get_scenery()->get_center();
for (int i = 0; i < 6; i++) {
_points3d[i][0] -= tileCenter.x();
_points3d[i][1] -= tileCenter.y();
_points3d[i][2] -= tileCenter.z();
}
} }

View file

@ -513,26 +513,6 @@ static void fgMainLoop( void ) {
// //
double visibility_meters = fgGetDouble("/environment/visibility-m"); double visibility_meters = fgGetDouble("/environment/visibility-m");
FGViewer *current_view = globals->get_current_view(); FGViewer *current_view = globals->get_current_view();
// Let the scenery center follow the current view position with
// 30m increments.
//
// Having the scenery center near the view position will eliminate
// jitter of objects which are placed very near the view position
// and haveing it's center near that view position.
// So the 3d insruments of the aircraft will not jitter with this.
//
// Following the view position exactly would introduce jitter of
// the scenery tiles (they would be from their center up to 10000m
// to the view and this will introduce roundoff too). By stepping
// at 30m incements the roundoff error of the scenery tiles is
// still present, but we will make exactly the same roundoff error
// at each frame until the center is switched to a new
// position. This roundoff is still visible but you will most
// propably not notice.
double *vp = globals->get_current_view()->get_absolute_view_pos();
SGVec3d cntr(vp);
if (30.0*30.0 < distSqr(cntr, globals->get_scenery()->get_center()))
globals->get_scenery()->set_center( cntr );
globals->get_tile_mgr()->prep_ssg_nodes( current_view->getSGLocation(), globals->get_tile_mgr()->prep_ssg_nodes( current_view->getSGLocation(),
visibility_meters ); visibility_meters );
@ -548,8 +528,7 @@ static void fgMainLoop( void ) {
double ref_time, r; double ref_time, r;
SGVec3d pt; SGVec3d pt;
bool valid = cur_fdm_state->is_valid_m(&ref_time, pt.sg(), &r); bool valid = cur_fdm_state->is_valid_m(&ref_time, pt.sg(), &r);
double *vp = globals->get_current_view()->get_absolute_view_pos(); SGVec3d viewpos(globals->get_current_view()->get_view_pos());
SGVec3d viewpos(vp);
if (valid && distSqr(viewpos, pt) < r*r) { if (valid && distSqr(viewpos, pt) < r*r) {
// Reuse the cache ... // Reuse the cache ...
double lev double lev
@ -630,10 +609,6 @@ static void fgIdleFunction ( void ) {
if ( idle_state == 0 ) { if ( idle_state == 0 ) {
idle_state++; idle_state++;
#ifdef GL_EXT_texture_lod_bias
// negative values sharpen, positive values blur mipmapped textures
glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, -0.5 ) ;
#endif
// This seems to be the absolute earliest in the init sequence // This seems to be the absolute earliest in the init sequence
// that these calls will return valid info. Too bad it's after // that these calls will return valid info. Too bad it's after
// we've already created and sized our window. :-( // we've already created and sized our window. :-(

View file

@ -633,10 +633,9 @@ FGRenderer::update( bool refresh_camera_settings ) {
resize( fgGetInt("/sim/startup/xsize"), resize( fgGetInt("/sim/startup/xsize"),
fgGetInt("/sim/startup/ysize") ); fgGetInt("/sim/startup/ysize") );
SGVec3d center = globals->get_scenery()->get_center();
SGVec3d position = current__view->getViewPosition(); SGVec3d position = current__view->getViewPosition();
SGQuatd attitude = current__view->getViewOrientation(); SGQuatd attitude = current__view->getViewOrientation();
SGVec3d osgPosition = attitude.transform(center - position); SGVec3d osgPosition = attitude.transform(-position);
mCameraView->setPosition(osgPosition.osg()); mCameraView->setPosition(osgPosition.osg());
mCameraView->setAttitude(inverse(attitude).osg()); mCameraView->setAttitude(inverse(attitude).osg());
} }
@ -678,8 +677,8 @@ FGRenderer::update( bool refresh_camera_settings ) {
static SGSkyState sstate; static SGSkyState sstate;
sstate.view_pos = current__view->get_view_pos(); sstate.view_pos = toVec3f(current__view->get_view_pos());
sstate.zero_elev = current__view->get_zero_elev(); sstate.zero_elev = toVec3f(current__view->get_zero_elev());
sstate.view_up = current__view->get_world_up(); sstate.view_up = current__view->get_world_up();
sstate.lon = current__view->getLongitude_deg() sstate.lon = current__view->getLongitude_deg()
* SGD_DEGREES_TO_RADIANS; * SGD_DEGREES_TO_RADIANS;
@ -823,7 +822,7 @@ FGRenderer::update( bool refresh_camera_settings ) {
mFrameStamp->setCalendarTime(*globals->get_time_params()->getGmt()); mFrameStamp->setCalendarTime(*globals->get_time_params()->getGmt());
mUpdateVisitor->setViewData(current__view->getViewPosition(), mUpdateVisitor->setViewData(current__view->getViewPosition(),
current__view->getViewOrientation()); current__view->getViewOrientation());
mUpdateVisitor->setSceneryCenter(globals->get_scenery()->get_center()); mUpdateVisitor->setSceneryCenter(SGVec3d(0, 0, 0));
SGVec3f direction(l->sun_vec()[0], l->sun_vec()[1], l->sun_vec()[2]); SGVec3f direction(l->sun_vec()[0], l->sun_vec()[1], l->sun_vec()[2]);
mUpdateVisitor->setLight(direction, l->scene_ambient(), mUpdateVisitor->setLight(direction, l->scene_ambient(),
l->scene_diffuse(), l->scene_specular()); l->scene_diffuse(), l->scene_specular());
@ -1014,9 +1013,6 @@ FGRenderer::pick( unsigned x, unsigned y,
if (!viewport) if (!viewport)
return false; return false;
// good old scenery center
SGVec3d center = globals->get_scenery()->get_center();
// don't know why, but the update has partly happened somehow, // don't know why, but the update has partly happened somehow,
// so update the scenery part of the viewer // so update the scenery part of the viewer
FGViewer *current_view = globals->get_current_view(); FGViewer *current_view = globals->get_current_view();
@ -1024,7 +1020,7 @@ FGRenderer::pick( unsigned x, unsigned y,
current_view->set_dirty(); current_view->set_dirty();
SGVec3d position = current_view->getViewPosition(); SGVec3d position = current_view->getViewPosition();
SGQuatd attitude = current_view->getViewOrientation(); SGQuatd attitude = current_view->getViewOrientation();
SGVec3d osgPosition = attitude.transform(center - position); SGVec3d osgPosition = attitude.transform(-position);
mCameraView->setPosition(osgPosition.osg()); mCameraView->setPosition(osgPosition.osg());
mCameraView->setAttitude(inverse(attitude).osg()); mCameraView->setAttitude(inverse(attitude).osg());
@ -1075,7 +1071,6 @@ FGRenderer::pick( unsigned x, unsigned y,
sceneryPick.info.wgs84 = SGVec3d(localPt*(*hi->getMatrix())); sceneryPick.info.wgs84 = SGVec3d(localPt*(*hi->getMatrix()));
else else
sceneryPick.info.wgs84 = SGVec3d(localPt); sceneryPick.info.wgs84 = SGVec3d(localPt);
sceneryPick.info.wgs84 += globals->get_scenery()->get_center();
sceneryPick.callback = pickCallback; sceneryPick.callback = pickCallback;
pickList.push_back(sceneryPick); pickList.push_back(sceneryPick);
} }

View file

@ -402,14 +402,6 @@ FGViewer::setOrientationOffsets (double roll_offset_deg, double pitch_offset_deg
_heading_offset_deg = heading_offset_deg; _heading_offset_deg = heading_offset_deg;
} }
double *
FGViewer::get_absolute_view_pos ()
{
if (_dirty)
recalc();
return _absolute_view_pos.data();
}
// recalc() is done every time one of the setters is called (making the // recalc() is done every time one of the setters is called (making the
// cached data "dirty") on the next "get". It calculates all the outputs // cached data "dirty") on the next "get". It calculates all the outputs
// for viewer. // for viewer.
@ -422,12 +414,9 @@ FGViewer::recalc ()
recalcLookAt(); recalcLookAt();
} }
SGVec3d center = globals->get_scenery()->get_center();
_view_pos = toVec3f(_absolute_view_pos - center);
SGGeod geodEyePoint = SGGeod::fromCart(_absolute_view_pos); SGGeod geodEyePoint = SGGeod::fromCart(_absolute_view_pos);
geodEyePoint.setElevationM(0); geodEyePoint.setElevationM(0);
_zero_elev = toVec3f(SGVec3d::fromGeod(geodEyePoint) - center); _zero_elev = SGVec3d::fromGeod(geodEyePoint);
SGQuatd hlOr = SGQuatd::fromLonLat(geodEyePoint); SGQuatd hlOr = SGQuatd::fromLonLat(geodEyePoint);
_surface_south = toVec3f(hlOr.backTransform(-SGVec3d::e1())); _surface_south = toVec3f(hlOr.backTransform(-SGVec3d::e1()));

View file

@ -209,12 +209,8 @@ public:
// Vectors and positions... // Vectors and positions...
// Get zero view_pos
const SGVec3f& get_view_pos() {if ( _dirty ) { recalc(); } return _view_pos; }
// Get the absolute view position in fgfs coordinates.
virtual double * get_absolute_view_pos ();
// Get zero elev // Get zero elev
const SGVec3f& get_zero_elev() {if ( _dirty ) { recalc(); } return _zero_elev; } const SGVec3d& get_zero_elev() {if ( _dirty ) { recalc(); } return _zero_elev; }
// Get world up vector // Get world up vector
const SGVec3f& get_world_up() {if ( _dirty ) { recalc(); } return _world_up; } const SGVec3f& get_world_up() {if ( _dirty ) { recalc(); } return _world_up; }
// Get surface east vector // Get surface east vector
@ -222,6 +218,7 @@ public:
// Get surface south vector // Get surface south vector
const SGVec3f& get_surface_south() {if ( _dirty ) { recalc(); } return _surface_south; } const SGVec3f& get_surface_south() {if ( _dirty ) { recalc(); } return _surface_south; }
const SGVec3d& get_view_pos() { if ( _dirty ) { recalc(); } return _absolute_view_pos; }
const SGVec3d& getViewPosition() { if ( _dirty ) { recalc(); } return _absolute_view_pos; } const SGVec3d& getViewPosition() { if ( _dirty ) { recalc(); } return _absolute_view_pos; }
const SGQuatd& getViewOrientation() { if ( _dirty ) { recalc(); } return mViewOrientation; } const SGQuatd& getViewOrientation() { if ( _dirty ) { recalc(); } return mViewOrientation; }
@ -275,7 +272,6 @@ private:
SGQuatd mViewOrientation; SGQuatd mViewOrientation;
SGVec3d _absolute_view_pos; SGVec3d _absolute_view_pos;
SGVec3f _relative_view_pos;
double _lon_deg; double _lon_deg;
double _lat_deg; double _lat_deg;
@ -345,19 +341,14 @@ private:
// Ratio of window width and height; height = width * // Ratio of window width and height; height = width *
// aspect_ratio. This value is automatically calculated based on // aspect_ratio. This value is automatically calculated based on
// window dimentions. // window dimentions.
double _aspect_ratio; double _aspect_ratio;
// default = 1.0, this value is user configurable and is // default = 1.0, this value is user configurable and is
// multiplied into the aspect_ratio to get the actual vertical fov // multiplied into the aspect_ratio to get the actual vertical fov
double _aspect_ratio_multiplier; double _aspect_ratio_multiplier;
// view position in opengl world coordinates (this is the
// abs_view_pos translated to scenery.center)
SGVec3f _view_pos;
// cartesion coordinates of current lon/lat if at sea level // cartesion coordinates of current lon/lat if at sea level
// translated to scenery.center SGVec3d _zero_elev;
SGVec3f _zero_elev;
// surface vector heading south // surface vector heading south
SGVec3f _surface_south; SGVec3f _surface_south;

View file

@ -42,10 +42,6 @@ FGAircraftModel::FGAircraftModel ()
FGAircraftModel::~FGAircraftModel () FGAircraftModel::~FGAircraftModel ()
{ {
// Unregister that one at the scenery manager
if (_aircraft)
globals->get_scenery()->unregister_placement_transform(_aircraft->getTransform());
delete _aircraft; delete _aircraft;
// SSG will delete it // SSG will delete it
globals->get_scenery()->get_aircraft_branch()->removeChild(_selector.get()); globals->get_scenery()->get_aircraft_branch()->removeChild(_selector.get());
@ -89,9 +85,6 @@ FGAircraftModel::init ()
// Do not do altitude computations with that model // Do not do altitude computations with that model
_selector->setNodeMask(~SG_NODEMASK_TERRAIN_BIT); _selector->setNodeMask(~SG_NODEMASK_TERRAIN_BIT);
globals->get_scenery()->get_aircraft_branch()->addChild(_selector.get()); globals->get_scenery()->get_aircraft_branch()->addChild(_selector.get());
// Register that one at the scenery manager
globals->get_scenery()->register_placement_transform(_aircraft->getTransform());
} }
void void

View file

@ -121,9 +121,6 @@ FGModelMgr::add_model (SGPropertyNode * node)
// Add this model to the global scene graph // Add this model to the global scene graph
globals->get_scenery()->get_scene_graph()->addChild(model->getSceneGraph()); globals->get_scenery()->get_scene_graph()->addChild(model->getSceneGraph());
// Register that one at the scenery manager
globals->get_scenery()->register_placement_transform(model->getTransform());
// Save this instance for updating // Save this instance for updating
add_instance(instance); add_instance(instance);
@ -212,9 +209,6 @@ FGModelMgr::Instance::Instance ()
FGModelMgr::Instance::~Instance () FGModelMgr::Instance::~Instance ()
{ {
// Unregister that one at the scenery manager
globals->get_scenery()->unregister_placement_transform(model->getTransform());
delete model; delete model;
} }

View file

@ -65,8 +65,7 @@ public:
}; };
// Scenery Management system // Scenery Management system
FGScenery::FGScenery() : FGScenery::FGScenery()
center(0, 0, 0)
{ {
SG_LOG( SG_TERRAIN, SG_INFO, "Initializing scenery subsystem" ); SG_LOG( SG_TERRAIN, SG_INFO, "Initializing scenery subsystem" );
} }
@ -128,32 +127,6 @@ void FGScenery::bind() {
void FGScenery::unbind() { void FGScenery::unbind() {
} }
void FGScenery::set_center( const SGVec3d& p ) {
if (center == p)
return;
center = p;
placement_list_type::iterator it = _placement_list.begin();
while (it != _placement_list.end()) {
(*it)->setSceneryCenter(center);
++it;
}
}
void FGScenery::register_placement_transform(SGPlacementTransform *trans) {
_placement_list.push_back(trans);
trans->setSceneryCenter(center);
}
void FGScenery::unregister_placement_transform(SGPlacementTransform *trans) {
placement_list_type::iterator it = _placement_list.begin();
while (it != _placement_list.end()) {
if ((*it) == trans) {
it = _placement_list.erase(it);
} else
++it;
}
}
bool bool
FGScenery::get_elevation_m(double lat, double lon, double max_alt, FGScenery::get_elevation_m(double lat, double lon, double max_alt,
double& alt, const SGMaterial** material, double& alt, const SGMaterial** material,
@ -172,18 +145,8 @@ FGScenery::get_cart_elevation_m(const SGVec3d& pos, double max_altoff,
if ( norm1(pos) < 1 ) if ( norm1(pos) < 1 )
return false; return false;
SGVec3d saved_center = center; SGVec3d start = pos + max_altoff*normalize(pos);
bool replaced_center = false; SGVec3d end(0, 0, 0);
if (exact) {
if (30*30 < distSqr(pos, center)) {
set_center( pos );
replaced_center = true;
}
}
SGVec3d start = pos + max_altoff*normalize(pos) - center;
SGVec3d end = - center;
osgUtil::IntersectVisitor intersectVisitor; osgUtil::IntersectVisitor intersectVisitor;
intersectVisitor.setTraversalMask(SG_NODEMASK_TERRAIN_BIT); intersectVisitor.setTraversalMask(SG_NODEMASK_TERRAIN_BIT);
@ -200,7 +163,6 @@ FGScenery::get_cart_elevation_m(const SGVec3d& pos, double max_altoff,
= intersectVisitor.getHitList(lineSegment.get())[i]; = intersectVisitor.getHitList(lineSegment.get())[i];
SGVec3d point; SGVec3d point;
point.osg() = hit.getWorldIntersectPoint(); point.osg() = hit.getWorldIntersectPoint();
point += center;
SGGeod geod = SGGeod::fromCart(point); SGGeod geod = SGGeod::fromCart(point);
double elevation = geod.getElevationM(); double elevation = geod.getElevationM();
if (alt < elevation) { if (alt < elevation) {
@ -211,9 +173,6 @@ FGScenery::get_cart_elevation_m(const SGVec3d& pos, double max_altoff,
} }
} }
if (replaced_center)
set_center( saved_center );
return hits; return hits;
} }
@ -225,21 +184,9 @@ FGScenery::get_cart_ground_intersection(const SGVec3d& pos, const SGVec3d& dir,
if ( norm1(pos) < 1 ) if ( norm1(pos) < 1 )
return false; return false;
// Well that 'exactness' is somehow problematic, but makes at least sure
// that we don't compute that with a cenery center at the other side of
// the world ...
SGVec3d saved_center = center;
bool replaced_center = false;
if (exact) {
if (30*30 < distSqr(pos, center)) {
set_center( pos );
replaced_center = true;
}
}
// Make really sure the direction is normalized, is really cheap compared to // Make really sure the direction is normalized, is really cheap compared to
// computation of ground intersection. // computation of ground intersection.
SGVec3d start = pos - center; SGVec3d start = pos;
SGVec3d end = start + 1e5*normalize(dir); // FIXME visibility ??? SGVec3d end = start + 1e5*normalize(dir); // FIXME visibility ???
osgUtil::IntersectVisitor intersectVisitor; osgUtil::IntersectVisitor intersectVisitor;
@ -260,13 +207,10 @@ FGScenery::get_cart_ground_intersection(const SGVec3d& pos, const SGVec3d& dir,
double newdist = length(start - point); double newdist = length(start - point);
if (newdist < dist) { if (newdist < dist) {
dist = newdist; dist = newdist;
nearestHit = point + center; nearestHit = point;
} }
} }
} }
if (replaced_center)
set_center( saved_center );
return hits; return hits;
} }

View file

@ -47,9 +47,6 @@ class SGMaterial;
// Define a structure containing global scenery parameters // Define a structure containing global scenery parameters
class FGScenery : public SGSubsystem { class FGScenery : public SGSubsystem {
// center of current scenery chunk
SGVec3d center;
// FIXME this should be a views property // FIXME this should be a views property
// angle of sun relative to current local horizontal // angle of sun relative to current local horizontal
double sun_angle; double sun_angle;
@ -64,10 +61,6 @@ class FGScenery : public SGSubsystem {
osg::ref_ptr<osg::Group> models_branch; osg::ref_ptr<osg::Group> models_branch;
osg::ref_ptr<osg::Group> aircraft_branch; osg::ref_ptr<osg::Group> aircraft_branch;
// list of all placement transform, used to move the scenery center on the fly.
typedef list<osg::ref_ptr<SGPlacementTransform> > placement_list_type;
placement_list_type _placement_list;
public: public:
FGScenery(); FGScenery();
@ -116,9 +109,6 @@ public:
bool get_cart_ground_intersection(const SGVec3d& start, const SGVec3d& dir, bool get_cart_ground_intersection(const SGVec3d& start, const SGVec3d& dir,
SGVec3d& nearestHit, bool exact = false); SGVec3d& nearestHit, bool exact = false);
const SGVec3d& get_center() const { return center; }
void set_center( const SGVec3d& p );
osg::Group *get_scene_graph () const { return scene_graph.get(); } osg::Group *get_scene_graph () const { return scene_graph.get(); }
inline void set_scene_graph (osg::Group * s) { scene_graph = s; } inline void set_scene_graph (osg::Group * s) { scene_graph = s; }
@ -166,9 +156,6 @@ public:
inline void set_aircraft_branch (osg::Group *t) { inline void set_aircraft_branch (osg::Group *t) {
aircraft_branch = t; aircraft_branch = t;
} }
void register_placement_transform(SGPlacementTransform *trans);
void unregister_placement_transform(SGPlacementTransform *trans);
}; };

View file

@ -743,7 +743,6 @@ FGTileEntry::add_ssg_nodes( osg::Group *terrain_branch,
// bump up the ref count so we can remove this later without // bump up the ref count so we can remove this later without
// having ssg try to free the memory. // having ssg try to free the memory.
terrain_branch->addChild( terra_transform.get() ); terrain_branch->addChild( terra_transform.get() );
globals->get_scenery()->register_placement_transform(terra_transform.get());
SG_LOG( SG_TERRAIN, SG_DEBUG, SG_LOG( SG_TERRAIN, SG_DEBUG,
"connected a tile into scene graph. terra_transform = " "connected a tile into scene graph. terra_transform = "
@ -755,14 +754,12 @@ FGTileEntry::add_ssg_nodes( osg::Group *terrain_branch,
// bump up the ref count so we can remove this later without // bump up the ref count so we can remove this later without
// having ssg try to free the memory. // having ssg try to free the memory.
gnd_lights_branch->addChild( gnd_lights_transform.get() ); gnd_lights_branch->addChild( gnd_lights_transform.get() );
globals->get_scenery()->register_placement_transform(gnd_lights_transform.get());
} }
if ( vasi_lights_transform.get() != NULL ) { if ( vasi_lights_transform.get() != NULL ) {
// bump up the ref count so we can remove this later without // bump up the ref count so we can remove this later without
// having ssg try to free the memory. // having ssg try to free the memory.
vasi_lights_selector->addChild( vasi_lights_transform.get() ); vasi_lights_selector->addChild( vasi_lights_transform.get() );
globals->get_scenery()->register_placement_transform(vasi_lights_transform.get());
vasi_lights_branch->addChild( vasi_lights_selector.get() ); vasi_lights_branch->addChild( vasi_lights_selector.get() );
} }
@ -770,7 +767,6 @@ FGTileEntry::add_ssg_nodes( osg::Group *terrain_branch,
// bump up the ref count so we can remove this later without // bump up the ref count so we can remove this later without
// having ssg try to free the memory. // having ssg try to free the memory.
rwy_lights_selector->addChild( rwy_lights_transform.get() ); rwy_lights_selector->addChild( rwy_lights_transform.get() );
globals->get_scenery()->register_placement_transform(rwy_lights_transform.get());
rwy_lights_branch->addChild( rwy_lights_selector.get() ); rwy_lights_branch->addChild( rwy_lights_selector.get() );
} }
@ -778,7 +774,6 @@ FGTileEntry::add_ssg_nodes( osg::Group *terrain_branch,
// bump up the ref count so we can remove this later without // bump up the ref count so we can remove this later without
// having ssg try to free the memory. // having ssg try to free the memory.
taxi_lights_selector->addChild( taxi_lights_transform.get() ); taxi_lights_selector->addChild( taxi_lights_transform.get() );
globals->get_scenery()->register_placement_transform(taxi_lights_transform.get());
taxi_lights_branch->addChild( taxi_lights_selector.get() ); taxi_lights_branch->addChild( taxi_lights_selector.get() );
} }
@ -797,9 +792,6 @@ FGTileEntry::disconnect_ssg_nodes()
SG_LOG( SG_TERRAIN, SG_DEBUG, "removing a fully loaded tile! terra_transform = " << terra_transform.get() ); SG_LOG( SG_TERRAIN, SG_DEBUG, "removing a fully loaded tile! terra_transform = " << terra_transform.get() );
} }
// Unregister that one at the scenery manager
globals->get_scenery()->unregister_placement_transform(terra_transform.get());
// find the terrain branch parent // find the terrain branch parent
int pcount = terra_transform->getNumParents(); int pcount = terra_transform->getNumParents();
if ( pcount > 0 ) { if ( pcount > 0 ) {
@ -822,8 +814,6 @@ FGTileEntry::disconnect_ssg_nodes()
// find the ground lighting branch // find the ground lighting branch
if ( gnd_lights_transform.get() ) { if ( gnd_lights_transform.get() ) {
// Unregister that one at the scenery manager
globals->get_scenery()->unregister_placement_transform(gnd_lights_transform.get());
pcount = gnd_lights_transform->getNumParents(); pcount = gnd_lights_transform->getNumParents();
if ( pcount > 0 ) { if ( pcount > 0 ) {
// find the first parent (should only be one) // find the first parent (should only be one)
@ -846,8 +836,6 @@ FGTileEntry::disconnect_ssg_nodes()
// find the vasi lighting branch // find the vasi lighting branch
if ( vasi_lights_transform.get() ) { if ( vasi_lights_transform.get() ) {
// Unregister that one at the scenery manager
globals->get_scenery()->unregister_placement_transform(vasi_lights_transform.get());
pcount = vasi_lights_transform->getNumParents(); pcount = vasi_lights_transform->getNumParents();
if ( pcount > 0 ) { if ( pcount > 0 ) {
// find the first parent (should only be one) // find the first parent (should only be one)
@ -870,8 +858,6 @@ FGTileEntry::disconnect_ssg_nodes()
// find the runway lighting branch // find the runway lighting branch
if ( rwy_lights_transform.get() ) { if ( rwy_lights_transform.get() ) {
// Unregister that one at the scenery manager
globals->get_scenery()->unregister_placement_transform(rwy_lights_transform.get());
pcount = rwy_lights_transform->getNumParents(); pcount = rwy_lights_transform->getNumParents();
if ( pcount > 0 ) { if ( pcount > 0 ) {
// find the first parent (should only be one) // find the first parent (should only be one)
@ -894,8 +880,6 @@ FGTileEntry::disconnect_ssg_nodes()
// find the taxi lighting branch // find the taxi lighting branch
if ( taxi_lights_transform.get() ) { if ( taxi_lights_transform.get() ) {
// Unregister that one at the scenery manager
globals->get_scenery()->unregister_placement_transform(taxi_lights_transform.get());
pcount = taxi_lights_transform->getNumParents(); pcount = taxi_lights_transform->getNumParents();
if ( pcount > 0 ) { if ( pcount > 0 ) {
// find the first parent (should only be one) // find the first parent (should only be one)

View file

@ -101,8 +101,7 @@ void fgUpdateSunPos( void ) {
<< l->get_sun_angle() ); << l->get_sun_angle() );
// calculate vector to sun's position on the earth's surface // calculate vector to sun's position on the earth's surface
SGVec3d rel_sunpos = globals->get_scenery()->get_center(); SGVec3d rel_sunpos = l->get_sunpos() - v->get_view_pos();
rel_sunpos += l->get_sunpos() - toVec3d(v->get_view_pos());
// vector in cartesian coordinates from current position to the // vector in cartesian coordinates from current position to the
// postion on the earth's surface the sun is directly over // postion on the earth's surface the sun is directly over
SGVec3f to_sun = toVec3f(rel_sunpos); SGVec3f to_sun = toVec3f(rel_sunpos);
@ -114,7 +113,7 @@ void fgUpdateSunPos( void ) {
// local plane representing "horizontal". // local plane representing "horizontal".
SGVec3f world_up = v->get_world_up(); SGVec3f world_up = v->get_world_up();
SGVec3f view_pos = v->get_view_pos(); SGVec3f view_pos = toVec3f(v->get_view_pos());
// surface direction to go to head towards sun // surface direction to go to head towards sun
SGVec3f surface_to_sun; SGVec3f surface_to_sun;
sgmap_vec_onto_cur_surface_plane( world_up.data(), view_pos.data(), sgmap_vec_onto_cur_surface_plane( world_up.data(), view_pos.data(),