From 1945793772a5f721079594b2c82ddc1d7aa3a6ec Mon Sep 17 00:00:00 2001 From: jarmonik Date: Mon, 13 Nov 2023 06:35:36 +0200 Subject: [PATCH] Fixed light control slider's default position bug --- OVP/D3D9Client/DebugControls.cpp | 16 ++++++++++++++++ OVP/D3D9Client/Mesh.cpp | 17 +++++++++++++++++ OVP/D3D9Client/Mesh.h | 2 ++ 3 files changed, 35 insertions(+) diff --git a/OVP/D3D9Client/DebugControls.cpp b/OVP/D3D9Client/DebugControls.cpp index 120afaac5..b229e748e 100644 --- a/OVP/D3D9Client/DebugControls.cpp +++ b/OVP/D3D9Client/DebugControls.cpp @@ -59,6 +59,7 @@ char SaveFileName[255]; void UpdateMaterialDisplay(bool bSetup=false); void SetGFXSliders(); +void UpdateLightsSlider(); INT_PTR CALLBACK WndProcGFX(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); void OpenGFXDlgClbk(void *context); @@ -1102,6 +1103,7 @@ void SelectMesh(D3D9Mesh *pMesh) } } SetupMeshGroups(); + UpdateLightsSlider(); } // ============================================================================================= @@ -1165,6 +1167,19 @@ void UpdateBakedLights(float lvl) } } +// ============================================================================================= +// +void UpdateLightsSlider() +{ + float val = 0.0f; + D3D9Mesh* mesh = (class D3D9Mesh*)vObj->GetMesh(sMesh); + if (mesh) { + if (bkl_id < 16 && bkl_id >= 0) val = mesh->GetBakedLightLevel(bkl_id).x; + if (bkl_id == 16) val = mesh->GetAmbientColor().x; + SendDlgItemMessage(hDlg, IDC_DBG_BKLADJ, TBM_SETPOS, 1, WORD(255.0f * val)); + } +} + // ============================================================================================= // LPDIRECT3DTEXTURE9 GetCombinedMap() @@ -1836,6 +1851,7 @@ INT_PTR CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case IDC_DBG_BKLID: if (HIWORD(wParam) == CBN_SELCHANGE) { bkl_id = int(SendDlgItemMessage(hDlg, IDC_DBG_BKLID, CB_GETCURSEL, 0, 0)); + UpdateLightsSlider(); } break; diff --git a/OVP/D3D9Client/Mesh.cpp b/OVP/D3D9Client/Mesh.cpp index 94be8c03a..57fb9470c 100644 --- a/OVP/D3D9Client/Mesh.cpp +++ b/OVP/D3D9Client/Mesh.cpp @@ -579,6 +579,15 @@ void D3D9Mesh::SetBakedLightLevel(int idx, const FVECTOR3 &level) } +// =========================================================================================== +// +FVECTOR3 D3D9Mesh::GetBakedLightLevel(int idx) +{ + if (idx >= 0 && idx <= 15) return BakedLightsControl[idx]; + return FVECTOR3(1, 1, 1); +} + + // =========================================================================================== // void D3D9Mesh::BakeLights(ImageProcessing* pBaker) @@ -1510,6 +1519,14 @@ void D3D9Mesh::SetAmbientColor(const FVECTOR3& c) cAmbient = c; } +// =========================================================================================== +// +const FVECTOR3& D3D9Mesh::GetAmbientColor() +{ + _TRACE; + return cAmbient; +} + // =========================================================================================== // void D3D9Mesh::SetupFog(const LPD3DXMATRIX pW) diff --git a/OVP/D3D9Client/Mesh.h b/OVP/D3D9Client/Mesh.h index 3f57da9e7..2754ea601 100644 --- a/OVP/D3D9Client/Mesh.h +++ b/OVP/D3D9Client/Mesh.h @@ -216,6 +216,7 @@ class D3D9Mesh : private D3D9Effect void BakeLights(ImageProcessing *pBaker); void BakeAO(ImageProcessing* pBaker, const FVECTOR3 &vSun); void SetBakedLightLevel(int idx, const FVECTOR3 &level); + FVECTOR3 GetBakedLightLevel(int idx); void LoadMeshFromHandle(MESHHANDLE hMesh, D3DXVECTOR3 *reorig = NULL, float *scale = NULL); void ReLoadMeshFromHandle(MESHHANDLE hMesh); void ReloadTextures(); @@ -326,6 +327,7 @@ class D3D9Mesh : private D3D9Effect void BoundingBox(const NMVERTEX *vtx, DWORD n, D9BBox *box); void SetAmbientColor(const FVECTOR3& c); + const FVECTOR3& GetAmbientColor(); void SetupFog(const LPD3DXMATRIX pW); void ResetRenderStatus();