Skip to content

Commit

Permalink
Fixed Pick related bugs and added Mesh visibility info in debug contr…
Browse files Browse the repository at this point in the history
…ols.
  • Loading branch information
jarmonik committed Nov 24, 2023
1 parent b868bef commit 0ad2cd4
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 30 deletions.
45 changes: 23 additions & 22 deletions OVP/D3D9Client/D3D9Client.rc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ EXSTYLE WS_EX_WINDOWEDGE
CAPTION "D3D9 Debug Controls"
FONT 8, "Ms Shell Dlg"
{
GROUPBOX "Mesh Options", IDC_DBG_MESHGRP, 3, 189, 176, 35, 0, WS_EX_LEFT
GROUPBOX "Mesh Options", IDC_STATIC, 5, 185, 176, 35, 0, WS_EX_LEFT
PUSHBUTTON "Close", IDCANCEL, 124, 429, 51, 14, 0, WS_EX_LEFT
PUSHBUTTON "Open", IDC_DBG_OPEN, 387, 34, 30, 14, 0, WS_EX_LEFT
PUSHBUTTON "Execute", IDC_DBG_EXECUTE, 490, 147, 56, 14, 0, WS_EX_LEFT
Expand Down Expand Up @@ -82,16 +82,16 @@ FONT 8, "Ms Shell Dlg"
LTEXT "Static", IDC_DBG_SPEEDDSP, 150, 69, 21, 10, SS_LEFT, WS_EX_LEFT
AUTOCHECKBOX "Add ambient light", IDC_DBG_AMBIENT, 18, 143, 70, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Wireframe", IDC_DBG_WIRE, 120, 133, 48, 8, 0, WS_EX_LEFT
GROUPBOX "Material", IDC_DBG_MATGRP, 3, 229, 175, 160, 0, WS_EX_LEFT
COMBOBOX IDC_DBG_MATPRP, 75, 244, 96, 15, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
COMBOBOX IDC_DBG_DEFSHADER, 75, 205, 96, 15, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
GROUPBOX "Material", IDC_DBG_MATGRP, 5, 225, 175, 170, 0, WS_EX_LEFT
COMBOBOX IDC_DBG_MATPRP, 77, 240, 96, 15, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
COMBOBOX IDC_DBG_DEFSHADER, 77, 201, 96, 15, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
COMBOBOX IDC_DBG_CONES, 200, 220, 165, 15, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
LTEXT "Material property", IDC_STATIC, 16, 246, 53, 8, SS_LEFT, WS_EX_LEFT
LTEXT "Default Shader", IDC_STATIC, 13, 207, 48, 8, SS_LEFT, WS_EX_LEFT
EDITTEXT IDC_DBG_RED, 29, 264, 30, 12, ES_AUTOHSCROLL, WS_EX_LEFT
EDITTEXT IDC_DBG_GREEN, 65, 264, 30, 12, ES_AUTOHSCROLL, WS_EX_LEFT
EDITTEXT IDC_DBG_BLUE, 101, 264, 30, 12, ES_AUTOHSCROLL, WS_EX_LEFT
EDITTEXT IDC_DBG_ALPHA, 137, 264, 30, 12, ES_AUTOHSCROLL, WS_EX_LEFT
LTEXT "Material property", IDC_STATIC, 18, 242, 53, 8, SS_LEFT, WS_EX_LEFT
LTEXT "Default Shader", IDC_STATIC, 15, 203, 48, 8, SS_LEFT, WS_EX_LEFT
EDITTEXT IDC_DBG_RED, 31, 260, 30, 12, ES_AUTOHSCROLL, WS_EX_LEFT
EDITTEXT IDC_DBG_GREEN, 67, 260, 30, 12, ES_AUTOHSCROLL, WS_EX_LEFT
EDITTEXT IDC_DBG_BLUE, 103, 260, 30, 12, ES_AUTOHSCROLL, WS_EX_LEFT
EDITTEXT IDC_DBG_ALPHA, 139, 260, 30, 12, ES_AUTOHSCROLL, WS_EX_LEFT
EDITTEXT IDC_DBG_VARA, 465, 127, 30, 12, ES_AUTOHSCROLL, WS_EX_LEFT
EDITTEXT IDC_DBG_VARC, 415, 127, 30, 12, ES_AUTOHSCROLL, WS_EX_LEFT
EDITTEXT IDC_DBG_VARB, 515, 127, 30, 12, ES_AUTOHSCROLL, WS_EX_LEFT
Expand All @@ -107,28 +107,28 @@ FONT 8, "Ms Shell Dlg"
LTEXT "Fb:", IDC_STATIC, 502, 129, 11, 8, SS_LEFT, WS_EX_LEFT
LTEXT "Fa:", IDC_STATIC, 452, 129, 11, 8, SS_LEFT, WS_EX_LEFT
LTEXT "Noise:", IDC_STATIC, 390, 129, 21, 8, SS_LEFT, WS_EX_LEFT
CONTROL "", IDC_DBG_MATADJ, TRACKBAR_CLASS, WS_TABSTOP | TBS_BOTH | TBS_NOTICKS, 17, 281, 156, 14, WS_EX_LEFT
CONTROL "", IDC_DBG_MATADJ, TRACKBAR_CLASS, WS_TABSTOP | TBS_BOTH | TBS_NOTICKS, 19, 277, 156, 14, WS_EX_LEFT
PUSHBUTTON "Save materials", IDC_DBG_MATSAVE, 5, 429, 51, 14, 0, WS_EX_LEFT
PUSHBUTTON "Create kernel", IDC_DBG_KERNEL, 315, 430, 47, 14, 0, WS_EX_LEFT
PUSHBUTTON "Data window", IDC_DBG_DATAWND, 5, 446, 50, 14, 0, WS_EX_LEFT
PUSHBUTTON "Save envmap", IDC_DBG_ENVSAVE, 205, 128, 60, 12, 0, WS_EX_LEFT
PUSHBUTTON ">>>", IDC_DBG_MORE, 124, 446, 50, 14, 0, WS_EX_LEFT
PUSHBUTTON "Reload Shader", IDC_DBG_RELOADSHD, 60, 446, 60, 14, 0, WS_EX_LEFT
PUSHBUTTON "Reload Textures", IDC_DBG_RELOADTEX, 60, 430, 60, 14, 0, WS_EX_LEFT
LTEXT "Texture: None", IDC_DBG_TEXTURE, 7, 351, 168, 10, SS_LEFT, WS_EX_LEFT
LTEXT "Texture: None", IDC_DBG_TEXTURE, 9, 347, 168, 10, SS_LEFT, WS_EX_LEFT
AUTOCHECKBOX "Pick", IDC_DBG_PICK, 120, 143, 30, 8, 0, WS_EX_LEFT
LTEXT "Mesh: None", IDC_DBG_MESHNAME, 7, 363, 168, 10, SS_LEFT, WS_EX_LEFT
LTEXT "Group Status:", IDC_DBG_GROUPSTAT, 8, 374, 170, 10, SS_LEFT, WS_EX_LEFT
PUSHBUTTON "Paste", IDC_DBG_PASTE, 131, 299, 37, 14, 0, WS_EX_LEFT
PUSHBUTTON "Copy", IDC_DBG_COPY, 88, 299, 39, 14, 0, WS_EX_LEFT
AUTOCHECKBOX "Link channels", IDC_DBG_LINK, 17, 306, 60, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Use and Save the property", IDC_DBG_DEFINED, 17, 334, 101, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Extend material range", IDC_DBG_EXTEND, 17, 320, 84, 8, 0, WS_EX_LEFT
LTEXT "Mesh: None", IDC_DBG_MESHNAME, 9, 358, 168, 10, SS_LEFT, WS_EX_LEFT
LTEXT "Group Status:", IDC_DBG_GROUPSTAT, 10, 369, 170, 10, SS_LEFT, WS_EX_LEFT
PUSHBUTTON "Paste", IDC_DBG_PASTE, 133, 295, 37, 14, 0, WS_EX_LEFT
PUSHBUTTON "Copy", IDC_DBG_COPY, 90, 295, 39, 14, 0, WS_EX_LEFT
AUTOCHECKBOX "Link channels", IDC_DBG_LINK, 19, 302, 60, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Use and Save the property", IDC_DBG_DEFINED, 19, 330, 101, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Extend material range", IDC_DBG_EXTEND, 19, 316, 84, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "FPS Limiter", IDC_DBG_FPSLIM, 205, 25, 51, 8, 0, WS_EX_LEFT
PUSHBUTTON "Export textures", IDC_DBG_EXPTEX, 315, 445, 52, 14, 0, WS_EX_LEFT
COMBOBOX IDC_DBG_BKLID, 10, 406, 50, 15, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
GROUPBOX "Baked Lights", 0, 5, 394, 175, 30, 0, WS_EX_LEFT
CONTROL "", IDC_DBG_BKLADJ, TRACKBAR_CLASS, WS_TABSTOP | TBS_BOTH | TBS_NOTICKS, 64, 404, 115, 15, WS_EX_LEFT
COMBOBOX IDC_DBG_BKLID, 11, 407, 50, 15, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
GROUPBOX "Baked Lights", 0, 6, 395, 175, 30, 0, WS_EX_LEFT
CONTROL "", IDC_DBG_BKLADJ, TRACKBAR_CLASS, WS_TABSTOP | TBS_BOTH | TBS_NOTICKS, 65, 405, 115, 15, WS_EX_LEFT
GROUPBOX "Mesh Group Information", IDC_STATIC, 195, 245, 175, 130, 0, WS_EX_LEFT
AUTOCHECKBOX "No Shadow", IDC_DBG_NOSHADOW, 200, 260, 53, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Do not render", IDC_DBG_NORENDER, 200, 270, 59, 8, 0, WS_EX_LEFT
Expand All @@ -146,6 +146,7 @@ FONT 8, "Ms Shell Dlg"
EDITTEXT IDC_DBG_GRPLABEL, 225, 355, 140, 12, ES_AUTOHSCROLL, WS_EX_LEFT
AUTOCHECKBOX "Exterior in VC", IDC_DBG_EXTVC, 120, 153, 58, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "10cm near clip distance", IDC_DBG_CLIPDIST, 18, 153, 91, 8, 0, WS_EX_LEFT
LTEXT "MeshVisMode: ", IDC_DBG_VISMODE, 10, 380, 162, 9, SS_LEFT, WS_EX_LEFT
}


Expand Down
17 changes: 14 additions & 3 deletions OVP/D3D9Client/DebugControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1335,9 +1335,20 @@ void UpdateMaterialDisplay(bool bSetup)

sprintf_s(lbl, 256, "Mesh: %s", RemovePath(hMesh->GetName()));
SetWindowText(GetDlgItem(hDlg, IDC_DBG_MESHNAME), lbl);

GetWindowText(GetDlgItem(hDlg, IDC_DBG_MESHGRP), lbl2, 64);
if (strcmp(lbl, lbl2)) SetWindowText(GetDlgItem(hDlg, IDC_DBG_MESHGRP), lbl); // Avoid causing flashing

string str = "";
DWORD vis = vObj->GetMeshVisMode(sMesh);

if (vis == 0) str = "NEVER";
if (vis == MESHVIS_ALWAYS) str = "ALWAYS";

if (vis & MESHVIS_COCKPIT) str.append("COCKPIT ");
if (vis & MESHVIS_VC) str.append("VC ");
if (vis & MESHVIS_EXTERNAL) str.append("EXTERNAL ");
if (vis & MESHVIS_EXTPASS) str.append("EXTPASS ");

sprintf_s(lbl, 256, "MeshVisMode: %s", str.c_str());
SetWindowText(GetDlgItem(hDlg, IDC_DBG_VISMODE), lbl);
}

// =============================================================================================
Expand Down
1 change: 1 addition & 0 deletions OVP/D3D9Client/VObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class vObject: public oapi::VisObject {
* \note Currently only vessel visuals return anything here.
*/
virtual MESHHANDLE GetMesh (UINT idx) { return NULL; }
virtual DWORD GetMeshVisMode (UINT idx) { return MESHVIS_ALWAYS; }

virtual void PreInitObject() { }

Expand Down
29 changes: 25 additions & 4 deletions OVP/D3D9Client/VVessel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,14 @@ MESHHANDLE vVessel::GetMesh (UINT idx)
}


// ============================================================================================
//
DWORD vVessel::GetMeshVisMode(UINT idx)
{
return (idx < nmesh ? meshlist[idx].vismode : MESHVIS_ALWAYS);
}


// ============================================================================================
//
bool vVessel::HasExtPass()
Expand Down Expand Up @@ -1921,17 +1929,30 @@ D3D9Pick vVessel::Pick(const D3DXVECTOR3 *vDir)
// check if mesh should be rendered in this pass
WORD vismode = meshlist[i].vismode;

if (vismode==0) continue;
if (DebugControls::IsActive() && (DebugControls::debugFlags & DBG_FLAGS_RENDEREXT))
{
vismode |= MESHVIS_EXTPASS;
}

if (vismode == 0) continue;

bool bRender = false;

if (bCockpit) {
if (!(vismode & MESHVIS_COCKPIT)) {
if ((!bVC) || (!(vismode & MESHVIS_VC))) continue;
// Internal View
if (vismode & MESHVIS_COCKPIT) bRender = true;
if (vismode & MESHVIS_EXTPASS) bRender = true;
if (bVC) {
if (vismode & MESHVIS_VC) bRender = true;
}
}
else {
if (!(vismode & MESHVIS_EXTERNAL)) continue;
// External view
if (vismode & MESHVIS_EXTERNAL) bRender = true;
}

if (!bRender) continue;

D3D9Pick pick = hMesh->Pick(&mWorld, meshlist[i].trans, vDir);
if (pick.pMesh) if (pick.dist<result.dist) result = pick;
}
Expand Down
1 change: 1 addition & 0 deletions OVP/D3D9Client/VVessel.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class vVessel: public vObject {
void clbkEvent(DWORD evnt, DWORD_PTR context);

MESHHANDLE GetMesh (UINT idx);
DWORD GetMeshVisMode(UINT idx);
bool GetMinMaxDistance(float *zmin, float *zmax, float *dmin);
void GetMinMaxLightDist(float *mind, float *maxd);
int GetMatrixTransform(gcCore::MatrixId matrix_id, DWORD mesh, DWORD group, FMATRIX4 *pMat);
Expand Down
2 changes: 1 addition & 1 deletion OVP/D3D9Client/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@
#define IDC_FLATS 2166
#define IDC_DBG_DEFSHADER 2167
#define IDC_DBG_DATAVIEW2 2168
#define IDC_DBG_MESHGRP 2169
#define IDC_GFX_INTENSITY 2170
#define IDC_GFX_DISTANCE 2171
#define IDC_GFX_GAMMA 2173
Expand Down Expand Up @@ -235,3 +234,4 @@
#define IDC_DBG_GRPLABEL 3051
#define IDC_DBG_EXTVC 3052
#define IDC_DBG_CLIPDIST 3053
#define IDC_DBG_VISMODE 3054

0 comments on commit 0ad2cd4

Please sign in to comment.