MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / clearMatInstList

Method clearMatInstList

Engine/source/materials/materialList.cpp:266–288  ·  view source on GitHub ↗

-------------------------------------------------------------------------- Clear all materials in the mMatInstList member variable --------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

264// Clear all materials in the mMatInstList member variable
265//--------------------------------------------------------------------------
266void MaterialList::clearMatInstList()
267{
268 // clear out old materials. any non null element of the list should be pointing at deletable memory,
269 // although multiple indexes may be pointing at the same memory so we have to be careful (see
270 // comment in loop body)
271 for (U32 i=0; i<mMatInstList.size(); i++)
272 {
273 if (mMatInstList[i])
274 {
275 BaseMatInstance* current = mMatInstList[i];
276
277 // ok, since ts material lists can remap difference indexes to the same object
278 // we need to make sure that we don't delete the same memory twice. walk the
279 // rest of the list and null out any pointers that match the one we deleted.
280 for (U32 j=0; j<mMatInstList.size(); j++)
281 if (mMatInstList[j] == current)
282 mMatInstList[j] = NULL;
283
284 mMatInstList[i] = NULL;
285 delete current;
286 }
287 }
288}
289
290//--------------------------------------------------------------------------
291// Map materials - map materials to the textures in the list

Callers 2

deleteAllMaterialsMethod · 0.80

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected