Skip to content

Commit 33ceae7

Browse files
authored
Apply transform later in gotoLocation (CelestiaProject#2362)
another PR to correct transform application. `gotoLocation` calls take in untransformed orientation in other places, so we should align them in `gotoSurface` and use original orientation. we apply the transform inside `gotoLocation`. doesn't affect frontends here.
1 parent f31ebd1 commit 33ceae7

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/celengine/observer.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -753,10 +753,16 @@ Observer::update(double dt, double timeScale)
753753
void
754754
Observer::updateOrientation()
755755
{
756-
transformedOrientationUniv = eulerDrivenOrientation * devicePoseQuaternion * originalOrientationUniv;
756+
transformedOrientationUniv = transform(originalOrientationUniv);
757757
transformedOrientation = frame->convertFromUniversal(transformedOrientationUniv, getTime());
758758
}
759759

760+
Eigen::Quaterniond
761+
Observer::transform(const Eigen::Quaterniond& original) const
762+
{
763+
return eulerDrivenOrientation * devicePoseQuaternion * original;
764+
}
765+
760766
Eigen::Quaterniond
761767
Observer::undoTransform(const Eigen::Quaterniond& transformed) const
762768
{
@@ -1458,7 +1464,7 @@ Observer::gotoLocation(const UniversalCoord& toPosition,
14581464
journey.from = position;
14591465
journey.initialOrientation = transformedOrientation;
14601466
journey.to = toPosition;
1461-
journey.finalOrientation = toOrientation;
1467+
journey.finalOrientation = transform(toOrientation);
14621468

14631469
journey.startInterpolation = StartInterpolation;
14641470
journey.endInterpolation = EndInterpolation;
@@ -1502,9 +1508,9 @@ Observer::gotoSurface(const Selection& sel, double duration)
15021508
Eigen::Vector3d v = getPosition().offsetFromKm(sel.getPosition(getTime()));
15031509
v.normalize();
15041510

1505-
Eigen::Vector3d viewDir = transformedOrientationUniv.conjugate() * -Eigen::Vector3d::UnitZ();
1506-
Eigen::Vector3d up = transformedOrientationUniv.conjugate() * Eigen::Vector3d::UnitY();
1507-
Eigen::Quaterniond q = transformedOrientationUniv;
1511+
Eigen::Vector3d viewDir = originalOrientationUniv.conjugate() * -Eigen::Vector3d::UnitZ();
1512+
Eigen::Vector3d up = originalOrientationUniv.conjugate() * Eigen::Vector3d::UnitY();
1513+
Eigen::Quaterniond q = originalOrientationUniv;
15081514
if (v.dot(viewDir) < 0.0)
15091515
{
15101516
q = math::LookAt<double>(Eigen::Vector3d::Zero(), up, v);

src/celengine/observer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ class Observer
304304
void setOriginalOrientation(const Eigen::Quaterniond&);
305305
void updateUniversal();
306306
void updateOrientation();
307+
Eigen::Quaterniond transform(const Eigen::Quaterniond&) const;
307308
Eigen::Quaterniond undoTransform(const Eigen::Quaterniond&) const;
308309
void convertFrameCoordinates(const ObserverFrame::SharedConstPtr &newFrame);
309310

0 commit comments

Comments
 (0)