Skip to content

Commit 6b00181

Browse files
intorrXottab-DUTY
authored andcommitted
Replace FixedMAP mapLOD with xr_vector.
1 parent 63e2ba5 commit 6b00181

File tree

7 files changed

+19
-26
lines changed

7 files changed

+19
-26
lines changed

src/Layers/xrRender/D3DXRenderBase.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ class D3DXRenderBase : public IRender, public pureFrame
6767
xr_vector<R_dsgraph::mapMatrixStates::value_type *> matStates;
6868
xr_vector<R_dsgraph::mapMatrixTextures::value_type *> matTextures;
6969
xr_vector<R_dsgraph::mapMatrixTextures::value_type *> matTexturesTemp;
70-
xr_vector<R_dsgraph::_LodItem> lstLODs;
7170
xr_vector<int> lstLODgroups;
7271
xr_vector<ISpatial*> lstRenderables;
7372
xr_vector<ISpatial*> lstSpatial;
@@ -127,7 +126,6 @@ class D3DXRenderBase : public IRender, public pureFrame
127126
matTextures.clear();
128127
matTexturesTemp.clear();
129128

130-
lstLODs.clear();
131129
lstLODgroups.clear();
132130
lstRenderables.clear();
133131
lstSpatial.clear();
@@ -142,7 +140,7 @@ class D3DXRenderBase : public IRender, public pureFrame
142140
}
143141
mapSorted.destroy();
144142
mapHUD.destroy();
145-
mapLOD.destroy();
143+
mapLOD.clear();
146144
mapDistort.destroy();
147145

148146
#if RENDER != R_R1

src/Layers/xrRender/r__dsgraph_build.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,7 @@ void CRender::add_leafs_Static(dxRender_Visual* pVisual)
519519
{
520520
if (ssa < r_ssaDISCARD)
521521
return;
522-
mapLOD_Node* N = mapLOD.insertInAnyWay(D);
523-
N->val.ssa = ssa;
524-
N->val.pVisual = pVisual;
522+
mapLOD.emplace_back(std::make_pair(D, _LodItem({ ssa, pVisual })));
525523
}
526524
#if RENDER != R_R1
527525
if (ssa > r_ssaLOD_B || phase == PHASE_SMAP)
@@ -737,9 +735,7 @@ void CRender::add_Static(dxRender_Visual* pVisual, u32 planes)
737735
{
738736
if (ssa < r_ssaDISCARD)
739737
return;
740-
mapLOD_Node* N = mapLOD.insertInAnyWay(D);
741-
N->val.ssa = ssa;
742-
N->val.pVisual = pVisual;
738+
mapLOD.emplace_back(std::make_pair(D, _LodItem({ ssa, pVisual })));
743739
}
744740
#if RENDER != R_R1
745741
if (ssa > r_ssaLOD_B || phase == PHASE_SMAP)

src/Layers/xrRender/r__dsgraph_render_lods.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,24 @@
1212
extern float r_ssaLOD_A;
1313
extern float r_ssaLOD_B;
1414

15+
template <class T> IC bool cmp_first_l(const T &lhs, const T &rhs) { return (lhs.first < rhs.first); }
16+
template <class T> IC bool cmp_first_h(const T &lhs, const T &rhs) { return (lhs.first > rhs.first); }
17+
1518
ICF bool pred_dot(const std::pair<float, u32>& _1, const std::pair<float, u32>& _2) { return _1.first < _2.first; }
19+
1620
void D3DXRenderBase::r_dsgraph_render_lods(bool _setup_zb, bool _clear)
1721
{
22+
if (mapLOD.empty())
23+
return;
24+
1825
if (_setup_zb)
19-
mapLOD.getLR(lstLODs); // front-to-back
26+
std::sort(mapLOD.begin(), mapLOD.end(), cmp_first_l<R_dsgraph::mapLOD_T::value_type>); // front-to-back
2027
else
21-
mapLOD.getRL(lstLODs); // back-to-front
22-
if (lstLODs.empty())
23-
return;
28+
std::sort(mapLOD.begin(), mapLOD.end(), cmp_first_h<R_dsgraph::mapLOD_T::value_type>); // back-to-front
2429

2530
// *** Fill VB and generate groups
2631
u32 shid = _setup_zb ? SE_R1_LMODELS : SE_R1_NORMAL_LQ;
27-
FLOD* firstV = (FLOD*)lstLODs[0].pVisual;
32+
FLOD* firstV = (FLOD*)mapLOD[0].second.pVisual;
2833
ref_selement cur_S = firstV->shader->E[shid];
2934
float ssaRange = r_ssaLOD_A - r_ssaLOD_B;
3035
if (ssaRange < EPS_S)
@@ -37,9 +42,9 @@ void D3DXRenderBase::r_dsgraph_render_lods(bool _setup_zb, bool _clear)
3742
//Msg("dbg_lods: shader[%X]",u32((void*)firstV->shader._get()));
3843
//Msg("dbg_lods: shader_E[%X]",u32((void*)cur_S._get()));
3944

40-
for (u32 i = 0; i < lstLODs.size(); i++)
45+
for (u32 i = 0; i < mapLOD.size(); i++)
4146
{
42-
const u32 iBatchSize = std::min(lstLODs.size() - i, (size_t)uiImpostersFit);
47+
const u32 iBatchSize = std::min(mapLOD.size() - i, (size_t)uiImpostersFit);
4348
int cur_count = 0;
4449
u32 vOffset;
4550
FLOD::_hw* V =
@@ -48,7 +53,7 @@ void D3DXRenderBase::r_dsgraph_render_lods(bool _setup_zb, bool _clear)
4853
for (u32 j = 0; j < iBatchSize; ++j, ++i)
4954
{
5055
// sort out redundancy
51-
R_dsgraph::_LodItem& P = lstLODs[i];
56+
R_dsgraph::_LodItem& P = mapLOD[i].second;
5257
if (P.pVisual->shader->E[shid] == cur_S)
5358
cur_count++;
5459
else
@@ -121,10 +126,10 @@ void D3DXRenderBase::r_dsgraph_render_lods(bool _setup_zb, bool _clear)
121126
for (u32 g = 0; g < lstLODgroups.size(); g++)
122127
{
123128
int p_count = lstLODgroups[g];
124-
u32 uiNumPasses = lstLODs[current].pVisual->shader->E[shid]->passes.size();
129+
u32 uiNumPasses = mapLOD[current].second.pVisual->shader->E[shid]->passes.size();
125130
if (uiPass < uiNumPasses)
126131
{
127-
RCache.set_Element(lstLODs[current].pVisual->shader->E[shid], uiPass);
132+
RCache.set_Element(mapLOD[current].second.pVisual->shader->E[shid], uiPass);
128133
RCache.set_Geometry(firstV->geom);
129134
RCache.Render(D3DPT_TRIANGLELIST, vCurOffset, 0, 4 * p_count, 0, 2 * p_count);
130135
}
@@ -137,8 +142,6 @@ void D3DXRenderBase::r_dsgraph_render_lods(bool _setup_zb, bool _clear)
137142
lstLODgroups.clear();
138143
}
139144

140-
lstLODs.clear();
141-
142145
if (_clear)
143146
mapLOD.clear();
144147
}

src/Layers/xrRender/r__dsgraph_types.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,5 @@ using mapSorted_Node = mapSorted_T::TNode;
163163
using mapHUD_T = FixedMAP<float, _MatrixItemS>;
164164
using mapHUD_Node = mapHUD_T::TNode;
165165

166-
using mapLOD_T = FixedMAP<float, _LodItem>;
167-
using mapLOD_Node = mapLOD_T::TNode;
166+
using mapLOD_T = xr_vector<std::pair<float, _LodItem>>;
168167
}

src/Layers/xrRenderPC_R2/r2_loader.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ void CRender::level_Load(IReader* fs)
102102
pApp->LoadEnd();
103103

104104
// sanity-clear
105-
lstLODs.clear();
106105
lstLODgroups.clear();
107106
mapLOD.clear();
108107

src/Layers/xrRenderPC_R3/r3_loader.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ void CRender::level_Load(IReader* fs)
108108
pApp->LoadEnd();
109109

110110
// sanity-clear
111-
lstLODs.clear();
112111
lstLODgroups.clear();
113112
mapLOD.clear();
114113

src/Layers/xrRenderPC_R4/r4_loader.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ void CRender::level_Load(IReader* fs)
108108
pApp->LoadEnd();
109109

110110
// sanity-clear
111-
lstLODs.clear();
112111
lstLODgroups.clear();
113112
mapLOD.clear();
114113

0 commit comments

Comments
 (0)