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

Pre-prepared Qt3D::QNode objects to not correctly propagate their scene to their children

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.5.1
    • 5.7.0
    • Qt3D
    • None
    • Qt5.5 Alpha
      Windows 7
      Visual Studio 2013, 64-bit compilers

    Description

      Image we have a Qt3D::QNode object which represents a part of the scene hierarchy we have yet to add to the main scene hierarchy. When we add the object to the main scene hierarchy, it does not get correctly propagate its scene and property observation to the hierarchy already attached to the node.

      For example consider the case where we add a Qt3D::QEntity which already has a mesh, transform and required shaders. Backend objects are created for this entity, and the object appears. However, changes to the object's transform are not reflected in the back end. This example will be continued throughout the rest of the bug report.

      The problem appears to be with the way the QNodePrivate::m_scene member is handled. When the entity is created and its transform added, it is not attached to any scene hierarchy. Thus when QNodePrivate::addChild(childNode) is called as each component is added to the detached entity, the entity's QNodePrivate::m_scene member is null and no scene object is propagated to the components including the transform component.

      Once the object is added to the main scene hierarchy, QNodePrivate::addChild(childNode) is called on the entity's parent, (childNode is the entity we are adding). The parent will have a non null QNodePrivate::m_scene and the entity has m_scene set, but it does not propagate this change to its children and its transform's m_scene member remains null.

      Further to this, QScene::addEntityForComponent() will not be called to associate the entity and it's transform component (or any other component).

      Attached is a modified version of "examplescene.cpp" from the "dynamicscene-cpp" example which illustrates this problem. The scene has been reduced to a single box, which is created and added to the scene hierarchy on the first update (after the ExampleScene is already in the hierarchy). The box transform is modified every update, but the renderer does not reflect this change. Uncommenting buildScene() in the ExampleScene constructor shows the box correctly moving in the renderer.

      Note: there is a chance that there is a race condition between when the ExampleScene() is added and when the first call to ExampleScene::updateScene() occurs, which may result in the expected behaviour, but I've not confirmed this can happen.

      Attachments

        1. examplescene.cpp
          3 kB
        2. SphereEntity.qml
          0.5 kB
        3. TestDynamicEntityLoadingBug.qml
          2 kB
        For Gerrit Dashboard: QTBUG-45947
        # Subject Branch Project Status CR V

        Activity

          People

            lemire_p Paul Lemire
            Kaznix Kazys
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes