Loading...
Searching...
No Matches
ConfigurePrimitive.hpp
1#pragma once
2#include <halp/controls.hpp>
3#include <halp/meta.hpp>
4
5#include <Threedim/StringListControl.hpp>
6
7#include <ossia/dataflow/geometry_port.hpp>
8
9#include <cstdint>
10#include <memory>
11#include <string>
12#include <vector>
13
14namespace Threedim
15{
16
17// Authors metadata flags on matching scene_nodes: active, visible --
18// the flags that are meaningful for a live renderer.
19//
20// Usage pattern:
21// glTF → ConfigurePrimitive(paths=["*/chairs/*"], active=false) → ScenePreprocessor
22// disables the entire `chairs` subtree non-destructively — flipping
23// the toggle re-activates it without reloading the glTF or rebuilding
24// any GPU state.
25//
26// `visible` acts at the leaf level (hides from rendering but keeps the
27// subtree composed); `active` is stronger (skips the subtree in the
28// flatten walk entirely — no transforms applied, no data uploaded).
30{
31public:
32 halp_meta(name, "Configure Primitive")
33 halp_meta(category, "Visuals/3D/Scene")
34 halp_meta(c_name, "configure_primitive")
35 halp_meta(description, "Set active and visible flags on scene nodes selected by path patterns.")
36 halp_meta(authors, "ossia team")
37 halp_meta(
38 manual_url,
39 "https://ossia.io/score-docs/processes/configure-primitive.html")
40 halp_meta(uuid, "4b8e9d2a-7c5f-4e3a-9b1c-3d2f5e8a7b9c")
41
42 enum Mode
43 {
44 // Applies the flags to every matching node. Non-matching nodes
45 // keep their existing flags (no change).
46 SetActive,
47 SetInactive,
48 SetVisible,
49 SetInvisible,
50 // Apply both at once — useful for "this subtree is off right now".
51 SetActiveAndVisible,
52 SetInactiveAndInvisible
53 };
54
55 struct ins
56 {
57 struct
58 {
59 halp_meta(name, "Scene In");
60 ossia::scene_spec scene;
61 uint8_t dirty{0};
62 } scene_in;
63
64 // Port-driven rebuild: controls trigger rebuild() via update().
65 // scene_in pointer/version changes detected in operator()().
66 struct : halp::combobox_t<"Mode", Mode>
67 {
68 struct range
69 {
70 std::string_view values[6]{
71 "Set active", "Set inactive",
72 "Set visible", "Set invisible",
73 "Active + visible", "Inactive + invisible"};
74 int init{0};
75 };
76 void update(ConfigurePrimitive& n) { n.rebuild(); }
77 } mode;
78
79 // Path-glob list. Same syntax as SceneGraphFilter: `*` wildcards
80 // within a segment, `**` crosses slashes, `?` single char, literal
81 // names otherwise.
82 struct : string_list_control<"Paths">
83 {
84 halp_meta(description, "Scene paths, one per row. Glob syntax: * within a segment, ** across segments, ? one character.")
85 void update(ConfigurePrimitive& n) { n.rebuild(); }
86 } paths;
87 } inputs;
88
89 struct outs
90 {
91 struct
92 {
93 halp_meta(name, "Scene Out");
94 ossia::scene_spec scene;
95 uint8_t dirty{0};
96 } scene_out;
97 } outputs;
98
99 void rebuild();
100 void operator()();
101
102 std::shared_ptr<const ossia::scene_state> m_cached_out;
103 uint8_t m_pending_dirty{0xFF};
104 const ossia::scene_state* m_cached_in_state{};
105 int64_t m_cached_in_version{-1};
106 int m_cached_mode{-1};
107 std::vector<std::string> m_cached_paths;
108 int64_t m_version_counter{0};
109};
110
111}
Definition ConfigurePrimitive.hpp:30
Definition ConfigurePrimitive.hpp:56
Definition ConfigurePrimitive.hpp:90
Definition StringListControl.hpp:83
Definition MIDISync.hpp:128