fix: share weather cadence across renderers
This commit is contained in:
@@ -495,26 +495,6 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
// update() is not called for every drawable frame. State executes once
|
||||
// per particle simulation frame, making it the appropriate existing
|
||||
// Core render lifecycle for the Source-owned monotonic playback clock.
|
||||
if (pass == ValidationPass::State && resources->timeline) {
|
||||
const auto frame = resources->timeline->tick();
|
||||
resources->timeMix = frame.mix;
|
||||
const auto now = std::chrono::steady_clock::now();
|
||||
if (now - resources->lastPlaybackHeartbeat >= std::chrono::seconds(1)) {
|
||||
resources->lastPlaybackHeartbeat = now;
|
||||
Log::Info(
|
||||
Event::Render,
|
||||
"ParticleTimeline: event=PLAYBACK_TICK state=" + std::to_string(static_cast<int>(frame.state)) +
|
||||
" speed=" + std::to_string(resources->timeline->playbackSpeed()) +
|
||||
" cursor=" + std::to_string(frame.t0Index) + " mix=" + std::to_string(frame.mix) +
|
||||
" window=" + std::to_string(frame.t0Index) + "/" + std::to_string(frame.t1Index) +
|
||||
" fieldUploadCount=" + std::to_string(resources->fieldUploadCount) +
|
||||
" simulationResetCount=" + std::to_string(resources->resetCount));
|
||||
}
|
||||
}
|
||||
|
||||
if (pass == ValidationPass::State) {
|
||||
const auto now = std::chrono::steady_clock::now();
|
||||
if (now - resources->lastMotionLog >= std::chrono::seconds(1)) {
|
||||
@@ -1105,9 +1085,14 @@ void RenderRasterParticleLayer::update(gfx::ShaderRegistry& shaders,
|
||||
const uint8_t fixtureMode = properties.fixtureMode;
|
||||
const uint32_t particleCount = properties.particleCount;
|
||||
float timelineMix = properties.timeMix;
|
||||
bool cadenceAdvanced = true;
|
||||
uint64_t cadenceRevision = sourceTimelineCadenceRevision;
|
||||
if (formalSource && sourceTimeline) {
|
||||
const auto frame = sourceTimeline->tick();
|
||||
const auto advance = sourceTimeline->advanceIfDue(std::chrono::steady_clock::now());
|
||||
const auto& frame = advance.frame;
|
||||
timelineMix = frame.mix;
|
||||
cadenceRevision = frame.cadenceRevision;
|
||||
cadenceAdvanced = frame.cadenceRevision != sourceTimelineCadenceRevision;
|
||||
if (frame.windowRevision != sourceTimelineWindowRevision) {
|
||||
sourceField = *frame.t0;
|
||||
sourceNextField = *frame.t1;
|
||||
@@ -1741,7 +1726,7 @@ void RenderRasterParticleLayer::update(gfx::ShaderRegistry& shaders,
|
||||
|
||||
// Camera-driven frames may recompose existing weather drawables, but do
|
||||
// not advance the shared timeline, State, or Trail before the deadline.
|
||||
if (formalSource && sourceTimeline && !sourceTimeline->cadenceDue(std::chrono::steady_clock::now())) {
|
||||
if (formalSource && sourceTimeline && !cadenceAdvanced) {
|
||||
auto& compositeGroup = static_cast<LayerGroup&>(*layerGroup);
|
||||
compositeGroup.clearDrawables();
|
||||
const auto center = transformState.getLatLng(LatLng::Unwrapped);
|
||||
@@ -1848,6 +1833,8 @@ void RenderRasterParticleLayer::update(gfx::ShaderRegistry& shaders,
|
||||
return;
|
||||
}
|
||||
|
||||
if (formalSource && sourceTimeline) sourceTimelineCadenceRevision = cadenceRevision;
|
||||
|
||||
// Read targets are registered only for their one-time clear. Normal frames register
|
||||
// only the opposite write targets, in dependency order, so a sampled texture can
|
||||
// never be attached to the active render pass.
|
||||
|
||||
Reference in New Issue
Block a user