summaryrefslogtreecommitdiffstats
path: root/src/core/geometry/qboundingvolume.cpp
diff options
context:
space:
mode:
authorMike Krus <mike.krus@kdab.com>2020-03-09 15:28:11 +0000
committerMike Krus <mike.krus@kdab.com>2020-04-23 14:18:22 +0100
commit9a2ab2f1c0dc7ffe83f3e22aa97951de216b4ef7 (patch)
treeb89fbf07593668f11544a2e937500fc3802489bf /src/core/geometry/qboundingvolume.cpp
parent60f42119fe5c341880f4576e0c9ad8d99ee277d5 (diff)
Add ability to override bounding data and trigger calculation
With this, can set min and max extents of a geometry renderer which will avoid calculating it from the real geometry. Can also trigger the computation from user code (via public API) if user doesn't want to wait for next frame to get the data. Change-Id: I821bfb7c9d710a77a2b87ec607b4ed35a0c7f236 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/core/geometry/qboundingvolume.cpp')
-rw-r--r--src/core/geometry/qboundingvolume.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/core/geometry/qboundingvolume.cpp b/src/core/geometry/qboundingvolume.cpp
index 4e261396a..8f63e3d13 100644
--- a/src/core/geometry/qboundingvolume.cpp
+++ b/src/core/geometry/qboundingvolume.cpp
@@ -40,6 +40,7 @@
#include "qboundingvolume.h"
#include "qboundingvolume_p.h"
#include <Qt3DCore/private/corelogging_p.h>
+#include <Qt3DCore/private/calcboundingvolumejob_p.h>
QT_BEGIN_NAMESPACE
@@ -53,6 +54,7 @@ QBoundingVolumePrivate::QBoundingVolumePrivate()
: QComponentPrivate()
, m_view(nullptr)
, m_implicitPointsValid(false)
+ , m_explicitPointsValid(false)
, m_primaryProvider(true)
{
}
@@ -178,12 +180,64 @@ bool QBoundingVolume::areImplicitPointsValid() const
return d->m_implicitPointsValid;
}
+QVector3D QBoundingVolume::minPoint() const
+{
+ Q_D(const QBoundingVolume);
+ return d->m_minPoint;
+}
+
+QVector3D QBoundingVolume::maxPoint() const
+{
+ Q_D(const QBoundingVolume);
+ return d->m_maxPoint;
+}
+
void QBoundingVolume::setView(QGeometryView *view)
{
Q_D(QBoundingVolume);
d->setView(view);
}
+void QBoundingVolume::setMinPoint(const QVector3D &minPoint)
+{
+ Q_D(QBoundingVolume);
+ if (d->m_minPoint != minPoint) {
+ d->m_minPoint = minPoint;
+ d->m_explicitPointsValid = true;
+ d->markDirty(QScene::GeometryDirty);
+ emit minPointChanged(d->m_minPoint);
+ }
+}
+
+void QBoundingVolume::setMaxPoint(const QVector3D &maxPoint)
+{
+ Q_D(QBoundingVolume);
+ if (d->m_maxPoint != maxPoint) {
+ d->m_maxPoint = maxPoint;
+ d->m_explicitPointsValid = true;
+ d->markDirty(QScene::GeometryDirty);
+ emit maxPointChanged(d->m_maxPoint);
+ }
+}
+
+bool QBoundingVolume::updateImplicitBounds()
+{
+ Q_D(QBoundingVolume);
+ if (!d->m_view)
+ return false;
+
+ auto data = BoundingVolumeComputeData::fromView(d->m_view);
+ if (!data.valid())
+ return false;
+
+ auto res = data.compute();
+ if (!res.valid())
+ return false;
+
+ d->setImplicitBounds(res.m_min, res.m_max, res.m_center, res.m_radius);
+ return true;
+}
+
} // namespace Qt3DCore
QT_END_NAMESPACE