mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-12 02:40:00 +01:00
added force non visible to BBox visitor
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
#include "Primitives.h"
|
#include "Primitives.h"
|
||||||
#include "Decorations.h"
|
#include "Decorations.h"
|
||||||
|
|
||||||
BoundingBoxVisitor::BoundingBoxVisitor(): Visitor()
|
BoundingBoxVisitor::BoundingBoxVisitor(bool force): force_(force)
|
||||||
{
|
{
|
||||||
modelview_ = glm::identity<glm::mat4>();
|
modelview_ = glm::identity<glm::mat4>();
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ void BoundingBoxVisitor::visit(Group &n)
|
|||||||
return;
|
return;
|
||||||
glm::mat4 mv = modelview_;
|
glm::mat4 mv = modelview_;
|
||||||
for (NodeSet::iterator node = n.begin(); node != n.end(); node++) {
|
for (NodeSet::iterator node = n.begin(); node != n.end(); node++) {
|
||||||
if ( (*node)->visible_ )
|
if ( (*node)->visible_ || force_)
|
||||||
(*node)->accept(*this);
|
(*node)->accept(*this);
|
||||||
modelview_ = mv;
|
modelview_ = mv;
|
||||||
}
|
}
|
||||||
@@ -46,14 +46,13 @@ void BoundingBoxVisitor::visit(Switch &n)
|
|||||||
if (!n.visible_ || n.numChildren() < 1)
|
if (!n.visible_ || n.numChildren() < 1)
|
||||||
return;
|
return;
|
||||||
glm::mat4 mv = modelview_;
|
glm::mat4 mv = modelview_;
|
||||||
n.activeChild()->accept(*this);
|
if ( n.activeChild()->visible_ || force_)
|
||||||
|
n.activeChild()->accept(*this);
|
||||||
modelview_ = mv;
|
modelview_ = mv;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoundingBoxVisitor::visit(Primitive &n)
|
void BoundingBoxVisitor::visit(Primitive &n)
|
||||||
{
|
{
|
||||||
if (!n.visible_)
|
|
||||||
return;
|
|
||||||
|
|
||||||
bbox_.extend(n.bbox().transformed(modelview_));
|
bbox_.extend(n.bbox().transformed(modelview_));
|
||||||
|
|
||||||
@@ -64,3 +63,4 @@ void BoundingBoxVisitor::visit(Scene &n)
|
|||||||
{
|
{
|
||||||
n.ws()->accept(*this);
|
n.ws()->accept(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,11 +8,11 @@
|
|||||||
class BoundingBoxVisitor: public Visitor
|
class BoundingBoxVisitor: public Visitor
|
||||||
{
|
{
|
||||||
glm::mat4 modelview_;
|
glm::mat4 modelview_;
|
||||||
|
bool force_;
|
||||||
GlmToolkit::AxisAlignedBoundingBox bbox_;
|
GlmToolkit::AxisAlignedBoundingBox bbox_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
BoundingBoxVisitor(bool force = false);
|
||||||
BoundingBoxVisitor();
|
|
||||||
|
|
||||||
void setModelview(glm::mat4 modelview);
|
void setModelview(glm::mat4 modelview);
|
||||||
GlmToolkit::AxisAlignedBoundingBox bbox();
|
GlmToolkit::AxisAlignedBoundingBox bbox();
|
||||||
@@ -23,6 +23,7 @@ public:
|
|||||||
void visit(Group& n) override;
|
void visit(Group& n) override;
|
||||||
void visit(Switch& n) override;
|
void visit(Switch& n) override;
|
||||||
void visit(Primitive& n) override;
|
void visit(Primitive& n) override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BOUNDINGBOXVISITOR_H
|
#endif // BOUNDINGBOXVISITOR_H
|
||||||
|
|||||||
Reference in New Issue
Block a user