mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-05 23:40:02 +01:00
fixed Switch node in Scene, removed Animation node from scene, created display mode for Source.
66 lines
1.3 KiB
C++
66 lines
1.3 KiB
C++
#include <glm/gtc/matrix_transform.hpp>
|
|
|
|
#include "BoundingBoxVisitor.h"
|
|
|
|
#include "Log.h"
|
|
#include "Primitives.h"
|
|
#include "Decorations.h"
|
|
|
|
BoundingBoxVisitor::BoundingBoxVisitor(): Visitor()
|
|
{
|
|
modelview_ = glm::identity<glm::mat4>();
|
|
|
|
}
|
|
|
|
void BoundingBoxVisitor::setModelview(glm::mat4 modelview)
|
|
{
|
|
modelview_ = modelview;
|
|
}
|
|
|
|
GlmToolkit::AxisAlignedBoundingBox BoundingBoxVisitor::bbox()
|
|
{
|
|
return bbox_;
|
|
}
|
|
|
|
void BoundingBoxVisitor::visit(Node &n)
|
|
{
|
|
// use the transform modified during update
|
|
modelview_ *= n.transform_;
|
|
}
|
|
|
|
void BoundingBoxVisitor::visit(Group &n)
|
|
{
|
|
if (!n.visible_)
|
|
return;
|
|
glm::mat4 mv = modelview_;
|
|
for (NodeSet::iterator node = n.begin(); node != n.end(); node++) {
|
|
if ( (*node)->visible_ )
|
|
(*node)->accept(*this);
|
|
modelview_ = mv;
|
|
}
|
|
}
|
|
|
|
void BoundingBoxVisitor::visit(Switch &n)
|
|
{
|
|
if (!n.visible_ || n.numChildren() < 1)
|
|
return;
|
|
glm::mat4 mv = modelview_;
|
|
n.activeChild()->accept(*this);
|
|
modelview_ = mv;
|
|
}
|
|
|
|
void BoundingBoxVisitor::visit(Primitive &n)
|
|
{
|
|
if (!n.visible_)
|
|
return;
|
|
|
|
bbox_.extend(n.bbox().transformed(modelview_));
|
|
|
|
// Log::Info("visitor box (%f, %f)-(%f, %f)", bbox_.min().x, bbox_.min().y, bbox_.max().x, bbox_.max().y);
|
|
}
|
|
|
|
void BoundingBoxVisitor::visit(Scene &n)
|
|
{
|
|
n.ws()->accept(*this);
|
|
}
|