Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
SceneComponent.cpp
Go to the documentation of this file.
2
6
7namespace EngineCore
8{
9
11
12 SceneComponent::SceneComponent(Scene* scene, const entt::entity & parent, const glm::mat4 & transform )
14 {
15 auto & registry = Ecs::RegistryManager::get();
16 component = registry.create();
17
18 transformComponent = &registry.emplace<Ecs::LocalTransform>( component );
19 transformComponent->matrix = transform;
20
21 setParent(parent);
22 }
23
24 SceneComponent::SceneComponent(Scene* scene, const entt::entity & parent, const glm::vec3 & position )
26 {
27 auto & registry = Ecs::RegistryManager::get();
28 component = registry.create();
29
30 transformComponent = &registry.emplace<Ecs::LocalTransform>( component );
32
33 setParent(parent);
34 }
35
36 SceneComponent::SceneComponent(Scene* scene, const entt::entity & parent,
37 const glm::vec3 & position,
38 const glm::quat & rotation )
40 {
41 auto & registry = Ecs::RegistryManager::get();
42 component = registry.create();
43
44 transformComponent = &registry.emplace<Ecs::LocalTransform>( component );
47 setParent(parent);
48 }
49
50 SceneComponent::SceneComponent(Scene* scene, const entt::entity & parent,
51 const glm::vec3 & position,
52 const glm::vec3 & rotation )
54 {
55 auto & registry = Ecs::RegistryManager::get();
56 component = registry.create();
57
58 transformComponent = &registry.emplace<Ecs::LocalTransform>( component );
61 setParent(parent);
62 }
63
65 Scene* scene,
66 const entt::entity & parent,
67 const glm::vec3 & position,
68 const glm::quat & rotation,
69 const glm::vec3 & scale
70 )
72 {
73 auto& registry = Ecs::RegistryManager::get();
74 component = registry.create();
75
76 transformComponent = &registry.emplace<Ecs::LocalTransform>( component );
80 setParent(parent);
81 }
82
83 void SceneComponent::setParent( const entt::entity & parent )
84 {
85 if ( parentComponent == nullptr )
86 {
87 auto & registry = Ecs::RegistryManager::get();
88 parentComponent = &registry.emplace<Ecs::Parent>( parent );
89 parentComponent->parent = parent;
90 }
91
92 if ( parentComponent->parent != parent )
93 {
94 parentComponent->parent = parent;
95 }
96 }
97
98} // namespace EngineCore
static entt::registry & get()
Gets the registry for all components.
static void setScale(Ecs::LocalTransform &transform, const glm::vec3 &newScale)
static void setPosition(Ecs::LocalTransform &transform, const glm::vec3 &newPosition)
static void setRotation(Ecs::LocalTransform &transform, const glm::vec3 &newRotation)
LogicComponent(Scene *owningScene)
entt::entity component
Stores the data.
void setParent(const entt::entity &parent)
Ecs::LocalTransform * transformComponent
A scene is the overarching structure which can spawn actors.
Definition Scene.h:17
Log category system implementation.
Stores parent relationships.
Definition EcsData.h:44