Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Problem with picking when QRenderSettings::renderPolicy is set to OnDemand

    General and Desktop
    qt3d picking qt5.9 c++
    1
    2
    1452
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • I
      iota142 last edited by iota142

      Hi,

      I'm trying to use the QObjectPicker to select a mesh in a Qt3DWindow.
      All works as expected, but if I set the property QRenderSettings::renderPolicy to OnDemand then the signal QObjectPicker::clicked() is emitted only when the rendering is done (when something change, as says the documentation).
      Is it the normal behavior? Do I something wrong?

      I'm using the latest beta of Qt 5.9 (beta 3), on MacOSX.

      A minimal example to reproduce the problem:

      #include <QApplication>
      
      #include <Qt3DExtras>
      #include <Qt3DCore>
      #include <Qt3DRender>
      
      #include <QtDebug>
      
      Qt3DCore::QEntity* createPickableMeshEntity(Qt3DCore::QNode* parent)
      {
          Qt3DCore::QEntity* const entity = new Qt3DCore::QEntity(parent);
          Qt3DExtras::QCuboidMesh* const mesh = new Qt3DExtras::QCuboidMesh(entity);
          Qt3DExtras::QPhongMaterial* const material = new Qt3DExtras::QPhongMaterial(entity);
          Qt3DRender::QObjectPicker* const picker = new Qt3DRender::QObjectPicker(entity);
      
          entity->addComponent(mesh);
          entity->addComponent(material);
          entity->addComponent(picker);
      
          QObject::connect(picker, &Qt3DRender::QObjectPicker::clicked, [](Qt3DRender::QPickEvent*)
          {
              qDebug() << "Cube clicked.";
          });
          return entity;
      }
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          Qt3DExtras::Qt3DWindow window;
          Qt3DCore::QNode root;
          Qt3DRender::QCamera* const camera = new Qt3DRender::QCamera(&root);
          Qt3DExtras::QForwardRenderer renderer;
      
          renderer.setCamera(camera);
          renderer.setSurface(&window);
          // If the render policy is set to Qt3DRender::QRenderSettings::Always then when the user click on the cube
          // the message "Cube clicked" is immediatly displayed as expected.
          // But with the flag Qt3DRender::QRenderSettings::OnDemand, the message will be displayed only if
          // the rendering is triggered (in this example, when I resize the window).
          window.renderSettings()->setRenderPolicy(Qt3DRender::QRenderSettings::OnDemand);
          window.setRootEntity(createPickableMeshEntity(&root));
          window.setActiveFrameGraph(&renderer);
          window.show();
          return a.exec();
      }
      

      Thanks!

      1 Reply Last reply Reply Quote 0
      • I
        iota142 last edited by

        I have reported this issue on the Qt bug tracker.
        If someone is interested: https://bugreports.qt.io/browse/QTBUG-60738

        1 Reply Last reply Reply Quote 0
        • First post
          Last post