3 #include <Engine/RaEngine.hpp>
11 #include <Core/Utils/IndexedObject.hpp>
12 #include <Core/Utils/Observable.hpp>
25 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
26 explicit Entity(
const std::string& name =
"" );
35 inline const std::string& getName()
const;
36 inline void rename(
const std::string& name );
39 inline void setTransform(
const Core::Transform& transform );
40 inline void setTransform(
const Core::Matrix4& transform );
41 const Core::Transform& getTransform()
const;
42 const Core::Matrix4& getTransformAsMatrix()
const;
44 void swapTransformBuffers();
51 void addComponent(
Component* component );
54 void removeComponent(
const std::string& name );
57 Component* getComponent(
const std::string& name );
58 const Component* getComponent(
const std::string& name )
const;
60 const std::vector<std::unique_ptr<Component>>& getComponents()
const;
65 inline uint getNumComponents()
const;
67 virtual Core::Aabb computeAabb();
69 void invalidateAabb();
72 Core::Transform m_transform;
73 Core::Transform m_doubleBufferedTransform;
74 mutable std::mutex m_transformMutex;
76 std::vector<std::unique_ptr<Component>> m_components;
78 std::string m_name {};
79 bool m_transformChanged {
false };
81 bool m_isAabbValid {
false };
90 inline const std::string& Entity::getName()
const {
94 inline void Entity::rename(
const std::string& name ) {
98 inline void Entity::setTransform(
const Core::Transform& transform ) {
99 m_transformChanged =
true;
100 m_doubleBufferedTransform = transform;
103 inline void Entity::setTransform(
const Core::Matrix4& transform ) {
104 setTransform( Core::Transform( transform ) );
107 inline const Core::Transform& Entity::getTransform()
const {
109 std::lock_guard<std::mutex> lock( m_transformMutex );
113 inline const Core::Matrix4& Entity::getTransformAsMatrix()
const {
115 std::lock_guard<std::mutex> lock( m_transformMutex );
116 return m_transform.matrix();
120 return uint( m_components.size() );
124 return m_transformationObservers;
A component is an element that can be updated by a system. It is also linked to some other components...
An entity is an scene element. It ties together components with a transform.
Core::Utils::Observable< const Entity * > & transformationObservers() const
get a ref to transformation observers to add/remove an observer
uint getNumComponents() const
Get component belonging to a given system.