CMatrix4::buildProjectionMatrixOrthoRH BUG

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
tomwindcloud
Posts: 2
Joined: Sun Sep 11, 2011 11:25 am

CMatrix4::buildProjectionMatrixOrthoRH BUG

Post by tomwindcloud »

It spended me 3 hours to find the bug:
source bug code:

Code: Select all

template <class T>
        inline CMatrix4<T>& CMatrix4<T>::buildProjectionMatrixOrthoRH(
                        f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar)
        {
                _IRR_DEBUG_BREAK_IF(widthOfViewVolume==0.f); //divide by zero
                _IRR_DEBUG_BREAK_IF(heightOfViewVolume==0.f); //divide by zero
                _IRR_DEBUG_BREAK_IF(zNear==zFar); //divide by zero
                M[0] = (T)(2/widthOfViewVolume);
                M[1] = 0;
                M[2] = 0;
                M[3] = 0;
 
                M[4] = 0;
                M[5] = (T)(2/heightOfViewVolume);
                M[6] = 0;
                M[7] = 0;
 
                M[8] = 0;
                M[9] = 0;
                M[10] = (T)(1/(zNear-zFar));
                M[11] = 0;
 
                M[12] = 0;
                M[13] = 0;
                M[14] = (T)(zNear/(zNear-zFar));
                M[15] = -1;
 
#if defined ( USE_MATRIX_TEST )
                definitelyIdentityMatrix=false;
#endif
                return *this;
        }
M[15] should be 1, not -1.
PS: the edition is 1.7.2
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: CMatrix4::buildProjectionMatrixOrthoRH BUG

Post by hybrid »

Are you sure, any sources for this claim, any example which fails with the current one and works with the new one? Not that I cannot believe this, but it would be good to have some confidence in this change :-)
Ok, commited as both Direct3D and OpenGL seem to have the one there. But it would still be nice if you can tell me about a test case and what happened before the change.
tomwindcloud
Posts: 2
Joined: Sun Sep 11, 2011 11:25 am

Re: CMatrix4::buildProjectionMatrixOrthoRH BUG

Post by tomwindcloud »

HI, hybrid:
I write a project with four splitter windows with one perspective view and three ortho view. The perspective view worked well, but the ortho view failed, i can't see anything. What's the problem? I get into knots.
Then, i theck the Directx document, i found D3DXMatrixOrthoRH's doc:
2/w 0 0 0
0 2/h 0 0
0 0 1/(zn-zf) 0
0 0 zn/(zn-zf) l

So i modify M[15] with 1, then the ortho view works well. It taked me three hours to get it work, my god!
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: CMatrix4::buildProjectionMatrixOrthoRH BUG

Post by hybrid »

So why do you use RH corrds? As it seems, the LH version worked.
Post Reply