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

QObjectPicker doesn't work with multiple layers

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.6.0
    • Qt3D
    • None
    • Tested in windows, nvidia GPUs with opengl.
    • Windows

    Description

      QObjectPicker doesn't work if there are multiple QLayers and QLayerFilters. I had this problem in our internal application and reported it in mailing list and was asked to create a bug here. I also managed to reproduce the bug in a simple app with two spheres having different layers as components. I am attaching the files with this report. Also I am copying the details from the mail here:

      We have a Qt3D application where we have multiple QLayers for different types of meshes. We have found out that QObjectPicker doesn’t work properly with multiple QLayers. It doesn’t get triggered consistently if the entity has layer component which is not filtered at the top of the framegraph.

      Consider the following simplified framegraph with two layer filter branches, one for opaque and one for transparent objects:

      Qt3DRender::QViewport* mainViewport = new Qt3DRender::QViewport(renderSurfaceSelector);
      mainViewport->setNormalizedRect(QRectF(0, 0, 1.0, 1.0));

      Qt3DRender::QCameraSelector* cameraSelector = new Qt3DRender::QCameraSelector(mainViewport);
      cameraSelector->setCamera(view->camera());

      Qt3DRender::QRenderStateSet* renderStateSet = new Qt3DRender::QRenderStateSet(cameraSelector);

      { Qt3DRender::QDepthTest* depthTest = new Qt3DRender::QDepthTest; depthTest->setDepthFunction(Qt3DRender::QDepthTest::LessOrEqual); renderStateSet->addRenderState(depthTest); Qt3DRender::QCullFace* cullFace = new Qt3DRender::QCullFace(renderStateSet); cullFace->setMode(Qt3DRender::QCullFace::NoCulling); renderStateSet->addRenderState(cullFace); }

      // Opaque branch
      Qt3DRender::QLayerFilter* layerFilterOpaque = new Qt3DRender::QLayerFilter(renderStateSet);
      layerFilterOpaque->addLayer(opaqueLayer);
      // Transparent branch
      Qt3DRender::QLayerFilter* layerFilterTransparent = new Qt3DRender::QLayerFilter(renderStateSet);
      layerFilterTransparent->addLayer(transparentLayer);

      When we dynamically add meshes to the scene, we check if the default material is transparent and assign the respective layers like this:
      if (transparent)

      { entity->addComponent(transparentLayer); }

      else

      { entity->addComponent(opaqueLayer); }

      After this, when we click on the dynamically added mesh, only entities with opaqueLayer get triggered 100% of time, entities with transparentLayer gets triggered inconsistently, and sometimes, it gets triggered if we click the backface of the mesh. The hit ratio is around 20%.

      If we swap the order of layer filters in framegraph, the transparentLayer entities get triggered 100% of time and the opaqueLayer entities get triggered inconsistently. So we think that it is the framegraph which is causing this problem.

      But if we modify a material and change the layers of an existing entity(with opaqueLayer), QObjectPicker gets triggered all the time. The following code demonstrates how we do that:

      pickedEntity->addComponent(transparentLayer);
      pickedEntity->removeComponent(opaqueLayer);
      pickedEntity->setEnabled(false);
      pickedEntity->setEnabled(true);

      Additionally, we also found that if the same scene with the above mentioned framegraph only contains dynamically created entities with transparentLayer as a component, QObjectPicker is not triggered at all.

      How to fix this issue? Why does it work if we modify the layer after creating it with opaqueLayer, but not when adding dynamically while creating? Does QObjectPicker depend on how we setup the framegraph?

      Attachments

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

        Activity

          People

            mkrus Mike Krus
            sakthimm Sakthi G
            Mike Krus Mike Krus
            Mike Krus Mike Krus
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes