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(poolstl::par,//std::execution::par,
38 view_root.begin(),
39 view_root.end(),
40 [&view_root](entt::entity entity)
41 {
42 APP_SCOPE_PERF_THREAD("Transform/Resolve Transform Global","Pool Thread");
43
44 auto& transform_comp = view_root.get<transform_component>(entity);
45
46 transform_comp.resolve_transform_global();
47 });
48}
49
50void transform_system::on_play_begin(hpp::span<const entt::handle> entities, delta_t dt)
51{
52 for(auto entity : entities)
53 {
54 if(auto transform_comp = entity.try_get<transform_component>())
55 {
56 transform_comp->resolve_transform_global();
57 }
58 }
59}
60
61} // 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_literal)
Create a scoped performance timer that records to the timeline profiler. Only accepts string literals...
Definition profiler.h:675
entt::handle 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:70
std::unique_ptr< entt::registry > registry
The registry that manages all entities in the scene.
Definition scene.h:187