1#include <Engine/Scene/Entity.hpp>
3#include <Core/Math/LinearAlgebra.hpp>
4#include <Engine/RadiumEngine.hpp>
5#include <Engine/Scene/Component.hpp>
6#include <Engine/Scene/SignalManager.hpp>
13 Core::Utils::IndexedObject(),
14 m_transform { Core::Transform::Identity() },
15 m_doubleBufferedTransform { Core::Transform::Identity() },
21 m_transformationObservers.detachAll();
23 RadiumEngine::getInstance()->getSignalManager()->fireEntityDestroyed( ItemEntry(
this ) );
27 CORE_ASSERT( getComponent( component->
getName() ) ==
nullptr,
28 "Component \"" << component->
getName()
29 <<
"\" has already been added to the entity." );
34 RadiumEngine::getInstance()->getSignalManager()->fireComponentAdded(
37 m_isAabbValid =
false;
43 [name](
const auto& c ) { return c->getName() == name; } );
45 return pos != m_components.end() ? pos->get() :
nullptr;
51 [name](
const auto& c ) { return c->getName() == name; } );
53 return pos != m_components.end() ? pos->get() :
nullptr;
62 [name](
const auto& c ) { return c->getName() == name; } );
64 CORE_ASSERT( pos != m_components.end(),
"Component not found in entity" );
65 m_components.erase( pos );
67 m_isAabbValid =
false;
70void Entity::swapTransformBuffers() {
71 if ( m_transformChanged ) {
72 m_transform = m_doubleBufferedTransform;
73 m_transformChanged =
false;
74 m_transformationObservers.notify(
this );
78Core::Aabb Entity::computeAabb() {
79 if ( !m_isAabbValid ) {
82 for (
const auto& component : m_components ) {
84 aabb.extend( component->computeAabb() );
94void Entity::invalidateAabb() {
95 m_isAabbValid =
false;
A component is an element that can be updated by a system. It is also linked to some other components...
virtual const std::string & getName() const
Return the component's name.
virtual void setEntity(Entity *entity)
Set entity the component is part of. This method is called by the entity.
hepler function to manage enum as underlying types in VariableSet