Qt3D strange camera behavior at huge coordinates



  • Hello, everyone.

    I'm currently developing a Qt3D application in which there's basically a Qt3DRender::QCamera moving through a grid. I tried some stress tests, in which I let the camera moving only through the y-axis for a long time. In the following example, I translate the camera using its translateWorld method, with the "TranslateViewCenter" option, translating it by 0.1 every 1 ms. Everything happens fine until it reaches a position of about 9959 on the y-axis, when the camera gets weird, changes its tilt, and stops moving in a fluent way. I'm printing the camera's position and the view point every translation, so you can see what happens:

    Position:  QVector3D(0, 9958.33, 0.68404) View Center:  QVector3D(0, 9960.21, 0)
    Position:  QVector3D(0, 9958.43, 0.68404) View Center:  QVector3D(0, 9960.31, 0)
    Position:  QVector3D(0, 9958.53, 0.68404) View Center:  QVector3D(0, 9960.41, 0)
    Position:  QVector3D(0, 9958.63, 0.68404) View Center:  QVector3D(0, 9960.51, 0)
    Position:  QVector3D(0, 9958.73, 0.68404) View Center:  QVector3D(0, 9960.61, 0)
    Position:  QVector3D(0, 9958.83, 0.68404) View Center:  QVector3D(0, 9960.71, 0)
    Position:  QVector3D(0, 9958.93, 0.68404) View Center:  QVector3D(0, 9960.8, 0)
    Position:  QVector3D(0, 9959.03, 0.68404) View Center:  QVector3D(0, 9960.9, 0)
    Position:  QVector3D(0, 9959.13, 0.68404) View Center:  QVector3D(0, 9961, 0)
    Position:  QVector3D(0, 9959.22, 0.68404) View Center:  QVector3D(0, 9961, 0)
    Position:  QVector3D(0, 9959.32, 0.68404) View Center:  QVector3D(0, 9961, 0)
    Position:  QVector3D(0, 9959.42, 0.68404) View Center:  QVector3D(0, 9961, 0)
    Position:  QVector3D(0, 9959.52, 0.68404) View Center:  QVector3D(0, 9961, 0)
    Position:  QVector3D(0, 9959.62, 0.68404) View Center:  QVector3D(0, 9961, 0)
    Position:  QVector3D(0, 9959.72, 0.68404) View Center:  QVector3D(0, 9961, 0)
    Position:  QVector3D(0, 9959.82, 0.68404) View Center:  QVector3D(0, 9961, 0)
    Position:  QVector3D(0, 9959.92, 0.68404) View Center:  QVector3D(0, 9961, 0)
    Position:  QVector3D(0, 9960.02, 0.68404) View Center:  QVector3D(0, 9961, 0)
    Position:  QVector3D(0, 9960.12, 0.68404) View Center:  QVector3D(0, 9961, 0)
    Position:  QVector3D(0, 9960.22, 0.68404) View Center:  QVector3D(0, 9961, 0)
    Position:  QVector3D(0, 9960.32, 0.68404) View Center:  QVector3D(0, 9961, 0)
    Position:  QVector3D(0, 9960.42, 0.68404) View Center:  QVector3D(0, 9961, 0)
    Position:  QVector3D(0, 9960.52, 0.68404) View Center:  QVector3D(0, 9961, 0)
    Position:  QVector3D(0, 9960.62, 0.68404) View Center:  QVector3D(0, 9961, 0)
    Position:  QVector3D(0, 9960.72, 0.68404) View Center:  QVector3D(0, 9961, 0)
    Position:  QVector3D(0, 9960.82, 0.68404) View Center:  QVector3D(0, 9961, 0)
    Position:  QVector3D(0, 9960.92, 0.68404) View Center:  QVector3D(0, 9961, 0)
    Position:  QVector3D(0, 9961.02, 0.68404) View Center:  QVector3D(0, 9961, 0)
    Position:  QVector3D(0, 9961.02, 0.68404) View Center:  QVector3D(0, 9961, 0)
    Position:  QVector3D(0, 9961.22, 0.68404) View Center:  QVector3D(0, 9961.2, 0)
    Position:  QVector3D(0, 9961.22, 0.68404) View Center:  QVector3D(0, 9961.2, 0)
    Position:  QVector3D(0, 9961.42, 0.68404) View Center:  QVector3D(0, 9961.4, 0)
    Position:  QVector3D(0, 9961.42, 0.68404) View Center:  QVector3D(0, 9961.4, 0)
    Position:  QVector3D(0, 9961.62, 0.68404) View Center:  QVector3D(0, 9961.6, 0)
    Position:  QVector3D(0, 9961.62, 0.68404) View Center:  QVector3D(0, 9961.6, 0)
    Position:  QVector3D(0, 9961.81, 0.68404) View Center:  QVector3D(0, 9961.8, 0)
    Position:  QVector3D(0, 9961.81, 0.68404) View Center:  QVector3D(0, 9961.8, 0)
    Position:  QVector3D(0, 9962.01, 0.68404) View Center:  QVector3D(0, 9962, 0)
    Position:  QVector3D(0, 9962.01, 0.68404) View Center:  QVector3D(0, 9962, 0)
    Position:  QVector3D(0, 9962.21, 0.68404) View Center:  QVector3D(0, 9962.2, 0)
    Position:  QVector3D(0, 9962.21, 0.68404) View Center:  QVector3D(0, 9962.2, 0)
    Position:  QVector3D(0, 9962.41, 0.68404) View Center:  QVector3D(0, 9962.4, 0)
    Position:  QVector3D(0, 9962.41, 0.68404) View Center:  QVector3D(0, 9962.4, 0)
    Position:  QVector3D(0, 9962.61, 0.68404) View Center:  QVector3D(0, 9962.6, 0)
    Position:  QVector3D(0, 9962.61, 0.68404) View Center:  QVector3D(0, 9962.6, 0)
    Position:  QVector3D(0, 9962.81, 0.68404) View Center:  QVector3D(0, 9962.8, 0)
    Position:  QVector3D(0, 9962.81, 0.68404) View Center:  QVector3D(0, 9962.8, 0)
    

    You may notice that, until the line "Position: QVector3D(0, 9959.03, 0.68404) View Center: QVector3D(0, 9960.9, 0)", the camera increases its position and view point by 0.1, but then, the view point locks at 9961, as the positions continues being updated, causing the tilt alteration. Some lines ahead, the view point unlocks, but now, both position and view point move only after two translations, causing the effect of not being a fluid movement. This happens always at the same value, even if my initial position is close to this point (e.g. 9950).
    Does anyone know a possible reason for this strange behavior?


  • Qt Champions 2017

    @diegocarrillo said in Qt3D strange camera behavior at huge coordinates:

    Does anyone know a possible reason for this strange behavior?

    A possible reason could be that something is stored in a matrix, for example the projection and that matrix is going numerically unstable when applied to the different entities/objects. Just a guess though.



  • My "gut" feeling it is floating point precision you are running into:
    https://gamedev.stackexchange.com/questions/3351/about-floating-point-precision-and-why-do-we-still-use-it

    I am not sure how the world is represented in Qt3D though.



  • @fcarney I couldn't really understand what was going on, but the link you posted inspired me to create a method which translates every entity to the origin at a given point, and now everything works completely fine! It makes sense that this problem was originated by floating point precision. Thank you!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.