fix: keep particle timeline playback ticking
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <cmath>
|
||||
#include <chrono>
|
||||
#include <limits>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
@@ -198,6 +199,7 @@ public:
|
||||
bool worldWrapLogged = false;
|
||||
bool antimeridianLogged = false;
|
||||
uint64_t lastCameraLogFrame = 0;
|
||||
std::chrono::steady_clock::time_point lastPlaybackHeartbeat{};
|
||||
uint64_t maskGeneration = 0;
|
||||
uint64_t fieldGeneration = 0;
|
||||
uint64_t gpuFieldGeneration = 0;
|
||||
@@ -228,6 +230,7 @@ public:
|
||||
gfx::Texture2DPtr stateTexture;
|
||||
particle::ParticleFieldSnapshot field;
|
||||
particle::ParticleFieldSnapshot nextField;
|
||||
std::shared_ptr<style::RasterArrayTimelineRuntime> timeline;
|
||||
std::shared_ptr<PremultipliedImage> fieldImage;
|
||||
std::shared_ptr<PremultipliedImage> nextFieldImage;
|
||||
std::shared_ptr<PremultipliedImage> maskFixture;
|
||||
@@ -351,6 +354,26 @@ 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));
|
||||
}
|
||||
}
|
||||
|
||||
drawable.setTexture(source, shaders::idParticleGpuValidationPreviousTexture);
|
||||
if (mask) {
|
||||
drawable.setTexture(mask, shaders::idParticleGpuValidationMaskTexture);
|
||||
@@ -1113,6 +1136,9 @@ void RenderRasterParticleLayer::update(gfx::ShaderRegistry& shaders,
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Keep the shared Core runtime alive in the per-frame drawable tweaker.
|
||||
// This is a pointer to Source-owned state, not a second timeline.
|
||||
resources->timeline = sourceTimeline;
|
||||
const auto requestedTimeMix = std::clamp(timelineMix, 0.0f, 1.0f);
|
||||
if (resources->timeMix != requestedTimeMix) {
|
||||
resources->timeMix = requestedTimeMix;
|
||||
|
||||
Reference in New Issue
Block a user