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(description, "Apply a parent position, rotation and scale transform to a scene.")
37 halp_meta(authors, "ossia team")
38 halp_meta(uuid, "7a9f2b41-4d58-4e93-b7c2-0f5d3e8a6b1c")
39
40 struct ins
41 {
42 struct
43 {
44 halp_meta(name, "Scene In");
45 ossia::scene_spec scene;
46 uint8_t dirty{0};
47 } scene_in;
48
49 halp::xyz_spinboxes_f32<
50 "Position", halp::range{-10000., 10000., 0.}>
51 position;
52 halp::xyz_spinboxes_f32<"Rotation", halp::range{0., 359.9999999, 0.}>
53 rotation;
54 halp::xyz_spinboxes_f32<
55 "Scale", halp::range{0.00001, 1000., 1.}>
56 scale;
57 } inputs;
58
59 struct outs
60 {
61 struct
62 {
63 halp_meta(name, "Scene Out");
64 ossia::scene_spec scene;
65 uint8_t dirty{0};
66 } scene_out;
67 } outputs;
68
69 void operator()();
70
71 // Render-thread hooks. init claims one RawTransform slot for the
72 // emitted scene_transform; update packs the current control TRS
73 // into a RawLocalTransform and uploads; release returns the slot.
74 // The preprocessor composes the world-space matrix for this slot
75 // from the scene-node parent chain CPU-side.
76 void init(score::gfx::RenderList& r, QRhiResourceUpdateBatch& res);
77 void update(
78 score::gfx::RenderList& r, QRhiResourceUpdateBatch& res,
80 void release(score::gfx::RenderList& r);
81
83
84 // Ossia-facing snapshot of xform_slot. Written once in init(),
85 // copied onto the emitted scene_transform's raw_slot every
86 // operator()() tick.
87 ossia::gpu_slot_ref m_xform_ref{};
88
89 // Cache: republish the same emitted scene_state when neither upstream
90 // (input scene_state pointer / version) nor controls (TRS) changed.
91 // Prevents downstream SceneSelector / SceneGraphFilter / SceneDuplicator /
92 // CreateCollection from rebuilding every frame.
93 std::shared_ptr<const ossia::scene_state> m_state;
94 const ossia::scene_state* m_cached_in_state{};
95 int64_t m_cached_in_version{-1};
96 CachedTRS m_cachedTRS{};
97 int64_t m_version_counter{0};
98};
99
100}
Definition Transform3D.hpp:31
List of nodes to be rendered to an output.
Definition RenderList.hpp:33
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:11
Definition Transform3D.hpp:41
Definition Transform3D.hpp:60
Connection between two score::gfx::Port.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:236
Definition GpuResourceRegistry.hpp:84