1919#include < DirectXMath.h>
2020
2121// Enable for testing only
22- #define ENABLE_DEBUGOVERLAY
22+ // #define ENABLE_DEBUGOVERLAY
2323
2424#ifdef ENABLE_DEBUGOVERLAY
2525#include " DebugOverlay.h"
@@ -339,17 +339,17 @@ HRESULT m_IDirect3DDeviceX::SetTransform(D3DTRANSFORMSTATETYPE dtstTransformStat
339339 break ;
340340 }
341341
342- if (Config.DdrawConvertHomogeneousW )
342+ if (Config.DdrawConvertHomogeneousW )
343343 {
344344#ifdef ENABLE_DEBUGOVERLAY
345345 // Set the original matrix
346346 DOverlay.SetTransform (dtstTransformStateType, lpD3DMatrix);
347347#endif
348348
349- if (dtstTransformStateType == D3DTS_VIEW)
349+ if (dtstTransformStateType == D3DTS_VIEW)
350350 {
351351 D3DVIEWPORT9 Viewport9;
352- if (SUCCEEDED ((*d3d9Device)->GetViewport (&Viewport9)))
352+ if (SUCCEEDED ((*d3d9Device)->GetViewport (&Viewport9)))
353353 {
354354 const float width = (float )Viewport9.Width ;
355355 const float height = (float )Viewport9.Height ;
@@ -365,15 +365,13 @@ HRESULT m_IDirect3DDeviceX::SetTransform(D3DTRANSFORMSTATETYPE dtstTransformStat
365365 view._42 = 1 .0f ; // translate Y
366366 view._44 = 1 .0f ;
367367
368- if (!Config.DdrawConvertHomogeneousToWorld )
369- {
370- // Override the original matrix
371- std::memcpy (lpD3DMatrix, &view, sizeof (_D3DMATRIX));
372- }
373- else
368+ // Override the original matrix
369+ std::memcpy (lpD3DMatrix, &view, sizeof (_D3DMATRIX));
370+
371+ if (Config.DdrawConvertHomogeneousToWorld )
374372 {
375373 DirectX::XMVECTOR position, direction;
376- if (Config.DdrawConvertHomogeneousToWorldUseGameCamera )
374+ if (Config.DdrawConvertHomogeneousToWorldUseGameCamera )
377375 {
378376 // To reconstruct the 3D world, we need to know where the camera is and where it is looking
379377 position = DirectX::XMVectorSet (lpD3DMatrix->_41 , lpD3DMatrix->_42 , lpD3DMatrix->_43 , lpD3DMatrix->_44 );
@@ -384,12 +382,9 @@ HRESULT m_IDirect3DDeviceX::SetTransform(D3DTRANSFORMSTATETYPE dtstTransformStat
384382 const float cameradir = 1 .0f ;
385383
386384 position = DirectX::XMVectorSet (0 .0f , 0 .0f , -cameradir, 0 .0f );
387- DirectX::XMVectorSet (0 .0f , 0 .0f , cameradir, 0 .0f );
385+ direction = DirectX::XMVectorSet (0 .0f , 0 .0f , cameradir, 0 .0f );
388386 }
389387
390- // Override the original matrix
391- std::memcpy (lpD3DMatrix, &view, sizeof (_D3DMATRIX));
392-
393388 // Store the original matrix so it can be restored
394389 std::memcpy (&RenderData.DdrawConvertHomogeneousToWorld_ViewMatrixOriginal , &view, sizeof (_D3DMATRIX));
395390
@@ -1703,7 +1698,7 @@ HRESULT m_IDirect3DDeviceX::EndScene()
17031698 }
17041699
17051700#ifdef ENABLE_DEBUGOVERLAY
1706- DOverlay.EndScene (RenderData );
1701+ DOverlay.EndScene ();
17071702#endif
17081703
17091704 // The IDirect3DDevice7::EndScene method ends a scene that was begun by calling the IDirect3DDevice7::BeginScene method.
@@ -2137,7 +2132,7 @@ HRESULT m_IDirect3DDeviceX::SetRenderState(D3DRENDERSTATETYPE dwRenderStateType,
21372132 break ;
21382133 }
21392134 case D3DRS_LIGHTING:
2140- if (Config.DdrawDisableLighting )
2135+ if (Config.DdrawDisableLighting )
21412136 {
21422137 dwRenderState = FALSE ;
21432138 }
@@ -2548,9 +2543,10 @@ HRESULT m_IDirect3DDeviceX::DrawIndexedPrimitive(D3DPRIMITIVETYPE dptPrimitiveTy
25482543 const UINT stride = GetVertexStride (dwVertexTypeDesc);
25492544
25502545 // Handle PositionT
2551- if ( (dwVertexTypeDesc & D3DFVF_XYZRHW) != 0 && Config. DdrawConvertHomogeneousW )
2546+ if (Config. DdrawConvertHomogeneousW && (dwVertexTypeDesc & 0x0E ) == D3DFVF_XYZRHW )
25522547 {
2553- if (!Config.DdrawConvertHomogeneousToWorld )
2548+ D3DFVF_XYZB1;
2549+ if (!Config.DdrawConvertHomogeneousToWorld )
25542550 {
25552551 /* UINT8 *vertex = (UINT8*)lpVertices;
25562552
0 commit comments