Commit 3c7ea6da authored by Pierre Kraemer's avatar Pierre Kraemer

SCHNApps: view bounding box computation bug fix

parent 717b0a34
......@@ -84,7 +84,7 @@
</size>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="dartInfo">
<attribute name="title">
......
......@@ -108,7 +108,7 @@ public slots:
return NULL;
}
virtual void transformedBB(qglviewer::Vec& bbMin, qglviewer::Vec& bbMax) = 0;
virtual bool transformedBB(qglviewer::Vec& bbMin, qglviewer::Vec& bbMax) = 0;
protected:
virtual void updateBB() = 0;
......@@ -293,7 +293,7 @@ public:
void updateBB();
void updateBBDrawer();
void transformedBB(qglviewer::Vec& bbMin, qglviewer::Vec& bbMax);
bool transformedBB(qglviewer::Vec& bbMin, qglviewer::Vec& bbMax);
/*********************************************************
* MANAGE TOPO DRAWING
......
......@@ -110,7 +110,7 @@ void MapHandler<PFP>::updateBB()
updateBBDrawer();
DEBUG_EMIT("frameModified");
DEBUG_EMIT("boundingBoxModified");
emit(boundingBoxModified());
}
......@@ -157,8 +157,11 @@ void MapHandler<PFP>::updateBBDrawer()
}
template <typename PFP>
void MapHandler<PFP>::transformedBB(qglviewer::Vec& bbMin, qglviewer::Vec& bbMax)
bool MapHandler<PFP>::transformedBB(qglviewer::Vec& bbMin, qglviewer::Vec& bbMax)
{
if (!m_bb.isInitialized())
return false;
const Geom::Vec3f& BBmin = m_bb.min();
const Geom::Vec3f& BBmax = m_bb.max();
......@@ -198,6 +201,8 @@ void MapHandler<PFP>::transformedBB(qglviewer::Vec& bbMin, qglviewer::Vec& bbMax
bbMin = qglviewer::Vec(bb.min()[0], bb.min()[1], bb.min()[2]);
bbMax = qglviewer::Vec(bb.max()[0], bb.max()[1], bb.max()[2]);
return true;
}
template <typename PFP>
......
......@@ -45,7 +45,7 @@ void MapHandlerGen::notifyAttributeModification(const AttributeHandlerGen& attr)
if (m_vbo.contains(nameAttr))
m_vbo[nameAttr]->updateData(attr);
if (m_bbVertexAttribute->getName() == attr.name())
if (m_bbVertexAttribute && m_bbVertexAttribute->getName() == attr.name())
updateBB();
DEBUG_EMIT("attributeModified");
......
......@@ -28,6 +28,8 @@ View::View(const QString& name, SCHNApps* s, const QGLWidget* shareWidget) :
m_name(name),
m_schnapps(s),
m_currentCamera(NULL),
m_bbMin(0.0, 0.0, 0.0),
m_bbMax(0.0, 0.0, 0.0),
m_buttonArea(NULL),
m_closeButton(NULL),
m_VsplitButton(NULL),
......@@ -716,13 +718,16 @@ void View::updateBoundingBox()
{
if (!l_maps.empty())
{
l_maps.first()->transformedBB(m_bbMin, m_bbMax);
bool initialized = false;
foreach (MapHandlerGen* mhg, l_maps)
{
qglviewer::Vec minbb;
qglviewer::Vec maxbb;
mhg->transformedBB(minbb, maxbb);
if (mhg->transformedBB(minbb, maxbb))
{
if (initialized)
{
for (unsigned int dim = 0; dim < 3; ++dim)
{
if (minbb[dim] < m_bbMin[dim])
......@@ -731,6 +736,23 @@ void View::updateBoundingBox()
m_bbMax[dim] = maxbb[dim];
}
}
else
{
for (unsigned int dim = 0; dim < 3; ++dim)
{
m_bbMin[dim] = minbb[dim];
m_bbMax[dim] = maxbb[dim];
}
initialized = true;
}
}
}
if (!initialized)
{
m_bbMin.setValue(0, 0, 0);
m_bbMax.setValue(0, 0, 0);
}
}
else
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment