Unravel Engine C++ Reference
Loading...
Searching...
No Matches
transform_system.cpp
Go to the documentation of this file.
1#include "transform_system.h"
2
4#include <engine/ecs/ecs.h>
6
7#include <logging/logging.h>
8
9#define POOLSTL_STD_SUPPLEMENT 1
10#include <poolstl/poolstl.hpp>
11
12namespace unravel
13{
14
16{
17 APPLOG_TRACE("{}::{}", hpp::type_name_str(*this), __func__);
18
19 return true;
20}
21
23{
24 APPLOG_TRACE("{}::{}", hpp::type_name_str(*this), __func__);
25
26 return true;
27}
28
30{
31 APP_SCOPE_PERF("Transform/System Update");
32
33 // Create a view for entities with transform_component and submesh_component
34 auto view_root = scn.registry->view<transform_component, root_component>();
35
36 // Use std::for_each with the view's iterators
37 std::for_each(std::execution::par,
38 view_root.begin(),
39 view_root.end(),
40 [&view_root](entt::entity entity)
41 {
42 auto& transform_comp = view_root.get<transform_component>(entity);
43
44 transform_comp.resolve_transform_global();
45 });
46}
47
48void transform_system::on_play_begin(hpp::span<const entt::handle> entities, delta_t dt)
49{
50 for(auto entity : entities)
51 {
52 if(auto transform_comp = entity.try_get<transform_component>())
53 {
54 transform_comp->resolve_transform_global();
55 }
56 }
57}
58
59} // namespace unravel
Component that handles transformations (position, rotation, scale, etc.) in the ACE framework.
void on_play_begin(hpp::span< const entt::handle > entities, delta_t dt)
auto init(rtti::context &ctx) -> bool
auto deinit(rtti::context &ctx) -> bool
void on_frame_update(scene &scn, delta_t dt)
std::chrono::duration< float > delta_t
#define APPLOG_TRACE(...)
Definition logging.h:17
#define APP_SCOPE_PERF(name)
Create a scoped performance timer that only accepts string literals.
Definition profiler.h:160
entt::entity entity
Root component structure for the ACE framework, serves as the base component.
Represents a scene in the ACE framework, managing entities and their relationships.
Definition scene.h:21
std::unique_ptr< entt::registry > registry
The registry that manages all entities in the scene.
Definition scene.h:117