Skip to content

Commit

Permalink
Fixed light control slider's default position bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jarmonik committed Nov 13, 2023
1 parent 8f77cee commit 1945793
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
16 changes: 16 additions & 0 deletions OVP/D3D9Client/DebugControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -1102,6 +1103,7 @@ void SelectMesh(D3D9Mesh *pMesh)
}
}
SetupMeshGroups();
UpdateLightsSlider();
}

// =============================================================================================
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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;

Expand Down
17 changes: 17 additions & 0 deletions OVP/D3D9Client/Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions OVP/D3D9Client/Mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 1945793

Please sign in to comment.