Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QPickingSettings does not change the behaviour



  • Qt3DRender::QPickingSettings *settings = new Qt3DRender::QPickingSettings();
    settings->setPickMethod(Qt3DRender::QPickingSettings::PickMethod::TrianglePicking);
    

    Hello, I am using Qt3D to make 3D object pickable. But after I set the PickMethod as TrianglePicking, the behaviour still look like the default BoundingVolumePicking. Do I mistake something?

    For example, even if I click the centre empty space of torus, the torus will be picked. (change its colour from yellow to red). This behaves more like BoundingVolumePicking than TrianglePicking.
    Could anyone check? Thanks in advance!
    Screenshot 2020-07-20 at 22.59.31.png

    Also, I made a simple check. My PickingSetting does not take effect. Does anyone know why?

    QObject::connect(m_picker, &Qt3DRender::QObjectPicker::clicked, [torusMaterial](Qt3DRender::QPickEvent *pointer){
        if ( dynamic_cast<const Qt3DRender::QPickEvent*>( &(*( pointer ))) ){
            qInfo() << "is pickEvent";
            if ( dynamic_cast<const Qt3DRender::QPickTriangleEvent*>( &(*( pointer ))) ){
               qInfo() << "is TrianglePickEvent";
            } else qInfo() << "is not TrianglePickEvent";
        } else qInfo() << "not anything";
        torusMaterial->setDiffuse(QColor(255, 0, 0, 127));
        qInfo() << "clicked";
    });
    

    Above code gives me result "is pickEvent" "is not TrianglePickEvent" "clicked"


Log in to reply