@@ -372,6 +372,21 @@ HRESULT m_IDirect3DDeviceX::SetTransform(D3DTRANSFORMSTATETYPE dtstTransformStat
372
372
}
373
373
else
374
374
{
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
+
375
390
// Override the original matrix
376
391
std::memcpy (lpD3DMatrix, &view, sizeof (_D3DMATRIX));
377
392
@@ -387,25 +402,7 @@ HRESULT m_IDirect3DDeviceX::SetTransform(D3DTRANSFORMSTATETYPE dtstTransformStat
387
402
DirectX::XMStoreFloat4x4 ((DirectX::XMFLOAT4X4*)&RenderData.DdrawConvertHomogeneousToWorld_ProjectionMatrix , proj);
388
403
389
404
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);
409
406
410
407
// Store the 3D view matrix so it can be set later
411
408
DirectX::XMStoreFloat4x4 ((DirectX::XMFLOAT4X4*)&RenderData.DdrawConvertHomogeneousToWorld_ViewMatrix , viewMatrix);
@@ -2139,6 +2136,12 @@ HRESULT m_IDirect3DDeviceX::SetRenderState(D3DRENDERSTATETYPE dwRenderStateType,
2139
2136
dwRenderStateType = D3DRS_DEPTHBIAS;
2140
2137
break ;
2141
2138
}
2139
+ case D3DRS_LIGHTING:
2140
+ if (Config.DdrawDisableLighting )
2141
+ {
2142
+ dwRenderState = FALSE ;
2143
+ }
2144
+ break ;
2142
2145
case D3DRENDERSTATE_TEXTUREPERSPECTIVE:
2143
2146
return D3D_OK; // As long as the device's D3DPTEXTURECAPS_PERSPECTIVE is enabled, the correction will be applied automatically.
2144
2147
case D3DRENDERSTATE_LINEPATTERN:
@@ -2549,7 +2552,7 @@ HRESULT m_IDirect3DDeviceX::DrawIndexedPrimitive(D3DPRIMITIVETYPE dptPrimitiveTy
2549
2552
{
2550
2553
if (!Config.DdrawConvertHomogeneousToWorld )
2551
2554
{
2552
- UINT8 *vertex = (UINT8*)lpVertices;
2555
+ /* UINT8 *vertex = (UINT8*)lpVertices;
2553
2556
2554
2557
for (UINT x = 0; x < dwVertexCount; x++)
2555
2558
{
@@ -2558,17 +2561,17 @@ HRESULT m_IDirect3DDeviceX::DrawIndexedPrimitive(D3DPRIMITIVETYPE dptPrimitiveTy
2558
2561
pos[3] = 1.0f;
2559
2562
2560
2563
vertex += stride;
2561
- }
2564
+ }*/
2562
2565
2563
2566
// Update the FVF
2564
2567
dwVertexTypeDesc = (dwVertexTypeDesc & ~D3DFVF_XYZRHW) | D3DFVF_XYZW;
2565
2568
}
2566
2569
else
2567
2570
{
2568
- const UINT newstride = stride - sizeof (float );
2571
+ const UINT targetStride = stride - sizeof (float );
2569
2572
const UINT restSize = stride - sizeof (float ) * 4 ;
2570
2573
2571
- RenderData.DdrawConvertHomogeneousToWorld_IntermediateGeometry .resize (newstride * dwVertexCount);
2574
+ RenderData.DdrawConvertHomogeneousToWorld_IntermediateGeometry .resize (targetStride * dwVertexCount);
2572
2575
2573
2576
UINT8 *sourceVertex = (UINT8*)lpVertices;
2574
2577
UINT8 *targetVertex = (UINT8*)RenderData.DdrawConvertHomogeneousToWorld_IntermediateGeometry .data ();
@@ -2596,7 +2599,7 @@ HRESULT m_IDirect3DDeviceX::DrawIndexedPrimitive(D3DPRIMITIVETYPE dptPrimitiveTy
2596
2599
2597
2600
// Move to next vertex
2598
2601
sourceVertex += stride;
2599
- targetVertex += newstride ;
2602
+ targetVertex += targetStride ;
2600
2603
}
2601
2604
2602
2605
// Set transform
@@ -2610,7 +2613,7 @@ HRESULT m_IDirect3DDeviceX::DrawIndexedPrimitive(D3DPRIMITIVETYPE dptPrimitiveTy
2610
2613
(*d3d9Device)->SetFVF (newVertexTypeDesc);
2611
2614
2612
2615
// 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 );
2614
2617
2615
2618
// Restore transform
2616
2619
_D3DMATRIX identityMatrix;
0 commit comments