Radium Engine  1.5.20
Loading...
Searching...
No Matches
ItemEntry.cpp
1
2#include <Engine/Scene/ItemEntry.hpp>
3
4#include <Engine/RadiumEngine.hpp>
5
6#include <Engine/Scene/EntityManager.hpp>
8
9#include <Engine/Rendering/RenderObject.hpp>
10#include <Engine/Rendering/RenderObjectManager.hpp>
11
12namespace Ra {
13namespace Engine {
14namespace Scene {
15
17 if ( ent.isValid() ) {
18 if ( ent.isRoNode() ) {
19 return engine->getRenderObjectManager()->getRenderObject( ent.m_roIndex )->getName();
20 }
21 else if ( ent.isComponentNode() ) { return ent.m_component->getName(); }
22 else if ( ent.isEntityNode() ) { return ent.m_entity->getName(); }
23 }
24 return "Invalid Entry";
25}
26
28 const ItemEntry& ent ) {
30 if ( ent.isValid() ) {
31 if ( ent.isRoNode() ) { result.push_back( ent.m_roIndex ); }
32 else if ( ent.isComponentNode() ) { result = ent.m_component->m_renderObjects; }
33 else if ( ent.isEntityNode() ) {
34 for ( const auto& c : ent.m_entity->getComponents() ) {
35 result.insert( result.end(), c->m_renderObjects.begin(), c->m_renderObjects.end() );
36 }
37 }
38 }
39 return result;
40}
41
42bool ItemEntry::isValid() const {
43 ON_DEBUG( checkConsistency() );
44 Engine::RadiumEngine* engine = Engine::RadiumEngine::getInstance();
45 return m_entity != nullptr // It has an entity
46 && engine->getEntityManager() // Is entityManager up ?
47 && engine->getEntityManager()->entityExists( m_entity->getName() ) // The entity exists
48 && ( ( !isRoNode() ||
49 engine->getRenderObjectManager()->exists( m_roIndex ) ) ); // The RO exists
50}
51
53 Engine::RadiumEngine* engine = Engine::RadiumEngine::getInstance();
54
55 if ( m_entity->getIndex() == SystemEntity::getInstance()->getIndex() ) { return false; }
56
57 if ( isRoNode() ) {
58 const bool isUI =
59 engine->getRenderObjectManager()->getRenderObject( m_roIndex )->getType() ==
61 const bool isDebug =
62 engine->getRenderObjectManager()->getRenderObject( m_roIndex )->getType() ==
64 return ( !( isUI || isDebug ) );
65 }
66
67 return true;
68}
69
70} // namespace Scene
71} // namespace Engine
72} // namespace Ra
Scene::EntityManager * getEntityManager() const
Rendering::RenderObjectManager * getRenderObjectManager() const
Manager getters.
virtual const std::string & getName() const
Return the component's name.
Definition Component.hpp:56
T end(T... args)
T insert(T... args)
@ UI
"Ui" render objects are drawn on top of everything else and view independant
@ Debug
"Debug" render objects are drawn like any other object (not lit though)
std::string getEntryName(const Engine::RadiumEngine *engine, const ItemEntry &ent)
Returns the name associated to the given item.
Definition ItemEntry.cpp:16
std::vector< Ra::Core::Utils::Index > getItemROs(const Engine::RadiumEngine *, const ItemEntry &ent)
Definition ItemEntry.cpp:27
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3
T push_back(T... args)
Ra::Core::Utils::Index m_roIndex
RO index of the represented object.
Definition ItemEntry.hpp:67
bool isValid() const
Returns true if the item represents any valid object.
Definition ItemEntry.cpp:42
bool isSelectable() const
Returns true if the item can be selected.
Definition ItemEntry.cpp:52
bool isComponentNode() const
Returns true if the item represents a component.
Definition ItemEntry.hpp:85
void checkConsistency() const
Debug checks.
Definition ItemEntry.hpp:95
Entity * m_entity
The entity represented by the item, or owning the object represented.
Definition ItemEntry.hpp:60
bool isEntityNode() const
Returns true if the item represents an entity.
Definition ItemEntry.hpp:80
bool isRoNode() const
Returns true if the item represents a render object.
Definition ItemEntry.hpp:90