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