in src/raw/RawModel.cpp [148:195]
int RawModel::AddMaterial(
const long id,
const char* name,
const RawMaterialType materialType,
const int textures[RAW_TEXTURE_USAGE_MAX],
std::shared_ptr<RawMatProps> materialInfo,
const std::vector<std::string>& userProperties) {
for (size_t i = 0; i < materials.size(); i++) {
if (materials[i].name != name) {
continue;
}
if (materials[i].type != materialType) {
continue;
}
if (*(materials[i].info) != *materialInfo) {
continue;
}
bool match = true;
for (int j = 0; match && j < RAW_TEXTURE_USAGE_MAX; j++) {
match = match && (materials[i].textures[j] == textures[j]);
}
if (materials[i].userProperties.size() != userProperties.size()) {
match = false;
} else {
for (int j = 0; match && j < userProperties.size(); j++) {
match = match && (materials[i].userProperties[j] == userProperties[j]);
}
}
if (match) {
return (int)i;
}
}
RawMaterial material;
material.id = id;
material.name = name;
material.type = materialType;
material.info = materialInfo;
material.userProperties = userProperties;
for (int i = 0; i < RAW_TEXTURE_USAGE_MAX; i++) {
material.textures[i] = textures[i];
}
materials.emplace_back(material);
return (int)materials.size() - 1;
}