Is it safe to use the same parameters for input and output in D3DX functions?

Using the D3DX library, which is part of directX, in particular directx9, in this case I wonder if it is possible to use the same matrix (or vector, etc.) for input and output

D3DXMATRIX mat;
D3DXMatrixInverse(&mat, NULL, &mat);

I avoid this, believing that it will lead to bad things when parts of the array are partially overwritten as the results are calculated, but I see a lot of code that does just that.

A quick test shows that it works fine, so I assume that the D3DX functions take a copy where input is needed, or some other method to ensure that it works fine, but I can’t find it documented anywhere. therefore, I reluctantly rely on his work.

?

+3
2

, . msdn:

, [in] [out]

+3

, . , , ...

: D3DX9Math.inl, . , , . , D3DXVec3Cross:

D3DXINLINE D3DXVECTOR3* D3DXVec3Cross
    ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 )
{
    D3DXVECTOR3 v;

#ifdef D3DX_DEBUG
    if(!pOut || !pV1 || !pV2)
        return NULL;
#endif

    v.x = pV1->y * pV2->z - pV1->z * pV2->y;
    v.y = pV1->z * pV2->x - pV1->x * pV2->z;
    v.z = pV1->x * pV2->y - pV1->y * pV2->x;

    *pOut = v;
    return pOut;
}

, THEN, return. , - .

+1

Source: https://habr.com/ru/post/1738311/


All Articles