Unravel Engine C++ Reference
Loading...
Searching...
No Matches
reflection_probe_system.cpp
Go to the documentation of this file.
2#include <engine/events.h>
3
6#include <engine/ecs/ecs.h>
8#include <logging/logging.h>
9
10namespace unravel
11{
12
14{
15 APPLOG_TRACE("{}::{}", hpp::type_name_str(*this), __func__);
16
17 return true;
18}
19
21{
22 APPLOG_TRACE("{}::{}", hpp::type_name_str(*this), __func__);
23
24 return true;
25}
26
28{
29 APP_SCOPE_PERF("Reflection Probe/System Update");
30 const float seconds = dt.count();
32 [&](auto e, auto&& transform, auto&& probe)
33 {
34 if(!scn.registry->all_of<active_component>(e))
35 {
36 probe.release_resources();
37 }
38
39 probe.update(seconds);
40 });
41}
42
43void reflection_probe_system::on_play_begin(hpp::span<const entt::handle> entities, delta_t dt)
44{
45 // Ensure play mode starts with up-to-date reflections: flag every probe for a full one-frame bake.
46 // Probes in mode 'on_demand' or 'once' will bake exactly once here; realtime probes will resume their interval afterwards.
47 for(const auto& entity : entities)
48 {
49 if(!entity || !entity.valid())
50 {
51 continue;
52 }
53
54 if(auto* probe = entity.try_get<reflection_probe_component>())
55 {
56 probe->mark_dirty(true);
57 }
58 }
59}
60
61auto reflection_probe_system::mark_all_dirty(scene& scn, bool force_full_first_frame) -> size_t
62{
63 size_t count = 0;
64 scn.registry->view<reflection_probe_component>().each(
65 [&](auto /*e*/, auto&& probe)
66 {
67 probe.mark_dirty(force_full_first_frame);
68 ++count;
69 });
70 return count;
71}
72
73} // namespace unravel
Class that contains core reflection probe data, used for rendering and other purposes.
void on_play_begin(hpp::span< const entt::handle > entities, delta_t dt)
static auto mark_all_dirty(scene &scn, bool force_full_first_frame=false) -> size_t
Flags every reflection probe in the scene for rebuild.
void on_frame_update(scene &scn, delta_t dt)
auto deinit(rtti::context &ctx) -> bool
auto init(rtti::context &ctx) -> bool
Component that handles transformations (position, rotation, scale, etc.) in the ACE framework.
std::chrono::duration< float > delta_t
#define APPLOG_TRACE(...)
Definition logging.h:17
#define APP_SCOPE_PERF(name_literal)
Create a scoped performance timer that records to the timeline profiler. Only accepts string literals...
Definition profiler.h:675
entt::handle entity
Represents a scene in the ACE framework, managing entities and their relationships.
Definition scene.h:70
std::unique_ptr< entt::registry > registry
The registry that manages all entities in the scene.
Definition scene.h:187