Radium Engine  1.5.20
Loading...
Searching...
No Matches
TransformEditor.cpp
1#include <Gui/TransformEditor/TransformEditor.hpp>
2
3#include <Engine/Scene/Component.hpp>
4#include <Engine/Scene/Entity.hpp>
5
6namespace Ra {
7namespace Gui {
8void TransformEditor::setEditable( const Engine::Scene::ItemEntry& ent ) {
9 m_currentEdit = ent;
10 getTransform();
11}
12
13void TransformEditor::getTransform() {
14 if ( canEdit() ) {
15 if ( m_currentEdit.isEntityNode() ) {
16 m_transform = m_currentEdit.m_entity->getTransform();
17 }
18 else if ( m_currentEdit.isComponentNode() || m_currentEdit.isRoNode() ) {
19 m_transform = m_currentEdit.m_component->getTransform( m_currentEdit.m_roIndex );
20 }
21 }
22}
23
24bool TransformEditor::canEdit() const {
25 return m_currentEdit.isValid() && m_currentEdit.isSelectable() &&
26 ( m_currentEdit.isEntityNode() ||
27 m_currentEdit.m_component->canEdit( m_currentEdit.m_roIndex ) );
28}
29
30void TransformEditor::setTransform( const Ra::Core::Transform& tr ) {
31 if ( canEdit() ) {
32 if ( m_currentEdit.isEntityNode() ) { m_currentEdit.m_entity->setTransform( tr ); }
33 else { m_currentEdit.m_component->setTransform( m_currentEdit.m_roIndex, tr ); }
34 }
35}
36
37Core::Transform TransformEditor::getWorldTransform() const {
38 return m_currentEdit.isEntityNode() ? Ra::Core::Transform::Identity()
39 : m_currentEdit.m_entity->getTransform();
40}
41
42TransformEditor::~TransformEditor() {
43 setEditable( Engine::Scene::ItemEntry() );
44}
45} // namespace Gui
46} // namespace Ra
virtual void setTransform(const Core::Utils::Index &, const Core::Transform &)
Set the new transform associated with the RO index key.
Definition Component.hpp:84
virtual Core::Transform getTransform(const Core::Utils::Index &) const
Get the transform associated with the given RO index key.
Definition Component.hpp:79
virtual bool canEdit(const Core::Utils::Index &) const
Returns true if a transform can be edited with the render object index given as a key.
Definition Component.hpp:76
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
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
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