Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem with picking when QRenderSettings::renderPolicy is set to OnDemand

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

Scheduled Pinned Locked Moved Solved General and Desktop
qt3dpickingqt5.9c++
2 Posts 1 Posters 1.7k Views
  • 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 Offline
    I Offline
    iota142
    wrote on last edited by iota142
    #1

    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
    0
    • I Offline
      I Offline
      iota142
      wrote on last edited by
      #2

      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
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved