Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-65506

QMesh returns null QGeometryFactory pointer

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P2: Important P2: Important
    • 5.9.5, 5.10.1
    • 5.10.0
    • Qt3D
    • None
    • Windows 10,Qt 5.10, Qt Creator 4.5, MinGW 32Bit
    • f91ee783c5704b0d55da0d96dacf6eca8933e748

      The following code is working without problem with Qt 5.9.x and with Qt 5.10 ( MinGW 32bit) it returns
      null pointer for Qt3DRender::QGeometryFactory *geometry_factory ( Qt3DRender::QGeometry *geometry )

       

      Qt3DRender::QMesh * mesh = new Qt3DRender::QMesh();
       QUrl url("pathto/mesh.obj");
       mesh->setSource( url );
      if (mesh->source().isEmpty()) {
       throw std::runtime_error("A source is needed to build the geometry.");
       }
      Qt3DRender::QGeometryFactory *geometry_factory = mesh->geometryFactory().data(); // << mesh->geometryFactory().data() returns null pointer
       if (!geometry_factory) {
       throw std::runtime_error("Could not construct geometry from mesh: " +
       mesh->source().toString().toStdString());
       }
       Qt3DRender::QGeometry *geometry = geometry_factory->operator()();
      

      Same issue has been reported with Qt 5.8 ( https://bugreports.qt.io/browse/QTBUG-59066 )
      and looks like it is still unresolved in Qt 5.10 ( but in Qt 5.9 works... )

      I compared the source code between 5.9 and 5.10 and i noticed the following differences:

      In Qt 5.9.3 right after we set the source setGeometryFactory is called

      void QMesh::setSource(const QUrl& source)
      {
       Q_D(QMesh);
       if (d->m_source == source)
       return;
       d->m_source = source;
       // update the functor
       QGeometryRenderer::setGeometryFactory(QGeometryFactoryPtr(new MeshFunctor(d->m_source, d->m_meshName)));
       const bool blocked = blockNotifications(true);
       emit sourceChanged(source);
       blockNotifications(blocked);
      }

      While in Qt 5.10 it calls updateFunctor from QMeshPrivate which checks if m_scene is set before

      void QMesh::setSource(const QUrl& source)
      {
       Q_D(QMesh);
       if (d->m_source == source)
       return;
       d->m_source = source;
       d->updateFunctor();
       const bool blocked = blockNotifications(true);
       emit sourceChanged(source);
       blockNotifications(blocked);
      }
      void QMeshPrivate::updateFunctor()
      {
       Q_Q(QMesh);
       Qt3DCore::QAspectEngine *engine = m_scene ? m_scene->engine() : nullptr;
       if (engine)
       q->setGeometryFactory(QGeometryFactoryPtr(new MeshLoaderFunctor(q, engine)));
      }

      There is not public interface to set m_scene and that is the reason why i always receive null QGeometryFactory pointer

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            lemire_p Paul Lemire
            qtdeveloper Dev Dev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes