Extend mechanism of visitor for all important classes that has

attributes of a scene (for saving in XML, or other visitors)
This commit is contained in:
brunoherbelin
2020-04-01 14:41:42 +02:00
parent 178bf45f08
commit 37a6754de2
13 changed files with 176 additions and 101 deletions

View File

@@ -1,6 +1,8 @@
#include "Scene.h"
#include "Shader.h"
#include "Primitives.h"
#include "Visitor.h"
#include "Log.h"
#include <glad/glad.h>
@@ -32,6 +34,11 @@ void Node::update( float dt )
}
}
void Node::accept(Visitor& v) {
v.visit(*this);
}
// Primitive
Primitive::~Primitive()
@@ -110,6 +117,13 @@ void Primitive::draw(glm::mat4 modelview, glm::mat4 projection)
}
}
void Primitive::accept(Visitor& v)
{
Node::accept(v);
v.visit(*this);
}
void Primitive::deleteGLBuffers_()
{
if ( arrayBuffer_ ) glDeleteBuffers ( 1, &arrayBuffer_);
@@ -124,6 +138,12 @@ Group::~Group()
children_.clear();
}
void Group::accept(Visitor& v)
{
Node::accept(v);
v.visit(*this);
}
void Group::init()
{
visible_ = true;
@@ -159,7 +179,7 @@ void Group::draw(glm::mat4 modelview, glm::mat4 projection)
void Group::addChild(Node *child)
{
children_.push_back ( child );
children_.push_back( child );
child->parent_ = this;
}
@@ -176,3 +196,7 @@ int Group::numChildren()
return children_.size();
}
void Scene::accept(Visitor& v) {
v.visit(*this);
}