Skip to content

Commit

Permalink
EarthManipulator: fix frame incoherence in setViewpoint when already …
Browse files Browse the repository at this point in the history
…tethered.
  • Loading branch information
gwaldron committed Feb 2, 2015
1 parent 27aef93 commit b965a4f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/osgEarthUtil/EarthManipulator
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,7 @@ namespace osgEarth { namespace Util
double _pending_viewpoint_duration_s;

bool _setting_viewpoint;
bool _set_viewpoint_started_while_tethered;
Viewpoint _start_viewpoint;
double _delta_heading, _delta_pitch, _delta_range, _arc_height;
osg::Vec3d _delta_focal_point;
Expand Down
22 changes: 20 additions & 2 deletions src/osgEarthUtil/EarthManipulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,9 @@ EarthManipulator::setViewpoint( const Viewpoint& vp, double duration_s )
vp.getSRS()->transform( vp.getFocalPoint(), _cached_srs.get(), vpFocalPoint );
}

// if we are currently tethered, make a note of it.
_set_viewpoint_started_while_tethered = _tether_node.valid();

_start_viewpoint = getViewpoint();

_delta_heading = vp.getHeading() - _start_viewpoint.getHeading(); //TODO: adjust for crossing -180
Expand Down Expand Up @@ -1443,7 +1446,12 @@ EarthManipulator::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapt
if ( _frame_count < 2 )
_time_s_set_viewpoint = _time_s_now;

updateSetViewpoint();
// if we're tethered, we need to update the viewpoint in the post-update
// phase to pre
if ( !_tether_node.valid() || !_set_viewpoint_started_while_tethered )
{
updateSetViewpoint();
}

aa.requestContinuousUpdate( _setting_viewpoint );
}
Expand Down Expand Up @@ -1769,7 +1777,17 @@ EarthManipulator::updateTether()
{
vp.getSRS()->transform( vp.getFocalPoint(), _cached_srs.get(), vpFocalPoint );
}
_delta_focal_point = vpFocalPoint - _start_viewpoint.getFocalPoint(); // TODO: adjust for lon=180 crossing

if ( _set_viewpoint_started_while_tethered )
{
_start_viewpoint.setFocalPoint( vpFocalPoint );
_delta_focal_point.set(0,0,0);
updateSetViewpoint();
}
else
{
_delta_focal_point = vpFocalPoint - _start_viewpoint.getFocalPoint(); // TODO: adjust for lon=180 crossing
}
}
}

Expand Down

0 comments on commit b965a4f

Please sign in to comment.