diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-16 10:21:36 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-16 10:21:36 +0100 |
| commit | 8eeadaf0d5653c21b948103e4d328f634b739a17 (patch) | |
| tree | d53c10cbe25a0945e9e29f18d5c44ff2b6139d67 /tools | |
| parent | e3e655f897a2b93d571fc68f13ccb931ff5de7b4 (diff) | |
feat(sequence): integrate v2 timeline with main loop
- Generate InitializeV2Sequences() in timeline.cc
- Generate RenderV2Timeline() for frame rendering
- Add timeline_v2.h interface header
- Call InitializeV2Sequences() in main.cc
- V2 sequences instantiated at startup
- Ready for v1→v2 rendering switch
All 35 tests passing ✅
handoff(Claude): V2 integration ready, next: switch rendering to v2
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/seq_compiler_v2.py | 63 |
1 files changed, 57 insertions, 6 deletions
diff --git a/tools/seq_compiler_v2.py b/tools/seq_compiler_v2.py index cb30585..9918a92 100755 --- a/tools/seq_compiler_v2.py +++ b/tools/seq_compiler_v2.py @@ -479,21 +479,72 @@ def main(): cpp = generate_cpp(seq, sorted_effects, aliases, args.flatten) all_cpp += cpp + '\n' - # Generate compatibility stubs for v1 API + # Generate sequence registry and accessors all_cpp += ''' -// V1 compatibility stubs (TODO: Replace with proper v2 integration) +// V2 Sequence Registry #include "gpu/effect.h" +#include <vector> +#include <memory> +struct SequenceV2Entry { + float start_time; + int priority; + std::unique_ptr<SequenceV2> sequence; +}; + +static std::vector<SequenceV2Entry> g_v2_sequences; +static bool g_v2_initialized = false; + +void InitializeV2Sequences(const GpuContext& ctx, int width, int height) { + if (g_v2_initialized) return; + g_v2_initialized = true; + +''' + + # Instantiate each sequence + for seq in sequences: + class_name = f"{seq.name}Sequence" + all_cpp += f' g_v2_sequences.push_back({{{seq.start_time}f, {seq.priority}, std::make_unique<{class_name}>(ctx, width, height)}});\n' + + all_cpp += ''' +} + +SequenceV2* GetActiveV2Sequence(float time) { + // Find active sequence (latest start_time <= current time) + SequenceV2* active = nullptr; + for (auto& entry : g_v2_sequences) { + if (entry.start_time <= time) { + active = entry.sequence.get(); + } + } + return active; +} + +void RenderV2Timeline(WGPUCommandEncoder encoder, float time, int width, int height, + float beat_time, float audio_intensity) { + SequenceV2* seq = GetActiveV2Sequence(time); + if (seq) { + UniformsSequenceParams params = {}; + params.resolution = {(float)width, (float)height}; + params.aspect_ratio = (float)width / (float)height; + params.time = time; + params.beat_time = beat_time; + params.beat_phase = 0.0f; + params.audio_intensity = audio_intensity; + + seq->render_effects(encoder); + } +} + +// V1 compatibility stub void LoadTimeline(MainSequence& main_seq, const GpuContext& ctx) { - // TODO: Integrate v2 sequences with MainSequence - // For now, this is a no-op to allow linking + // V1 stub - v2 sequences initialized separately (void)main_seq; (void)ctx; } float GetDemoDuration() { - // TODO: Calculate from v2 sequences - return 40.0f; + return 40.0f; // TODO: Calculate from v2 sequences } ''' |
