From 39472e4d817d8b2c47c9987556af1c12a45f282a Mon Sep 17 00:00:00 2001 From: ehofman Date: Thu, 5 Nov 2009 13:46:15 +0000 Subject: [PATCH] Save a costly SGVec3d::fromGeod() calculation --- simgear/scene/sky/sky.cxx | 14 ++++++-------- simgear/scene/sky/sky.hxx | 3 ++- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/simgear/scene/sky/sky.cxx b/simgear/scene/sky/sky.cxx index 2eec5cc3..21662c66 100644 --- a/simgear/scene/sky/sky.cxx +++ b/simgear/scene/sky/sky.cxx @@ -147,22 +147,20 @@ bool SGSky::reposition( const SGSkyState &st, const SGEphemeris& eph, double dt double angle = st.gst * 15; // degrees double angleRad = SGMiscd::deg2rad(angle); - SGVec3f view_pos, zero_elev, view_up; + SGVec3f zero_elev, view_up; double lon, lat, alt; - view_pos = toVec3f( SGVec3d::fromGeod(st.pos) ); - SGGeod geodZeroViewPos = SGGeod::fromGeodM(st.pos, 0); + SGGeod geodZeroViewPos = SGGeod::fromGeodM(st.pos_geod, 0); zero_elev = toVec3f( SGVec3d::fromGeod(geodZeroViewPos) ); - view_up = toVec3f( st.ori.backTransform(SGVec3d::e2()) ); - lon = st.pos.getLongitudeRad(); - lat = st.pos.getLatitudeRad(); - alt = st.pos.getElevationM(); + lon = st.pos_geod.getLongitudeRad(); + lat = st.pos_geod.getLatitudeRad(); + alt = st.pos_geod.getElevationM(); dome->reposition( zero_elev, alt, lon, lat, st.spin ); osg::Matrix m = osg::Matrix::rotate(angleRad, osg::Vec3(0, 0, -1)); - m.postMultTranslate(toOsg(view_pos)); + m.postMultTranslate(toOsg(st.pos)); _ephTransform->setMatrix(m); double sun_ra = eph.getSunRightAscension(); diff --git a/simgear/scene/sky/sky.hxx b/simgear/scene/sky/sky.hxx index 1f1190f8..28678041 100644 --- a/simgear/scene/sky/sky.hxx +++ b/simgear/scene/sky/sky.hxx @@ -57,7 +57,8 @@ using std::vector; typedef struct { - SGGeod pos; + SGVec3d pos; + SGGeod pos_geod; SGQuatd ori; double spin; double gst; -- 2.39.5