Utility/Node: Implement movement
This commit is contained in:
parent
b13c5c950a
commit
1ac0b2e11a
|
|
@ -23,6 +23,7 @@ namespace Nz
|
||||||
public:
|
public:
|
||||||
Node();
|
Node();
|
||||||
Node(const Node& node);
|
Node(const Node& node);
|
||||||
|
Node(Node&& node) noexcept;
|
||||||
virtual ~Node();
|
virtual ~Node();
|
||||||
|
|
||||||
void EnsureDerivedUpdate() const;
|
void EnsureDerivedUpdate() const;
|
||||||
|
|
@ -92,6 +93,7 @@ namespace Nz
|
||||||
Vector3f ToLocalScale(const Vector3f& globalScale) const;
|
Vector3f ToLocalScale(const Vector3f& globalScale) const;
|
||||||
|
|
||||||
Node& operator=(const Node& node);
|
Node& operator=(const Node& node);
|
||||||
|
Node& operator=(Node&& node) noexcept;
|
||||||
|
|
||||||
// Signals:
|
// Signals:
|
||||||
NazaraSignal(OnNodeInvalidation, const Node* /*node*/);
|
NazaraSignal(OnNodeInvalidation, const Node* /*node*/);
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,35 @@ namespace Nz
|
||||||
SetParent(node.m_parent, false);
|
SetParent(node.m_parent, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Node::Node(Node&& node) noexcept :
|
||||||
|
m_childs(std::move(node.m_childs)),
|
||||||
|
m_initialRotation(node.m_initialRotation),
|
||||||
|
m_rotation(node.m_rotation),
|
||||||
|
m_initialPosition(node.m_initialPosition),
|
||||||
|
m_initialScale(node.m_initialScale),
|
||||||
|
m_position(node.m_position),
|
||||||
|
m_scale(node.m_scale),
|
||||||
|
m_parent(node.m_parent),
|
||||||
|
m_derivedUpdated(false),
|
||||||
|
m_inheritPosition(node.m_inheritPosition),
|
||||||
|
m_inheritRotation(node.m_inheritRotation),
|
||||||
|
m_inheritScale(node.m_inheritScale),
|
||||||
|
m_transformMatrixUpdated(false),
|
||||||
|
OnNodeInvalidation(std::move(node.OnNodeInvalidation)),
|
||||||
|
OnNodeNewParent(std::move(node.OnNodeNewParent)),
|
||||||
|
OnNodeRelease(std::move(node.OnNodeRelease))
|
||||||
|
{
|
||||||
|
if (m_parent)
|
||||||
|
{
|
||||||
|
m_parent->RemoveChild(&node);
|
||||||
|
m_parent->AddChild(this);
|
||||||
|
node.m_parent = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Node* child : m_childs)
|
||||||
|
child->m_parent = this;
|
||||||
|
}
|
||||||
|
|
||||||
Node::~Node()
|
Node::~Node()
|
||||||
{
|
{
|
||||||
OnNodeRelease(this);
|
OnNodeRelease(this);
|
||||||
|
|
@ -643,6 +672,42 @@ namespace Nz
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Node& Node::operator=(Node&& node) noexcept
|
||||||
|
{
|
||||||
|
if (m_parent)
|
||||||
|
SetParent(nullptr);
|
||||||
|
|
||||||
|
m_inheritPosition = node.m_inheritPosition;
|
||||||
|
m_inheritRotation = node.m_inheritRotation;
|
||||||
|
m_inheritScale = node.m_inheritScale;
|
||||||
|
m_initialPosition = node.m_initialPosition;
|
||||||
|
m_initialRotation = node.m_initialRotation;
|
||||||
|
m_initialScale = node.m_initialScale;
|
||||||
|
m_position = node.m_position;
|
||||||
|
m_rotation = node.m_rotation;
|
||||||
|
m_scale = node.m_scale;
|
||||||
|
|
||||||
|
m_childs = std::move(node.m_childs);
|
||||||
|
for (Node* child : m_childs)
|
||||||
|
child->m_parent = this;
|
||||||
|
|
||||||
|
m_parent = node.m_parent;
|
||||||
|
if (m_parent)
|
||||||
|
{
|
||||||
|
m_parent->RemoveChild(&node);
|
||||||
|
m_parent->AddChild(this);
|
||||||
|
node.m_parent = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
OnNodeInvalidation = std::move(node.OnNodeInvalidation);
|
||||||
|
OnNodeNewParent = std::move(node.OnNodeNewParent);
|
||||||
|
OnNodeRelease = std::move(node.OnNodeRelease);
|
||||||
|
|
||||||
|
InvalidateNode();
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
void Node::AddChild(Node* node) const
|
void Node::AddChild(Node* node) const
|
||||||
{
|
{
|
||||||
#ifdef NAZARA_DEBUG
|
#ifdef NAZARA_DEBUG
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue