载入中...
搜索中...
未找到
ParticleRecording.cpp
浏览该文件的文档.
3namespace eve::particles {
5 auto sim = emitter.sim();
6 const auto config = emitter.config();
7 if ((config->renderMode != "billboard" && config->renderMode != "axis" && config->renderMode != "stretched") ||
8 config->sortMode != "none")
11 "sprite recording requires a supported sprite mode and stable birth ordering", "particleRecording"));
12 if (sim->alive != 0 || emitter.config()->gpuSimulation || emitter.gpuSim()->residentActive ||
13 sim->recording.state() == ParticleRecordState::Recording)
16 "recording requires an empty CPU emitter without an active recording", "particleRecording"));
17 auto prepared = sim->recording.prepare(budget);
18 if (!prepared) return prepared;
19 sim->recordingSeconds = 0;
20 return Result<void>::success();
21}
25 if (config.gpuSimulation || config.sortMode != "none" ||
26 (config.renderMode != "billboard" && config.renderMode != "axis" && config.renderMode != "stretched")) {
28 return;
29 }
30 auto appearance = evaluateParticleAppearance(config, particle);
31 if (!appearance) {
33 return;
34 }
35 auto appended = sim.recording.append({sim.recordingSeconds, particle.birthSerial, kind, appearance.value()});
36 if (!appended) sim.recording.invalidate();
37}
39 auto sim = emitter.sim();
40 if (emitter.gpuSim()->residentActive) sim->recording.invalidate();
41 for (int i = 0; i < sim->alive; ++i)
42 recordParticleEvent(*emitter.config(), *sim, sim->particles[std::size_t(i)], ParticleRecordEventKind::Death);
43 return sim->recording.finish();
44}
45} // namespace eve::particles
std::string kind
std::unique_ptr< TrailEmitter > emitter
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Move-only operation result carrying either a value or Status.
Definition Result.h:176
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:185
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
ECS emitter entity. Script configures components; ParticleSimSystem / ParticleRenderSystem drive per-...
void invalidate() noexcept
Mark active recording invalid after a producer failure; disabled journals remain disabled.
ParticleRecordState state() const noexcept
Current lifecycle and failure state.
Result< void > append(ParticleRecordEvent event)
Append an owning event at a nondecreasing explicit time; never allocates or calls user code.
Result< void > prepareParticleRecording(ParticleEmitter &emitter, std::size_t budget)
Prepare bounded CPU event capture before the first live birth. @ownership Journal belongs to the emit...
void recordParticleEvent(const ParticleEmitter::Config &config, ParticleEmitter::Sim &sim, const Particle &particle, ParticleRecordEventKind kind)
Internal simulation hook; captures at Sim recordingSeconds and records sticky failures....
Result< ParticleAppearance > evaluateParticleAppearance(const ParticleEmitter::Config &cfg, const Particle &p)
Evaluate the same CPU sprite curves and render mode for live rendering and bake capture....
ParticleRecordEventKind
Snapshot creates or updates a birth; death closes it at the exact simulation boundary.
Result< std::vector< ParticleRecordEvent > > finishParticleRecording(ParticleEmitter &emitter)
Close all live births at the current explicit recording time and transfer owned events....
bool gpuSimulation
Opt-in GPU-accelerated simulation (falls back to CPU when unavailable).
std::string sortMode
"none" | "oldest" | "youngest" | "distance" transparent ordering.
std::string renderMode
"billboard" | "axis" | "stretched" | "ribbon".
double recordingSeconds
Explicit accumulated executed simulation dt since recording preparation.
ParticleEventJournal recording
Optional bounded recording owner; disabled by default, independent of emitter looping/reset age.
Single live particle (CPU simulation).
std::uint64_t birthSerial
Nonzero CPU birth identity within its owning Sim lifetime; moves with the particle during compaction.