score
Home
Classes
Namespaces
Files
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
11
namespace
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.
31
class
SceneInspector
32
{
33
public
:
34
halp_meta(name,
"Scene Inspector"
)
35
halp_meta(category,
"Visuals/3D/Scene"
)
36
halp_meta(c_name,
"scene_inspector"
)
37
halp_meta(description,
"List scene paths, names and hierarchy and report geometry and component counts."
)
38
halp_meta(authors,
"ossia team"
)
39
halp_meta(
40
manual_url,
41
"https://ossia.io/score-docs/processes/scene-inspector.html"
)
42
halp_meta(uuid,
"b5f2c8a3-4d1e-4b7f-9e6c-3a8d5f0b2c9e"
)
43
44
enum
Mode
45
{
46
Paths,
// canonical slash-paths, directly copy-pasteable
47
Names,
// bare node names (may have duplicates)
48
Tree,
// indented with ├──/└── glyphs
49
Summary
// high-level per-root summary + counts
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
struct : halp::combobox_t<
"Mode"
, Mode>
62
{
63
struct
range
64
{
65
std::string_view values[4]{
"Paths"
,
"Names"
,
"Tree"
,
"Summary"
};
66
int
init{0};
67
};
68
} mode;
69
70
halp::toggle<
"Show components"
> show_components;
71
halp::toggle<
"Show stats"
> show_stats;
72
halp::toggle<
"Include hidden"
> include_hidden;
73
halp::spinbox_i32<
"Max depth"
, halp::irange{-1, 64, -1}> max_depth;
74
} inputs;
75
76
struct
outs
77
{
78
halp::val_port<
"Rows"
, std::vector<std::string>> rows;
79
halp::val_port<
"Readable"
, std::string> readable;
80
81
halp::val_port<
"Node count"
,
int
> node_count;
82
halp::val_port<
"Mesh count"
,
int
> mesh_count;
83
halp::val_port<
"Light count"
,
int
> light_count;
84
halp::val_port<
"Camera count"
,
int
> camera_count;
85
halp::val_port<
"Material count"
,
int
> material_count;
86
halp::val_port<
"Total triangles"
,
int
> total_triangles;
87
halp::val_port<
"Total vertices"
,
int
> total_vertices;
88
} outputs;
89
90
void
operator()();
91
92
// Identity + version cache: if inputs haven't changed we skip the
93
// whole walk. Matches the pattern used by SceneGraphFilter etc.
94
const
ossia::scene_state* m_cached_in_state{};
95
int64_t m_cached_in_version{-1};
96
int
m_cached_mode{-1};
97
bool
m_cached_show_components{
false
};
98
bool
m_cached_show_stats{
false
};
99
bool
m_cached_include_hidden{
false
};
100
int
m_cached_max_depth{-2};
101
bool
m_cached_valid{
false
};
102
};
103
104
}
Threedim::SceneInspector
Definition
SceneInspector.hpp:32
Threedim::SceneInspector::ins
Definition
SceneInspector.hpp:53
Threedim::SceneInspector::outs
Definition
SceneInspector.hpp:77
range
Definition
MIDISync.hpp:128