@@ -372,6 +372,21 @@ HRESULT m_IDirect3DDeviceX::SetTransform(D3DTRANSFORMSTATETYPE dtstTransformStat
372372 }
373373 else
374374 {
375+ DirectX::XMVECTOR position, direction;
376+ if (Config.DdrawConvertHomogeneousToWorldUseGameCamera )
377+ {
378+ // To reconstruct the 3D world, we need to know where the camera is and where it is looking
379+ position = DirectX::XMVectorSet (lpD3DMatrix->_41 , lpD3DMatrix->_42 , lpD3DMatrix->_43 , lpD3DMatrix->_44 );
380+ direction = DirectX::XMVectorSet (lpD3DMatrix->_31 , lpD3DMatrix->_32 , lpD3DMatrix->_33 , lpD3DMatrix->_34 );
381+ }
382+ else
383+ {
384+ const float cameradir = 1 .0f ;
385+
386+ position = DirectX::XMVectorSet (0 .0f , 0 .0f , -cameradir, 0 .0f );
387+ DirectX::XMVectorSet (0 .0f , 0 .0f , cameradir, 0 .0f );
388+ }
389+
375390 // Override the original matrix
376391 std::memcpy (lpD3DMatrix, &view, sizeof (_D3DMATRIX));
377392
@@ -387,25 +402,7 @@ HRESULT m_IDirect3DDeviceX::SetTransform(D3DTRANSFORMSTATETYPE dtstTransformStat
387402 DirectX::XMStoreFloat4x4 ((DirectX::XMFLOAT4X4*)&RenderData.DdrawConvertHomogeneousToWorld_ProjectionMatrix , proj);
388403
389404 DirectX::XMVECTOR up = DirectX::XMVectorSet (0 .0f , 1 .0f , 0 .0f , 0 .0f );
390-
391- DirectX::XMMATRIX viewMatrix;
392- if (Config.DdrawConvertHomogeneousToWorldUseGameCamera )
393- {
394- // To reconstruct the 3D world, we need to know where the camera is and where it is looking
395- DirectX::XMVECTOR position = DirectX::XMVectorSet (lpD3DMatrix->_41 , lpD3DMatrix->_42 , lpD3DMatrix->_43 , lpD3DMatrix->_44 );
396- DirectX::XMVECTOR direction = DirectX::XMVectorSet (lpD3DMatrix->_31 , lpD3DMatrix->_32 , lpD3DMatrix->_33 , lpD3DMatrix->_34 );
397-
398- viewMatrix = DirectX::XMMatrixLookToLH (position, direction, up);
399- }
400- else
401- {
402- const float cameradir = 1 .0f ;
403-
404- DirectX::XMVECTOR pos = DirectX::XMVectorSet (0 .0f , 0 .0f , -cameradir, 0 .0f );
405- DirectX::XMVECTOR direction = DirectX::XMVectorSet (0 .0f , 0 .0f , cameradir, 0 .0f );
406-
407- viewMatrix = DirectX::XMMatrixLookToLH (pos, direction, up);
408- }
405+ DirectX::XMMATRIX viewMatrix = DirectX::XMMatrixLookToLH (position, direction, up);
409406
410407 // Store the 3D view matrix so it can be set later
411408 DirectX::XMStoreFloat4x4 ((DirectX::XMFLOAT4X4*)&RenderData.DdrawConvertHomogeneousToWorld_ViewMatrix , viewMatrix);
@@ -2139,6 +2136,12 @@ HRESULT m_IDirect3DDeviceX::SetRenderState(D3DRENDERSTATETYPE dwRenderStateType,
21392136 dwRenderStateType = D3DRS_DEPTHBIAS;
21402137 break ;
21412138 }
2139+ case D3DRS_LIGHTING:
2140+ if (Config.DdrawDisableLighting )
2141+ {
2142+ dwRenderState = FALSE ;
2143+ }
2144+ break ;
21422145 case D3DRENDERSTATE_TEXTUREPERSPECTIVE:
21432146 return D3D_OK; // As long as the device's D3DPTEXTURECAPS_PERSPECTIVE is enabled, the correction will be applied automatically.
21442147 case D3DRENDERSTATE_LINEPATTERN:
@@ -2549,7 +2552,7 @@ HRESULT m_IDirect3DDeviceX::DrawIndexedPrimitive(D3DPRIMITIVETYPE dptPrimitiveTy
25492552 {
25502553 if (!Config.DdrawConvertHomogeneousToWorld )
25512554 {
2552- UINT8 *vertex = (UINT8*)lpVertices;
2555+ /* UINT8 *vertex = (UINT8*)lpVertices;
25532556
25542557 for (UINT x = 0; x < dwVertexCount; x++)
25552558 {
@@ -2558,17 +2561,17 @@ HRESULT m_IDirect3DDeviceX::DrawIndexedPrimitive(D3DPRIMITIVETYPE dptPrimitiveTy
25582561 pos[3] = 1.0f;
25592562
25602563 vertex += stride;
2561- }
2564+ }*/
25622565
25632566 // Update the FVF
25642567 dwVertexTypeDesc = (dwVertexTypeDesc & ~D3DFVF_XYZRHW) | D3DFVF_XYZW;
25652568 }
25662569 else
25672570 {
2568- const UINT newstride = stride - sizeof (float );
2571+ const UINT targetStride = stride - sizeof (float );
25692572 const UINT restSize = stride - sizeof (float ) * 4 ;
25702573
2571- RenderData.DdrawConvertHomogeneousToWorld_IntermediateGeometry .resize (newstride * dwVertexCount);
2574+ RenderData.DdrawConvertHomogeneousToWorld_IntermediateGeometry .resize (targetStride * dwVertexCount);
25722575
25732576 UINT8 *sourceVertex = (UINT8*)lpVertices;
25742577 UINT8 *targetVertex = (UINT8*)RenderData.DdrawConvertHomogeneousToWorld_IntermediateGeometry .data ();
@@ -2596,7 +2599,7 @@ HRESULT m_IDirect3DDeviceX::DrawIndexedPrimitive(D3DPRIMITIVETYPE dptPrimitiveTy
25962599
25972600 // Move to next vertex
25982601 sourceVertex += stride;
2599- targetVertex += newstride ;
2602+ targetVertex += targetStride ;
26002603 }
26012604
26022605 // Set transform
@@ -2610,7 +2613,7 @@ HRESULT m_IDirect3DDeviceX::DrawIndexedPrimitive(D3DPRIMITIVETYPE dptPrimitiveTy
26102613 (*d3d9Device)->SetFVF (newVertexTypeDesc);
26112614
26122615 // Draw indexed primitive UP
2613- hr = (*d3d9Device)->DrawIndexedPrimitiveUP (dptPrimitiveType, 0 , dwVertexCount, GetNumberOfPrimitives (dptPrimitiveType, dwIndexCount), lpIndices, D3DFMT_INDEX16, lpVertices, newstride );
2616+ hr = (*d3d9Device)->DrawIndexedPrimitiveUP (dptPrimitiveType, 0 , dwVertexCount, GetNumberOfPrimitives (dptPrimitiveType, dwIndexCount), lpIndices, D3DFMT_INDEX16, lpVertices, targetStride );
26142617
26152618 // Restore transform
26162619 _D3DMATRIX identityMatrix;
0 commit comments