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

Qt3D Overrides Camera Aspect Ratio

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.11.3
    • Qt3D
    • None
    • Linux/X11, Windows

    Description

      If the user explicitly sets the aspect ratio on a Qt3D Camera, the value is overridden.

      This behaviour can easily be reproduced by opening "Qt3D: Simple QML Example" and observing 1) that the aspect ratio set on the camera is 16/9, and 2) that the actual viewport aspect ratio is 4/3. One would expect to see the image (particularly the sphere) distort when the aspect ratio is set to a value not matching the relative viewport dimensions.

      I added basic logging to see what is going on:

      ~/Qt/Examples/Qt-5.11.3/qt3d/simple-qml$ diff main.qml main.qml.bak
      70,71d69
      < 
      <         onProjectionMatrixChanged: console.log("Projection Matrix: ", projectionMatrix)
      

      Which outputs the following:

      qml: Projection Matrix: QMatrix4x4(1.358, 0, 0, 0, 0, 2.41421, 0, 0, 0, 0, -1.0002, -0.20002, 0, 0, -1, 0)
      qml: Projection Matrix: QMatrix4x4(1.81066, 0, 0, 0, 0, 2.41421, 0, 0, 0, 0, -1.0002, -0.20002, 0, 0, -1, 0)
      

       The value for the projection matrix differs in the element (0,0) which is calculated as cotan(vfov / 2) / ar. Values of 1.358 and 1.81066 correspond with ar=16/9 and ar=4/3 respectively. Most likely Qt is using the aspect ratio of the viewport to update the camera.

      Is there ever a case in which Qt won't override the value set by the user? It seems we do have the ability to change the value but it is always overridden by some hidden force. If there is no situation in which the value remains unchanged then it would be better for the property to be marked as read-only.

      Attachments

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

        Activity

          People

            seanharmer Sean Harmer
            xfol Bryce Hillam
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes