Loading [MathJax]/extensions/TeX/AMSmath.js
Radium Engine  1.7.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ItemEntry.cpp
1
2#include <Engine/RadiumEngine.hpp>
3#include <Engine/Rendering/RenderObject.hpp>
4#include <Engine/Rendering/RenderObjectManager.hpp>
5#include <Engine/Rendering/RenderObjectTypes.hpp>
6#include <Engine/Scene/Component.hpp>
7#include <Engine/Scene/Entity.hpp>
8#include <Engine/Scene/EntityManager.hpp>
9#include <Engine/Scene/ItemEntry.hpp>
11#include <memory>
12
13namespace Ra {
14namespace Engine {
15namespace Scene {
16
18 if ( ent.isValid() ) {
19 if ( ent.isRoNode() ) {
20 return engine->getRenderObjectManager()->getRenderObject( ent.m_roIndex )->getName();
21 }
22 else if ( ent.isComponentNode() ) { return ent.m_component->getName(); }
23 else if ( ent.isEntityNode() ) { return ent.m_entity->getName(); }
24 }
25 return "Invalid Entry";
26}
27
29 const ItemEntry& ent ) {
31 if ( ent.isValid() ) {
32 if ( ent.isRoNode() ) { result.push_back( ent.m_roIndex ); }
33 else if ( ent.isComponentNode() ) { result = ent.m_component->m_renderObjects; }
34 else if ( ent.isEntityNode() ) {
35 for ( const auto& c : ent.m_entity->getComponents() ) {
36 result.insert( result.end(), c->m_renderObjects.begin(), c->m_renderObjects.end() );
37 }
38 }
39 }
40 return result;
41}
42
43bool ItemEntry::isValid() const {
44 ON_DEBUG( checkConsistency() );
45 Engine::RadiumEngine* engine = Engine::RadiumEngine::getInstance();
46 return m_entity != nullptr // It has an entity
47 && engine->getEntityManager() // Is entityManager up ?
48 && engine->getEntityManager()->entityExists( m_entity->getName() ) // The entity exists
49 && ( ( !isRoNode() ||
50 engine->getRenderObjectManager()->exists( m_roIndex ) ) ); // The RO exists
51}
52
54 Engine::RadiumEngine* engine = Engine::RadiumEngine::getInstance();
55
56 if ( m_entity->getIndex() == SystemEntity::getInstance()->getIndex() ) { return false; }
57
58 if ( isRoNode() ) {
59 const bool isUI =
60 engine->getRenderObjectManager()->getRenderObject( m_roIndex )->getType() ==
62 const bool isDebug =
63 engine->getRenderObjectManager()->getRenderObject( m_roIndex )->getType() ==
65 return ( !( isUI || isDebug ) );
66 }
67
68 return true;
69}
70
71} // namespace Scene
72} // namespace Engine
73} // 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:17
std::vector< Ra::Core::Utils::Index > getItemROs(const Engine::RadiumEngine *, const ItemEntry &ent)
Definition ItemEntry.cpp:28
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:4
T push_back(T... args)
Ra::Core::Utils::Index m_roIndex
RO index of the represented object.
Definition ItemEntry.hpp:66
bool isValid() const
Returns true if the item represents any valid object.
Definition ItemEntry.cpp:43
bool isSelectable() const
Returns true if the item can be selected.
Definition ItemEntry.cpp:53
bool isComponentNode() const
Returns true if the item represents a component.
Definition ItemEntry.hpp:84
void checkConsistency() const
Debug checks.
Definition ItemEntry.hpp:94
Entity * m_entity
The entity represented by the item, or owning the object represented.
Definition ItemEntry.hpp:59
bool isEntityNode() const
Returns true if the item represents an entity.
Definition ItemEntry.hpp:79
bool isRoNode() const
Returns true if the item represents a render object.
Definition ItemEntry.hpp:89