From 2f6107982cfc8b848452b992d2f5cb4b92f5f442 Mon Sep 17 00:00:00 2001 From: frohlich Date: Mon, 7 Sep 2009 21:40:46 +0000 Subject: [PATCH] Use the new vector conversion functions. Modified Files: src/FDM/groundcache.cxx src/Main/renderer.cxx src/Main/viewer.cxx src/Scenery/scenery.cxx --- src/FDM/groundcache.cxx | 9 +++++---- src/Main/renderer.cxx | 26 +++++++++++++------------- src/Main/viewer.cxx | 2 +- src/Scenery/scenery.cxx | 6 +++--- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/FDM/groundcache.cxx b/src/FDM/groundcache.cxx index ad56fc90f..69cd3f187 100644 --- a/src/FDM/groundcache.cxx +++ b/src/FDM/groundcache.cxx @@ -151,8 +151,8 @@ public: const SGMaterial* material = _material; _haveHit = false; - _center = SGVec3d(inverseMatrix.preMult(_center.osg())); - _down = SGVec3d(osg::Matrix::transform3x3(_down.osg(), inverseMatrix)); + _center = toSG(inverseMatrix.preMult(toOsg(_center))); + _down = toSG(osg::Matrix::transform3x3(toOsg(_down), inverseMatrix)); if (velocity) { SGVec3d staticCenter(_center); @@ -208,7 +208,7 @@ public: _sceneryHit = ori.transform(_sceneryHit); _sceneryHit += dt*velocity->linear; } - _sceneryHit = SGVec3d(matrix.preMult(_sceneryHit.osg())); + _sceneryHit = toSG(matrix.preMult(toOsg(_sceneryHit))); } else { _material = material; _haveHit = haveHit; @@ -263,7 +263,8 @@ public: SGLineSegmentd downSeg(_center, _center + _maxDown*_down); double maxDist = bound._radius + _radius; - return distSqr(downSeg, SGVec3d(bound._center)) <= maxDist*maxDist; + SGVec3d boundCenter(toVec3d(toSG(bound._center))); + return distSqr(downSeg, boundCenter) <= maxDist*maxDist; } SGSharedPtr getBVHNode() const diff --git a/src/Main/renderer.cxx b/src/Main/renderer.cxx index b222ca0fd..7bde729aa 100644 --- a/src/Main/renderer.cxx +++ b/src/Main/renderer.cxx @@ -238,13 +238,13 @@ public: osg::Light* light = lightSource->getLight(); FGLight *l = static_cast(globals->get_subsystem("lighting")); - light->setAmbient(l->scene_ambient().osg()); - light->setDiffuse(l->scene_diffuse().osg()); - light->setSpecular(l->scene_specular().osg()); - SGVec4f position(l->sun_vec()[0], l->sun_vec()[1], l->sun_vec()[2], 0); - light->setPosition(position.osg()); - SGVec3f direction(l->sun_vec()[0], l->sun_vec()[1], l->sun_vec()[2]); - light->setDirection(direction.osg()); + light->setAmbient(toOsg(l->scene_ambient())); + light->setDiffuse(toOsg(l->scene_diffuse())); + light->setSpecular(toOsg(l->scene_specular())); + osg::Vec4f position(l->sun_vec()[0], l->sun_vec()[1], l->sun_vec()[2], 0); + light->setPosition(position); + osg::Vec3f direction(l->sun_vec()[0], l->sun_vec()[1], l->sun_vec()[2]); + light->setDirection(direction); light->setSpotExponent(0); light->setSpotCutoff(180); light->setConstantAttenuation(1); @@ -292,7 +292,7 @@ public: #if 0 FGLight *l = static_cast(globals->get_subsystem("lighting")); - lightModel->setAmbientIntensity(l->scene_ambient().osg()); + lightModel->setAmbientIntensity(toOsg(l->scene_ambient()); #else lightModel->setAmbientIntensity(osg::Vec4(0, 0, 0, 1)); #endif @@ -335,7 +335,7 @@ public: SGUpdateVisitor* updateVisitor = static_cast(nv); osg::Fog* fog = static_cast(sa); fog->setMode(osg::Fog::EXP2); - fog->setColor(updateVisitor->getFogColor().osg()); + fog->setColor(toOsg(updateVisitor->getFogColor())); fog->setDensity(updateVisitor->getFogExp2Density()); } }; @@ -571,11 +571,11 @@ FGRenderer::update( bool refresh_camera_settings ) { if ( fgGetBool("/sim/rendering/textures") ) { SGVec4f clearColor(l->adj_fog_color()); - camera->setClearColor(clearColor.osg()); + camera->setClearColor(toOsg(clearColor)); } } else { SGVec4f clearColor(l->sky_color()); - camera->setClearColor(clearColor.osg()); + camera->setClearColor(toOsg(clearColor)); } // update fog params if visibility has changed @@ -785,8 +785,8 @@ FGRenderer::pick(std::vector& pickList, if (!pickCallback) continue; SGSceneryPick sceneryPick; - sceneryPick.info.local = SGVec3d(hit->getLocalIntersectPoint()); - sceneryPick.info.wgs84 = SGVec3d(hit->getWorldIntersectPoint()); + sceneryPick.info.local = toSG(hit->getLocalIntersectPoint()); + sceneryPick.info.wgs84 = toSG(hit->getWorldIntersectPoint()); sceneryPick.callback = pickCallback; pickList.push_back(sceneryPick); } diff --git a/src/Main/viewer.cxx b/src/Main/viewer.cxx index 118776da3..2e34db687 100644 --- a/src/Main/viewer.cxx +++ b/src/Main/viewer.cxx @@ -659,6 +659,6 @@ FGViewer::update (double dt) } } recalc(); - _cameraGroup->update(_absolute_view_pos.osg(), mViewOrientation.osg()); + _cameraGroup->update(toOsg(_absolute_view_pos), toOsg(mViewOrientation)); _cameraGroup->setCameraParameters(get_v_fov(), get_aspect_ratio()); } diff --git a/src/Scenery/scenery.cxx b/src/Scenery/scenery.cxx index 5ca6ddd87..73c53733a 100644 --- a/src/Scenery/scenery.cxx +++ b/src/Scenery/scenery.cxx @@ -143,7 +143,7 @@ FGScenery::get_elevation_m(const SGGeod& geod, double& alt, osgUtil::IntersectVisitor intersectVisitor; intersectVisitor.setTraversalMask(SG_NODEMASK_TERRAIN_BIT); osg::ref_ptr lineSegment; - lineSegment = new osg::LineSegment(start.osg(), end.osg()); + lineSegment = new osg::LineSegment(toOsg(start), toOsg(end)); intersectVisitor.addLineSegment(lineSegment.get()); get_scene_graph()->accept(intersectVisitor); bool hits = false; @@ -195,7 +195,7 @@ FGScenery::get_cart_ground_intersection(const SGVec3d& pos, const SGVec3d& dir, osgUtil::IntersectVisitor intersectVisitor; intersectVisitor.setTraversalMask(SG_NODEMASK_TERRAIN_BIT); osg::ref_ptr lineSegment; - lineSegment = new osg::LineSegment(start.osg(), end.osg()); + lineSegment = new osg::LineSegment(toOsg(start), toOsg(end)); intersectVisitor.addLineSegment(lineSegment.get()); get_scene_graph()->accept(intersectVisitor); bool hits = false; @@ -235,7 +235,7 @@ bool FGScenery::scenery_available(const SGGeod& position, double range_m) if (!get_elevation_m(SGGeod::fromGeodM(position, SG_MAX_ELEVATION_M), elev, 0, 0)) return false; SGVec3f p = SGVec3f::fromGeod(SGGeod::fromGeodM(position, elev)); - simgear::CheckSceneryVisitor csnv(getPagerSingleton(), p.osg(), range_m); + simgear::CheckSceneryVisitor csnv(getPagerSingleton(), toOsg(p), range_m); // currently the PagedLODs will not be loaded by the DatabasePager // while the splashscreen is there, so CheckSceneryVisitor force-loads // missing objects in the main thread