Search Unity

BUG: camera.projectionMatrix broken in 3.4, PerspectiveOffCenter docs are incorrect

Discussion in 'Editor & General Support' started by brad_ict, Sep 14, 2011.

  1. brad_ict

    brad_ict

    Joined:
    Sep 14, 2010
    Posts:
    69
    EDITED: clarified that the frustum functions it just doesn't update the visual representation of the frustum in the Scene view.

    Here's a copy of my bug report for the community's benefit:

    1) What happened
    Couple of problems:
    1. Camera.projectionMatrix in 3.4 updates the frustum in the Game view but doesn't updated the visual representation of the frustum in the Scene view.

    2. The camera.projectionMatrix documentation example code is incorrect for PerspectiveOffCenter(). There are minor problems where "Matrix4x4 m" isn't initialized and the floats don't have parentheses around them and the sign in the right position. Here is the correct code. It's actually been wrong for a long time, reported it like a year ago but it never got updated:

    Code (csharp):
    1. static Matrix4x4 PerspectiveOffCenter(float left, float right, float bottom, float top, float near, float far)
    2.     {
    3.         float x = 2.0F * near / (right - left);
    4.         float y = 2.0F * near / (top - bottom);
    5.         float a = (right + left) / (right - left);
    6.         float b = (top + bottom) / (top - bottom);
    7.         float c = -(far + near) / (far - near);
    8.         float d = -(2.0F * far * near) / (far - near);
    9.         float e = -1.0F;
    10.         Matrix4x4 m;
    11.         m = Matrix4x4.zero;
    12.         m[0, 0] = x;
    13.         m[0, 1] = 0;
    14.         m[0, 2] = a;
    15.         m[0, 3] = 0;
    16.         m[1, 0] = 0;
    17.         m[1, 1] = y;
    18.         m[1, 2] = b;
    19.         m[1, 3] = 0;
    20.         m[2, 0] = 0;
    21.         m[2, 1] = 0;
    22.         m[2, 2] = c;
    23.         m[2, 3] = d;
    24.         m[3, 0] = 0;
    25.         m[3, 1] = 0;
    26.         m[3, 2] = e;
    27.         m[3, 3] = 0;
    28.         return m;
    29.     }
    2)

    How can we reproduce it using the example you attached.
    1. Try and change the arguments passed to camera.projectionMatrix and observe that the frustum does not change in the Scene view.
     
    Last edited: Sep 15, 2011