Skip to content

Commit

Permalink
Fixed Mesh Saving, Improved Picking options, Added VC shadow caster s…
Browse files Browse the repository at this point in the history
…election.
  • Loading branch information
jarmonik committed Nov 26, 2023
1 parent 0ad2cd4 commit c8e0d84
Show file tree
Hide file tree
Showing 18 changed files with 362 additions and 253 deletions.
14 changes: 11 additions & 3 deletions OVP/D3D9Client/D3D9Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,7 @@ MESHHANDLE D3D9Client::clbkGetMesh(VISHANDLE vis, UINT idx)
LogErr("NULL visual in clbkGetMesh(NULL,%u)",idx);
return NULL;
}
MESHHANDLE hMesh = ((vObject*)vis)->GetMesh(idx);
MESHHANDLE hMesh = (MESHHANDLE)((vObject*)vis)->GetMesh(idx);
if (hMesh==NULL) LogWrn("clbkGetMesh() returns NULL");
return hMesh;
}
Expand Down Expand Up @@ -1717,13 +1717,21 @@ LRESULT D3D9Client::RenderWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l

TRACKMOUSEEVENT te; te.cbSize = sizeof(TRACKMOUSEEVENT); te.dwFlags = TME_LEAVE; te.hwndTrack = hRenderWnd;
TrackMouseEvent(&te);
PickProp prp = { NULL, 0.1f, false };

bool bShift = (GetAsyncKeyState(VK_SHIFT) & 0x8000) != 0;
bool bCtrl = (GetAsyncKeyState(VK_CONTROL) & 0x8000) != 0;
bool bPckVsl = IsGenericProcEnabled(GENERICPROC_PICK_VESSEL);

if (DebugControls::IsActive() || bPckVsl || (bShift && bCtrl)) {
pick = GetScene()->PickScene(xpos, ypos);
if (DebugControls::IsActive() || bPckVsl || (bShift && bCtrl))
{
if (DebugControls::IsActive()) {
if (DebugControls::debugFlags & DBG_FLAGS_PICKCURRENT) prp.pMesh = DebugControls::GetMesh();
if (DebugControls::debugFlags & DBG_FLAGS_DUALSIDED) prp.bDualSided = true;
}

pick = GetScene()->PickScene(xpos, ypos, &prp);

if (bPckVsl) {
gcCore::PickData out;
out.hVessel = pick.vObj->GetObjectA();
Expand Down
5 changes: 5 additions & 0 deletions OVP/D3D9Client/D3D9Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ struct RenderTgtData {
int code;
};

struct PickProp {
D3D9Mesh* pMesh; // Mesh to pick, or NULL for full scene
float fnear; // Near clip distance, ignore entities closer than this
bool bDualSided; // Pick also back-facing triangles
};

struct SHADOWMAPPARAM {
LPDIRECT3DTEXTURE9 pShadowMap[SHM_CASCADE_COUNT];
Expand Down
108 changes: 56 additions & 52 deletions OVP/D3D9Client/D3D9Client.rc
Original file line number Diff line number Diff line change
Expand Up @@ -40,54 +40,54 @@ EXSTYLE WS_EX_WINDOWEDGE
CAPTION "D3D9 Debug Controls"
FONT 8, "Ms Shell Dlg"
{
GROUPBOX "Mesh Options", IDC_STATIC, 5, 185, 176, 35, 0, WS_EX_LEFT
GROUPBOX "Mesh Options", IDC_STATIC, 5, 165, 176, 60, 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
LTEXT "Selected Visual: Cape Canaveral", IDC_DBG_VISUAL, 7, 5, 104, 8, SS_LEFT, WS_EX_LEFT
COMBOBOX IDC_DBG_DISPLAY, 48, 33, 120, 15, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
LTEXT "Display", IDC_STATIC, 18, 36, 24, 8, SS_LEFT, WS_EX_LEFT
LTEXT "Camera", IDC_STATIC, 18, 51, 25, 11, SS_LEFT, WS_EX_LEFT
COMBOBOX IDC_DBG_CAMERA, 48, 51, 120, 15, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
EDITTEXT IDC_DBG_MESH, 54, 87, 44, 12, ES_AUTOHSCROLL, WS_EX_LEFT
LTEXT "Group Idx", IDC_STATIC, 18, 105, 32, 12, SS_LEFT, WS_EX_LEFT
LTEXT "Mesh Idx", IDC_STATIC, 18, 90, 30, 8, SS_LEFT, WS_EX_LEFT
EDITTEXT IDC_DBG_GROUP, 54, 105, 44, 12, WS_GROUP | ES_AUTOHSCROLL, WS_EX_LEFT
LTEXT "Selected Visual: Cape Canaveral", IDC_DBG_VISUAL, 7, 2, 104, 8, SS_LEFT, WS_EX_LEFT
COMBOBOX IDC_DBG_DISPLAY, 48, 27, 120, 15, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
LTEXT "Display", IDC_STATIC, 18, 30, 24, 8, SS_LEFT, WS_EX_LEFT
LTEXT "Camera", IDC_STATIC, 18, 43, 25, 11, SS_LEFT, WS_EX_LEFT
COMBOBOX IDC_DBG_CAMERA, 48, 42, 120, 15, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
EDITTEXT IDC_DBG_MESH, 54, 73, 44, 12, ES_AUTOHSCROLL, WS_EX_LEFT
LTEXT "Group Idx", IDC_STATIC, 18, 92, 32, 12, SS_LEFT, WS_EX_LEFT
LTEXT "Mesh Idx", IDC_STATIC, 18, 76, 30, 8, SS_LEFT, WS_EX_LEFT
EDITTEXT IDC_DBG_GROUP, 54, 89, 44, 12, WS_GROUP | ES_AUTOHSCROLL, WS_EX_LEFT
EDITTEXT IDC_DBG_FILE, 421, 35, 125, 12, WS_GROUP | ES_AUTOHSCROLL | ES_READONLY, WS_EX_LEFT
AUTOCHECKBOX "Highlight selected group", IDC_DBG_HSG, 18, 123, 92, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Highlight selected mesh", IDC_DBG_HSM, 18, 133, 91, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Highlight selected group", IDC_DBG_HSG, 18, 107, 92, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Highlight selected mesh", IDC_DBG_HSM, 18, 117, 91, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Boxes", IDC_DBG_BOXES, 208, 162, 35, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Normalize", IDC_DBG_NORM, 400, 79, 47, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Mipmap fade", IDC_DBG_FADE, 400, 92, 57, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Reduce seams", IDC_DBG_SEAMS, 460, 79, 63, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Spheres", IDC_DBG_SPHERES, 208, 173, 42, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Surface Tiles", IDC_DBG_TILEBB, 208, 185, 57, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Spheres", IDC_DBG_SPHERES, 208, 171, 42, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Surface Tiles", IDC_DBG_TILEBB, 208, 180, 57, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Selected group only", IDC_DBG_GRPO, 274, 162, 79, 8, 0, WS_EX_LEFT
GROUPBOX "Bounding geometry", IDC_STATIC, 195, 150, 175, 50, 0, WS_EX_LEFT
GROUPBOX "Visualize local light cones", IDC_STATIC, 195, 205, 175, 35, 0, WS_EX_LEFT
GROUPBOX "Mesh debugger", IDC_STATIC, 5, 20, 175, 160, 0, WS_EX_LEFT
GROUPBOX "Bounding geometry", IDC_STATIC, 195, 150, 175, 45, 0, WS_EX_LEFT
GROUPBOX "Visualize local light cones", IDC_STATIC, 195, 200, 175, 35, 0, WS_EX_LEFT
GROUPBOX "Selection and Display Options", IDC_STATIC, 5, 15, 175, 145, 0, WS_EX_LEFT
GROUPBOX "Misc.", IDC_STATIC, 195, 10, 173, 70, 0, WS_EX_LEFT
GROUPBOX "Scene Debugger", IDC_STATIC, 195, 85, 173, 60, 0, WS_EX_LEFT
GROUPBOX "Texture Tools", IDC_STATIC, 380, 15, 173, 151, 0, WS_EX_LEFT
AUTOCHECKBOX "Selected mesh only", IDC_DBG_MSHO, 274, 174, 77, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Dual sided", IDC_DBG_DUAL, 120, 123, 49, 8, 0, WS_EX_LEFT
PUSHBUTTON "<", IDC_DBG_GRPUP, 102, 105, 9, 12, BS_CENTER, WS_EX_LEFT
PUSHBUTTON ">", IDC_DBG_GRPDN, 114, 105, 9, 12, BS_CENTER, WS_EX_LEFT
PUSHBUTTON "<", IDC_DBG_MSHUP, 102, 87, 9, 12, BS_CENTER, WS_EX_LEFT
PUSHBUTTON ">", IDC_DBG_MSHDN, 114, 87, 9, 12, BS_CENTER, WS_EX_LEFT
AUTOCHECKBOX "Selected visual only", IDC_DBG_VISO, 274, 186, 79, 8, 0, WS_EX_LEFT
CONTROL "", IDC_DBG_SPEED, TRACKBAR_CLASS, WS_TABSTOP | TBS_BOTH | TBS_NOTICKS, 42, 69, 108, 13, WS_EX_LEFT
AUTOCHECKBOX "Selected mesh only", IDC_DBG_MSHO, 274, 171, 77, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Dual sided", IDC_DBG_DUAL, 120, 107, 49, 8, 0, WS_EX_LEFT
PUSHBUTTON "<", IDC_DBG_GRPUP, 102, 90, 9, 12, BS_CENTER, WS_EX_LEFT
PUSHBUTTON ">", IDC_DBG_GRPDN, 114, 90, 9, 12, BS_CENTER, WS_EX_LEFT
PUSHBUTTON "<", IDC_DBG_MSHUP, 102, 73, 9, 12, BS_CENTER, WS_EX_LEFT
PUSHBUTTON ">", IDC_DBG_MSHDN, 114, 73, 9, 12, BS_CENTER, WS_EX_LEFT
AUTOCHECKBOX "Selected visual only", IDC_DBG_VISO, 274, 180, 79, 8, 0, WS_EX_LEFT
CONTROL "", IDC_DBG_SPEED, TRACKBAR_CLASS, WS_TABSTOP | TBS_BOTH | TBS_NOTICKS, 42, 58, 108, 13, WS_EX_LEFT
CONTROL "", IDC_DBG_RESBIAS, TRACKBAR_CLASS, WS_TABSTOP | TBS_AUTOTICKS | TBS_BOTH, 205, 55, 155, 20, WS_EX_LEFT
LTEXT "Speed", IDC_STATIC, 18, 69, 22, 8, SS_LEFT, WS_EX_LEFT
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, 5, 225, 175, 170, 0, WS_EX_LEFT
LTEXT "Speed", IDC_STATIC, 18, 58, 22, 8, SS_LEFT, WS_EX_LEFT
LTEXT "Static", IDC_DBG_SPEEDDSP, 150, 58, 21, 10, SS_LEFT, WS_EX_LEFT
AUTOCHECKBOX "Add ambient light", IDC_DBG_AMBIENT, 18, 127, 70, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Wireframe", IDC_DBG_WIRE, 120, 117, 48, 8, 0, WS_EX_LEFT
GROUPBOX "Material", IDC_DBG_MATGRP, 5, 230, 175, 165, 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
COMBOBOX IDC_DBG_DEFSHADER, 75, 177, 96, 15, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
COMBOBOX IDC_DBG_CONES, 200, 215, 165, 15, CBS_DROPDOWNLIST | CBS_HASSTRINGS, 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
LTEXT "Mesh Shader", IDC_STATIC, 15, 179, 43, 9, 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
Expand Down Expand Up @@ -116,37 +116,41 @@ FONT 8, "Ms Shell Dlg"
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, 9, 347, 168, 10, SS_LEFT, WS_EX_LEFT
AUTOCHECKBOX "Pick", IDC_DBG_PICK, 120, 143, 30, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Pick", IDC_DBG_PICK, 120, 127, 30, 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 "Use and Save the property", IDC_DBG_DEFINED, 19, 324, 101, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Extend material range", IDC_DBG_EXTEND, 19, 313, 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, 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
AUTOCHECKBOX "Always Lit", IDC_DBG_NOLIGHT, 200, 280, 47, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Additive Blend", IDC_DBG_ADDITIVE, 200, 290, 61, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Texture Alpha Only (No Color)", IDC_DBG_NOCOLOR, 200, 300, 109, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Order Independent Transparency", IDC_DBG_OIT, 200, 310, 121, 8, 0, WS_EX_LEFT
EDITTEXT IDC_DBG_MATIDX, 225, 325, 30, 12, ES_AUTOHSCROLL, WS_EX_LEFT
EDITTEXT IDC_DBG_TEXIDX, 225, 340, 30, 12, ES_AUTOHSCROLL, WS_EX_LEFT
LTEXT "MatIdx", IDC_STATIC, 200, 326, 22, 9, SS_LEFT, WS_EX_LEFT
LTEXT "TexIdx", IDC_STATIC, 200, 342, 22, 9, SS_LEFT, WS_EX_LEFT
GROUPBOX "Mesh Group Information", IDC_STATIC, 195, 240, 175, 135, 0, WS_EX_LEFT
AUTOCHECKBOX "No Shadow", IDC_DBG_NOSHADOW, 200, 255, 53, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Do not render", IDC_DBG_NORENDER, 200, 265, 59, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Always Lit", IDC_DBG_NOLIGHT, 200, 275, 47, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Additive Blend", IDC_DBG_ADDITIVE, 200, 285, 61, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Texture Alpha Only (No Color)", IDC_DBG_NOCOLOR, 200, 295, 109, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Order Independent Transparency", IDC_DBG_OIT, 200, 305, 121, 8, 0, WS_EX_LEFT
EDITTEXT IDC_DBG_MATIDX, 225, 320, 30, 12, ES_AUTOHSCROLL, WS_EX_LEFT
EDITTEXT IDC_DBG_TEXIDX, 225, 335, 30, 12, ES_AUTOHSCROLL, WS_EX_LEFT
LTEXT "MatIdx", IDC_STATIC, 200, 321, 22, 9, SS_LEFT, WS_EX_LEFT
LTEXT "TexIdx", IDC_STATIC, 200, 337, 22, 9, SS_LEFT, WS_EX_LEFT
PUSHBUTTON "Save Mesh", IDC_DBG_MESHSAVE, 200, 430, 55, 14, 0, WS_EX_LEFT
PUSHBUTTON "Unrendered", IDC_DBG_NEXT, 127, 105, 48, 12, 0, WS_EX_LEFT
LTEXT "Label", IDC_STATIC, 201, 357, 18, 9, SS_LEFT, WS_EX_LEFT
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
PUSHBUTTON "Unrendered", IDC_DBG_NEXT, 127, 90, 48, 12, 0, WS_EX_LEFT
LTEXT "Label", IDC_STATIC, 201, 352, 18, 9, SS_LEFT, WS_EX_LEFT
EDITTEXT IDC_DBG_GRPLABEL, 225, 350, 140, 12, ES_AUTOHSCROLL, WS_EX_LEFT
AUTOCHECKBOX "Exterior in VC", IDC_DBG_EXTVC, 120, 137, 58, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "2cm near clip distance", IDC_DBG_CLIPDIST, 18, 136, 87, 8, 0, WS_EX_LEFT
LTEXT "MeshVisMode: ", IDC_DBG_VISMODE, 10, 380, 162, 9, SS_LEFT, WS_EX_LEFT
AUTOCHECKBOX "Pick only current mesh", IDC_DBG_PICKCURRENT, 18, 146, 87, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Dynamic", IDC_DBG_DYNAMIC, 285, 255, 43, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Is VC Mesh", IDC_DBG_ISVCMESH, 15, 193, 52, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Cast VC Shadow", IDC_DBG_VCSHADOW, 15, 203, 69, 8, 0, WS_EX_LEFT
}


Expand Down
2 changes: 1 addition & 1 deletion OVP/D3D9Client/D3D9ControlPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ void D3D9Client::RenderControlPanel()
if (vObj) {
DWORD nMesh = vObj->GetMeshCount();
for (DWORD i = 0; i < nMesh; i++) {
D3D9Mesh *hMesh = static_cast<D3D9Mesh *>(vObj->GetMesh(i));
D3D9Mesh *hMesh = vObj->GetMesh(i);
hMesh->ResetRenderStatus();
}
}
Expand Down
Loading

0 comments on commit c8e0d84

Please sign in to comment.