fix: share weather cadence across renderers
This commit is contained in:
@@ -55,7 +55,7 @@ bool RasterArrayTimelineRuntime::append(Entry entry) {
|
||||
}
|
||||
|
||||
RasterArrayTimelineFrame RasterArrayTimelineRuntime::frameLocked() const {
|
||||
return {entries[t0].field, entries[t0 + 1].field, mix, t0, t0 + 1, windowRevision, state};
|
||||
return {entries[t0].field, entries[t0 + 1].field, mix, t0, t0 + 1, windowRevision, cadenceRevision, state};
|
||||
}
|
||||
|
||||
RasterArrayTimelineFrame RasterArrayTimelineRuntime::frame() const {
|
||||
@@ -86,14 +86,14 @@ bool RasterArrayTimelineRuntime::moveToLocked(const size_t nextT0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
RasterArrayTimelineFrame RasterArrayTimelineRuntime::tick() {
|
||||
RasterArrayCadenceAdvance RasterArrayTimelineRuntime::advanceIfDue(const std::chrono::steady_clock::time_point now) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
const auto now = std::chrono::steady_clock::now();
|
||||
if (targetFps_ != RasterArrayTargetFps::Auto && lastCadenceTick.time_since_epoch().count() != 0) {
|
||||
const auto interval = std::chrono::duration<double>(1.0 / static_cast<uint8_t>(targetFps_));
|
||||
if (now - lastCadenceTick < interval) return frameLocked();
|
||||
if (now - lastCadenceTick < interval) return {frameLocked(), false};
|
||||
}
|
||||
lastCadenceTick = now;
|
||||
++cadenceRevision;
|
||||
++cadenceTickCount;
|
||||
if (lastCadenceLog.time_since_epoch().count() == 0 || now - lastCadenceLog >= std::chrono::seconds(1)) {
|
||||
lastCadenceLog = now;
|
||||
@@ -102,11 +102,11 @@ RasterArrayTimelineFrame RasterArrayTimelineRuntime::tick() {
|
||||
}
|
||||
if (lastTick == std::chrono::steady_clock::time_point{}) {
|
||||
lastTick = now;
|
||||
return frameLocked();
|
||||
return {frameLocked(), true};
|
||||
}
|
||||
const auto elapsed = std::chrono::duration<float, std::milli>(now - lastTick).count();
|
||||
lastTick = now;
|
||||
if (state != RasterArrayPlaybackState::Playing) return frameLocked();
|
||||
if (state != RasterArrayPlaybackState::Playing) return {frameLocked(), true};
|
||||
const auto duration = static_cast<float>(entries[t0 + 1].timestamp - entries[t0].timestamp);
|
||||
mix += elapsed * speed / duration;
|
||||
while (mix >= 1.0f) {
|
||||
@@ -117,13 +117,13 @@ RasterArrayTimelineFrame RasterArrayTimelineRuntime::tick() {
|
||||
Log::Warning(Event::Render,
|
||||
std::string("ParticleTimeline: event=TIMELINE_REJECTED reason=") +
|
||||
(invalid ? "INVALID_NEXT" : "GAP_HOLD") + " t1=" + entries[t0 + 1].field->fieldID);
|
||||
return frameLocked();
|
||||
return {frameLocked(), true};
|
||||
}
|
||||
if (!moveToLocked(t0 + 1)) {
|
||||
mix = 1.0f;
|
||||
state = RasterArrayPlaybackState::Ended;
|
||||
Log::Info(Event::Render, "ParticleTimeline: event=END t1=" + entries[t0 + 1].field->fieldID);
|
||||
return frameLocked();
|
||||
return {frameLocked(), true};
|
||||
}
|
||||
Log::Info(Event::Render,
|
||||
"ParticleTimeline: event=WINDOW_BOUNDARY oldT1=" + entries[t0].field->fieldID +
|
||||
@@ -132,7 +132,11 @@ RasterArrayTimelineFrame RasterArrayTimelineRuntime::tick() {
|
||||
"ParticleTimeline: event=TIMELINE_CACHE_HIT index=" + std::to_string(t0 + 1) +
|
||||
" cacheSize=" + std::to_string(entries.size()) + " capacity=" + std::to_string(cacheCapacity_));
|
||||
}
|
||||
return frameLocked();
|
||||
return {frameLocked(), true};
|
||||
}
|
||||
|
||||
RasterArrayTimelineFrame RasterArrayTimelineRuntime::tick() {
|
||||
return advanceIfDue(std::chrono::steady_clock::now()).frame;
|
||||
}
|
||||
|
||||
bool RasterArrayTimelineRuntime::setTargetFps(const RasterArrayTargetFps target) {
|
||||
|
||||
Reference in New Issue
Block a user