Skip to content

Commit 9ab3eae

Browse files
committed
Fixed display on HUD of transparent surfaces. Untested!
1 parent b3c4ad8 commit 9ab3eae

File tree

3 files changed

+34
-12
lines changed

3 files changed

+34
-12
lines changed

src/Layers/xrRender/D3DXRenderBase.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class D3DXRenderBase : public IRender, public pureFrame
4040
R_dsgraph::mapHUD_T mapHUD;
4141
R_dsgraph::mapLOD_T mapLOD;
4242
R_dsgraph::mapSorted_T mapDistort;
43+
R_dsgraph::mapHUD_T mapHUDSorted;
4344

4445
#if RENDER != R_R1
4546
R_dsgraph::mapSorted_T mapWmark; // sorted
@@ -142,10 +143,12 @@ class D3DXRenderBase : public IRender, public pureFrame
142143
mapHUD.clear();
143144
mapLOD.clear();
144145
mapDistort.clear();
146+
mapHUDSorted.clear();
145147

146148
#if RENDER != R_R1
147149
mapWmark.clear();
148150
mapEmissive.clear();
151+
mapHUDEmissive.clear();
149152
#endif
150153
}
151154

src/Layers/xrRender/r__dsgraph_build.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,14 @@ void D3DXRenderBase::r_dsgraph_insert_dynamic(dxRender_Visual* pVisual, Fvector&
7474
if (RI.val_bHUD)
7575
{
7676
if (sh->flags.bStrictB2F)
77-
{
78-
mapSorted.emplace_back(std::make_pair(distSQ, _MatrixItemS({ SSA, RI.val_pObject, pVisual, *RI.val_pTransform, sh })));
79-
}
77+
mapHUDSorted.emplace_back(std::make_pair(distSQ, _MatrixItemS({ SSA, RI.val_pObject, pVisual, *RI.val_pTransform, sh })));
8078
else
81-
{
82-
mapHUD.emplace_back(std::make_pair(distSQ, _MatrixItemS({ SSA, RI.val_pObject, pVisual, *RI.val_pTransform, sh })));
79+
mapHUD .emplace_back(std::make_pair(distSQ, _MatrixItemS({ SSA, RI.val_pObject, pVisual, *RI.val_pTransform, sh })));
80+
8381
#if RENDER != R_R1
84-
if (sh->flags.bEmissive)
85-
mapHUDEmissive.emplace_back(std::make_pair(distSQ, _MatrixItemS({ SSA, RI.val_pObject, pVisual, *RI.val_pTransform, sh_d }))); // sh_d -> L_special
86-
#endif // RENDER!=R_R1
87-
}
82+
if (sh->flags.bEmissive)
83+
mapHUDEmissive.emplace_back(std::make_pair(distSQ, _MatrixItemS({ SSA, RI.val_pObject, pVisual, *RI.val_pTransform, sh_d }))); // sh_d -> L_special
84+
#endif
8885
return;
8986
}
9087

src/Layers/xrRender/r__dsgraph_render.cpp

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,10 @@ void D3DXRenderBase::r_dsgraph_render_hud_ui()
386386
{
387387
VERIFY(g_hud && g_hud->RenderActiveItemUIQuery());
388388

389-
extern ENGINE_API float psHUD_FOV;
390-
391389
PIX_EVENT(r_dsgraph_render_hud_ui);
392390

391+
extern ENGINE_API float psHUD_FOV;
392+
393393
// Change projection
394394
Fmatrix Pold = Device.mProject;
395395
Fmatrix FTold = Device.mFullTransform;
@@ -435,6 +435,29 @@ void D3DXRenderBase::r_dsgraph_render_sorted()
435435
for (auto &i : mapSorted)
436436
sorted_L1(i);
437437
mapSorted.clear();
438+
439+
extern ENGINE_API float psHUD_FOV;
440+
441+
// Change projection
442+
Fmatrix Pold = Device.mProject;
443+
Fmatrix FTold = Device.mFullTransform;
444+
Device.mProject.build_projection(deg2rad(psHUD_FOV * Device.fFOV /* *Device.fASPECT*/), Device.fASPECT,
445+
VIEWPORT_NEAR, g_pGamePersistent->Environment().CurrentEnv->far_plane);
446+
447+
Device.mFullTransform.mul(Device.mProject, Device.mView);
448+
RCache.set_xform_project(Device.mProject);
449+
450+
// Rendering
451+
rmNear();
452+
std::sort(mapHUDSorted.begin(), mapHUDSorted.end(), cmp_first_h<R_dsgraph::mapSorted_T::value_type>); // back-to-front
453+
for (auto &i : mapHUDSorted)
454+
sorted_L1(i);
455+
rmNormal();
456+
457+
// Restore projection
458+
Device.mProject = Pold;
459+
Device.mFullTransform = FTold;
460+
RCache.set_xform_project(Device.mProject);
438461
}
439462

440463
//////////////////////////////////////////////////////////////////////////
@@ -467,7 +490,6 @@ void D3DXRenderBase::r_dsgraph_render_emissive()
467490
for (auto &i : mapHUDEmissive)
468491
sorted_L1(i);
469492
mapHUDEmissive.clear();
470-
471493
rmNormal();
472494

473495
// Restore projection

0 commit comments

Comments
 (0)