Radium Engine  1.5.20
Loading...
Searching...
No Matches
ItemEntry.hpp
1#pragma once
2
3#include <Engine/RaEngine.hpp>
4
5#include <Core/Utils/Index.hpp>
6
7#include <string>
8#include <vector>
9
10namespace Ra {
11namespace Engine {
12class RadiumEngine;
13
14namespace Scene {
15
16class Entity;
17class Component;
18
25struct RA_ENGINE_API ItemEntry {
27 ItemEntry() = default;
28
33 explicit ItemEntry( Entity* ent,
34 Component* comp = nullptr,
35 Ra::Core::Utils::Index ro = Ra::Core::Utils::Index::Invalid() ) :
36 m_entity { ent }, m_component { comp }, m_roIndex { ro } {}
37
39 inline bool operator==( const ItemEntry& rhs ) const;
40
42 bool isValid() const;
43
45 bool isSelectable() const;
46
48 inline bool isEntityNode() const;
49
51 inline bool isComponentNode() const;
52
54 inline bool isRoNode() const;
55
57 inline void checkConsistency() const;
58
60 Entity* m_entity { nullptr };
61
64 Component* m_component { nullptr };
65
67 Ra::Core::Utils::Index m_roIndex {};
68};
69
71RA_ENGINE_API std::string getEntryName( const Engine::RadiumEngine* engine, const ItemEntry& ent );
72
78 const ItemEntry& ent );
79
81 ON_DEBUG( checkConsistency() );
82 return ( m_entity && !m_component );
83}
84
86 ON_DEBUG( checkConsistency() );
87 return ( m_entity && m_component && m_roIndex.isInvalid() );
88}
89
90bool ItemEntry::isRoNode() const {
91 ON_DEBUG( checkConsistency() );
92 return ( m_entity && m_component && m_roIndex.isValid() );
93}
94
96 CORE_ASSERT( m_entity || ( !m_component && m_roIndex.isInvalid() ),
97 "Component or RO is set while entity is not" );
98 CORE_ASSERT( m_component || m_roIndex.isInvalid(), "RO is set while component is not" );
99}
100
101inline bool ItemEntry::operator==( const ItemEntry& rhs ) const {
102 return m_entity == rhs.m_entity && m_component == rhs.m_component && m_roIndex == rhs.m_roIndex;
103}
104
105} // namespace Scene
106} // namespace Engine
107} // namespace Ra
A component is an element that can be updated by a system. It is also linked to some other components...
Definition Component.hpp:31
An entity is an scene element. It ties together components with a transform.
Definition Entity.hpp:23
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
Ra::Core::Utils::Index m_roIndex
RO index of the represented object.
Definition ItemEntry.hpp:67
ItemEntry(Entity *ent, Component *comp=nullptr, Ra::Core::Utils::Index ro=Ra::Core::Utils::Index::Invalid())
Definition ItemEntry.hpp:33
ItemEntry()=default
Create an invalid entry.
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 operator==(const ItemEntry &rhs) const
Compare two items.
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