sandbox
Loading...
Searching...
No Matches
hierarchy_module.hpp
1
// SPDX-License-Identifier: MIT
2
// #ifndef LIBSBX_SCENES_HIERARCHY_MODULE_HPP_
3
// #define LIBSBX_SCENES_HIERARCHY_MODULE_HPP_
4
5
// #include <easy/profiler.h>
6
7
// #include <libsbx/utility/timer.hpp>
8
9
// #include <libsbx/core/module.hpp>
10
// #include <libsbx/core/engine.hpp>
11
// #include <libsbx/core/profiler.hpp>
12
13
14
// #include <libsbx/scenes/scenes_module.hpp>
15
16
// #include <libsbx/scenes/components/relationship.hpp>
17
// #include <libsbx/scenes/components/global_transform.hpp>
18
// #include <libsbx/scenes/components/transform.hpp>
19
20
// namespace sbx::scenes {
21
22
// class hierarchy_module final : public core::module<hierarchy_module> {
23
24
// friend class scene;
25
26
// inline static const auto is_registered = register_module(stage::post);
27
28
// struct stack_entry {
29
// scenes::node node;
30
// math::matrix4x4 parent_world;
31
// bool is_parent_dirty;
32
// }; // struct stack_entry
33
34
// public:
35
36
// hierarchy_module() {
37
38
// }
39
40
// ~hierarchy_module() override = default;
41
42
// auto update() -> void override {
43
// SBX_PROFILE_SCOPE("hierarchy_module");
44
45
// auto& scenes_module = core::engine::get_module<scenes::scenes_module>();
46
47
// auto& scene = scenes_module.scene();
48
49
// auto root = scene.root();
50
51
// EASY_BLOCK("updating global transforms");
52
53
// auto stack = std::vector<stack_entry>{};
54
// stack.reserve(256u);
55
56
// stack.push_back({root, math::matrix4x4::identity, false});
57
58
// while (!stack.empty()) {
59
// const auto [current, parent_matrix, is_parent_dirty] = stack.back();
60
// stack.pop_back();
61
62
// auto& transform = scene.get_component<scenes::transform>(current);
63
// auto& global_transform = scene.get_component<scenes::global_transform>(current);
64
// const auto& relationship = scene.get_component<const scenes::relationship>(current);
65
66
// const auto is_dirty = is_parent_dirty || transform.is_dirty();
67
68
// if (is_dirty) {
69
// global_transform.model = parent_matrix * transform.local_transform();
70
// global_transform.normal = math::matrix4x4::transposed(math::matrix4x4::inverted(global_transform.model));
71
// transform.clear_is_dirty();
72
// }
73
74
// for (const auto child : relationship.children()) {
75
// if (child != scenes::node::null) {
76
// stack.push_back({child, global_transform.model, is_dirty});
77
// }
78
// }
79
// }
80
81
// EASY_END_BLOCK;
82
// }
83
84
// }; // class hierarchy_module
85
86
// } // namespace sbx::scenes
87
88
// #endif // LIBSBX_SCENES_HIERARCHY_MODULE_HPP_
libsbx-scenes
libsbx
scenes
hierarchy_module.hpp
Generated by
1.9.5