Loading...
Searching...
No Matches
SceneInspector.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 <string>
9#include <vector>
10
11namespace Threedim
12{
13
14// Read-only introspection node for scene_spec. Walks the incoming
15// scene tree and emits:
16// - `Rows`: a list of strings, one per node. In Paths mode each row
17// is a canonical slash-path (`/Root/Body/Wheels`), directly usable
18// in SceneGraphFilter(paths=...) / ConfigurePrimitive /
19// SceneSelector. In Tree mode each row is indented with
20// box-drawing glyphs for visual hierarchy. In Names mode each row
21// is a bare node name.
22// - `Readable`: a formatted multi-line dump of the same information,
23// suitable to pipe into Ui::TextBox for a wider-view inspector.
24// - Scalar stats: node / mesh / light / camera / material counts
25// plus totalled triangle and vertex counts.
26//
27// Answers "what paths exist in this scene?": filter and selector nodes need
28// string patterns, and without a way to enumerate the tree they have to be
29// guessed. Placed between a loader and a filter, the Rows list gives the path
30// to paste into the downstream node.
32{
33public:
34 halp_meta(name, "Scene Inspector")
35 halp_meta(category, "Visuals/3D/Scene")
36 halp_meta(c_name, "scene_inspector")
37 halp_meta(authors, "ossia team")
38 halp_meta(
39 manual_url,
40 "https://ossia.io/score-docs/processes/scene-inspector.html")
41 halp_meta(uuid, "b5f2c8a3-4d1e-4b7f-9e6c-3a8d5f0b2c9e")
42
43 enum Mode
44 {
45 Paths, // canonical slash-paths, directly copy-pasteable
46 Names, // bare node names (may have duplicates)
47 Tree, // indented with ├──/└── glyphs
48 Summary // high-level per-root summary + counts
49 };
50
51 struct ins
52 {
53 struct
54 {
55 halp_meta(name, "Scene In");
56 ossia::scene_spec scene;
57 uint8_t dirty{0};
58 } scene_in;
59
60 struct : halp::combobox_t<"Mode", Mode>
61 {
62 struct range
63 {
64 std::string_view values[4]{"Paths", "Names", "Tree", "Summary"};
65 int init{0};
66 };
67 } mode;
68
69 halp::toggle<"Show components"> show_components;
70 halp::toggle<"Show stats"> show_stats;
71 halp::toggle<"Include hidden"> include_hidden;
72 halp::spinbox_i32<"Max depth", halp::irange{-1, 64, -1}> max_depth;
73 } inputs;
74
75 struct outs
76 {
77 halp::val_port<"Rows", std::vector<std::string>> rows;
78 halp::val_port<"Readable", std::string> readable;
79
80 halp::val_port<"Node count", int> node_count;
81 halp::val_port<"Mesh count", int> mesh_count;
82 halp::val_port<"Light count", int> light_count;
83 halp::val_port<"Camera count", int> camera_count;
84 halp::val_port<"Material count", int> material_count;
85 halp::val_port<"Total triangles", int> total_triangles;
86 halp::val_port<"Total vertices", int> total_vertices;
87 } outputs;
88
89 void operator()();
90
91 // Identity + version cache: if inputs haven't changed we skip the
92 // whole walk. Matches the pattern used by SceneGraphFilter etc.
93 const ossia::scene_state* m_cached_in_state{};
94 int64_t m_cached_in_version{-1};
95 int m_cached_mode{-1};
96 bool m_cached_show_components{false};
97 bool m_cached_show_stats{false};
98 bool m_cached_include_hidden{false};
99 int m_cached_max_depth{-2};
100 bool m_cached_valid{false};
101};
102
103}
Definition SceneInspector.hpp:32
Definition SceneInspector.hpp:52
Definition SceneInspector.hpp:76
Definition MIDISync.hpp:126