feat: add runtime particle timeline playback
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:
@@ -772,6 +772,14 @@ void RenderRasterParticleLayer::prepare(const LayerPrepareParameters& parameters
|
||||
return;
|
||||
}
|
||||
const auto& source = static_cast<const RenderRasterArraySource&>(*parameters.source);
|
||||
sourceTimeline = source.impl().timeline;
|
||||
if (sourceTimeline) {
|
||||
const auto frame = sourceTimeline->frame();
|
||||
sourceField = *frame.t0;
|
||||
sourceNextField = *frame.t1;
|
||||
sourceTimelineWindowRevision = frame.windowRevision;
|
||||
return;
|
||||
}
|
||||
if (source.impl().field) {
|
||||
sourceField = *source.impl().field;
|
||||
sourceNextField = source.impl().nextField ? *source.impl().nextField : *source.impl().field;
|
||||
@@ -798,6 +806,16 @@ void RenderRasterParticleLayer::update(gfx::ShaderRegistry& shaders,
|
||||
const uint8_t maskMode = properties.maskMode;
|
||||
const uint8_t fixtureMode = properties.fixtureMode;
|
||||
const uint32_t particleCount = properties.particleCount;
|
||||
float timelineMix = properties.timeMix;
|
||||
if (formalSource && sourceTimeline) {
|
||||
const auto frame = sourceTimeline->tick();
|
||||
timelineMix = frame.mix;
|
||||
if (frame.windowRevision != sourceTimelineWindowRevision) {
|
||||
sourceField = *frame.t0;
|
||||
sourceNextField = *frame.t1;
|
||||
sourceTimelineWindowRevision = frame.windowRevision;
|
||||
}
|
||||
}
|
||||
auto resources = gpuResources;
|
||||
if (resources && resources->contextDestroyed) {
|
||||
// VALIDATION ONLY: follow the 30-02 resource-generation rule. No stale
|
||||
@@ -1095,16 +1113,18 @@ void RenderRasterParticleLayer::update(gfx::ShaderRegistry& shaders,
|
||||
return;
|
||||
}
|
||||
}
|
||||
const auto requestedTimeMix = std::clamp(properties.timeMix, 0.0f, 1.0f);
|
||||
const auto requestedTimeMix = std::clamp(timelineMix, 0.0f, 1.0f);
|
||||
if (resources->timeMix != requestedTimeMix) {
|
||||
resources->timeMix = requestedTimeMix;
|
||||
Log::Info(Event::Render,
|
||||
"ParticleGPU: event=TIME_MIX_UPDATE value=" + std::to_string(resources->timeMix) +
|
||||
" T0=" + resources->field.fixtureID + " T1=" + resources->nextField.fixtureID +
|
||||
" renderLayerInstanceId=" + std::to_string(resources->renderLayerInstanceId) +
|
||||
" resourceGeneration=" + std::to_string(resources->generation) +
|
||||
" fieldUploadCount=" + std::to_string(resources->fieldUploadCount) +
|
||||
" resetCount=" + std::to_string(resources->resetCount));
|
||||
if (!sourceTimeline || std::abs(resources->timeMix * 4.0f - std::round(resources->timeMix * 4.0f)) < 0.01f) {
|
||||
Log::Info(Event::Render,
|
||||
"ParticleGPU: event=TIME_MIX_UPDATE value=" + std::to_string(resources->timeMix) +
|
||||
" T0=" + resources->field.fixtureID + " T1=" + resources->nextField.fixtureID +
|
||||
" renderLayerInstanceId=" + std::to_string(resources->renderLayerInstanceId) +
|
||||
" resourceGeneration=" + std::to_string(resources->generation) +
|
||||
" fieldUploadCount=" + std::to_string(resources->fieldUploadCount) +
|
||||
" resetCount=" + std::to_string(resources->resetCount));
|
||||
}
|
||||
}
|
||||
|
||||
const bool visualChanged = resources->lineWidth != properties.lineWidth ||
|
||||
|
||||
Reference in New Issue
Block a user