From cc7a466ebdbd302ee8d182a1310dd9b0cec70eec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9B=BE?= <442739441@qq.com> Date: Tue, 26 Feb 2019 08:20:58 +0800 Subject: [PATCH] AddMaterial Get material index by comparing ID --- src/raw/RawModel.cpp | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/src/raw/RawModel.cpp b/src/raw/RawModel.cpp index cafc076..106f744 100644 --- a/src/raw/RawModel.cpp +++ b/src/raw/RawModel.cpp @@ -144,28 +144,8 @@ int RawModel::AddMaterial( const int textures[RAW_TEXTURE_USAGE_MAX], std::shared_ptr materialInfo, const std::vector& 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) { + for (size_t i = 0; i < materials.size(); i++) { + if (materials[i].id == id) { return (int)i; } }