MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / Load_GameSpecific_CFORM

Method Load_GameSpecific_CFORM

ogsr_engine/xrGame/Level_load.cpp:133–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131};
132
133void CLevel::Load_GameSpecific_CFORM(CDB::TRI* tris, const size_t count)
134{
135 typedef xr_vector<translation_pair> ID_INDEX_PAIRS;
136 ID_INDEX_PAIRS translator;
137 translator.reserve(GMLib.CountMaterial());
138 u16 default_id = (u16)GMLib.GetMaterialIdx("default");
139 translator.push_back(translation_pair(u32(-1), default_id));
140
141 u16 index = 0, static_mtl_count = 1;
142 int max_ID = 0;
143 int max_static_ID = 0;
144 for (GameMtlIt I = GMLib.FirstMaterial(); GMLib.LastMaterial() != I; ++I, ++index)
145 {
146 if (!(*I)->Flags.test(SGameMtl::flDynamic))
147 {
148 ++static_mtl_count;
149 translator.emplace_back((*I)->GetID(), index);
150 if ((*I)->GetID() > max_static_ID)
151 max_static_ID = (*I)->GetID();
152 }
153 if ((*I)->GetID() > max_ID)
154 max_ID = (*I)->GetID();
155 }
156 // Msg("* Material remapping ID: [Max:%d, StaticMax:%d]",max_ID,max_static_ID);
157 VERIFY(max_static_ID < 0xFFFF);
158
159 if (static_mtl_count < 128)
160 {
161 CDB::TRI* I = tris;
162 CDB::TRI* E = tris + count;
163 for (; I != E; ++I)
164 {
165 ID_INDEX_PAIRS::iterator i = std::find(translator.begin(), translator.end(), (u16)(*I).material);
166 if (i != translator.end())
167 {
168 (*I).material = (*i).m_index;
169 SGameMtl* mtl = GMLib.GetMaterialByIdx((*i).m_index);
170 (*I).suppress_shadows = mtl->Flags.is(SGameMtl::flSuppressShadows);
171 (*I).suppress_wm = mtl->Flags.is(SGameMtl::flSuppressWallmarks);
172 continue;
173 }
174
175 Debug.fatal(DEBUG_INFO, "Game material '%d' not found", (*I).material);
176 }
177 return;
178 }
179
180 std::sort(translator.begin(), translator.end());
181 {
182 CDB::TRI* I = tris;
183 CDB::TRI* E = tris + count;
184 for (; I != E; ++I)
185 {
186 ID_INDEX_PAIRS::iterator i = std::lower_bound(translator.begin(), translator.end(), (u16)(*I).material);
187 if ((i != translator.end()) && ((*i).m_id == (*I).material))
188 {
189 (*I).material = (*i).m_index;
190 SGameMtl* mtl = GMLib.GetMaterialByIdx((*i).m_index);

Callers 1

build_callbackFunction · 0.80

Calls 12

translation_pairClass · 0.85
isMethod · 0.80
u32Enum · 0.70
findFunction · 0.50
sortFunction · 0.50
reserveMethod · 0.45
push_backMethod · 0.45
testMethod · 0.45
GetIDMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
fatalMethod · 0.45

Tested by

no test coverage detected