Closed morallo closed 3 years ago
There are a number of things going on here. Bottom line is: I think rotMatrix
is no longer used and it's irrelevant whether we invert it or not (but I need to test it).
The reason we create a new matrix from yaw, pitch, roll is because XWA's coordinate system does not match SteamVR's coordinate system. For instance, the block that starts here:
shows how the yaw and pitch are inverted. Also, the block here:
adds an optional offset to the yaw, pitch. Even if we got rid of this offset we still need to invert the yaw and pitch, though.
The explanation for why this matrix was inverted starts here:
However, I think the matrix inversion is no longer necessary because the invidual yaw, pitch angles are inverted when building the matrix. This is probably dead code. I'm going to see if I can remove rotMatrix
altogether. There's a similar matrix in the DirectSBS path -- we can probably remove that as well.
@morallo This was indeed dead code. I just removed it and things work fine. Good catch!
hi @Prof-Butts, while trying to fully understand how the 3D transformations work, I realized that in the SteamVR path the rotation matrix is calculated again from yaw,pitch,roll, instead of using the value provided by
GetSteamVRPositionalData()
See here that
rotMatrix
is never used after inverting it. Instead, the calculatedrotMatrixFull
is passed to the shader asg_VSMatrixCB.fullViewMat.fullViewMat
.https://github.com/Prof-Butts/xwa_ddraw_d3d11/blob/c57c9053ab82e6dd7055931489b6ff8c0d349d61/impl11/ddraw/PrimarySurface.cpp#L7416
So, this has no real effect on performance since it is only done once per frame, but I wanted to make sure I'm not missing anything.
My only remaining question is: why
rotMatrix
is inverted, but notrotMatrixFull
? And why would you invert it in the first place? I guess this is left over from a previous version of the code?