mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 03:29:44 -06:00
Don't scale camera path speed if no duration was given
Just using the current distance for camera speed works better than setting a default duration based on the path length
This commit is contained in:
@@ -57,12 +57,6 @@ public:
|
||||
Waypoint startPoint() const;
|
||||
Waypoint endPoint() const;
|
||||
|
||||
/**
|
||||
* Return the specified duration for the path, in seconds. Note that the time it
|
||||
* takes to actually traverse the path will not exactly match the provided duration
|
||||
*/
|
||||
double duration() const;
|
||||
|
||||
/**
|
||||
* Return the total length of the the curve for the path, in meters
|
||||
*/
|
||||
@@ -128,7 +122,6 @@ private:
|
||||
|
||||
Waypoint _start;
|
||||
Waypoint _end;
|
||||
double _duration; // seconds
|
||||
Type _type;
|
||||
|
||||
std::unique_ptr<PathCurve> _curve;
|
||||
|
||||
@@ -107,19 +107,19 @@ Path::Path(Waypoint start, Waypoint end, Type type,
|
||||
throw ghoul::MissingCaseException();
|
||||
}
|
||||
|
||||
_duration = duration.value_or(std::log(pathLength()));
|
||||
// Compute speed factor to match any given duration, by traversing the path and
|
||||
// computing how much faster/slower it should be
|
||||
_speedFactorFromDuration = 1.0;
|
||||
if (duration.has_value()) {
|
||||
constexpr const double dt = 0.05; // 20 fps
|
||||
while (!hasReachedEnd()) {
|
||||
traversePath(dt);
|
||||
}
|
||||
|
||||
// Compute speed factor to match the generated path length and duration, by
|
||||
// traversing the path and computing how much faster/slower it should be
|
||||
const int nSteps = 500;
|
||||
const double dt = (_duration / nSteps) > 0.01 ? (_duration / nSteps) : 0.01;
|
||||
|
||||
while (!hasReachedEnd()) {
|
||||
traversePath(dt);
|
||||
// We now know how long it took to traverse the path. Use that
|
||||
_speedFactorFromDuration = _progressedTime / *duration;
|
||||
}
|
||||
|
||||
_speedFactorFromDuration = _progressedTime / _duration;
|
||||
|
||||
// Reset playback variables
|
||||
_traveledDistance = 0.0;
|
||||
_progressedTime = 0.0;
|
||||
@@ -129,8 +129,6 @@ Waypoint Path::startPoint() const { return _start; }
|
||||
|
||||
Waypoint Path::endPoint() const { return _end; }
|
||||
|
||||
double Path::duration() const { return _duration; }
|
||||
|
||||
double Path::pathLength() const { return _curve->length(); }
|
||||
|
||||
std::vector<glm::dvec3> Path::controlPoints() const {
|
||||
|
||||
Reference in New Issue
Block a user