-
Notifications
You must be signed in to change notification settings - Fork 125
refactor(dx8): Replace unsafe Matrix4x4/D3DMATRIX casts with proper transpose conversion #1852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
refactor(dx8): Replace unsafe Matrix4x4/D3DMATRIX casts with proper transpose conversion #1852
Conversation
518ebd4 to
fa2fff2
Compare
Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp
Outdated
Show resolved
Hide resolved
9a7854f to
de78d22
Compare
780bdee to
93986cd
Compare
…ranspose conversion
93986cd to
2a0b73e
Compare
xezon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Goes into the right direction but it still looks like there are quirks.
Did you test the code paths? Is the math still correct?
| DX8Wrapper::_Get_DX8_Transform(D3DTS_VIEW, curView); | ||
| D3DXMatrixInverse(&inv, &det, (D3DXMATRIX*)&curView); | ||
| D3DXMATRIX d3dCurView = Build_D3DXMATRIX(curView); | ||
| D3DXMatrixInverse(&inv, &det, &d3dCurView); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this inverse meant to be a transpose or does it really want to do the inverse here on a D3DXMATRIX that is in DX coordinates?
| DX8CALL(GetTransform(transform,(D3DMATRIX*)&m)); | ||
| D3DXMATRIX d3dMat; | ||
| DX8CALL(GetTransform(transform,&d3dMat)); | ||
| Build_Matrix4(m, (D3DMATRIX&)d3dMat); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There still is a reinterpret cast here.
| float det; | ||
|
|
||
| Matrix4x4 curView; | ||
| DX8Wrapper::_Get_DX8_Transform(D3DTS_VIEW, curView); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add another function to get D3DXMATRIX here instead of doing this conversion?
Summary
Replaces all C-style casts between
Matrix4x4/Matrix3DandD3DXMATRIX/D3DMATRIXwith proper conversion functions that handle the row-major/column-major transpose.Before:
After: