added addChild/removeChild to GraphicalContainerNode
This commit is contained in:
parent
4026283f1c
commit
aed140ca5c
@ -26,7 +26,7 @@ void ContainerNode::removeChild(SceneNode* node)
|
||||
if(*it == node)
|
||||
{
|
||||
m_children.erase(it);
|
||||
break;
|
||||
// break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ public:
|
||||
*/
|
||||
void removeChild(SceneNode* node);
|
||||
/**
|
||||
* @brief addedToSceneTree is called when this node is added to a SceneTree
|
||||
* @brief setSceneTree is called when this node is added to a SceneTree
|
||||
*
|
||||
* @param tree
|
||||
*/
|
||||
|
@ -4,3 +4,28 @@ GraphicalContainerNode::GraphicalContainerNode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void GraphicalContainerNode::addChild(GraphicalNode *node)
|
||||
{
|
||||
if(node != nullptr)
|
||||
{
|
||||
node->setSceneTree(m_scene);
|
||||
m_children.push_back(node);
|
||||
node->m_parent = this;
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicalContainerNode::removeChild(GraphicalNode *node)
|
||||
{
|
||||
if(node != nullptr)
|
||||
{
|
||||
for(auto it = m_children.begin(); it != m_children.end(); ++it)
|
||||
{
|
||||
if(*it == node)
|
||||
{
|
||||
m_children.erase(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,8 @@ protected:
|
||||
std::vector<GraphicalNode*> m_children;
|
||||
public:
|
||||
GraphicalContainerNode();
|
||||
void addChild(GraphicalNode* node);
|
||||
void removeChild(GraphicalNode* node);
|
||||
};
|
||||
|
||||
#endif // GRAPHICALCONTAINERNODE_H
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "graphicalnode.h"
|
||||
#include "scenetree.h"
|
||||
|
||||
GraphicalNode::GraphicalNode()
|
||||
GraphicalNode::GraphicalNode() : m_visible(true)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ class LightNode : public GraphicalNode
|
||||
{
|
||||
Light *m_light;
|
||||
public:
|
||||
LightNode(Light* light) : m_light(light) {GraphicalNode::m_visible = true;}
|
||||
LightNode(Light* light) : m_light(light) {}
|
||||
|
||||
virtual void update()
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
glm::mat4 m_movement;
|
||||
glm::mat4 m_acceleration;
|
||||
|
||||
MeshNode(Mesh* mesh) : m_geometry(mesh, glm::mat4()) {GraphicalNode::m_visible = true;}
|
||||
MeshNode(Mesh* mesh) : m_geometry(mesh, glm::mat4()) {}
|
||||
|
||||
virtual void update()
|
||||
{
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "glm/vec2.hpp"
|
||||
#include "sparrowshell/shellbuffer.h"
|
||||
#include "sparrowshell/shellscrollbar.h"
|
||||
#include "scene/graphicalcontainernode.h"
|
||||
|
||||
class Input;
|
||||
class MeshNode;
|
||||
@ -18,7 +19,7 @@ namespace sf {
|
||||
class Window;
|
||||
}
|
||||
|
||||
class SparrowShell : public ContainerNode
|
||||
class SparrowShell : public GraphicalContainerNode
|
||||
{
|
||||
private:
|
||||
sf::Window* m_window;
|
||||
@ -52,8 +53,8 @@ public:
|
||||
void out(std::string);
|
||||
void setSceneTree(SceneTree* tree)
|
||||
{
|
||||
ContainerNode::setSceneTree(tree);
|
||||
// m_buffer->setSceneTree(tree);
|
||||
GraphicalContainerNode::setSceneTree(tree);
|
||||
m_buffer->setSceneTree(tree);
|
||||
}
|
||||
|
||||
glm::ivec2 getPosition(){return m_position;}
|
||||
|
Loading…
x
Reference in New Issue
Block a user