added force non visible to BBox visitor

This commit is contained in:
Bruno
2021-02-07 20:43:56 +01:00
parent 6929eb3307
commit 5328995a79
2 changed files with 8 additions and 7 deletions

View File

@@ -6,7 +6,7 @@
#include "Primitives.h"
#include "Decorations.h"
BoundingBoxVisitor::BoundingBoxVisitor(): Visitor()
BoundingBoxVisitor::BoundingBoxVisitor(bool force): force_(force)
{
modelview_ = glm::identity<glm::mat4>();
@@ -35,7 +35,7 @@ void BoundingBoxVisitor::visit(Group &n)
return;
glm::mat4 mv = modelview_;
for (NodeSet::iterator node = n.begin(); node != n.end(); node++) {
if ( (*node)->visible_ )
if ( (*node)->visible_ || force_)
(*node)->accept(*this);
modelview_ = mv;
}
@@ -46,14 +46,13 @@ void BoundingBoxVisitor::visit(Switch &n)
if (!n.visible_ || n.numChildren() < 1)
return;
glm::mat4 mv = modelview_;
if ( n.activeChild()->visible_ || force_)
n.activeChild()->accept(*this);
modelview_ = mv;
}
void BoundingBoxVisitor::visit(Primitive &n)
{
if (!n.visible_)
return;
bbox_.extend(n.bbox().transformed(modelview_));
@@ -64,3 +63,4 @@ void BoundingBoxVisitor::visit(Scene &n)
{
n.ws()->accept(*this);
}

View File

@@ -8,11 +8,11 @@
class BoundingBoxVisitor: public Visitor
{
glm::mat4 modelview_;
bool force_;
GlmToolkit::AxisAlignedBoundingBox bbox_;
public:
BoundingBoxVisitor();
BoundingBoxVisitor(bool force = false);
void setModelview(glm::mat4 modelview);
GlmToolkit::AxisAlignedBoundingBox bbox();
@@ -23,6 +23,7 @@ public:
void visit(Group& n) override;
void visit(Switch& n) override;
void visit(Primitive& n) override;
};
#endif // BOUNDINGBOXVISITOR_H