Merge pull request #2363 from NZJenkins/setmodelview

Minimal SetModelView implementation
This commit is contained in:
Luke Usher 2022-05-21 13:31:07 +01:00 committed by GitHub
commit 3d244b78b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 9 deletions

View File

@ -9076,8 +9076,9 @@ xbox::void_xt WINAPI xbox::EMUPATCH(D3DDevice_SetModelView)
LOG_FUNC_ARG(pComposite)
LOG_FUNC_END;
// TODO: Implement
LOG_UNIMPLEMENTED();
// TODO handle other matrices
d3d8TransformState.SetWorldView(0, pModelView);
LOG_TEST_CASE("SetModelView");
}
// ******************************************************************
@ -9097,13 +9098,7 @@ xbox::hresult_xt WINAPI xbox::EMUPATCH(D3DDevice_GetModelView)(D3DXMATRIX* pMode
{
LOG_FUNC_ONE_ARG(pModelView);
D3DXMATRIX mtxWorld, mtxView;
// I hope this is right
g_pD3DDevice->GetTransform( D3DTS_WORLD, &mtxWorld );
g_pD3DDevice->GetTransform( D3DTS_VIEW, &mtxView );
*pModelView = mtxWorld * mtxView;
*pModelView = *d3d8TransformState.GetWorldView(0);
return D3D_OK;
}

View File

@ -144,6 +144,22 @@ D3DMATRIX* D3D8TransformState::GetWorldView(unsigned i)
return &WorldView[i];
}
void D3D8TransformState::SetWorldView(unsigned i, const D3DMATRIX* pMatrix)
{
assert(i < 4);
if (!pMatrix) {
// null indicates the title is done with setting
// the worldview matrix explicitly
bWorldViewDirty[i] = true;
return;
}
else {
bWorldViewDirty[i] = false;
WorldView[i] = *pMatrix;
}
}
D3DMATRIX* D3D8TransformState::GetWorldViewInverseTranspose(unsigned i)
{
assert(i < 4);

View File

@ -28,6 +28,7 @@ public:
D3D8TransformState();
void SetTransform(xbox::X_D3DTRANSFORMSTATETYPE state, const D3DMATRIX* pMatrix);
D3DMATRIX* GetWorldView(unsigned i);
void SetWorldView(unsigned i, const D3DMATRIX* pMatrix);
D3DMATRIX* GetWorldViewInverseTranspose(unsigned i);
// The transforms set by the Xbox title