Skip to content

Commit eb5a63f

Browse files
committed
Refactor of custom shader flags and removed of redundant code
1 parent 9486e6e commit eb5a63f

File tree

6 files changed

+64
-67
lines changed

6 files changed

+64
-67
lines changed

src/Layers/xrRender/HW.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ class CHW
6464
ID3D11RenderTargetView* pBaseRT; // combine with DX9 pBaseRT via typedef
6565
ID3D11DepthStencilView* pBaseZB;
6666

67-
ID3D11Texture2D* pBaseTEXZB;
68-
6967
CHWCaps Caps;
7068

7169
D3D_DRIVER_TYPE m_DriverType; // DevT equivalent

src/Layers/xrRender/Shader.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,21 @@ ShaderElement::ShaderElement()
109109
flags.isLandscape = FALSE;
110110
flags.isWater = FALSE;
111111

112-
flags.isScope = FALSE; // Redotix99: for 3D Shader Based Scopes
113-
flags.isScope2 = FALSE;
114-
flags.isScope3 = FALSE;
112+
flags.iScopeLense = 0; // Redotix99: for 3D Shader Based Scopes
113+
// 0 = eNoLense,
114+
// 1 = eBackLense,
115+
// 2 = eZwriteLense,
116+
// 3 = eReticleLense
115117
}
116118

117119
BOOL ShaderElement::equal(ShaderElement& S)
118120
{
119121
if (flags.iPriority != S.flags.iPriority) return FALSE;
120122
if (flags.bStrictB2F != S.flags.bStrictB2F) return FALSE;
121123
if (flags.bEmissive != S.flags.bEmissive) return FALSE;
122-
if (flags.isScope != S.flags.isScope) return FALSE; // Redotix99: for 3D Shader Based Scopes
123-
if (flags.isScope2 != S.flags.isScope2) return FALSE;
124-
if (flags.isScope3 != S.flags.isScope3) return FALSE;
124+
125+
if (flags.iScopeLense != S.flags.iScopeLense) return FALSE; // Redotix99: for 3D Shader Based Scopes
126+
125127
if (flags.bLandscape != S.flags.bLandscape) return FALSE;
126128
if (flags.bWmark != S.flags.bWmark) return FALSE;
127129
if (flags.bDistort != S.flags.bDistort) return FALSE;

src/Layers/xrRender/Shader.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,7 @@ struct ECORE_API ShaderElement : public xr_resource_flagged
130130
u32 isLandscape : 1;
131131
u32 isWater : 1;
132132

133-
u32 isScope : 1; // Redotix99: for 3D Shader Based Scopes
134-
u32 isScope2 : 1;
135-
u32 isScope3 : 1;
133+
u32 iScopeLense : 2; // Redotix99: for 3D Shader Based Scopes
136134
};
137135

138136
public:

src/Layers/xrRender/r__dsgraph_build.cpp

Lines changed: 43 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -73,38 +73,49 @@ void R_dsgraph_structure::r_dsgraph_insert_dynamic(dxRender_Visual* pVisual, Fve
7373
// NOTE: Invisible elements exist only in R1
7474
_MatrixItem item = {SSA, RI.val_pObject, pVisual, *RI.val_pTransform};
7575

76-
// Redotix99: for 3D Shader Based Scopes
77-
if (sh->flags.isScope)
78-
{
79-
mapHUD_Node* N = mapHUD.insertInAnyWay(EPS);
80-
N->val.ssa = SSA;
81-
N->val.pObject = RI.val_pObject;
82-
N->val.pVisual = pVisual;
83-
N->val.Matrix = *RI.val_pTransform;
84-
N->val.se = sh;
85-
return;
86-
}
87-
// Redotix99: for 3D Shader Based Scopes
88-
if (sh->flags.isScope2)
89-
{
90-
mapHUD_Node* N = mapScopeHUD.insertInAnyWay(distSQ);
91-
N->val.ssa = SSA;
92-
N->val.pObject = RI.val_pObject;
93-
N->val.pVisual = pVisual;
94-
N->val.Matrix = *RI.val_pTransform;
95-
N->val.se = sh;
96-
return;
97-
}
98-
// Redotix99: for 3D Shader Based Scopes
99-
if (sh->flags.isScope3)
100-
{
101-
mapSorted_Node* N = mapScopeHUDSorted.insertInAnyWay(distSQ);
102-
N->val.ssa = SSA;
103-
N->val.pObject = RI.val_pObject;
104-
N->val.pVisual = pVisual;
105-
N->val.Matrix = *RI.val_pTransform;
106-
N->val.se = sh;
107-
return;
76+
switch (sh->flags.iScopeLense) {
77+
case 0:
78+
break;
79+
80+
case 1: {
81+
mapHUD_Node* N = mapHUD.insertInAnyWay(EPS);
82+
N->val.ssa = SSA;
83+
N->val.pObject = RI.val_pObject;
84+
N->val.pVisual = pVisual;
85+
N->val.Matrix = *RI.val_pTransform;
86+
N->val.se = sh;
87+
88+
if (!sh->passes[0]->ps->hud_disabled)
89+
{
90+
HUDMask_Node* N2 = HUDMask.insertInAnyWay(EPS);
91+
N2->val.ssa = SSA;
92+
N2->val.pObject = RI.val_pObject;
93+
N2->val.pVisual = pVisual;
94+
N2->val.Matrix = *RI.val_pTransform;
95+
N2->val.se = sh;
96+
}
97+
return;
98+
}
99+
100+
case 2: {
101+
mapHUD_Node * N = mapScopeHUD.insertInAnyWay(distSQ);
102+
N->val.ssa = SSA;
103+
N->val.pObject = RI.val_pObject;
104+
N->val.pVisual = pVisual;
105+
N->val.Matrix = *RI.val_pTransform;
106+
N->val.se = sh;
107+
return;
108+
}
109+
110+
case 3: {
111+
mapSorted_Node * N = mapScopeHUDSorted.insertInAnyWay(distSQ);
112+
N->val.ssa = SSA;
113+
N->val.pObject = RI.val_pObject;
114+
N->val.pVisual = pVisual;
115+
N->val.Matrix = *RI.val_pTransform;
116+
N->val.se = sh;
117+
return;
118+
}
108119
}
109120

110121
// HUD rendering

src/Layers/xrRender/r__dsgraph_render.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -600,20 +600,22 @@ void R_dsgraph_structure::r_dsgraph_render_hud(bool NoPS)
600600
{
601601
mapHUD.traverseLR(sorted_L1);
602602
mapHUD.clear();
603+
604+
rmNormal();
605+
606+
if (scope_3D_fake_enabled)
607+
{
608+
mapScopeHUD.traverseLR(sorted_L1);
609+
}
610+
mapScopeHUD.clear();
603611
}
604612
else
605613
{
606614
HUDMask.traverseLR(hud_node);
607615
HUDMask.clear();
608-
}
609-
610-
rmNormal();
611616

612-
if (scope_3D_fake_enabled)
613-
{
614-
mapScopeHUD.traverseLR(sorted_L1);
617+
rmNormal();
615618
}
616-
mapScopeHUD.clear();
617619

618620
// Restore projection
619621
Device.mProject = Pold;

src/Layers/xrRenderDX10/dx10ResourceManager_Scripting.cpp

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -119,21 +119,9 @@ class adopt_compiler
119119
}
120120

121121
// Redotix99: for 3D Shader Based Scopes
122-
adopt_compiler& _o_scope(bool E)
122+
adopt_compiler& _o_scopelense(u32 lenseType)
123123
{
124-
C->SH->flags.isScope = E;
125-
return *this;
126-
}
127-
128-
adopt_compiler& _o_scope2(bool E)
129-
{
130-
C->SH->flags.isScope2 = E;
131-
return *this;
132-
}
133-
134-
adopt_compiler& _o_scope3(bool E)
135-
{
136-
C->SH->flags.isScope3 = E;
124+
C->SH->flags.iScopeLense = lenseType;
137125
return *this;
138126
}
139127

@@ -416,9 +404,7 @@ void CResourceManager::LS_Load()
416404
.def("blend", &adopt_compiler::_blend, return_reference_to(_1))
417405
.def("aref", &adopt_compiler::_aref, return_reference_to(_1))
418406

419-
.def("scope", &adopt_compiler::_o_scope, return_reference_to(_1)) // Redotix99: for 3D Shader Based Scopes
420-
.def("scope2", &adopt_compiler::_o_scope2, return_reference_to(_1))
421-
.def("scope3", &adopt_compiler::_o_scope3, return_reference_to(_1))
407+
.def("scopelense", &adopt_compiler::_o_scopelense, return_reference_to(_1)) // Redotix99: for 3D Shader Based Scopes
422408

423409
// For compatibility only
424410
.def("dx10color_write_enable", &adopt_compiler::_dx10color_write_enable, return_reference_to(_1))

0 commit comments

Comments
 (0)