summaryrefslogtreecommitdiffstats
path: root/src/render/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'src/render/frontend')
-rw-r--r--src/render/frontend/qabstractfunctor.h1
-rw-r--r--src/render/frontend/qcamera.cpp103
-rw-r--r--src/render/frontend/qcamera.h8
-rw-r--r--src/render/frontend/qcameralens.cpp79
-rw-r--r--src/render/frontend/qcameralens.h10
-rw-r--r--src/render/frontend/qcameralens_p.h9
-rw-r--r--src/render/frontend/qlevelofdetail.cpp107
-rw-r--r--src/render/frontend/qlevelofdetail.h24
-rw-r--r--src/render/frontend/qlevelofdetail_p.h6
-rw-r--r--src/render/frontend/qlevelofdetailboundingsphere.cpp (renamed from src/render/frontend/qboundingsphere.cpp)105
-rw-r--r--src/render/frontend/qlevelofdetailboundingsphere.h (renamed from src/render/frontend/qboundingsphere.h)35
-rw-r--r--src/render/frontend/qlevelofdetailswitch.cpp14
-rw-r--r--src/render/frontend/qpickingsettings.cpp60
-rw-r--r--src/render/frontend/qrenderaspect.cpp87
-rw-r--r--src/render/frontend/qrenderaspect.h2
-rw-r--r--src/render/frontend/qrenderaspect_p.h15
-rw-r--r--src/render/frontend/qrenderplugin_p.h89
-rw-r--r--src/render/frontend/qrenderpluginfactory.cpp99
-rw-r--r--src/render/frontend/qrenderpluginfactory_p.h (renamed from src/render/frontend/qboundingsphere_p.h)53
-rw-r--r--src/render/frontend/qrenderpluginfactoryif.cpp65
-rw-r--r--src/render/frontend/qrenderpluginfactoryif_p.h82
-rw-r--r--src/render/frontend/qrendersettings.cpp7
-rw-r--r--src/render/frontend/render-frontend.pri14
-rw-r--r--src/render/frontend/sphere.cpp3
-rw-r--r--src/render/frontend/sphere_p.h2
25 files changed, 868 insertions, 211 deletions
diff --git a/src/render/frontend/qabstractfunctor.h b/src/render/frontend/qabstractfunctor.h
index d9c4d65a4..95f6aee51 100644
--- a/src/render/frontend/qabstractfunctor.h
+++ b/src/render/frontend/qabstractfunctor.h
@@ -80,6 +80,7 @@ public:
virtual ~QAbstractFunctor();
virtual qintptr id() const = 0;
+ // TODO: Remove when moving a copy of this to Qt3DCore
template<class T>
const T *functor_cast(const QAbstractFunctor *other) const
{
diff --git a/src/render/frontend/qcamera.cpp b/src/render/frontend/qcamera.cpp
index b9e180b97..13d689e0e 100644
--- a/src/render/frontend/qcamera.cpp
+++ b/src/render/frontend/qcamera.cpp
@@ -40,6 +40,8 @@
#include "qcamera.h"
#include "qcamera_p.h"
+#include <QtMath>
+
QT_BEGIN_NAMESPACE
namespace Qt3DRender {
@@ -199,6 +201,36 @@ QCameraPrivate::QCameraPrivate()
*/
/*!
+ * \qmlmethod void Qt3D.Render::Camera::viewAll()
+ *
+ * Rotates and moves the camera so that it's viewCenter is the center of the scene's bounding volume
+ * and the entire scene fits in the view port.
+ *
+ * \note Only works if the lens is in perspective projection mode.
+ * \sa Qt3D.Render::Camera::projectionType
+ */
+
+/*!
+ * \qmlmethod void Qt3D.Render::Camera::viewEntity(Entity entity)
+ *
+ * Rotates and moves the camera so that it's viewCenter is the center of the entity's bounding volume
+ * and the entire entity fits in the view port.
+ *
+ * \note Only works if the lens is in perspective projection mode.
+ * \sa Qt3D.Render::Camera::projectionType
+ */
+
+/*!
+ * \qmlmethod void Qt3D.Render::Camera::viewSphere(vector3d center, real radius)
+ *
+ * Rotates and moves the camera so that it's viewCenter is \a center
+ * and a sphere of \a radius fits in the view port.
+ *
+ * \note Only works if the lens is in perspective projection mode.
+ * \sa Qt3D.Render::Camera::projectionType
+ */
+
+/*!
* \qmlproperty enumeration Qt3D.Render::Camera::projectionType
*
* Holds the type of the camera projection.
@@ -346,6 +378,11 @@ QCameraPrivate::QCameraPrivate()
*/
/*!
+ * \property QCamera::exposure
+ * Holds the current exposure of the camera.
+ */
+
+/*!
* \property QCamera::position
* Holds the camera's position.
*/
@@ -387,6 +424,8 @@ QCamera::QCamera(Qt3DCore::QNode *parent)
QObject::connect(d_func()->m_lens, SIGNAL(bottomChanged(float)), this, SIGNAL(bottomChanged(float)));
QObject::connect(d_func()->m_lens, SIGNAL(topChanged(float)), this, SIGNAL(topChanged(float)));
QObject::connect(d_func()->m_lens, SIGNAL(projectionMatrixChanged(const QMatrix4x4 &)), this, SIGNAL(projectionMatrixChanged(const QMatrix4x4 &)));
+ QObject::connect(d_func()->m_lens, SIGNAL(exposureChanged(float)), this, SIGNAL(exposureChanged(float)));
+ QObject::connect(d_func()->m_lens, &QCameraLens::viewSphere, this, &QCamera::viewSphere);
QObject::connect(d_func()->m_transform, SIGNAL(matrixChanged()), this, SIGNAL(viewMatrixChanged()));
addComponent(d_func()->m_lens);
addComponent(d_func()->m_transform);
@@ -415,6 +454,7 @@ QCamera::QCamera(QCameraPrivate &dd, Qt3DCore::QNode *parent)
QObject::connect(d_func()->m_lens, SIGNAL(bottomChanged(float)), this, SIGNAL(bottomChanged(float)));
QObject::connect(d_func()->m_lens, SIGNAL(topChanged(float)), this, SIGNAL(topChanged(float)));
QObject::connect(d_func()->m_lens, SIGNAL(projectionMatrixChanged(const QMatrix4x4 &)), this, SIGNAL(projectionMatrixChanged(const QMatrix4x4 &)));
+ QObject::connect(d_func()->m_lens, &QCameraLens::viewSphere, this, &QCamera::viewSphere);
QObject::connect(d_func()->m_transform, SIGNAL(matrixChanged()), this, SIGNAL(viewMatrixChanged()));
addComponent(d_func()->m_lens);
addComponent(d_func()->m_transform);
@@ -630,6 +670,54 @@ void QCamera::rotateAboutViewCenter(const QQuaternion& q)
}
/*!
+ * Rotates and moves the camera so that it's viewCenter is the center of the scene's bounding volume
+ * and the entire scene fits in the view port.
+ *
+ * \note Only works if the lens is in perspective projection mode.
+ * \sa Qt3D.Render::Camera::projectionType
+ */
+void QCamera::viewAll()
+{
+ Q_D(QCamera);
+ d->m_lens->viewAll(id());
+}
+
+/*!
+ * Rotates and moves the camera so that it's viewCenter is \a center
+ * and a sphere of \a radius fits in the view port.
+ *
+ * \note Only works if the lens is in perspective projection mode.
+ * \sa Qt3D.Render::Camera::projectionType
+ */
+void QCamera::viewSphere(const QVector3D &center, float radius)
+{
+ Q_D(QCamera);
+ if (d->m_lens->projectionType() != QCameraLens::PerspectiveProjection || radius <= 0.f)
+ return;
+ double dist = radius / std::tan(qDegreesToRadians(d->m_lens->fieldOfView()) / 2.0f);
+ QVector3D dir = (d->m_viewCenter - d->m_position).normalized();
+ QVector3D newPos = center - (dir * dist);
+ setViewCenter(center);
+ setPosition(newPos);
+}
+
+/*!
+ * Rotates and moves the camera so that it's viewCenter is the center of the entity's bounding volume
+ * and the entire entity fits in the view port.
+ *
+ * \note Only works if the lens is in perspective projection mode.
+ * \sa Qt3D.Render::Camera::projectionType
+ */
+void QCamera::viewEntity(Qt3DCore::QEntity *entity)
+{
+ if (!entity)
+ return;
+
+ Q_D(QCamera);
+ d->m_lens->viewEntity(entity->id(), id());
+}
+
+/*!
* Sets the camera's projection type to \a type.
*/
void QCamera::setProjectionType(QCameraLens::ProjectionType type)
@@ -773,12 +861,27 @@ void QCamera::setProjectionMatrix(const QMatrix4x4 &projectionMatrix)
d->m_lens->setProjectionMatrix(projectionMatrix);
}
+/*!
+ * Sets the camera's exposure to \a exposure.
+ */
+void QCamera::setExposure(float exposure)
+{
+ Q_D(QCamera);
+ d->m_lens->setExposure(exposure);
+}
+
QMatrix4x4 QCamera::projectionMatrix() const
{
Q_D(const QCamera);
return d->m_lens->projectionMatrix();
}
+float QCamera::exposure() const
+{
+ Q_D(const QCamera);
+ return d->m_lens->exposure();
+}
+
/*!
* Sets the camera's position in 3D space to \a position.
*/
diff --git a/src/render/frontend/qcamera.h b/src/render/frontend/qcamera.h
index f5bd49fa2..5c86ea122 100644
--- a/src/render/frontend/qcamera.h
+++ b/src/render/frontend/qcamera.h
@@ -72,6 +72,7 @@ class QT3DRENDERSHARED_EXPORT QCamera : public Qt3DCore::QEntity
Q_PROPERTY(float bottom READ bottom WRITE setBottom NOTIFY bottomChanged)
Q_PROPERTY(float top READ top WRITE setTop NOTIFY topChanged)
Q_PROPERTY(QMatrix4x4 projectionMatrix READ projectionMatrix WRITE setProjectionMatrix NOTIFY projectionMatrixChanged)
+ Q_PROPERTY(float exposure READ exposure WRITE setExposure NOTIFY exposureChanged REVISION 9)
// LookAt
Q_PROPERTY(QVector3D position READ position WRITE setPosition NOTIFY positionChanged)
Q_PROPERTY(QVector3D upVector READ upVector WRITE setUpVector NOTIFY upVectorChanged)
@@ -126,6 +127,7 @@ public:
float bottom() const;
float top() const;
QMatrix4x4 projectionMatrix() const;
+ float exposure() const;
QVector3D position() const;
QVector3D upVector() const;
QVector3D viewCenter() const;
@@ -143,10 +145,15 @@ public Q_SLOTS:
void setBottom(float bottom);
void setTop(float top);
void setProjectionMatrix(const QMatrix4x4 &projectionMatrix);
+ void setExposure(float exposure);
void setPosition(const QVector3D &position);
void setUpVector(const QVector3D &upVector);
void setViewCenter(const QVector3D &viewCenter);
+ void viewAll();
+ void viewSphere(const QVector3D &center, float radius);
+ void viewEntity(Qt3DCore::QEntity *entity);
+
Q_SIGNALS:
void projectionTypeChanged(QCameraLens::ProjectionType projectionType);
void nearPlaneChanged(float nearPlane);
@@ -158,6 +165,7 @@ Q_SIGNALS:
void bottomChanged(float bottom);
void topChanged(float top);
void projectionMatrixChanged(const QMatrix4x4 &projectionMatrix);
+ void exposureChanged(float exposure);
void positionChanged(const QVector3D &position);
void upVectorChanged(const QVector3D &upVector);
void viewCenterChanged(const QVector3D &viewCenter);
diff --git a/src/render/frontend/qcameralens.cpp b/src/render/frontend/qcameralens.cpp
index 269bc8d16..c9be49484 100644
--- a/src/render/frontend/qcameralens.cpp
+++ b/src/render/frontend/qcameralens.cpp
@@ -202,6 +202,11 @@ namespace Qt3DRender {
*/
/*!
+ * \property QCameraLens::exposure
+ * Holds the current exposure of the camera lens.
+ */
+
+/*!
* \internal
*/
QCameraLensPrivate::QCameraLensPrivate()
@@ -215,7 +220,45 @@ QCameraLensPrivate::QCameraLensPrivate()
, m_right(0.5f)
, m_bottom(-0.5f)
, m_top(0.5f)
+ , m_exposure(0.0f)
+{
+}
+
+void QCameraLens::viewAll(Qt3DCore::QNodeId cameraId)
{
+ Q_D(QCameraLens);
+ if (d->m_projectionType == PerspectiveProjection) {
+ QVariant v;
+ v.setValue(cameraId);
+ d->m_pendingViewAllCommand = sendCommand(QLatin1Literal("QueryRootBoundingVolume"), v);
+ }
+}
+
+void QCameraLens::viewEntity(Qt3DCore::QNodeId entityId, Qt3DCore::QNodeId cameraId)
+{
+ Q_D(QCameraLens);
+ if (d->m_projectionType == PerspectiveProjection) {
+ QVector<Qt3DCore::QNodeId> ids = {entityId, cameraId};
+ QVariant v;
+ v.setValue(ids);
+ d->m_pendingViewAllCommand = sendCommand(QLatin1Literal("QueryEntityBoundingVolume"), v);
+ }
+}
+
+void QCameraLensPrivate::processViewAllCommand(Qt3DCore::QNodeCommand::CommandId commandId,
+ const QVariant &data)
+{
+ Q_Q(QCameraLens);
+ if (m_pendingViewAllCommand != commandId)
+ return;
+
+ QVector<float> boundingVolumeData = data.value< QVector<float> >();
+ if (boundingVolumeData.size() != 4)
+ return;
+ QVector3D center(boundingVolumeData[0], boundingVolumeData[1], boundingVolumeData[2]);
+ float radius = boundingVolumeData[3];
+ Q_EMIT q->viewSphere(center, radius);
+ m_pendingViewAllCommand = Qt3DCore::QNodeCommand::CommandId();
}
/*!
@@ -559,14 +602,50 @@ QMatrix4x4 QCameraLens::projectionMatrix() const
return d->m_projectionMatrix;
}
+/*!
+ * Sets the camera lens' \a exposure
+ */
+void QCameraLens::setExposure(float exposure)
+{
+ Q_D(QCameraLens);
+ if (qFuzzyCompare(d->m_exposure, exposure))
+ return;
+ d->m_exposure = exposure;
+
+ emit exposureChanged(exposure);
+}
+
+float QCameraLens::exposure() const
+{
+ Q_D(const QCameraLens);
+ return d->m_exposure;
+}
+
Qt3DCore::QNodeCreatedChangeBasePtr QCameraLens::createNodeCreationChange() const
{
auto creationChange = Qt3DCore::QNodeCreatedChangePtr<QCameraLensData>::create(this);
auto &data = creationChange->data;
data.projectionMatrix = d_func()->m_projectionMatrix;
+ data.exposure = d_func()->m_exposure;
return creationChange;
}
+void QCameraLens::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change)
+{
+ Q_D(QCameraLens);
+ switch (change->type()) {
+ case Qt3DCore::CommandRequested: {
+ Qt3DCore::QNodeCommandPtr command = qSharedPointerCast<Qt3DCore::QNodeCommand>(change);
+
+ if (command->name() == QLatin1Literal("ViewAll"))
+ d->processViewAllCommand(command->inReplyTo(), command->data());
+ }
+ break;
+ default:
+ break;
+ }
+}
+
} // Qt3DRender
QT_END_NAMESPACE
diff --git a/src/render/frontend/qcameralens.h b/src/render/frontend/qcameralens.h
index ad414cada..0cd22e348 100644
--- a/src/render/frontend/qcameralens.h
+++ b/src/render/frontend/qcameralens.h
@@ -66,6 +66,7 @@ class QT3DRENDERSHARED_EXPORT QCameraLens : public Qt3DCore::QComponent
Q_PROPERTY(float bottom READ bottom WRITE setBottom NOTIFY bottomChanged)
Q_PROPERTY(float top READ top WRITE setTop NOTIFY topChanged)
Q_PROPERTY(QMatrix4x4 projectionMatrix READ projectionMatrix WRITE setProjectionMatrix NOTIFY projectionMatrixChanged)
+ Q_PROPERTY(float exposure READ exposure WRITE setExposure NOTIFY exposureChanged REVISION 9)
public:
explicit QCameraLens(QNode *parent = nullptr);
@@ -102,6 +103,11 @@ public:
void setPerspectiveProjection(float fieldOfView, float aspect,
float nearPlane, float farPlane);
+ float exposure() const;
+
+ void viewAll(Qt3DCore::QNodeId cameraId);
+ void viewEntity(Qt3DCore::QNodeId entityId, Qt3DCore::QNodeId cameraId);
+
public Q_SLOTS:
void setProjectionType(ProjectionType projectionType);
void setNearPlane(float nearPlane);
@@ -113,6 +119,7 @@ public Q_SLOTS:
void setBottom(float bottom);
void setTop(float top);
void setProjectionMatrix(const QMatrix4x4 &projectionMatrix);
+ void setExposure(float exposure);
Q_SIGNALS:
void projectionTypeChanged(QCameraLens::ProjectionType projectionType);
@@ -125,6 +132,8 @@ Q_SIGNALS:
void bottomChanged(float bottom);
void topChanged(float top);
void projectionMatrixChanged(const QMatrix4x4 &projectionMatrix);
+ void exposureChanged(float exposure);
+ void viewSphere(const QVector3D &center, float radius);
protected:
explicit QCameraLens(QCameraLensPrivate &dd, QNode *parent = nullptr);
@@ -132,6 +141,7 @@ protected:
private:
Q_DECLARE_PRIVATE(QCameraLens)
Qt3DCore::QNodeCreatedChangeBasePtr createNodeCreationChange() const Q_DECL_OVERRIDE;
+ void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) Q_DECL_OVERRIDE;
};
} // Qt3DRender
diff --git a/src/render/frontend/qcameralens_p.h b/src/render/frontend/qcameralens_p.h
index ecaa45b68..d78579b70 100644
--- a/src/render/frontend/qcameralens_p.h
+++ b/src/render/frontend/qcameralens_p.h
@@ -51,7 +51,8 @@
// We mean it.
//
-#include <Qt3DCore/private/qcomponent_p.h>
+#include <private/qcomponent_p.h>
+#include <private/qnodecommand_p.h>
#include "qcameralens.h"
#include <Qt3DCore/qpropertyupdatedchange.h>
@@ -101,6 +102,11 @@ public:
mutable QMatrix4x4 m_projectionMatrix;
+ float m_exposure;
+
+ Qt3DCore::QNodeCommand::CommandId m_pendingViewAllCommand;
+ void processViewAllCommand(Qt3DCore::QNodeCommand::CommandId commandId, const QVariant &data);
+
private:
inline void updatePerpectiveProjection()
{
@@ -130,6 +136,7 @@ private:
struct QCameraLensData
{
QMatrix4x4 projectionMatrix;
+ float exposure;
};
} // namespace Qt3DRender
diff --git a/src/render/frontend/qlevelofdetail.cpp b/src/render/frontend/qlevelofdetail.cpp
index 0d70803ca..03df4e6a8 100644
--- a/src/render/frontend/qlevelofdetail.cpp
+++ b/src/render/frontend/qlevelofdetail.cpp
@@ -37,7 +37,6 @@
**
****************************************************************************/
-#include "qboundingsphere.h"
#include "qlevelofdetail.h"
#include "qlevelofdetail_p.h"
#include "qcamera.h"
@@ -51,23 +50,9 @@ QLevelOfDetailPrivate::QLevelOfDetailPrivate()
: QComponentPrivate()
, m_camera(nullptr)
, m_currentIndex(0)
- , m_thresholdType(QLevelOfDetail::DistanceToCamera)
- , m_volumeOverride(nullptr)
+ , m_thresholdType(QLevelOfDetail::DistanceToCameraThreshold)
+ , m_volumeOverride()
{
- Q_Q(QLevelOfDetail);
- m_volumeOverride = new QBoundingSphere(q);
- QObject::connect(m_volumeOverride, SIGNAL(radiusChanged(float)), q, SLOT(_q_radiusChanged(float)));
- QObject::connect(m_volumeOverride, SIGNAL(centerChanged(const QVector3D &)), q, SLOT(_q_centerChanged(const QVector3D&)));
-}
-
-void QLevelOfDetailPrivate::_q_radiusChanged(float radius)
-{
- notifyPropertyChange("radius", radius);
-}
-
-void QLevelOfDetailPrivate::_q_centerChanged(const QVector3D &center)
-{
- notifyPropertyChange("center", center);
}
/*!
@@ -92,7 +77,7 @@ void QLevelOfDetailPrivate::_q_centerChanged(const QVector3D &center)
The currentIndex property can then be used, for example, to enable or
disable entities, change material, etc.
- The LevelOfDetail component is not shareable between multiple Entity's.
+ The LevelOfDetail component is not shareable between multiple \l [QML]{Entity}{entities}.
\code
#include <Qt3DCore/QEntity>
@@ -156,7 +141,7 @@ void QLevelOfDetailPrivate::_q_centerChanged(const QVector3D &center)
id: lod
camera: mainCamera
thresholds: [20, 35, 50, 65]
- thresholdType: LevelOfDetail.DistanceToCamera
+ thresholdType: LevelOfDetail.DistanceToCameraThreshold
}
CylinderMesh {
@@ -180,8 +165,8 @@ void QLevelOfDetailPrivate::_q_centerChanged(const QVector3D &center)
*
* Specifies how the values in the thresholds are interpreted
*
- * \value DistanceToCamera Distance from the entity to the selected camera
- * \value ProjectedScreenPixelSize Size of the entity when projected on the
+ * \value DistanceToCameraThreshold Distance from the entity to the selected camera
+ * \value ProjectedScreenPixelSizeThreshold Size of the entity when projected on the
* screen as seen from the selected camera, expressed in number of
* pixels on the side of the bounding square in screen space.
*/
@@ -192,43 +177,14 @@ void QLevelOfDetailPrivate::_q_centerChanged(const QVector3D &center)
* Specifies how the values in the thresholds are interpreted
*
* \list
- * \li DistanceToCamera Distance from the entity to the selected camera
- * \li ProjectedScreenPixelSize Size of the entity when projected on the
+ * \li DistanceToCameraThreshold Distance from the entity to the selected camera
+ * \li ProjectedScreenPixelSizeThreshold Size of the entity when projected on the
* screen as seen from the selected camera, expressed in number of
* pixels on the side of the bounding square in screen space.
* \endlist
* \sa Qt3DRender::QLevelOfDetail::ThresholdType
*/
-
-/*!
- * \enum Qt3DRender::QLevelOfDetail::SizeProxyMode
- *
- * Specifies what is used as a proxy for the entity when computing distance
- * or size.
- *
- * \value BoundingSphere use the bounding sphere specified by the center
- * and radius properties.
- * \value ChildrenBoundingSphere use the bounding sphere of the entity the
- * component is attached to.
- */
-
-/*!
- * \qmlproperty enumeration LevelOfDetail::SizeProxyMode
- *
- * Specifies what is used as a proxy for the entity when computing distance
- * or size.
- *
- * \list
- * \li BoundingSphere use the bounding sphere specified by the center
- * and radius properties.
- * \li ChildrenBoundingSphere use the bounding sphere of the entity the
- * component is attached to.
- * \endlist
- * \sa Qt3DRender::QLevelOfDetail::SizeProxyMode
- */
-
-
/*!
* \qmlproperty Camera LevelOfDetail::camera
*
@@ -272,11 +228,11 @@ void QLevelOfDetailPrivate::_q_centerChanged(const QVector3D &center)
* Array of range values as float point numbers. The value for the most detailed representation
* should be specified first.
*
- * If LevelOfDetail::thresholdType is set to LevelOfDetail.Distance, values should be specified in
- * ascending order, in camera space coordinates
+ * If LevelOfDetail::thresholdType is set to LevelOfDetail.DistanceToCameraThreshold, values should
+ * be specified in ascending order, in camera space coordinates
*
- * If LevelOfDetail::thresholdType is set to LevelOfDetail.ProjectedScreenPixelSize, values should
- * be specified in descending order, in screen space pixels.
+ * If LevelOfDetail::thresholdType is set to LevelOfDetail.ProjectedScreenPixelSizeThreshold, values
+ * should be specified in descending order, in screen space pixels.
*/
/*!
@@ -285,10 +241,12 @@ void QLevelOfDetailPrivate::_q_centerChanged(const QVector3D &center)
* Array of range values as float point numbers. The value for the most detailed representation
* should be specified first.
*
- * If Qt3DRender::QLevelOfDetail::thresholdType is set to Qt3DRender::QLevelOfDetail::Distance, values should be specified in
+ * If Qt3DRender::QLevelOfDetail::thresholdType is set to
+ * Qt3DRender::QLevelOfDetail::DistanceToCameraThreshold, values should be specified in
* ascending order, in camera space coordinates
*
- * If Qt3DRender::QLevelOfDetail::thresholdType is set to Qt3DRender::QLevelOfDetail::ProjectedScreenPixelSize, values should
+ * If Qt3DRender::QLevelOfDetail::thresholdType is set to
+ * Qt3DRender::QLevelOfDetail::ProjectedScreenPixelSizeThreshold, values should
* be specified in descending order, in screen space pixels.
*
* \sa Qt3DRender::QLevelOfDetail::ThresholdType
@@ -306,7 +264,7 @@ void QLevelOfDetailPrivate::_q_centerChanged(const QVector3D &center)
* If this value to null, the bounding volume of the entity is used. Care must be
* taken that this bounding volume never becomes invalid.
*
- * \sa BoundingSphere
+ * \sa Qt3DRender::QLevelOfDetailBoundingSphere
*/
/*!
@@ -319,7 +277,7 @@ void QLevelOfDetailPrivate::_q_centerChanged(const QVector3D &center)
* If this value to nullptr, the bounding volume of the entity is used. Care must be
* taken that this bounding volume never becomes invalid.
*
- * \sa QBoundingSphere
+ * \sa Qt3dRender::QLevelOfDetailBoundingSphere
*/
@@ -354,8 +312,7 @@ Qt3DCore::QNodeCreatedChangeBasePtr QLevelOfDetail::createNodeCreationChange() c
data.currentIndex = d->m_currentIndex;
data.thresholdType = d->m_thresholdType;
data.thresholds = d->m_thresholds;
- data.radius = d->m_volumeOverride ? d->m_volumeOverride->radius() : -1.f;
- data.center = d->m_volumeOverride ? d->m_volumeOverride->center() : QVector3D();
+ data.volumeOverride = d->m_volumeOverride;
return creationChange;
}
@@ -381,7 +338,7 @@ QCamera *QLevelOfDetail::camera() const
}
/*!
- * Sets the camera relative to which distance and size are computed.
+ * Sets the \a camera relative to which distance and size are computed.
*/
void QLevelOfDetail::setCamera(QCamera *camera)
{
@@ -399,7 +356,7 @@ int QLevelOfDetail::currentIndex() const
}
/*!
- * Sets the current index.
+ * Sets the \a currentIndex.
*
* \note This should not normally be set by the user.
*
@@ -424,6 +381,7 @@ QLevelOfDetail::ThresholdType QLevelOfDetail::thresholdType() const
/*!
* Sets the way thresholds values are interpreted
+ * with parameter \a thresholdType
* \sa Qt3DRender::QLevelOfDetail::ThresholdType
*/
void QLevelOfDetail::setThresholdType(QLevelOfDetail::ThresholdType thresholdType)
@@ -441,36 +399,35 @@ QVector<qreal> QLevelOfDetail::thresholds() const
return d->m_thresholds;
}
+QLevelOfDetailBoundingSphere QLevelOfDetail::createBoundingSphere(const QVector3D &center, float radius)
+{
+ return QLevelOfDetailBoundingSphere(center, radius);
+}
+
/*!
- * Sets the range values.
+ * Sets the range values in \a thresholds.
* \sa Qt3DRender::QLevelOfDetail::thresholdType
*/
-void QLevelOfDetail::setThresholds(QVector<qreal> thresholds)
+void QLevelOfDetail::setThresholds(const QVector<qreal> &thresholds)
{
Q_D(QLevelOfDetail);
if (d->m_thresholds != thresholds) {
d->m_thresholds = thresholds;
- thresholdsChanged(d->m_thresholds);
+ emit thresholdsChanged(d->m_thresholds);
}
}
-QBoundingSphere *QLevelOfDetail::volumeOverride() const
+QLevelOfDetailBoundingSphere QLevelOfDetail::volumeOverride() const
{
Q_D(const QLevelOfDetail);
return d->m_volumeOverride;
}
-void QLevelOfDetail::setVolumeOverride(QBoundingSphere *volumeOverride)
+void QLevelOfDetail::setVolumeOverride(const QLevelOfDetailBoundingSphere &volumeOverride)
{
Q_D(QLevelOfDetail);
if (d->m_volumeOverride != volumeOverride) {
- if (d->m_volumeOverride)
- disconnect(d->m_volumeOverride);
d->m_volumeOverride = volumeOverride;
- if (d->m_volumeOverride) {
- connect(d->m_volumeOverride, SIGNAL(radiusChanged(float)), this, SLOT(_q_radiusChanged(float)));
- connect(d->m_volumeOverride, SIGNAL(centerChanged(const QVector3D &)), this, SLOT(_q_centerChanged(const QVector3D&)));
- }
emit volumeOverrideChanged(volumeOverride);
}
}
diff --git a/src/render/frontend/qlevelofdetail.h b/src/render/frontend/qlevelofdetail.h
index f3325aea0..2e752d962 100644
--- a/src/render/frontend/qlevelofdetail.h
+++ b/src/render/frontend/qlevelofdetail.h
@@ -42,6 +42,7 @@
#include <Qt3DCore/qcomponent.h>
#include <Qt3DRender/qt3drender_global.h>
+#include <Qt3DRender/qlevelofdetailboundingsphere.h>
#include <QVector3D>
@@ -50,7 +51,6 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
class QCamera;
-class QBoundingSphere;
class QLevelOfDetailPrivate;
class QT3DRENDERSHARED_EXPORT QLevelOfDetail : public Qt3DCore::QComponent
@@ -60,12 +60,12 @@ class QT3DRENDERSHARED_EXPORT QLevelOfDetail : public Qt3DCore::QComponent
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
Q_PROPERTY(ThresholdType thresholdType READ thresholdType WRITE setThresholdType NOTIFY thresholdTypeChanged)
Q_PROPERTY(QVector<qreal> thresholds READ thresholds WRITE setThresholds NOTIFY thresholdsChanged)
- Q_PROPERTY(Qt3DRender::QBoundingSphere *volumeOverride READ volumeOverride WRITE setVolumeOverride NOTIFY volumeOverrideChanged)
+ Q_PROPERTY(Qt3DRender::QLevelOfDetailBoundingSphere volumeOverride READ volumeOverride WRITE setVolumeOverride NOTIFY volumeOverrideChanged)
public:
enum ThresholdType {
- DistanceToCamera,
- ProjectedScreenPixelSize,
+ DistanceToCameraThreshold,
+ ProjectedScreenPixelSizeThreshold,
};
Q_ENUM(ThresholdType) // LCOV_EXCL_LINE
@@ -76,21 +76,23 @@ public:
int currentIndex() const;
ThresholdType thresholdType() const;
QVector<qreal> thresholds() const;
- QBoundingSphere *volumeOverride() const;
+ QLevelOfDetailBoundingSphere volumeOverride() const;
+
+ Q_INVOKABLE QLevelOfDetailBoundingSphere createBoundingSphere(const QVector3D &center, float radius);
public Q_SLOTS:
void setCamera(QCamera *camera);
void setCurrentIndex(int currentIndex);
void setThresholdType(ThresholdType thresholdType);
- void setThresholds(QVector<qreal> thresholds);
- void setVolumeOverride(QBoundingSphere *volumeOverride);
+ void setThresholds(const QVector<qreal> &thresholds);
+ void setVolumeOverride(const QLevelOfDetailBoundingSphere &volumeOverride);
Q_SIGNALS:
void cameraChanged(QCamera *camera);
void currentIndexChanged(int currentIndex);
void thresholdTypeChanged(ThresholdType thresholdType);
- void thresholdsChanged(QVector<qreal> thresholds);
- void volumeOverrideChanged(QBoundingSphere *volumeOverride);
+ void thresholdsChanged(const QVector<qreal> &thresholds);
+ void volumeOverrideChanged(const QLevelOfDetailBoundingSphere &volumeOverride);
protected:
explicit QLevelOfDetail(QLevelOfDetailPrivate &dd, Qt3DCore::QNode *parent = nullptr);
@@ -99,12 +101,12 @@ protected:
private:
Q_DECLARE_PRIVATE(QLevelOfDetail)
- Q_PRIVATE_SLOT(d_func(), void _q_radiusChanged(float))
- Q_PRIVATE_SLOT(d_func(), void _q_centerChanged(const QVector3D&))
};
} // namespace Qt3DRender
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(Qt3DRender::QLevelOfDetailBoundingSphere)
+
#endif // QT3DRENDER_QLEVELOFDETAIL_H
diff --git a/src/render/frontend/qlevelofdetail_p.h b/src/render/frontend/qlevelofdetail_p.h
index ab25e9ad3..1d7a05a71 100644
--- a/src/render/frontend/qlevelofdetail_p.h
+++ b/src/render/frontend/qlevelofdetail_p.h
@@ -53,6 +53,7 @@
#include <private/qcomponent_p.h>
#include <qlevelofdetail.h>
+#include <Qt3DRender/qlevelofdetailboundingsphere.h>
#include <QVector3D>
@@ -74,7 +75,7 @@ public:
int m_currentIndex;
QLevelOfDetail::ThresholdType m_thresholdType;
QVector<qreal> m_thresholds;
- QPointer<QBoundingSphere> m_volumeOverride;
+ QLevelOfDetailBoundingSphere m_volumeOverride;
};
struct QLevelOfDetailData
@@ -83,8 +84,7 @@ struct QLevelOfDetailData
int currentIndex;
QLevelOfDetail::ThresholdType thresholdType;
QVector<qreal> thresholds;
- float radius;
- QVector3D center;
+ QLevelOfDetailBoundingSphere volumeOverride;
};
} // namespace Qt3DRender
diff --git a/src/render/frontend/qboundingsphere.cpp b/src/render/frontend/qlevelofdetailboundingsphere.cpp
index 4d8b1aba8..abf8081d3 100644
--- a/src/render/frontend/qboundingsphere.cpp
+++ b/src/render/frontend/qlevelofdetailboundingsphere.cpp
@@ -37,110 +37,121 @@
**
****************************************************************************/
-#include "qboundingsphere.h"
-#include "qboundingsphere_p.h"
+#include "qlevelofdetailboundingsphere.h"
+#include <QSharedData>
QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-QBoundingSpherePrivate::QBoundingSpherePrivate()
- : QObjectPrivate()
- , m_radius(1.f)
+class QLevelOfDetailBoundingSpherePrivate: public QSharedData
{
+public:
+ QLevelOfDetailBoundingSpherePrivate()
+ : QSharedData()
+ , m_radius(0.0f)
+ {}
-}
+ QLevelOfDetailBoundingSpherePrivate(QVector3D center, float radius)
+ : QSharedData()
+ , m_center(center)
+ , m_radius(radius)
+ {}
+
+ ~QLevelOfDetailBoundingSpherePrivate()
+ {}
+
+ QVector3D m_center;
+ float m_radius;
+};
/*!
- \class Qt3DRender::QBoundingSphere
+ \class Qt3DRender::QLevelOfDetailBoundingSphere
\inmodule Qt3DRender
\since 5.9
- \brief The QBoundingSphere class provides a simple spherical volume, defined by it's center and radius.
+ \brief The QLevelOfDetailBoundingSphere class provides a simple spherical volume, defined by it's center and radius.
*/
/*!
\qmltype LevelOfDetail
- \instantiates Qt3DRender::QLevelOfDetail
+ \instantiates Qt3DRender::QLevelOfDetailBoundingSphere
\inherits Component3D
\inqmlmodule Qt3D.Render
- \brief The BoundingSphere class provides a simple spherical volume, defined by it's center and radius.
+ \brief The LevelOfDetailBoundingSphere class provides a simple spherical volume, defined by it's center and radius.
*/
/*!
- * \qmlproperty QVector3D BoundingSphere::center
+ * \qmlproperty QVector3D LevelOfDetailBoundingSphere::center
*
* Specifies the center of the bounding sphere
*/
/*!
- * \property QBoundingSphere::center
+ * \property QLevelOfDetailBoundingSphere::center
*
* Specifies the center of the bounding sphere
*/
/*!
- * \qmlproperty qreal BoundingSphere::radius
+ * \qmlproperty qreal LevelOfDetailBoundingSphere::radius
*
* Specifies the radius of the bounding sphere
*/
/*!
- * \property QBoundingSphere::radius
+ * \property QLevelOfDetailBoundingSphere::radius
*
* Specifies the radius of the bounding sphere
*/
-/*! \fn Qt3DRender::QBoundingSphere::QBoundingSphere(QObject *parent)
- Constructs a new QBoundingSphere with the specified \a parent.
+/*! \fn Qt3DRender::QLevelOfDetailBoundingSphere::QLevelOfDetailBoundingSphere(const QVector3D &center = QVector3D(), float radius = -1.0f)
+ Constructs a new QLevelOfDetailBoundingSphere with the specified \a center and \a radius.
*/
-QBoundingSphere::QBoundingSphere(QObject *parent)
- : QObject(*new QBoundingSpherePrivate, parent)
+
+
+QLevelOfDetailBoundingSphere::QLevelOfDetailBoundingSphere(QVector3D center, float radius)
+ : d_ptr(new QLevelOfDetailBoundingSpherePrivate(center, radius))
{
+}
+QLevelOfDetailBoundingSphere::QLevelOfDetailBoundingSphere(const QLevelOfDetailBoundingSphere &other)
+ : d_ptr(other.d_ptr)
+{
}
-QBoundingSphere::QBoundingSphere(const QVector3D &center, float radius, QObject *parent)
- : QBoundingSphere(parent)
+QLevelOfDetailBoundingSphere::~QLevelOfDetailBoundingSphere()
{
- Q_D(QBoundingSphere);
- d->m_center = center;
- d->m_radius = radius;
}
-QVector3D QBoundingSphere::center() const
+QLevelOfDetailBoundingSphere &QLevelOfDetailBoundingSphere::operator =(const QLevelOfDetailBoundingSphere &other)
{
- Q_D(const QBoundingSphere);
- return d->m_center;
+ d_ptr = other.d_ptr;
+ return *this;
}
-float QBoundingSphere::radius() const
+QVector3D QLevelOfDetailBoundingSphere::center() const
{
- Q_D(const QBoundingSphere);
- return d->m_radius;
+ return d_ptr->m_center;
}
-/*!
- * Sets the radius of the bounding sphere.
- */
-void QBoundingSphere::setRadius(float radius)
+float QLevelOfDetailBoundingSphere::radius() const
{
- Q_D(QBoundingSphere);
- if (d->m_radius != radius) {
- d->m_radius = radius;
- emit radiusChanged(radius);
- }
+ return d_ptr->m_radius;
}
-/*!
- * Sets the center of the bounding sphere.
- */
-void QBoundingSphere::setCenter(const QVector3D &center)
+bool QLevelOfDetailBoundingSphere::isEmpty() const
+{
+ return d_ptr->m_radius <= 0.0f;
+}
+
+bool QLevelOfDetailBoundingSphere::operator ==(const QLevelOfDetailBoundingSphere &other) const
+{
+ return d_ptr->m_center == other.center() && other.d_ptr->m_radius == other.radius();
+}
+
+bool QLevelOfDetailBoundingSphere::operator !=(const QLevelOfDetailBoundingSphere &other) const
{
- Q_D(QBoundingSphere);
- if (d->m_center != center) {
- d->m_center = center;
- emit centerChanged(center);
- }
+ return !(*this == other);
}
} // namespace Qt3DRender
diff --git a/src/render/frontend/qboundingsphere.h b/src/render/frontend/qlevelofdetailboundingsphere.h
index e7f9b7784..b35df95e8 100644
--- a/src/render/frontend/qboundingsphere.h
+++ b/src/render/frontend/qlevelofdetailboundingsphere.h
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef QT3DRENDER_QBOUNDINGSPHERE_H
-#define QT3DRENDER_QBOUNDINGSPHERE_H
+#ifndef QT3DRENDER_QLEVELOFDETAILBOUNDINGSPHERE_H
+#define QT3DRENDER_QLEVELOFDETAILBOUNDINGSPHERE_H
#include <Qt3DCore/qcomponent.h>
#include <Qt3DRender/qt3drender_global.h>
@@ -49,34 +49,33 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QBoundingSpherePrivate;
+class QLevelOfDetailBoundingSpherePrivate;
-class QT3DRENDERSHARED_EXPORT QBoundingSphere : public QObject
+class QT3DRENDERSHARED_EXPORT QLevelOfDetailBoundingSphere
{
- Q_OBJECT
- Q_PROPERTY(QVector3D center READ center WRITE setCenter NOTIFY centerChanged)
- Q_PROPERTY(float radius READ radius WRITE setRadius NOTIFY radiusChanged)
+ Q_GADGET
+ Q_PROPERTY(QVector3D center READ center CONSTANT)
+ Q_PROPERTY(float radius READ radius CONSTANT)
public:
- explicit QBoundingSphere(QObject *parent = nullptr);
- QBoundingSphere(const QVector3D &center, float radius, QObject *parent = nullptr);
+ explicit QLevelOfDetailBoundingSphere(QVector3D center = QVector3D(), float radius = 1.0f);
+ QLevelOfDetailBoundingSphere(const QLevelOfDetailBoundingSphere &other);
+ ~QLevelOfDetailBoundingSphere();
+
+ QLevelOfDetailBoundingSphere &operator =(const QLevelOfDetailBoundingSphere &other);
QVector3D center() const;
float radius() const;
-public Q_SLOTS:
- void setRadius(float radius);
- void setCenter(const QVector3D &center);
-
-Q_SIGNALS:
- void radiusChanged(float radius);
- void centerChanged(const QVector3D &center);
+ bool isEmpty() const;
+ bool operator ==(const QLevelOfDetailBoundingSphere &other) const;
+ bool operator !=(const QLevelOfDetailBoundingSphere &other) const;
private:
- Q_DECLARE_PRIVATE(QBoundingSphere)
+ QSharedDataPointer<QLevelOfDetailBoundingSpherePrivate> d_ptr;
};
} // namespace Qt3DRender
QT_END_NAMESPACE
-#endif // QT3DRENDER_QBOUNDINGSPHERE_H
+#endif // QT3DRENDER_QLEVELOFDETAILBOUNDINGSPHERE_H
diff --git a/src/render/frontend/qlevelofdetailswitch.cpp b/src/render/frontend/qlevelofdetailswitch.cpp
index 9a63343ed..845fdd5a6 100644
--- a/src/render/frontend/qlevelofdetailswitch.cpp
+++ b/src/render/frontend/qlevelofdetailswitch.cpp
@@ -69,11 +69,17 @@ namespace Qt3DRender {
This component is assigned to an entity. When the entity changes distance relative
to the camera, the LevelOfDetailSwitch will disable all the child entities except
- the one matching index \l LevelOfDetailSwitch::currentIndex.
+ the one matching index \l currentIndex.
\sa LevelOfDetail
*/
+/*!
+ \qmlproperty int LevelOfDetailSwitch::currentIndex
+
+ The index of the presently selected child entity.
+*/
+
/*! \fn Qt3DRender::QLevelOfDetailSwitch::QLevelOfDetailSwitch(Qt3DCore::QNode *parent)
Constructs a new QLevelOfDetailSwitch with the specified \a parent.
*/
@@ -107,8 +113,10 @@ void QLevelOfDetailSwitch::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &cha
emit currentIndexChanged(ndx);
int entityIndex = 0;
- for (Qt3DCore::QEntity *entity : entities()) {
- for (Qt3DCore::QNode *childNode : entity->childNodes()) {
+ const auto entities = this->entities();
+ for (Qt3DCore::QEntity *entity : entities) {
+ const auto childNodes = entity->childNodes();
+ for (Qt3DCore::QNode *childNode : childNodes) {
Qt3DCore::QEntity *childEntity = qobject_cast<Qt3DCore::QEntity *>(childNode);
if (childEntity) {
childEntity->setEnabled(entityIndex == ndx);
diff --git a/src/render/frontend/qpickingsettings.cpp b/src/render/frontend/qpickingsettings.cpp
index db6840d7f..1cda638cb 100644
--- a/src/render/frontend/qpickingsettings.cpp
+++ b/src/render/frontend/qpickingsettings.cpp
@@ -53,6 +53,11 @@ namespace Qt3DRender {
The picking settings determine how the entity picking is handled. For more details about
entity picking, see QObjectPicker component documentation.
+
+ Picking is triggered by mouse events. It will cast a ray through the scene and look for
+ geometry intersecting the ray.
+
+ \sa QObjectPicker, QPickEvent, QPickTriangleEvent
*/
/*!
@@ -64,6 +69,11 @@ namespace Qt3DRender {
The picking settings determine how the entity picking is handled. For more details about
entity picking, see Qt3DRender::QObjectPicker component documentation.
+
+ Picking is triggered by mouse events. It will cast a ray through the scene and look for
+ geometry intersecting the ray.
+
+ \sa ObjectPicker
*/
QPickingSettingsPrivate::QPickingSettingsPrivate()
@@ -104,9 +114,6 @@ QPickingSettings::PickResultMode QPickingSettings::pickResultMode() const
return d->m_pickResultMode;
}
-/*!
- * \return the back facing picking flag
- */
QPickingSettings::FaceOrientationPickingMode QPickingSettings::faceOrientationPickingMode() const
{
Q_D(const QPickingSettings);
@@ -119,7 +126,7 @@ QPickingSettings::FaceOrientationPickingMode QPickingSettings::faceOrientationPi
* Specifies the picking method.
*
* \value BoundingVolumePicking An entity is considered picked if the picking ray intersects
- * the bounding volume of the entity.
+ * the bounding volume of the entity (default).
* \value TrianglePicking An entity is considered picked if the picking ray intersects with
* any triangle of the entity's mesh component.
*/
@@ -140,6 +147,12 @@ QPickingSettings::FaceOrientationPickingMode QPickingSettings::faceOrientationPi
\property QPickingSettings::pickMethod
Holds the current pick method.
+
+ By default, for performance reasons, ray casting will use bounding volume picking.
+ This may however lead to unexpected results if a small object is englobed
+ in the bounding sphere of a large object behind it.
+
+ Triangle picking will produce exact results but is computationally more expensive.
*/
void QPickingSettings::setPickMethod(QPickingSettings::PickMethod pickMethod)
{
@@ -157,8 +170,10 @@ void QPickingSettings::setPickMethod(QPickingSettings::PickMethod pickMethod)
* Specifies what is included into the picking results.
*
* \value NearestPick Only the nearest entity to picking ray origin intersected by the picking ray
- * is picked.
+ * is picked (default).
* \value AllPicks All entities that intersect the picking ray are picked.
+ *
+ * \sa Qt3DRender::QPickEvent
*/
/*!
@@ -177,6 +192,14 @@ void QPickingSettings::setPickMethod(QPickingSettings::PickMethod pickMethod)
\property QPickingSettings::pickResultMode
Holds the current pick results mode.
+
+ By default, pick results will only be produced for the entity closest to the camera.
+
+ When setting the pick method to AllPicks, events will be triggered for all the
+ entities with a QObjectPicker along the ray.
+
+ If a QObjectPicker is assigned to an entity with multiple children, an event will
+ be triggered for each child entity that intersects the ray.
*/
void QPickingSettings::setPickResultMode(QPickingSettings::PickResultMode pickResultMode)
{
@@ -189,8 +212,31 @@ void QPickingSettings::setPickResultMode(QPickingSettings::PickResultMode pickRe
}
/*!
- * \a faceOrientationPickingMode determines whether back facing faces are picked or not.
- */
+ \enum Qt3DRender::QPickingSettings::FaceOrientationPickingMode
+
+ Specifies how face orientation affects triangle picking
+
+ \value FrontFace Only front-facing triangles will be picked (default).
+ \value BackFace Only back-facing triangles will be picked.
+ \value FrontAndBackFace Both front- and back-facing triangles will be picked.
+*/
+
+/*!
+ \qmlproperty enumeration PickingSettings::faceOrientationPickingMode
+
+ Specifies how face orientation affects triangle picking
+
+ \list
+ \li PickingSettings.FrontFace Only front-facing triangles will be picked (default).
+ \li PickingSettings.BackFace Only back-facing triangles will be picked.
+ \li PickingSettings.FrontAndBackFace Both front- and back-facing triangles will be picked.
+ \endlist
+*/
+/*!
+ \property QPickingSettings::faceOrientationPickingMode
+
+ Specifies how face orientation affects triangle picking
+*/
void QPickingSettings::setFaceOrientationPickingMode(QPickingSettings::FaceOrientationPickingMode faceOrientationPickingMode)
{
Q_D(QPickingSettings);
diff --git a/src/render/frontend/qrenderaspect.cpp b/src/render/frontend/qrenderaspect.cpp
index d9b45b7a7..4d775aeb3 100644
--- a/src/render/frontend/qrenderaspect.cpp
+++ b/src/render/frontend/qrenderaspect.cpp
@@ -75,14 +75,18 @@
#include <Qt3DRender/qobjectpicker.h>
#include <Qt3DRender/qfrustumculling.h>
#include <Qt3DRender/qabstractlight.h>
+#include <Qt3DRender/qenvironmentlight.h>
#include <Qt3DRender/qdispatchcompute.h>
#include <Qt3DRender/qcomputecommand.h>
#include <Qt3DRender/qrendersurfaceselector.h>
#include <Qt3DRender/qrendersettings.h>
#include <Qt3DRender/qrendercapture.h>
+#include <Qt3DRender/qbuffercapture.h>
#include <Qt3DRender/qmemorybarrier.h>
+
#include <Qt3DRender/private/cameraselectornode_p.h>
#include <Qt3DRender/private/layerfilternode_p.h>
+#include <Qt3DRender/private/cameralens_p.h>
#include <Qt3DRender/private/filterkey_p.h>
#include <Qt3DRender/private/entity_p.h>
#include <Qt3DRender/private/renderer_p.h>
@@ -118,20 +122,26 @@
#include <Qt3DRender/private/qsceneimportfactory_p.h>
#include <Qt3DRender/private/frustumculling_p.h>
#include <Qt3DRender/private/light_p.h>
+#include <Qt3DRender/private/environmentlight_p.h>
#include <Qt3DRender/private/dispatchcompute_p.h>
#include <Qt3DRender/private/computecommand_p.h>
#include <Qt3DRender/private/rendersurfaceselector_p.h>
#include <Qt3DRender/private/rendersettings_p.h>
#include <Qt3DRender/private/backendnode_p.h>
#include <Qt3DRender/private/rendercapture_p.h>
+#include <Qt3DRender/private/buffercapture_p.h>
#include <Qt3DRender/private/technique_p.h>
#include <Qt3DRender/private/offscreensurfacehelper_p.h>
#include <Qt3DRender/private/memorybarrier_p.h>
+#include <private/qrenderpluginfactory_p.h>
+#include <private/qrenderplugin_p.h>
+
#include <Qt3DCore/qentity.h>
#include <Qt3DCore/qtransform.h>
#include <Qt3DCore/qnode.h>
+#include <Qt3DCore/QAspectEngine>
#include <Qt3DCore/private/qservicelocator_p.h>
#include <QDebug>
@@ -162,7 +172,7 @@ QRenderAspectPrivate::QRenderAspectPrivate(QRenderAspect::RenderType type)
, m_renderType(type)
, m_offscreenHelper(nullptr)
{
- // Load the scene parsers
+ m_instances.append(this);
loadSceneParsers();
}
@@ -175,6 +185,18 @@ QRenderAspectPrivate::~QRenderAspectPrivate()
if (m_renderer != nullptr)
qWarning() << Q_FUNC_INFO << "The renderer should have been deleted when reaching this point (this warning may be normal when running tests)";
delete m_nodeManagers;
+ m_instances.removeAll(this);
+}
+
+QRenderAspectPrivate *QRenderAspectPrivate::findPrivate(Qt3DCore::QAspectEngine *engine)
+{
+ const QVector<QAbstractAspect*> aspects = engine->aspects();
+ for (QAbstractAspect* aspect : aspects) {
+ QRenderAspect *renderAspect = qobject_cast<QRenderAspect *>(aspect);
+ if (renderAspect)
+ return static_cast<QRenderAspectPrivate *>(renderAspect->d_ptr.data());
+ }
+ return nullptr;
}
/*! \internal */
@@ -190,7 +212,7 @@ void QRenderAspectPrivate::registerBackendTypes()
q->registerBackendType<Qt3DCore::QEntity>(QSharedPointer<Render::RenderEntityFunctor>::create(m_renderer, m_nodeManagers));
q->registerBackendType<Qt3DCore::QTransform>(QSharedPointer<Render::NodeFunctor<Render::Transform, Render::TransformManager> >::create(m_renderer));
- q->registerBackendType<Qt3DRender::QCameraLens>(QSharedPointer<Render::NodeFunctor<Render::CameraLens, Render::CameraManager> >::create(m_renderer));
+ q->registerBackendType<Qt3DRender::QCameraLens>(QSharedPointer<Render::CameraLensFunctor>::create(m_renderer, q));
q->registerBackendType<QLayer>(QSharedPointer<Render::NodeFunctor<Render::Layer, Render::LayerManager> >::create(m_renderer));
q->registerBackendType<QLevelOfDetail>(QSharedPointer<Render::NodeFunctor<Render::LevelOfDetail, Render::LevelOfDetailManager> >::create(m_renderer));
q->registerBackendType<QLevelOfDetailSwitch>(QSharedPointer<Render::NodeFunctor<Render::LevelOfDetail, Render::LevelOfDetailManager> >::create(m_renderer));
@@ -215,6 +237,7 @@ void QRenderAspectPrivate::registerBackendTypes()
q->registerBackendType<QEffect>(QSharedPointer<Render::NodeFunctor<Render::Effect, Render::EffectManager> >::create(m_renderer));
q->registerBackendType<QFilterKey>(QSharedPointer<Render::NodeFunctor<Render::FilterKey, Render::FilterKeyManager> >::create(m_renderer));
q->registerBackendType<QAbstractLight>(QSharedPointer<Render::RenderLightFunctor>::create(m_renderer, m_nodeManagers));
+ q->registerBackendType<QEnvironmentLight>(QSharedPointer<Render::NodeFunctor<Render::EnvironmentLight, Render::EnvironmentLightManager> >::create(m_renderer));
q->registerBackendType<QMaterial>(QSharedPointer<Render::NodeFunctor<Render::Material, Render::MaterialManager> >::create(m_renderer));
q->registerBackendType<QParameter>(QSharedPointer<Render::NodeFunctor<Render::Parameter, Render::ParameterManager> >::create(m_renderer));
q->registerBackendType<QRenderPass>(QSharedPointer<Render::NodeFunctor<Render::RenderPass, Render::RenderPassManager> >::create(m_renderer));
@@ -238,15 +261,21 @@ void QRenderAspectPrivate::registerBackendTypes()
q->registerBackendType<QTechniqueFilter>(QSharedPointer<Render::FrameGraphNodeFunctor<Render::TechniqueFilter, QTechniqueFilter> >::create(m_renderer));
q->registerBackendType<QViewport>(QSharedPointer<Render::FrameGraphNodeFunctor<Render::ViewportNode, QViewport> >::create(m_renderer));
q->registerBackendType<QRenderCapture>(QSharedPointer<Render::FrameGraphNodeFunctor<Render::RenderCapture, QRenderCapture> >::create(m_renderer));
+ q->registerBackendType<QBufferCapture>(QSharedPointer<Render::FrameGraphNodeFunctor<Render::BufferCapture, QBufferCapture> >::create(m_renderer));
q->registerBackendType<QMemoryBarrier>(QSharedPointer<Render::FrameGraphNodeFunctor<Render::MemoryBarrier, QMemoryBarrier> >::create(m_renderer));
// Picking
q->registerBackendType<QObjectPicker>(QSharedPointer<Render::NodeFunctor<Render::ObjectPicker, Render::ObjectPickerManager> >::create(m_renderer));
+
+ // Plugins
+ for (const QString &plugin : m_pluginConfig)
+ loadRenderPlugin(plugin);
}
/*! \internal */
void QRenderAspectPrivate::unregisterBackendTypes()
{
+ Q_Q(QRenderAspect);
unregisterBackendType<Qt3DCore::QEntity>();
unregisterBackendType<Qt3DCore::QTransform>();
@@ -273,6 +302,7 @@ void QRenderAspectPrivate::unregisterBackendTypes()
unregisterBackendType<QEffect>();
unregisterBackendType<QFilterKey>();
unregisterBackendType<QAbstractLight>();
+ unregisterBackendType<QEnvironmentLight>();
unregisterBackendType<QMaterial>();
unregisterBackendType<QParameter>();
unregisterBackendType<QRenderPass>();
@@ -295,10 +325,22 @@ void QRenderAspectPrivate::unregisterBackendTypes()
unregisterBackendType<QTechniqueFilter>();
unregisterBackendType<QViewport>();
unregisterBackendType<QRenderCapture>();
+ unregisterBackendType<QBufferCapture>();
unregisterBackendType<QMemoryBarrier>();
// Picking
unregisterBackendType<QObjectPicker>();
+
+ // Plugins
+ for (Render::QRenderPlugin *plugin : qAsConst(m_renderPlugins))
+ plugin->unregisterBackendTypes(q);
+}
+
+void QRenderAspectPrivate::registerBackendType(const QMetaObject &obj,
+ const QBackendNodeMapperPtr &functor)
+{
+ Q_Q(QRenderAspect);
+ q->registerBackendType(obj, functor);
}
/*!
@@ -360,7 +402,7 @@ QVector<Qt3DCore::QAspectJobPtr> QRenderAspect::jobsToExecute(qint64 time)
d->m_renderer->dumpInfo();
#endif
- // Create jobs that will get exectued by the threadpool
+ // Create jobs that will get executed by the threadpool
QVector<QAspectJobPtr> jobs;
// 1 LoadBufferJobs, GeometryJobs, SceneLoaderJobs, LoadTextureJobs
@@ -379,6 +421,7 @@ QVector<Qt3DCore::QAspectJobPtr> QRenderAspect::jobsToExecute(qint64 time)
// don't spawn any jobs, if the renderer decides to skip this frame
if (!d->m_renderer->shouldRender()) {
d->m_renderer->skipNextFrame();
+ QThread::msleep(1);
return jobs;
}
@@ -456,7 +499,7 @@ void QRenderAspect::onRegistered()
d->m_renderer->setNodeManagers(d->m_nodeManagers);
// Create a helper for deferring creation of an offscreen surface used during cleanup
- // to the main thread, after we knwo what the surface format in use is.
+ // to the main thread, after we know what the surface format in use is.
d->m_offscreenHelper = new Render::OffscreenSurfaceHelper(d->m_renderer);
d->m_offscreenHelper->moveToThread(QCoreApplication::instance()->thread());
d->m_renderer->setOffscreenSurfaceHelper(d->m_offscreenHelper);
@@ -475,7 +518,8 @@ void QRenderAspect::onRegistered()
advanceService);
}
- d->m_renderer->setServices(d->services());
+ if (d->services())
+ d->m_renderer->setServices(d->services());
d->m_initialized = true;
}
@@ -537,6 +581,39 @@ void QRenderAspectPrivate::loadSceneParsers()
}
}
+void QRenderAspectPrivate::loadRenderPlugin(const QString &pluginName)
+{
+ Q_Q(QRenderAspect);
+ const QStringList keys = Render::QRenderPluginFactory::keys();
+ if (!keys.contains(pluginName))
+ return;
+
+ if (m_pluginConfig.contains(pluginName) && !m_loadedPlugins.contains(pluginName)) {
+ Render::QRenderPlugin *plugin
+ = Render::QRenderPluginFactory::create(pluginName, QStringList());
+ if (plugin != nullptr) {
+ m_loadedPlugins.append(pluginName);
+ m_renderPlugins.append(plugin);
+ plugin->registerBackendTypes(q, m_renderer);
+ }
+ }
+}
+
+QVector<QString> QRenderAspectPrivate::m_pluginConfig;
+QMutex QRenderAspectPrivate::m_pluginLock;
+QVector<QRenderAspectPrivate *> QRenderAspectPrivate::m_instances;
+
+void QRenderAspectPrivate::configurePlugin(const QString &plugin)
+{
+ QMutexLocker lock(&m_pluginLock);
+ if (!m_pluginConfig.contains(plugin)) {
+ m_pluginConfig.append(plugin);
+
+ for (QRenderAspectPrivate *instance : qAsConst(m_instances))
+ instance->loadRenderPlugin(plugin);
+ }
+}
+
} // namespace Qt3DRender
QT_END_NAMESPACE
diff --git a/src/render/frontend/qrenderaspect.h b/src/render/frontend/qrenderaspect.h
index 72e8e4bdb..48ef5b164 100644
--- a/src/render/frontend/qrenderaspect.h
+++ b/src/render/frontend/qrenderaspect.h
@@ -56,6 +56,7 @@ class TestAspect;
namespace Render {
class Renderer;
+class QRenderPlugin;
}
class QRenderAspectPrivate;
@@ -92,6 +93,7 @@ private:
void onEngineStartup() Q_DECL_OVERRIDE;
friend class Render::Renderer;
+ friend class Render::QRenderPlugin;
#if defined(QT_BUILD_INTERNAL)
friend class QRenderAspectTester;
friend class TestAspect;
diff --git a/src/render/frontend/qrenderaspect_p.h b/src/render/frontend/qrenderaspect_p.h
index 72183ef87..b8c8538ee 100644
--- a/src/render/frontend/qrenderaspect_p.h
+++ b/src/render/frontend/qrenderaspect_p.h
@@ -55,6 +55,8 @@
#include <Qt3DCore/private/qabstractaspect_p.h>
#include <Qt3DRender/private/qt3drender_global_p.h>
+#include <QtCore/qmutex.h>
+
QT_BEGIN_NAMESPACE
class QSurface;
@@ -62,9 +64,11 @@ class QSurface;
namespace Qt3DRender {
class QSceneImporter;
+
namespace Render {
class AbstractRenderer;
class NodeManagers;
+class QRenderPlugin;
}
namespace Render {
@@ -79,12 +83,16 @@ public:
Q_DECLARE_PUBLIC(QRenderAspect)
+ static QRenderAspectPrivate* findPrivate(Qt3DCore::QAspectEngine *engine);
+
void registerBackendTypes();
void unregisterBackendTypes();
void loadSceneParsers();
+ void loadRenderPlugin(const QString &pluginName);
void renderInitialize(QOpenGLContext *context);
void renderSynchronous();
void renderShutdown();
+ void registerBackendType(const QMetaObject &, const Qt3DCore::QBackendNodeMapperPtr &functor);
QVector<Qt3DCore::QAspectJobPtr> createGeometryRendererJobs();
Render::NodeManagers *m_nodeManagers;
@@ -92,8 +100,15 @@ public:
bool m_initialized;
QList<QSceneImporter *> m_sceneImporter;
+ QVector<QString> m_loadedPlugins;
+ QVector<Render::QRenderPlugin *> m_renderPlugins;
QRenderAspect::RenderType m_renderType;
Render::OffscreenSurfaceHelper *m_offscreenHelper;
+
+ static QMutex m_pluginLock;
+ static QVector<QString> m_pluginConfig;
+ static QVector<QRenderAspectPrivate *> m_instances;
+ static void configurePlugin(const QString &plugin);
};
}
diff --git a/src/render/frontend/qrenderplugin_p.h b/src/render/frontend/qrenderplugin_p.h
new file mode 100644
index 000000000..5144448c1
--- /dev/null
+++ b/src/render/frontend/qrenderplugin_p.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DRENDER_RENDER_QRENDERPLUGIN_P_H
+#define QT3DRENDER_RENDER_QRENDERPLUGIN_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qt3drender_global_p.h>
+
+#include <Qt3DCore/qbackendnode.h>
+#include <Qt3DRender/qrenderaspect.h>
+
+#include <QtCore/qobject.h>
+#include <QtCore/qstringlist.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+namespace Render {
+
+class AbstractRenderer;
+
+class QT3DRENDERSHARED_PRIVATE_EXPORT QRenderPlugin
+{
+public:
+ virtual bool registerBackendTypes(QRenderAspect *aspect, AbstractRenderer *renderer) = 0;
+ virtual bool unregisterBackendTypes(QRenderAspect *aspect) = 0;
+
+protected:
+ void registerBackendType(QRenderAspect *aspect, const QMetaObject &obj, const Qt3DCore::QBackendNodeMapperPtr &functor)
+ {
+ aspect->registerBackendType(obj, functor);
+ }
+ void unregisterBackendType(QRenderAspect *aspect, const QMetaObject &obj)
+ {
+ aspect->unregisterBackendType(obj);
+ }
+};
+
+} // namespace Render
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_RENDER_QRENDERPLUGIN_P_H
diff --git a/src/render/frontend/qrenderpluginfactory.cpp b/src/render/frontend/qrenderpluginfactory.cpp
new file mode 100644
index 000000000..51fa068c6
--- /dev/null
+++ b/src/render/frontend/qrenderpluginfactory.cpp
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qrenderpluginfactory_p.h"
+#include "qrenderpluginfactoryif_p.h"
+#include "qrenderplugin_p.h"
+
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/qdir.h>
+
+#include <private/qfactoryloader_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+namespace Render {
+
+#ifndef QT_NO_LIBRARY
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, (QRenderPluginFactoryInterface_iid, QLatin1String("/renderplugins"), Qt::CaseInsensitive))
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader, (QRenderPluginFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
+#endif
+
+QStringList QRenderPluginFactory::keys(const QString &pluginPath)
+{
+#ifndef QT_NO_LIBRARY
+ QStringList list;
+ if (!pluginPath.isEmpty()) {
+ QCoreApplication::addLibraryPath(pluginPath);
+ list = directLoader()->keyMap().values();
+ if (!list.isEmpty()) {
+ const QString postFix = QLatin1String(" (from ")
+ + QDir::toNativeSeparators(pluginPath)
+ + QLatin1Char(')');
+ const QStringList::iterator end = list.end();
+ for (QStringList::iterator it = list.begin(); it != end; ++it)
+ (*it).append(postFix);
+ }
+ }
+ list.append(loader()->keyMap().values());
+ return list;
+#else
+ return QStringList();
+#endif
+}
+
+QRenderPlugin *QRenderPluginFactory::create(const QString &name, const QStringList &args,
+ const QString &pluginPath)
+{
+#ifndef QT_NO_LIBRARY
+ if (!pluginPath.isEmpty()) {
+ QCoreApplication::addLibraryPath(pluginPath);
+ if (QRenderPlugin *ret
+ = qLoadPlugin<QRenderPlugin, QRenderPluginFactoryIf>(directLoader(), name, args)) {
+ return ret;
+ }
+ }
+ if (QRenderPlugin *ret = qLoadPlugin<QRenderPlugin, QRenderPluginFactoryIf>(loader(), name, args))
+ return ret;
+#endif
+ return nullptr;
+}
+
+} // namespace Render
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/frontend/qboundingsphere_p.h b/src/render/frontend/qrenderpluginfactory_p.h
index 171e4440f..9cffd500a 100644
--- a/src/render/frontend/qboundingsphere_p.h
+++ b/src/render/frontend/qrenderpluginfactory_p.h
@@ -1,44 +1,41 @@
/****************************************************************************
**
-** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the Qt3D module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
-#ifndef QT3DRENDER_QBOUNDINGSPHERE_P_H
-#define QT3DRENDER_QBOUNDINGSPHERE_P_H
+#ifndef QT3DRENDER_RENDER_QRENDERPLUGINFACTORY_P_H
+#define QT3DRENDER_RENDER_QRENDERPLUGINFACTORY_P_H
//
// W A R N I N G
@@ -51,26 +48,28 @@
// We mean it.
//
-#include <private/qobject_p.h>
-#include <qboundingsphere.h>
+#include <private/qt3drender_global_p.h>
+
+#include <QtCore/qstringlist.h>
QT_BEGIN_NAMESPACE
namespace Qt3DRender {
+namespace Render {
+
+class QRenderPlugin;
-class QT3DRENDERSHARED_EXPORT QBoundingSpherePrivate : public QObjectPrivate
+class QT3DRENDERSHARED_PRIVATE_EXPORT QRenderPluginFactory
{
public:
- QBoundingSpherePrivate();
-
- Q_DECLARE_PUBLIC(QBoundingSphere)
-
- QVector3D m_center;
- float m_radius;
+ static QStringList keys(const QString &pluginPath = QString());
+ static QRenderPlugin *create(const QString &name, const QStringList &args,
+ const QString &pluginPath = QString());
};
+} // namespace Render
} // namespace Qt3DRender
QT_END_NAMESPACE
-#endif // QT3DRENDER_QBOUNDINGSPHERE_P_H
+#endif // QT3DRENDER_RENDER_QRENDERPLUGINFACTORY_P_H
diff --git a/src/render/frontend/qrenderpluginfactoryif.cpp b/src/render/frontend/qrenderpluginfactoryif.cpp
new file mode 100644
index 000000000..af567084c
--- /dev/null
+++ b/src/render/frontend/qrenderpluginfactoryif.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qrenderpluginfactoryif_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+namespace Render {
+
+QRenderPluginFactoryIf::QRenderPluginFactoryIf(QObject *parent)
+ : QObject(parent)
+{
+
+}
+
+QRenderPluginFactoryIf::~QRenderPluginFactoryIf()
+{
+
+}
+
+QRenderPlugin *QRenderPluginFactoryIf::create(const QString &key, const QStringList &paramList)
+{
+ Q_UNUSED(key)
+ Q_UNUSED(paramList)
+ return nullptr;
+}
+
+} // namespace Render
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/frontend/qrenderpluginfactoryif_p.h b/src/render/frontend/qrenderpluginfactoryif_p.h
new file mode 100644
index 000000000..d5f0008d2
--- /dev/null
+++ b/src/render/frontend/qrenderpluginfactoryif_p.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DRENDER_RENDER_QRENDERPLUGINFACTORYIF_P_H
+#define QT3DRENDER_RENDER_QRENDERPLUGINFACTORYIF_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qobject.h>
+#include <QtCore/qplugin.h>
+#include <QtCore/qfactoryinterface.h>
+
+#include <private/qt3drender_global_p.h>
+
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+namespace Render {
+
+#define QRenderPluginFactoryInterface_iid "org.qt-project.Qt3DRender.QRenderPluginFactoryInterface 5.9"
+
+class QRenderPlugin;
+
+class QT3DRENDERSHARED_PRIVATE_EXPORT QRenderPluginFactoryIf : public QObject
+{
+ Q_OBJECT
+public:
+ explicit QRenderPluginFactoryIf(QObject *parent = nullptr);
+ ~QRenderPluginFactoryIf();
+
+ virtual QRenderPlugin *create(const QString &key, const QStringList &paramList);
+};
+
+} // namespace Render
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_QRENDERPLUGINFACTORYIF_P_H
diff --git a/src/render/frontend/qrendersettings.cpp b/src/render/frontend/qrendersettings.cpp
index 4fb348617..b73fed77b 100644
--- a/src/render/frontend/qrendersettings.cpp
+++ b/src/render/frontend/qrendersettings.cpp
@@ -73,13 +73,6 @@ namespace Qt3DRender {
\l{Qt 3D Render Framegraph}{FrameGraph}.
*/
-/*!
- \enum QRenderSettings::RenderPolicy
-
- This enum type describes types of render policies available.
- \value Always Always try to render (default)
- \value OnDemand Only render when something changes
-*/
/*! \internal */
QRenderSettingsPrivate::QRenderSettingsPrivate()
diff --git a/src/render/frontend/render-frontend.pri b/src/render/frontend/render-frontend.pri
index 0e78f9cff..75666a270 100644
--- a/src/render/frontend/render-frontend.pri
+++ b/src/render/frontend/render-frontend.pri
@@ -2,8 +2,6 @@ INCLUDEPATH += $$PWD
HEADERS += \
$$PWD/qabstractfunctor.h \
- $$PWD/qboundingsphere.h \
- $$PWD/qboundingsphere_p.h \
$$PWD/qrenderaspect.h \
$$PWD/qrenderaspect_p.h \
$$PWD/qitemmodelbuffer_p.h \
@@ -26,11 +24,14 @@ HEADERS += \
$$PWD/qpickingsettings.h \
$$PWD/qpickingsettings_p.h \
$$PWD/qcomputecommand_p.h \
- $$PWD/qcomputecommand.h
+ $$PWD/qcomputecommand.h \
+ $$PWD/qrenderplugin_p.h \
+ $$PWD/qrenderpluginfactory_p.h \
+ $$PWD/qrenderpluginfactoryif_p.h \
+ $$PWD/qlevelofdetailboundingsphere.h
SOURCES += \
$$PWD/qabstractfunctor.cpp \
- $$PWD/qboundingsphere.cpp \
$$PWD/qrenderaspect.cpp \
$$PWD/qitemmodelbuffer.cpp \
$$PWD/sphere.cpp \
@@ -43,5 +44,8 @@ SOURCES += \
$$PWD/qrendersettings.cpp \
$$PWD/qpickingsettings.cpp \
$$PWD/qrendertargetoutput.cpp \
- $$PWD/qcomputecommand.cpp
+ $$PWD/qcomputecommand.cpp \
+ $$PWD/qrenderpluginfactory.cpp \
+ $$PWD/qrenderpluginfactoryif.cpp \
+ $$PWD/qlevelofdetailboundingsphere.cpp
diff --git a/src/render/frontend/sphere.cpp b/src/render/frontend/sphere.cpp
index 80926efb9..2c22e0da4 100644
--- a/src/render/frontend/sphere.cpp
+++ b/src/render/frontend/sphere.cpp
@@ -223,8 +223,9 @@ Qt3DCore::QNodeId Sphere::id() const
return m_id;
}
-bool Sphere::intersects(const RayCasting::QRay3D &ray, QVector3D *q) const
+bool Sphere::intersects(const RayCasting::QRay3D &ray, QVector3D *q, QVector3D *uvw) const
{
+ Q_UNUSED(uvw);
return intersectRaySphere(ray, *this, q);
}
diff --git a/src/render/frontend/sphere_p.h b/src/render/frontend/sphere_p.h
index 1defbf059..1587aecab 100644
--- a/src/render/frontend/sphere_p.h
+++ b/src/render/frontend/sphere_p.h
@@ -106,7 +106,7 @@ public:
}
Qt3DCore::QNodeId id() const Q_DECL_FINAL;
- bool intersects(const RayCasting::QRay3D &ray, QVector3D *q) const Q_DECL_FINAL;
+ bool intersects(const RayCasting::QRay3D &ray, QVector3D *q, QVector3D *uvw = nullptr) const Q_DECL_FINAL;
Type type() const Q_DECL_FINAL;
static Sphere fromPoints(const QVector<QVector3D> &points);