Make constructor of Time explicit

Module breaking change
This commit is contained in:
Alexander Bock
2019-07-17 15:39:43 +02:00
parent c97d5126ec
commit 277aee5c0c
9 changed files with 30 additions and 29 deletions
+1 -1
View File
@@ -65,7 +65,7 @@ public:
*/
static double convertTime(const std::string& time);
Time(double secondsJ2000 = -1);
explicit Time(double secondsJ2000 = -1);
Time(const Time& other) = default;
/**
@@ -233,8 +233,8 @@ void RenderableTrailOrbit::update(const UpdateData& data) {
// Write the current location into the floating position
const glm::vec3 p = _translation->position({
{},
data.time.j2000Seconds(),
0.0,
data.time,
Time(0.0),
false
});
_vertexArray[_primaryRenderInformation.first] = { p.x, p.y, p.z };
@@ -412,8 +412,8 @@ RenderableTrailOrbit::UpdateReport RenderableTrailOrbit::updateTrails(
// location
const glm::vec3 p = _translation->position({
{},
_lastPointTime,
0.0,
Time(_lastPointTime),
Time(0.0),
false
});
_vertexArray[_primaryRenderInformation.first] = { p.x, p.y, p.z };
@@ -452,8 +452,8 @@ RenderableTrailOrbit::UpdateReport RenderableTrailOrbit::updateTrails(
// location
const glm::vec3 p = _translation->position({
{},
_firstPointTime,
0.0,
Time(_firstPointTime),
Time(0.0),
false
});
_vertexArray[_primaryRenderInformation.first] = { p.x, p.y, p.z };
@@ -496,7 +496,7 @@ void RenderableTrailOrbit::fullSweep(double time) {
const double secondsPerPoint = _period / (_resolution - 1);
// starting at 1 because the first position is a floating current one
for (int i = 1; i < _resolution; ++i) {
const glm::vec3 p = _translation->position({ {}, time, 0.0, false });
const glm::vec3 p = _translation->position({ {}, Time(time), Time(0.0), false });
_vertexArray[i] = { p.x, p.y, p.z };
time -= secondsPerPoint;
@@ -226,8 +226,8 @@ void RenderableTrailTrajectory::update(const UpdateData& data) {
for (int i = 0; i < nValues; ++i) {
const glm::vec3 p = _translation->position({
{},
_start + i * totalSampleInterval,
0.0,
Time(_start + i * totalSampleInterval),
Time(0.0),
false
});
_vertexArray[i] = { p.x, p.y, p.z };
@@ -771,7 +771,7 @@ void RenderableFieldlinesSequence::definePropertyCallbackFunctions() {
});
_pJumpToStartBtn.onChange([this] {
global::timeManager.setTimeNextFrame(_startTimes[0]);
global::timeManager.setTimeNextFrame(Time(_startTimes[0]));
});
}
@@ -426,7 +426,7 @@ RenderableTimeVaryingVolume::Timestep* RenderableTimeVaryingVolume::timestepFrom
void RenderableTimeVaryingVolume::jumpToTimestep(int target) {
Timestep* t = timestepFromIndex(target);
if (t) {
global::timeManager.setTimeNextFrame(t->metadata.time);
global::timeManager.setTimeNextFrame(Time(t->metadata.time));
}
}
+1 -1
View File
@@ -848,7 +848,7 @@ void SessionRecording::playbackCamera() {
pbFrame.followFocusNodeRotation = (rotationFollowing == "F");
}
if (_setSimulationTimeWithNextCameraKeyframe) {
global::timeManager.setTimeNextFrame(timeSim);
global::timeManager.setTimeNextFrame(Time(timeSim));
_setSimulationTimeWithNextCameraKeyframe = false;
_saveRenderingCurrentRecordedTime = timeRec;
}
+1 -1
View File
@@ -325,7 +325,7 @@ void ParallelPeer::dataMessageReceived(const std::vector<char>& message)
TimeKeyframeData timeKeyframeData;
timeKeyframeData.delta = kfMessage._dt;
timeKeyframeData.pause = kfMessage._paused;
timeKeyframeData.time = kfMessage._time;
timeKeyframeData.time = Time(kfMessage._time);
timeKeyframeData.jump = kfMessage._requiresTimeJump;
const double kfTimestamp = convertTimestamp(kfMessage._timestamp);
+4 -4
View File
@@ -333,12 +333,12 @@ int time_setTime(lua_State* L) {
if (nArguments == 1) {
if (isNumber) {
double value = lua_tonumber(L, 1);
global::timeManager.setTimeNextFrame(value);
global::timeManager.setTimeNextFrame(Time(value));
return 0;
}
if (isString) {
const char* time = lua_tostring(L, 1);
global::timeManager.setTimeNextFrame(Time::convertTime(time));
global::timeManager.setTimeNextFrame(Time(Time::convertTime(time)));
return 0;
}
ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack");
@@ -424,7 +424,7 @@ int time_interpolateTime(lua_State* L) {
global::timeManager.interpolateTime(targetTime, duration);
}
else {
global::timeManager.setTimeNextFrame(targetTime);
global::timeManager.setTimeNextFrame(Time(targetTime));
}
}
return 0;
@@ -486,7 +486,7 @@ int time_interpolateTimeRelative(lua_State* L) {
}
else {
global::timeManager.setTimeNextFrame(
global::timeManager.time().j2000Seconds() + delta
Time(global::timeManager.time().j2000Seconds() + delta)
);
}
}
+12 -11
View File
@@ -109,7 +109,7 @@ void TimeManager::interpolateTime(double targetTime, double durationSeconds) {
const bool pause = isPaused();
const TimeKeyframeData current = { time(), deltaTime(), false, false };
const TimeKeyframeData next = { targetTime, targetDeltaTime(), pause, false };
const TimeKeyframeData next = { Time(targetTime), targetDeltaTime(), pause, false };
clearKeyframes();
addKeyframe(now, current);
@@ -193,12 +193,12 @@ TimeKeyframeData TimeManager::interpolate(double applicationTime) {
} else if (hasPastKeyframes) {
// Extrapolate based on last past keyframe
const double deltaApplicationTime = applicationTime - lastPastKeyframe->timestamp;
Time predictedTime = {
Time predictedTime(
lastPastKeyframe->data.time.j2000Seconds() +
deltaApplicationTime *
(lastPastKeyframe->data.pause ? 0.0 : lastPastKeyframe->data.delta)
};
return TimeKeyframeData{
);
return TimeKeyframeData {
predictedTime,
lastPastKeyframe->data.delta,
false,
@@ -206,7 +206,7 @@ TimeKeyframeData TimeManager::interpolate(double applicationTime) {
};
}
// As the last option, fall back on the current time.
return TimeKeyframeData{ _currentTime, _targetDeltaTime, _timePaused, false };
return TimeKeyframeData { _currentTime, _targetDeltaTime, _timePaused, false };
}
void TimeManager::progressTime(double dt) {
@@ -316,7 +316,7 @@ TimeKeyframeData TimeManager::interpolate(const Keyframe<TimeKeyframeData>& past
deltaAppTime;
TimeKeyframeData data {
interpolatedTime,
Time(interpolatedTime),
interpolatedDeltaTime,
past.data.pause,
past.data.jump
@@ -532,9 +532,9 @@ void TimeManager::interpolateDeltaTime(double newDeltaTime, double interpolation
}
const double now = global::windowDelegate.applicationTime();
Time newTime = time().j2000Seconds() +
(_deltaTime + newDeltaTime) * 0.5 * interpolationDuration;
Time newTime(
time().j2000Seconds() + (_deltaTime + newDeltaTime) * 0.5 * interpolationDuration
);
TimeKeyframeData currentKeyframe = { time(), _deltaTime, false, false };
TimeKeyframeData futureKeyframe = { newTime, newDeltaTime, false, false };
@@ -556,8 +556,9 @@ void TimeManager::interpolatePause(bool pause, double interpolationDuration) {
const double now = global::windowDelegate.applicationTime();
double targetDelta = pause ? 0.0 : _targetDeltaTime;
Time newTime = time().j2000Seconds() +
(_deltaTime + targetDelta) * 0.5 * interpolationDuration;
Time newTime(
time().j2000Seconds() + (_deltaTime + targetDelta) * 0.5 * interpolationDuration
);
TimeKeyframeData currentKeyframe = { time(), _deltaTime, false, false };
TimeKeyframeData futureKeyframe = { newTime, _targetDeltaTime, pause, false };