Woops, stick to the same parameter for position and orientation

It broke the look at rotation :D
This commit is contained in:
Emma Broman
2021-06-09 17:12:42 +02:00
parent d0c433ff10
commit 04ff080a34
3 changed files with 5 additions and 5 deletions

View File

@@ -116,7 +116,7 @@ double Path::speedAtTime(double time) const {
CameraPose Path::interpolatedPose(double distance) const {
const double relativeDistance = distance / pathLength();
CameraPose cs;
cs.position = _curve->positionAt(distance);
cs.position = _curve->positionAt(relativeDistance);
cs.rotation = interpolateRotation(relativeDistance);
return cs;
}
@@ -151,7 +151,7 @@ glm::dquat Path::interpolateRotation(double t) const {
const double tScaled = ghoul::cubicEaseInOut((t - t1) / (t2 - t1));
lookAtPos = ghoul::interpolateLinear(tScaled, startNodePos, endNodePos);
}
else if (t2 < t) {
else if (t > t2) {
// Compute a position in front of the camera at the end orientation
const double inFrontDistance = glm::distance(endPos, endNodePos);
const glm::dvec3 viewDir = helpers::viewDirection(_end.rotation());

View File

@@ -45,8 +45,8 @@ const double PathCurve::length() const {
return _totalLength;
}
glm::dvec3 PathCurve::positionAt(double length) {
const double u = curveParameter(length);
glm::dvec3 PathCurve::positionAt(double relativeDistance) {
const double u = curveParameter(relativeDistance * _totalLength);
return interpolate(u);
}

View File

@@ -36,7 +36,7 @@ public:
virtual ~PathCurve() = 0;
const double length() const;
glm::dvec3 positionAt(double length);
glm::dvec3 positionAt(double relativeDistance);
// Compute curve parameter u that matches the input arc length s
double curveParameter(double s);