summaryrefslogtreecommitdiffstats
path: root/src/render
diff options
context:
space:
mode:
Diffstat (limited to 'src/render')
-rw-r--r--src/render/frontend/qcamera.cpp32
-rw-r--r--src/render/frontend/qcameralens.cpp4
-rw-r--r--src/render/geometry/qgeometryrenderer.cpp4
-rw-r--r--src/render/materialsystem/shaderbuilder.cpp4
-rw-r--r--src/render/renderers/opengl/renderer/renderviewbuilder.cpp4
-rw-r--r--src/render/services/vsyncframeadvanceservice.cpp5
6 files changed, 32 insertions, 21 deletions
diff --git a/src/render/frontend/qcamera.cpp b/src/render/frontend/qcamera.cpp
index b0fd16182..4d4e5bf4d 100644
--- a/src/render/frontend/qcamera.cpp
+++ b/src/render/frontend/qcamera.cpp
@@ -227,7 +227,7 @@ void QCameraPrivate::updateViewMatrixAndTransform(bool doEmit)
* 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.
+ * \note Only works if the lens is in perspective or orthographic projection mode.
* \sa Qt3D.Render::Camera::projectionType
*/
@@ -237,7 +237,7 @@ void QCameraPrivate::updateViewMatrixAndTransform(bool doEmit)
* Rotates and moves the camera so that it's viewCenter is the center of the entity's bounding volume
* and the entire \a entity fits in the view port.
*
- * \note Only works if the lens is in perspective projection mode.
+ * \note Only works if the lens is in perspective or orthographic projection mode.
* \sa Qt3D.Render::Camera::projectionType
*/
@@ -247,7 +247,7 @@ void QCameraPrivate::updateViewMatrixAndTransform(bool doEmit)
* 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.
+ * \note Only works if the lens is in perspective or orthographic projection mode.
* \sa Qt3D.Render::Camera::projectionType
*/
@@ -823,7 +823,7 @@ 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.
+ * \note Only works if the lens is in perspective or orthographic projection mode.
* \sa Qt3D.Render::Camera::projectionType
*/
void QCamera::viewAll()
@@ -836,15 +836,31 @@ void QCamera::viewAll()
* 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.
+ * \note Only works if the lens is in perspective or orthographic 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)
+ if ((d->m_lens->projectionType() != QCameraLens::PerspectiveProjection &&
+ d->m_lens->projectionType() != QCameraLens::OrthographicProjection) ||
+ radius <= 0.f)
return;
- double dist = radius / std::tan(qDegreesToRadians(d->m_lens->fieldOfView()) / 2.0f);
+
+ // Ensure the sphere fits in the view port even if aspect ratio < 1 (i.e. width < height)
+ float height = (1.05f * radius) / (d->m_lens->aspectRatio() < 1.0f ? d->m_lens->aspectRatio() : 1.0f);
+ float dist = 1.0f;
+ if (d->m_lens->projectionType() == QCameraLens::PerspectiveProjection) {
+ dist = height / std::sin(qDegreesToRadians(d->m_lens->fieldOfView()) / 2.0f);
+ }
+ else if (d->m_lens->projectionType() == QCameraLens::OrthographicProjection) {
+ d->m_lens->setOrthographicProjection(-height * d->m_lens->aspectRatio(), height * d->m_lens->aspectRatio(), -height, height,
+ nearPlane(), farPlane());
+ dist = height / std::sin(qDegreesToRadians(d->m_lens->fieldOfView()) / 2.0f);
+ }
+ else {
+ dist = (d->m_viewCenter - d->m_position).length();
+ }
QVector3D dir = (d->m_viewCenter - d->m_position).normalized();
QVector3D newPos = center - (dir * dist);
setViewCenter(center);
@@ -855,7 +871,7 @@ void QCamera::viewSphere(const QVector3D &center, float radius)
* Rotates and moves the camera so that it's viewCenter is the center of the
* \a {entity}'s bounding volume and the entire entity fits in the view port.
*
- * \note Only works if the lens is in perspective projection mode.
+ * \note Only works if the lens is in perspective or orthographic projection mode.
* \sa {Qt3D.Render::Camera::projectionType}{Camera.projectionType}
*/
void QCamera::viewEntity(Qt3DCore::QEntity *entity)
diff --git a/src/render/frontend/qcameralens.cpp b/src/render/frontend/qcameralens.cpp
index cf30b714a..868ee9abf 100644
--- a/src/render/frontend/qcameralens.cpp
+++ b/src/render/frontend/qcameralens.cpp
@@ -232,7 +232,7 @@ QCameraLensPrivate::QCameraLensPrivate()
void QCameraLens::viewAll(Qt3DCore::QNodeId cameraId)
{
Q_D(QCameraLens);
- if (d->m_projectionType == PerspectiveProjection) {
+ if (d->m_projectionType == PerspectiveProjection || d->m_projectionType == OrthographicProjection) {
QVariant v;
v.setValue(cameraId);
d->m_pendingViewAllCommand = {QLatin1String("QueryRootBoundingVolume"),
@@ -245,7 +245,7 @@ void QCameraLens::viewAll(Qt3DCore::QNodeId cameraId)
void QCameraLens::viewEntity(Qt3DCore::QNodeId entityId, Qt3DCore::QNodeId cameraId)
{
Q_D(QCameraLens);
- if (d->m_projectionType == PerspectiveProjection) {
+ if (d->m_projectionType == PerspectiveProjection || d->m_projectionType == OrthographicProjection) {
QVector<Qt3DCore::QNodeId> ids = {entityId, cameraId};
QVariant v;
v.setValue(ids);
diff --git a/src/render/geometry/qgeometryrenderer.cpp b/src/render/geometry/qgeometryrenderer.cpp
index 64f3e058e..8720a5c00 100644
--- a/src/render/geometry/qgeometryrenderer.cpp
+++ b/src/render/geometry/qgeometryrenderer.cpp
@@ -149,7 +149,7 @@ QGeometryRendererPrivate::~QGeometryRendererPrivate()
*/
/*!
- \qmlproperty int GeometryRenderer::restartIndex
+ \qmlproperty int GeometryRenderer::restartIndexValue
Holds the restart index.
*/
@@ -161,7 +161,7 @@ QGeometryRendererPrivate::~QGeometryRendererPrivate()
*/
/*!
- \qmlproperty bool GeometryRenderer::primitiveRestart
+ \qmlproperty bool GeometryRenderer::primitiveRestartEnabled
Holds the primitive restart flag.
*/
diff --git a/src/render/materialsystem/shaderbuilder.cpp b/src/render/materialsystem/shaderbuilder.cpp
index 23f1400c9..7434cd901 100644
--- a/src/render/materialsystem/shaderbuilder.cpp
+++ b/src/render/materialsystem/shaderbuilder.cpp
@@ -278,7 +278,7 @@ void ShaderBuilder::syncFromFrontEnd(const QNode *frontEnd, bool firstTime)
markDirty(AbstractRenderer::ShadersDirty);
}
- static const std::pair<QShaderProgram::ShaderType, QUrl (QShaderProgramBuilder::*)() const> shaderTypesToGetters[] = {
+ static const QVector<std::pair<QShaderProgram::ShaderType, QUrl (QShaderProgramBuilder::*)() const>> shaderTypesToGetters = {
{QShaderProgram::Vertex, &QShaderProgramBuilder::vertexShaderGraph},
{QShaderProgram::TessellationControl, &QShaderProgramBuilder::tessellationControlShaderGraph},
{QShaderProgram::TessellationEvaluation, &QShaderProgramBuilder::tessellationEvaluationShaderGraph},
@@ -287,7 +287,7 @@ void ShaderBuilder::syncFromFrontEnd(const QNode *frontEnd, bool firstTime)
{QShaderProgram::Compute, &QShaderProgramBuilder::computeShaderGraph},
};
- for (auto it = std::cbegin(shaderTypesToGetters), end = std::cend(shaderTypesToGetters); it != end; ++it) {
+ for (auto it = shaderTypesToGetters.cbegin(), end = shaderTypesToGetters.cend(); it != end; ++it) {
const QUrl url = (node->*(it->second))();
if (url != m_graphs.value(it->first)) {
setShaderGraph(it->first, url);
diff --git a/src/render/renderers/opengl/renderer/renderviewbuilder.cpp b/src/render/renderers/opengl/renderer/renderviewbuilder.cpp
index 8f1b17119..4034af146 100644
--- a/src/render/renderers/opengl/renderer/renderviewbuilder.cpp
+++ b/src/render/renderers/opengl/renderer/renderviewbuilder.cpp
@@ -326,8 +326,8 @@ public:
filteredCommandData->reserve(renderableEntities.size());
// Because dataCacheForLeaf.renderableEntities or computeEntities are sorted
// What we get out of EntityRenderCommandData is also sorted by Entity
- auto eIt = std::cbegin(renderableEntities);
- const auto eEnd = std::cend(renderableEntities);
+ auto eIt = renderableEntities.cbegin();
+ const auto eEnd = renderableEntities.cend();
int cIt = 0;
const int cEnd = commandData.size();
diff --git a/src/render/services/vsyncframeadvanceservice.cpp b/src/render/services/vsyncframeadvanceservice.cpp
index d7398e2ce..662c12e4e 100644
--- a/src/render/services/vsyncframeadvanceservice.cpp
+++ b/src/render/services/vsyncframeadvanceservice.cpp
@@ -80,12 +80,7 @@ qint64 VSyncFrameAdvanceService::waitForNextFrame()
{
Q_D(VSyncFrameAdvanceService);
-#ifdef Q_OS_MACOS
- if (!d->m_semaphore.tryAcquire(std::max(d->m_semaphore.available(), 1), 4))
- return -1;
-#else
d->m_semaphore.acquire(std::max(d->m_semaphore.available(), 1));
-#endif
const qint64 currentTime = d->m_elapsed.nsecsElapsed();
qCDebug(VSyncAdvanceService) << "Elapsed nsecs since last call " << currentTime - d->m_elapsedTimeSincePreviousFrame;