Loading...
Searching...
No Matches
Transform3D.hpp
1#pragma once
2#include "TransformHelper.hpp"
3
4#include <halp/controls.hpp>
5#include <halp/meta.hpp>
6
7#include <ossia/dataflow/geometry_port.hpp>
8
9#include <Gfx/Graph/GpuResourceRegistry.hpp>
10
11#include <cstdint>
12#include <memory>
13#include <vector>
14
15class QRhiResourceUpdateBatch;
16
17namespace score::gfx
18{
19class RenderList;
20struct Edge;
21}
22
23namespace Threedim
24{
25
26// Scene-in → scene-out transform: wraps the incoming scene's roots under a
27// single parent node carrying a `scene_transform` payload (TRS). Materials,
28// animations and cameras pass through by shared_ptr identity so downstream
29// identity-based caches stay hot.
31{
32public:
33 halp_meta(name, "Transform 3D")
34 halp_meta(c_name, "transform3d_avnd")
35 halp_meta(category, "Visuals/3D/Scene")
36 halp_meta(authors, "ossia team")
37 halp_meta(uuid, "7a9f2b41-4d58-4e93-b7c2-0f5d3e8a6b1c")
38
39 struct ins
40 {
41 struct
42 {
43 halp_meta(name, "Scene In");
44 ossia::scene_spec scene;
45 uint8_t dirty{0};
46 } scene_in;
47
48 halp::xyz_spinboxes_f32<
49 "Position", halp::range{-10000., 10000., 0.}>
50 position;
51 halp::xyz_spinboxes_f32<"Rotation", halp::range{0., 359.9999999, 0.}>
52 rotation;
53 halp::xyz_spinboxes_f32<
54 "Scale", halp::range{0.00001, 1000., 1.}>
55 scale;
56 } inputs;
57
58 struct outs
59 {
60 struct
61 {
62 halp_meta(name, "Scene Out");
63 ossia::scene_spec scene;
64 uint8_t dirty{0};
65 } scene_out;
66 } outputs;
67
68 void operator()();
69
70 // Render-thread hooks. init claims one RawTransform slot for the
71 // emitted scene_transform; update packs the current control TRS
72 // into a RawLocalTransform and uploads; release returns the slot.
73 // The preprocessor composes the world-space matrix for this slot
74 // from the scene-node parent chain CPU-side.
75 void init(score::gfx::RenderList& r, QRhiResourceUpdateBatch& res);
76 void update(
77 score::gfx::RenderList& r, QRhiResourceUpdateBatch& res,
79 void release(score::gfx::RenderList& r);
80
82
83 // Ossia-facing snapshot of xform_slot. Written once in init(),
84 // copied onto the emitted scene_transform's raw_slot every
85 // operator()() tick.
86 ossia::gpu_slot_ref m_xform_ref{};
87
88 // Cache: republish the same emitted scene_state when neither upstream
89 // (input scene_state pointer / version) nor controls (TRS) changed.
90 // Prevents downstream SceneSelector / SceneGraphFilter / SceneDuplicator /
91 // CreateCollection from rebuilding every frame.
92 std::shared_ptr<const ossia::scene_state> m_state;
93 const ossia::scene_state* m_cached_in_state{};
94 int64_t m_cached_in_version{-1};
95 CachedTRS m_cachedTRS{};
96 int64_t m_version_counter{0};
97};
98
99}
Definition Transform3D.hpp:31
List of nodes to be rendered to an output.
Definition RenderList.hpp:30
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:11
Definition Transform3D.hpp:59
Connection between two score::gfx::Port.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:103
Definition GpuResourceRegistry.hpp:84