diff options
25 files changed, 217 insertions, 197 deletions
diff --git a/src/animation/frontend/qabstractclipanimator.cpp b/src/animation/frontend/qabstractclipanimator.cpp index d72085b6e..78ad01508 100644 --- a/src/animation/frontend/qabstractclipanimator.cpp +++ b/src/animation/frontend/qabstractclipanimator.cpp @@ -150,7 +150,7 @@ QChannelMapper *QAbstractClipAnimator::channelMapper() const } /*! - \qmlproperty int QAbstractClipAnimator::loops + \qmlproperty int AbstractClipAnimator::loops This property holds the number of times the animation should play. diff --git a/src/extras/3dtext/qextrudedtextgeometry.cpp b/src/extras/3dtext/qextrudedtextgeometry.cpp index 4a460bfc7..c4c4ba77f 100644 --- a/src/extras/3dtext/qextrudedtextgeometry.cpp +++ b/src/extras/3dtext/qextrudedtextgeometry.cpp @@ -433,7 +433,7 @@ void QExtrudedTextGeometry::setDepth(float depth) } /*! - * \property QString QExtrudedTextGeometry::text + * \property QExtrudedTextGeometry::text * * Holds the text used for the mesh. */ @@ -444,7 +444,7 @@ QString QExtrudedTextGeometry::text() const } /*! - * \property QFont QExtrudedTextGeometry::font + * \property QExtrudedTextGeometry::font * * Holds the font of the text. */ @@ -455,7 +455,7 @@ QFont QExtrudedTextGeometry::font() const } /*! - * \property float QExtrudedTextGeometry::extrusionLength + * \property QExtrudedTextGeometry::extrusionLength * * Holds the extrusion length of the text. */ @@ -477,7 +477,7 @@ Qt3DRender::QAttribute *QExtrudedTextGeometry::positionAttribute() const } /*! - * \property QExtrudedTextMesh::normalAttribute + * \property QExtrudedTextGeometry::normalAttribute * * Holds the geometry normal attribute. */ @@ -488,7 +488,7 @@ Qt3DRender::QAttribute *QExtrudedTextGeometry::normalAttribute() const } /*! - * \property QExtrudedTextMesh::indexAttribute + * \property QExtrudedTextGeometry::indexAttribute * * Holds the geometry index attribute. */ diff --git a/src/extras/3dtext/qextrudedtextmesh.cpp b/src/extras/3dtext/qextrudedtextmesh.cpp index 9d1dc7359..0c3394dea 100644 --- a/src/extras/3dtext/qextrudedtextmesh.cpp +++ b/src/extras/3dtext/qextrudedtextmesh.cpp @@ -63,19 +63,19 @@ namespace Qt3DExtras { */ /*! - * \qmlproperty QString ExtrudedTextMesh::text + * \qmlproperty QString Qt3DExtras::ExtrudedTextMesh::text * * Holds the text used for the mesh. */ /*! - * \qmlproperty QFont ExtrudedTextMesh::font + * \qmlproperty QFont Qt3DExtras::ExtrudedTextMesh::font * * Holds the font of the text. */ /*! - * \qmlproperty float ExtrudedTextMesh::depth + * \qmlproperty float Qt3DExtras::ExtrudedTextMesh::depth * * Holds the extrusion depth of the text. */ @@ -123,7 +123,7 @@ void QExtrudedTextMesh::setDepth(float depth) } /*! - * \property QString QExtrudedTextMesh::text + * \property QExtrudedTextMesh::text * * Holds the text used for the mesh. */ @@ -133,7 +133,7 @@ QString QExtrudedTextMesh::text() const } /*! - * \property QFont QExtrudedTextMesh::font + * \property QExtrudedTextMesh::font * * Holds the font of the text. */ @@ -143,7 +143,7 @@ QFont QExtrudedTextMesh::font() const } /*! - * \property float QExtrudedTextMesh::depth + * \property QExtrudedTextMesh::depth * * Holds the extrusion depth of the text. */ diff --git a/src/extras/defaults/qforwardrenderer.cpp b/src/extras/defaults/qforwardrenderer.cpp index 3a5c6803b..f3137ea2d 100644 --- a/src/extras/defaults/qforwardrenderer.cpp +++ b/src/extras/defaults/qforwardrenderer.cpp @@ -270,6 +270,13 @@ QObject *QForwardRenderer::surface() const return d->m_surfaceSelector->surface(); } +/*! + \property QForwardRenderer::externalRenderTargetSize + + Contains the size of the external render target. External render + targets are relevant when rendering does not target a window + surface (as set in \l {QForwardRenderer::surface()}{surface()}). +*/ QSize QForwardRenderer::externalRenderTargetSize() const { Q_D(const QForwardRenderer); diff --git a/src/extras/defaults/qmorphphongmaterial.cpp b/src/extras/defaults/qmorphphongmaterial.cpp index 22f520de5..4b22e8765 100644 --- a/src/extras/defaults/qmorphphongmaterial.cpp +++ b/src/extras/defaults/qmorphphongmaterial.cpp @@ -250,6 +250,11 @@ float QMorphPhongMaterial::shininess() const return d->m_shininessParameter->value().toFloat(); } +/*! + \property QMorphPhongMaterial::interpolator + + Contains the interpolation method of the Phong lighting effect. +*/ float QMorphPhongMaterial::interpolator() const { Q_D(const QMorphPhongMaterial); diff --git a/src/extras/defaults/qskyboxentity.cpp b/src/extras/defaults/qskyboxentity.cpp index 3c7b0dd4e..202ba4fcb 100644 --- a/src/extras/defaults/qskyboxentity.cpp +++ b/src/extras/defaults/qskyboxentity.cpp @@ -256,7 +256,12 @@ void QSkyboxEntity::setBaseName(const QString &baseName) } } /*! - * Returns the base name. + \property QSkyboxEntity::baseName + + Contains the base name of the Skybox. +*/ +/*! + * Returns the base name of the Skybox. */ QString QSkyboxEntity::baseName() const { @@ -278,6 +283,11 @@ void QSkyboxEntity::setExtension(const QString &extension) } /*! + \property QSkyboxEntity::extension + + Contains the extension of the Skybox. +*/ +/*! * Returns the extension */ QString QSkyboxEntity::extension() const @@ -311,4 +321,9 @@ bool QSkyboxEntity::isGammaCorrectEnabled() const } // namespace Qt3DExtras +/*! + \property QSkyboxEntity::gammaCorrect + + A boolean indicating whether gamma correction is enabled. +*/ QT_END_NAMESPACE diff --git a/src/extras/shaders/es2/light.inc.frag b/src/extras/shaders/es2/light.inc.frag index 074af5799..57a30036f 100644 --- a/src/extras/shaders/es2/light.inc.frag +++ b/src/extras/shaders/es2/light.inc.frag @@ -27,7 +27,9 @@ void adsModelNormalMapped(const in FP vec3 vpos, const in FP vec3 vnormal, const FP vec3 s, ts; Light light; - for (int i = 0; i < lightCount; ++i) { + for (int i = 0; i < MAX_LIGHTS; ++i) { + if (i >= lightCount) // Make brcm happy with the for loop + break; if (i == 0) light = lights[0]; else if (i == 1) @@ -94,7 +96,9 @@ void adsModel(const in FP vec3 vpos, const in FP vec3 vnormal, const in FP vec3 FP vec3 s; Light light; - for (int i = 0; i < lightCount; ++i) { + for (int i = 0; i < MAX_LIGHTS; ++i) { + if (i >= lightCount) // Make brcm happy with the for loop + break; if (i == 0) light = lights[0]; else if (i == 1) @@ -151,7 +155,9 @@ void adModel(const in FP vec3 vpos, const in FP vec3 vnormal, out FP vec3 diffus FP vec3 s; Light light; - for (int i = 0; i < lightCount; ++i) { + for (int i = 0; i < MAX_LIGHTS; ++i) { + if (i >= lightCount) // Make brcm happy with the for loop + break; if (i == 0) light = lights[0]; else if (i == 1) diff --git a/src/input/frontend/qaxisaccumulator.cpp b/src/input/frontend/qaxisaccumulator.cpp index d656ad2de..0c156194b 100644 --- a/src/input/frontend/qaxisaccumulator.cpp +++ b/src/input/frontend/qaxisaccumulator.cpp @@ -190,6 +190,7 @@ QAxisAccumulator::SourceAxisType QAxisAccumulator::sourceAxisType() const */ /*! + \property Qt3DInput::QAxisAccumulator::value Returns the accumulated (integrated) value. */ float QAxisAccumulator::value() const diff --git a/src/input/frontend/qmousedevice.cpp b/src/input/frontend/qmousedevice.cpp index b5123533f..4a78b3b21 100644 --- a/src/input/frontend/qmousedevice.cpp +++ b/src/input/frontend/qmousedevice.cpp @@ -183,6 +183,11 @@ int QMouseDevice::axisIdentifier(const QString &name) const return -1; } +/*! + Returns the button identifier that corresponds with + the specified \a name. The possible return values are + documented in \l {Qt3DInput::}{QMouseEvent::Buttons}. +*/ int QMouseDevice::buttonIdentifier(const QString &name) const { if (name == QLatin1String("Left")) diff --git a/src/input/frontend/qmousehandler.cpp b/src/input/frontend/qmousehandler.cpp index 61708425a..9f30810a9 100644 --- a/src/input/frontend/qmousehandler.cpp +++ b/src/input/frontend/qmousehandler.cpp @@ -69,6 +69,11 @@ QMouseHandlerPrivate::~QMouseHandlerPrivate() { } +void QMouseHandlerPrivate::init(QObject *parent) +{ + m_pressAndHoldTimer->setParent(parent); +} + void QMouseHandlerPrivate::mouseEvent(const QMouseEventPtr &event) { Q_Q(QMouseHandler); @@ -259,6 +264,8 @@ void QMouseHandlerPrivate::mouseEvent(const QMouseEventPtr &event) QMouseHandler::QMouseHandler(QNode *parent) : QComponent(*new QMouseHandlerPrivate, parent) { + Q_D(QMouseHandler); + d->init(this); } QMouseHandler::~QMouseHandler() diff --git a/src/input/frontend/qmousehandler_p.h b/src/input/frontend/qmousehandler_p.h index bb82334a0..3b2f2284d 100644 --- a/src/input/frontend/qmousehandler_p.h +++ b/src/input/frontend/qmousehandler_p.h @@ -70,6 +70,8 @@ public: QMouseHandlerPrivate(); ~QMouseHandlerPrivate(); + void init(QObject *parent); + QMouseDevice *m_mouseDevice; bool m_containsMouse; QScopedPointer<QTimer> m_pressAndHoldTimer; diff --git a/src/input/frontend/qphysicaldevicecreatedchange.cpp b/src/input/frontend/qphysicaldevicecreatedchange.cpp index 51aa3449a..0abeea520 100644 --- a/src/input/frontend/qphysicaldevicecreatedchange.cpp +++ b/src/input/frontend/qphysicaldevicecreatedchange.cpp @@ -68,6 +68,9 @@ QPhysicalDeviceCreatedChangeBase::~QPhysicalDeviceCreatedChangeBase() { } +/*! + Returns a list of node ids. +*/ Qt3DCore::QNodeIdVector QPhysicalDeviceCreatedChangeBase::axisSettingIds() const { Q_D(const QPhysicalDeviceCreatedChangeBase); diff --git a/src/plugins/sceneparsers/assimp/assimpimporter.cpp b/src/plugins/sceneparsers/assimp/assimpimporter.cpp index a2f500a6c..ae395a59f 100644 --- a/src/plugins/sceneparsers/assimp/assimpimporter.cpp +++ b/src/plugins/sceneparsers/assimp/assimpimporter.cpp @@ -492,14 +492,11 @@ Qt3DCore::QEntity *AssimpImporter::node(aiNode *node) // Add Meshes to the node for (uint i = 0; i < node->mNumMeshes; i++) { - uint meshIdx = node->mMeshes[i]; - QMaterial *material = nullptr; - QGeometryRenderer *mesh = m_scene->m_meshes[meshIdx]; - // mesh material - uint materialIndex = m_scene->m_aiScene->mMeshes[meshIdx]->mMaterialIndex; + uint meshIndex = node->mMeshes[i]; + QGeometryRenderer *mesh = loadMesh(meshIndex); - if (m_scene->m_materials.contains(materialIndex)) - material = m_scene->m_materials[materialIndex]; + // mesh material + QMaterial *material; QList<Qt3DAnimation::QMorphingAnimation *> morphingAnimations = mesh->findChildren<Qt3DAnimation::QMorphingAnimation *>(); @@ -523,6 +520,9 @@ Qt3DCore::QEntity *AssimpImporter::node(aiNode *node) &Qt3DExtras::QMorphPhongMaterial::setInterpolator); } morphingAnimations[0]->deleteLater(); + } else { + uint materialIndex = m_scene->m_aiScene->mMeshes[meshIndex]->mMaterialIndex; + material = loadMaterial(materialIndex); } if (node->mNumMeshes == 1) { @@ -570,8 +570,9 @@ Qt3DCore::QEntity *AssimpImporter::node(aiNode *node) } // Add Camera - if (m_scene->m_cameras.contains(node)) - m_scene->m_cameras[node]->setParent(entityNode); + auto camera = loadCamera(node); + if (camera) + camera->setParent(entityNode); // TO DO : Add lights .... @@ -658,16 +659,6 @@ void AssimpImporter::parse() // Set parsed flags m_sceneParsed = !m_sceneParsed; - for (uint i = 0; i < m_scene->m_aiScene->mNumTextures; i++) - loadEmbeddedTexture(i); - for (uint i = 0; i < m_scene->m_aiScene->mNumMaterials; i++) - loadMaterial(i); - for (uint i = 0; i < m_scene->m_aiScene->mNumMeshes; i++) - loadMesh(i); - for (uint i = 0; i < m_scene->m_aiScene->mNumCameras; i++) - loadCamera(i); - for (uint i = 0; i < m_scene->m_aiScene->mNumLights; i++) - loadLight(i); for (uint i = 0; i < m_scene->m_aiScene->mNumAnimations; i++) loadAnimation(i); } @@ -675,10 +666,10 @@ void AssimpImporter::parse() /*! * Converts the provided Assimp aiMaterial identified by \a materialIndex to a - * Qt3D material and adds it to a dictionary of materials. + * Qt3D material * \sa Material */ -void AssimpImporter::loadMaterial(uint materialIndex) +QMaterial *AssimpImporter::loadMaterial(uint materialIndex) { // Generates default material based on what the assimp material contains aiMaterial *assimpMaterial = m_scene->m_aiScene->mMaterials[materialIndex]; @@ -692,22 +683,14 @@ void AssimpImporter::loadMaterial(uint materialIndex) // Add textures to materials dict copyMaterialTextures(material, assimpMaterial); - m_scene->m_materials.insert(materialIndex, material); - - Qt3DRender::AssimpImporter::SceneImporter *scene = m_scene; - QObject::connect(material, &QObject::destroyed, [&, scene, materialIndex](QObject *object) { - QMaterial *r = static_cast<QMaterial *>(object); - if (scene->m_materials[materialIndex] == r) - scene->m_materials.remove(materialIndex); - }); + return material; } /*! * Converts the Assimp aiMesh mesh identified by \a meshIndex to a QGeometryRenderer - * and adds it to a dictionary of meshes. * \sa QGeometryRenderer */ -void AssimpImporter::loadMesh(uint meshIndex) +QGeometryRenderer *AssimpImporter::loadMesh(uint meshIndex) { aiMesh *mesh = m_scene->m_aiScene->mMeshes[meshIndex]; @@ -849,21 +832,12 @@ void AssimpImporter::loadMesh(uint meshIndex) meshGeometry->addAttribute(indexAttribute); - m_scene->m_meshes[meshIndex] = geometryRenderer; - - Qt3DRender::AssimpImporter::SceneImporter *scene = m_scene; - QObject::connect(geometryRenderer, &QObject::destroyed, [&, scene, meshIndex](QObject *object) { - QGeometryRenderer *r = static_cast<QGeometryRenderer *>(object); - if (scene->m_meshes[meshIndex] == r) - scene->m_meshes.remove(meshIndex); - }); - if (mesh->mNumAnimMeshes > 0) { aiAnimMesh *animesh = mesh->mAnimMeshes[0]; if (animesh->mNumVertices != mesh->mNumVertices) - return; + return geometryRenderer; Qt3DAnimation::QMorphingAnimation *morphingAnimation = new Qt3DAnimation::QMorphingAnimation(geometryRenderer); @@ -988,14 +962,15 @@ void AssimpImporter::loadMesh(uint meshIndex) qCDebug(AssimpImporterLog) << Q_FUNC_INFO << " Mesh " << aiStringToQString(mesh->mName) << " Vertices " << mesh->mNumVertices << " Faces " << mesh->mNumFaces << " Indices " << indices; + + return geometryRenderer; } /*! - * Converts the provided Assimp aiTexture at \a textureIndex to a Texture and - * adds it to a dictionary of textures. + * Converts the provided Assimp aiTexture at \a textureIndex to a Texture * \sa Texture */ -void AssimpImporter::loadEmbeddedTexture(uint textureIndex) +QAbstractTexture *AssimpImporter::loadEmbeddedTexture(uint textureIndex) { aiTexture *assimpTexture = m_scene->m_aiScene->mTextures[textureIndex]; QAbstractTexture *texture = QAbstractNodeFactory::createNode<QTexture2D>("QTexture2D"); @@ -1017,37 +992,38 @@ void AssimpImporter::loadEmbeddedTexture(uint textureIndex) } imageData->setData(textureContent); texture->addTextureImage(imageData); - m_scene->m_embeddedTextures[textureIndex] = texture; - - Qt3DRender::AssimpImporter::SceneImporter *scene = m_scene; - QObject::connect(texture, &QObject::destroyed, [&, scene, textureIndex](QObject *object) { - QAbstractTexture *r = static_cast<QAbstractTexture *>(object); - if (scene->m_embeddedTextures[textureIndex] == r) - scene->m_embeddedTextures.remove(textureIndex); - }); + + return texture; } /*! * Loads the light in the current scene located at \a lightIndex. */ -void AssimpImporter::loadLight(uint lightIndex) +QAbstractLight *AssimpImporter::loadLight(uint lightIndex) { aiLight *light = m_scene->m_aiScene->mLights[lightIndex]; // TODO: Implement me! Q_UNUSED(light); + return nullptr; } /*! - * Parses the camera at cameraIndex and saves it to a dictionary of cameras. + * Converts the provided Assimp aiCamera in a node to a camera entity */ -void AssimpImporter::loadCamera(uint cameraIndex) +Qt3DCore::QEntity *AssimpImporter::loadCamera(aiNode *node) { - aiCamera *assimpCamera = m_scene->m_aiScene->mCameras[cameraIndex]; - aiNode *cameraNode = m_scene->m_aiScene->mRootNode->FindNode(assimpCamera->mName); + aiCamera *assimpCamera = nullptr; - // If no node is associated to the camera in the scene, camera not saved - if (cameraNode == nullptr) - return ; + for (uint i = 0; i < m_scene->m_aiScene->mNumCameras; ++i) { + auto camera = m_scene->m_aiScene->mCameras[i]; + if (camera->mName == node->mName) { + assimpCamera = camera; + break; + } + } + + if (assimpCamera == nullptr) + return nullptr; QEntity *camera = QAbstractNodeFactory::createNode<Qt3DCore::QEntity>("QEntity"); QCameraLens *lens = QAbstractNodeFactory::createNode<QCameraLens>("QCameraLens"); @@ -1067,14 +1043,7 @@ void AssimpImporter::loadCamera(uint cameraIndex) transform->setMatrix(m); camera->addComponent(transform); - m_scene->m_cameras[cameraNode] = camera; - - Qt3DRender::AssimpImporter::SceneImporter *scene = m_scene; - QObject::connect(camera, &QObject::destroyed, [&, scene, cameraNode](QObject *object) { - QEntity *r = static_cast<QEntity *>(object); - if (scene->m_cameras[cameraNode] == r) - scene->m_cameras.remove(cameraNode); - }); + return camera; } int findTimeIndex(const QVector<float> ×, float time) { @@ -1410,10 +1379,6 @@ AssimpImporter::SceneImporter::SceneImporter() AssimpImporter::SceneImporter::~SceneImporter() { delete m_importer; - qDeleteAll(m_materials.values()); - qDeleteAll(m_meshes.values()); - qDeleteAll(m_embeddedTextures.values()); - qDeleteAll(m_cameras.values()); } } // namespace Qt3DRender diff --git a/src/plugins/sceneparsers/assimp/assimpimporter.h b/src/plugins/sceneparsers/assimp/assimpimporter.h index 3c0a41124..068f6eed2 100644 --- a/src/plugins/sceneparsers/assimp/assimpimporter.h +++ b/src/plugins/sceneparsers/assimp/assimpimporter.h @@ -82,10 +82,8 @@ class QMorphingAnimation; namespace Qt3DRender { class QMaterial; -class QShaderProgram; -class QEffect; class QAbstractTexture; -class QMesh; +class QAbstractLight; class QGeometryRenderer; Q_DECLARE_LOGGING_CATEGORY(AssimpImporterLog) @@ -117,11 +115,11 @@ private: void cleanup(); void parse(); - void loadMaterial(uint materialIndex); - void loadMesh(uint meshIndex); - void loadEmbeddedTexture(uint textureIndex); - void loadLight(uint lightIndex); - void loadCamera(uint cameraIndex); + QMaterial *loadMaterial(uint materialIndex); + QGeometryRenderer *loadMesh(uint meshIndex); + QAbstractTexture *loadEmbeddedTexture(uint textureIndex); + QAbstractLight *loadLight(uint lightIndex); + Qt3DCore::QEntity *loadCamera(aiNode *node); void loadAnimation(uint animationIndex); void copyMaterialName(QMaterial *material, aiMaterial *assimpMaterial); @@ -141,11 +139,7 @@ private: Assimp::Importer *m_importer; mutable const aiScene *m_aiScene; - QMap<uint, QGeometryRenderer *> m_meshes; - QMap<uint, QMaterial*> m_materials; - QMap<uint, QEffect *> m_effects; QMap<uint, QAbstractTexture *> m_embeddedTextures; - QMap<aiNode*, Qt3DCore::QEntity*> m_cameras; QHash<aiTextureType, QString> m_textureToParameterName; QVector<Qt3DAnimation::QKeyframeAnimation *> m_animations; QVector<Qt3DAnimation::QMorphingAnimation *> m_morphAnimations; diff --git a/src/render/backend/openglvertexarrayobject.cpp b/src/render/backend/openglvertexarrayobject.cpp index eefc208d5..c0fdd8e65 100644 --- a/src/render/backend/openglvertexarrayobject.cpp +++ b/src/render/backend/openglvertexarrayobject.cpp @@ -101,8 +101,10 @@ void OpenGLVertexArrayObject::create(GraphicsContext *ctx, const VAOIdentifier & m_ctx = ctx; m_supportsVao = m_ctx->supportsVAO(); - m_vao.reset(m_supportsVao ? new QOpenGLVertexArrayObject() : nullptr); - m_vao->create(); + if (m_supportsVao) { + m_vao.reset(new QOpenGLVertexArrayObject()); + m_vao->create(); + } m_owners = key; } diff --git a/src/render/frontend/qcamera_p.h b/src/render/frontend/qcamera_p.h index a310fc765..2ef53818c 100644 --- a/src/render/frontend/qcamera_p.h +++ b/src/render/frontend/qcamera_p.h @@ -69,8 +69,6 @@ public: void updateViewMatrix() { - if (m_upVector.isNull() || QVector3D::crossProduct(m_cameraToCenter, m_upVector).normalized().isNull()) - qWarning() << "Camera up vector must not be colinear with the view vector"; QMatrix4x4 m; m.lookAt(m_position, m_viewCenter, m_upVector); m_transform->setMatrix(m); diff --git a/src/render/geometry/qgeometry.cpp b/src/render/geometry/qgeometry.cpp index 3d281866d..cf5ae70ef 100644 --- a/src/render/geometry/qgeometry.cpp +++ b/src/render/geometry/qgeometry.cpp @@ -128,6 +128,17 @@ QGeometry::QGeometry(QNode *parent) : QGeometry(*new QGeometryPrivate(), parent) {} /*! + \fn QGeometryFactory::operator()() + + Returns the generated geometry. +*/ +/*! + \fn bool QGeometryFactory::operator==(const QGeometryFactory &other) const = 0 + + Compares the factory with the factory specified in \a other. + Returns true if they are equal. +*/ +/*! \internal */ QGeometry::~QGeometry() @@ -143,6 +154,7 @@ QGeometry::QGeometry(QGeometryPrivate &dd, QNode *parent) } /*! + \fn void Qt3DRender::QGeometry::addAttribute(Qt3DRender::QAttribute *attribute) Adds an \a attribute to this geometry. */ void QGeometry::addAttribute(QAttribute *attribute) @@ -171,6 +183,12 @@ void QGeometry::addAttribute(QAttribute *attribute) } /*! + \fn Qt3DRender::QGeometry(QGeometryPrivate &dd, Qt3DCore::QNode *parent) + + \internal +*/ +/*! + \fn void Qt3DRender::QGeometry::removeAttribute(Qt3DRender::QAttribute *attribute) Removes the given \a attribute from this geometry. */ void QGeometry::removeAttribute(QAttribute *attribute) diff --git a/src/render/graphicshelpers/graphicscontext.cpp b/src/render/graphicshelpers/graphicscontext.cpp index 59b2155d1..37182a0ba 100644 --- a/src/render/graphicshelpers/graphicscontext.cpp +++ b/src/render/graphicshelpers/graphicscontext.cpp @@ -1261,7 +1261,14 @@ void GraphicsContext::setParameters(ShaderParameterPack ¶meterPack) for (const ShaderUniform &uniform : activeUniforms) { // We can use [] as we are sure the the uniform wouldn't // be un activeUniforms if there wasn't a matching value - applyUniform(uniform, values[uniform.m_nameId]); + const auto &v = values[uniform.m_nameId]; + + // skip invalid textures + if (v.valueType() == UniformValue::TextureValue && + v.constData<UniformValue::Texture>()->textureId == -1) + continue; + + applyUniform(uniform, v); } } diff --git a/src/render/lights/qabstractlight.cpp b/src/render/lights/qabstractlight.cpp index a826654c7..e5376f712 100644 --- a/src/render/lights/qabstractlight.cpp +++ b/src/render/lights/qabstractlight.cpp @@ -53,15 +53,6 @@ namespace Qt3DRender * \since 5.6 */ -/*! - \enum QAbstractLight::Type - - This enum type identifies the particular type of light. - \value PointLight - \value DirectionalLight - \value SpotLight -*/ - QAbstractLightPrivate::QAbstractLightPrivate(QAbstractLight::Type type) : m_type(type) , m_shaderData(new QShaderData) @@ -75,6 +66,20 @@ QAbstractLightPrivate::~QAbstractLightPrivate() { } +/*! + \property Qt3DRender::QAbstractLight::type + + Contains the type of light. +*/ +/*! + \enum Qt3DRender::QAbstractLight::Type + + Identifies the particular type of light. + + \value PointLight + \value DirectionalLight + \value SpotLight +*/ Qt3DCore::QNodeCreatedChangeBasePtr QAbstractLight::createNodeCreationChange() const { auto creationChange = Qt3DCore::QNodeCreatedChangePtr<QAbstractLightData>::create(this); @@ -104,8 +109,6 @@ QAbstractLight::~QAbstractLight() } /*! - \property Qt3DRender::QAbstractLight::type - Holds the current QAbstractLight type. */ QAbstractLight::Type QAbstractLight::type() const diff --git a/src/render/lights/qspotlight.cpp b/src/render/lights/qspotlight.cpp index 81c18387b..09335d432 100644 --- a/src/render/lights/qspotlight.cpp +++ b/src/render/lights/qspotlight.cpp @@ -116,6 +116,12 @@ QSpotLight::QSpotLight(QSpotLightPrivate &dd, QNode *parent) } /*! + \fn QVector3D Qt3DRender::QSpotLight::attenuation() const + + Returns the attenuation of the spot light. +*/ + +/*! \qmlproperty float Qt3D.Render::SpotLight::constantAttenuation Specifies the constant attenuation of the spot light */ diff --git a/src/render/materialsystem/qshaderprogram.cpp b/src/render/materialsystem/qshaderprogram.cpp index 2a65d257c..e6f9631d0 100644 --- a/src/render/materialsystem/qshaderprogram.cpp +++ b/src/render/materialsystem/qshaderprogram.cpp @@ -81,7 +81,7 @@ */ /*! - \enum QShaderProgram::ShaderStatus + \enum QShaderProgram::Status This enum identifies the status of shader used. @@ -137,6 +137,9 @@ QShaderProgram::QShaderProgram(QShaderProgramPrivate &dd, QNode *parent) { } +/*! + Posts a scene change with parameter \a change. +*/ void QShaderProgram::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) { Q_D(QShaderProgram); @@ -381,6 +384,9 @@ QString QShaderProgram::log() const Holds the status of the current shader program. */ +/*! + Returns the status of the current shader program. +*/ QShaderProgram::Status QShaderProgram::status() const { Q_D(const QShaderProgram); diff --git a/src/render/picking/pickeventfilter.cpp b/src/render/picking/pickeventfilter.cpp index 19d3b6b6e..297911e45 100644 --- a/src/render/picking/pickeventfilter.cpp +++ b/src/render/picking/pickeventfilter.cpp @@ -40,6 +40,7 @@ #include "pickeventfilter_p.h" #include <QtCore/QMutexLocker> +#include <QtGui/QHoverEvent> QT_BEGIN_NAMESPACE @@ -87,11 +88,17 @@ bool PickEventFilter::eventFilter(QObject *obj, QEvent *e) switch (e->type()) { case QEvent::MouseButtonPress: case QEvent::MouseButtonRelease: - case QEvent::MouseMove: - case QEvent::HoverMove: { + case QEvent::MouseMove: { QMutexLocker locker(&m_mutex); m_pendingMouseEvents.push_back(QMouseEvent(*static_cast<QMouseEvent *>(e))); } break; + case QEvent::HoverMove: { + QMutexLocker locker(&m_mutex); + QHoverEvent *he = static_cast<QHoverEvent *>(e); + m_pendingMouseEvents.push_back(QMouseEvent(QEvent::MouseMove, + he->pos(), Qt::NoButton, Qt::NoButton, + he->modifiers())); + } break; case QEvent::KeyPress: case QEvent::KeyRelease: { QMutexLocker locker(&m_mutex); diff --git a/src/render/picking/qpicktriangleevent.cpp b/src/render/picking/qpicktriangleevent.cpp index 2a4cdfea2..cde7a4952 100644 --- a/src/render/picking/qpicktriangleevent.cpp +++ b/src/render/picking/qpicktriangleevent.cpp @@ -236,6 +236,13 @@ uint QPickTriangleEvent::vertex3Index() const return d->m_vertex3Index; } +/*! + \property Qt3DRender::QPickTriangleEvent::uvw + +*/ +/*! + Returns the 3D coordinates u,v, and w. +*/ QVector3D QPickTriangleEvent::uvw() const { Q_D(const QPickTriangleEvent); diff --git a/src/render/texture/gltexture.cpp b/src/render/texture/gltexture.cpp index 340034dcb..fae7fb487 100644 --- a/src/render/texture/gltexture.cpp +++ b/src/render/texture/gltexture.cpp @@ -182,6 +182,10 @@ QOpenGLTexture* GLTexture::getOrCreateGLTexture() } } + // don't try to create the texture if the format was not set + if (m_properties.format == QAbstractTexture::Automatic) + return nullptr; + if (texturedDataInvalid) return nullptr; diff --git a/tests/auto/render/vsyncframeadvanceservice/tst_vsyncframeadvanceservice.cpp b/tests/auto/render/vsyncframeadvanceservice/tst_vsyncframeadvanceservice.cpp index 6f455ea56..c35473111 100644 --- a/tests/auto/render/vsyncframeadvanceservice/tst_vsyncframeadvanceservice.cpp +++ b/tests/auto/render/vsyncframeadvanceservice/tst_vsyncframeadvanceservice.cpp @@ -35,76 +35,49 @@ class FakeRenderThread Q_DECL_FINAL : public QThread public: FakeRenderThread(Qt3DRender::Render::VSyncFrameAdvanceService *tickService) : m_tickService(tickService) + , m_running(1) + , m_submitCount(0) { } - // QThread interface -protected: - void run() Q_DECL_FINAL - { - QThread::msleep(1000); - m_tickService->proceedToNextFrame(); - } - -private: - Qt3DRender::Render::VSyncFrameAdvanceService *m_tickService; -}; - -class FakeAspectThread Q_DECL_FINAL : public QThread -{ -public: - FakeAspectThread(Qt3DRender::Render::VSyncFrameAdvanceService *tickService) - : m_tickService(tickService) - , m_count(0) - , m_running(true) - , m_waitForStarted(0) - { - } - - int count() const { return m_count; } + int submitCount() const { return m_submitCount; } void stopRunning() { - QMutexLocker lock(&m_mutex); - m_running = false; + m_running.fetchAndStoreOrdered(0); + m_submitSemaphore.release(1); } - void waitForStarted() + void enqueueRenderView() { - m_waitForStarted.acquire(1); + m_submitSemaphore.release(1); } protected: // QThread interface void run() Q_DECL_FINAL { - m_waitForStarted.release(1); - while (true) { - - bool running = true; - { - QMutexLocker lock(&m_mutex); - running = m_running; - } - - if (!running) { - qDebug() << "exiting"; - return; - } - - m_tickService->waitForNextFrame(); - ++m_count; + m_tickService->proceedToNextFrame(); - QThread::msleep(100); + while (true) { + if (!isReadyToSubmit()) + break; + ++m_submitCount; + m_tickService->proceedToNextFrame(); } } private: + bool isReadyToSubmit() + { + m_submitSemaphore.acquire(1); + return m_running.load() == 1; + } + Qt3DRender::Render::VSyncFrameAdvanceService *m_tickService; - int m_count; - bool m_running; - QMutex m_mutex; - QSemaphore m_waitForStarted; + QAtomicInt m_running; + QSemaphore m_submitSemaphore; + int m_submitCount; }; class tst_VSyncFrameAdvanceService : public QObject @@ -118,43 +91,22 @@ private Q_SLOTS: // GIVEN Qt3DRender::Render::VSyncFrameAdvanceService tickService(true); FakeRenderThread renderThread(&tickService); - QElapsedTimer t; // WHEN - t.start(); renderThread.start(); - tickService.waitForNextFrame(); - // THEN - // we allow for a little margin by checking for 950 - // instead of 1000 - QVERIFY(t.elapsed() >= 950); - } - - void checkWaitForNextFrame() - { - // GIVEN - Qt3DRender::Render::VSyncFrameAdvanceService tickService(false); - FakeAspectThread aspectThread(&tickService); - - // WHEN - aspectThread.start(); - aspectThread.waitForStarted(); - - QElapsedTimer t; - t.start(); - - while (t.elapsed() < 1000) - tickService.proceedToNextFrame(); + for (int i = 0; i < 10; ++i) { + tickService.waitForNextFrame(); + renderThread.enqueueRenderView(); + } - aspectThread.stopRunning(); + tickService.waitForNextFrame(); - // To make sure the aspectThread can finish - tickService.proceedToNextFrame(); - aspectThread.wait(); + renderThread.stopRunning(); + renderThread.wait(); // THEN - QCOMPARE(aspectThread.count(), 10); + QCOMPARE(renderThread.submitCount(), 10); } }; |