Loading...
Searching...
No Matches
SceneSelector.hpp
1#pragma once
2#include <halp/controls.hpp>
3#include <halp/meta.hpp>
4
5#include <ossia/dataflow/geometry_port.hpp>
6
7#include <cstdint>
8#include <memory>
9#include <string>
10
11namespace Threedim
12{
13
14// Extracts a subtree from an incoming scene and emits it as a fresh
15// scene_spec. Where SceneGraphFilter prunes (keeps the tree shape, drops
16// non-matches), SceneSelector extracts: it gathers the matches and forgets
17// the ancestors.
18//
19// Use case: pull out the camera, a light rig, or a character subtree
20// so it can be re-transformed / re-materialized and then merged back
21// in via SceneGroup.
22//
23// Rebase modes:
24// Preserve : emit the subtree root as-is, so its transform
25// remains in its original parent frame (the
26// ancestors are gone but the transform still
27// matches where it was).
28// ZeroOut : drop the subtree's own TRS so it renders at the
29// world origin, for re-placing the extracted subtree
30// via an upstream Transform3D / SceneGroup.
32{
33public:
34 halp_meta(name, "Scene Selector")
35 halp_meta(category, "Visuals/3D/Scene")
36 halp_meta(c_name, "scene_selector")
37 halp_meta(description, "Extract matching scene subtrees with optional transform rebasing.")
38 halp_meta(authors, "ossia team")
39 halp_meta(
40 manual_url,
41 "https://ossia.io/score-docs/processes/scene-selector.html")
42 halp_meta(uuid, "6c4d8b3f-5e2a-4d1f-9c7b-8a3e5f0d7b4c")
43
44 enum Mode
45 {
46 ByPath,
47 ByName,
48 ByIndex // index into the root list (0 = first root)
49 };
50
51 enum Rebase
52 {
53 Preserve,
54 ZeroOut
55 };
56
57 struct ins
58 {
59 struct
60 {
61 halp_meta(name, "Scene In");
62 ossia::scene_spec scene;
63 uint8_t dirty{0};
64 } scene_in;
65
66 // Port-driven rebuild: controls trigger rebuild(); upstream
67 // scene_in changes detected in operator()().
68 struct : halp::combobox_t<"Mode", Mode>
69 {
70 struct range
71 {
72 std::string_view values[3]{"By path", "By name", "By index"};
73 int init{0};
74 };
75 void update(SceneSelector& n) { n.rebuild(); }
76 } mode;
77
78 struct : halp::lineedit<"Path / Name", "">
79 { void update(SceneSelector& n) { n.rebuild(); } } path;
80 struct : halp::spinbox_i32<"Index", halp::irange{0, 1024, 0}>
81 { void update(SceneSelector& n) { n.rebuild(); } } index;
82
83 struct : halp::combobox_t<"Rebase", Rebase>
84 {
85 struct range
86 {
87 std::string_view values[2]{"Preserve transform", "Zero out"};
88 int init{0};
89 };
90 void update(SceneSelector& n) { n.rebuild(); }
91 } rebase;
92 } inputs;
93
94 struct outs
95 {
96 struct
97 {
98 halp_meta(name, "Scene Out");
99 ossia::scene_spec scene;
100 uint8_t dirty{0};
101 } scene_out;
102 } outputs;
103
104 void rebuild();
105 void operator()();
106
107 std::shared_ptr<const ossia::scene_state> m_cached_out;
108 uint8_t m_pending_dirty{0xFF};
109 const ossia::scene_state* m_cached_in_state{};
110 int64_t m_cached_in_version{-1};
111 int64_t m_version_counter{0};
112};
113
114}
Definition SceneSelector.hpp:32
Definition SceneSelector.hpp:58
Definition SceneSelector.hpp:95
Definition MIDISync.hpp:128