mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-20 10:25:40 +00:00
Model/material changes - addition of CMaterial clone functions, better encapsulation for CMaterialSet, removal of SModelData from model loading methods
This commit is contained in:
@@ -2,10 +2,41 @@
|
||||
#include <Core/CResCache.h>
|
||||
#include <iostream>
|
||||
|
||||
CMaterialSet::CMaterialSet() {}
|
||||
CMaterialSet::CMaterialSet()
|
||||
{
|
||||
}
|
||||
|
||||
CMaterialSet::~CMaterialSet()
|
||||
{
|
||||
for (u32 m = 0; m < materials.size(); m++)
|
||||
delete materials[m];
|
||||
for (u32 iMat = 0; iMat < mMaterials.size(); iMat++)
|
||||
delete mMaterials[iMat];
|
||||
}
|
||||
|
||||
CMaterialSet* CMaterialSet::Clone()
|
||||
{
|
||||
CMaterialSet *pOut = new CMaterialSet();
|
||||
|
||||
pOut->mMaterials.resize(mMaterials.size());
|
||||
for (u32 iMat = 0; iMat < mMaterials.size(); iMat++)
|
||||
pOut->mMaterials[iMat] = mMaterials[iMat]->Clone();
|
||||
|
||||
return pOut;
|
||||
}
|
||||
|
||||
u32 CMaterialSet::NumMaterials()
|
||||
{
|
||||
return mMaterials.size();
|
||||
}
|
||||
|
||||
CMaterial* CMaterialSet::MaterialByIndex(u32 index)
|
||||
{
|
||||
if (index >= NumMaterials()) return nullptr;
|
||||
return mMaterials[index];
|
||||
}
|
||||
|
||||
CMaterial* CMaterialSet::MaterialByName(const std::string &name)
|
||||
{
|
||||
for (auto it = mMaterials.begin(); it != mMaterials.end(); it++)
|
||||
if ((*it)->Name() == name) return *it;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user