Merge branch 'master' into remove-useless-code

This commit is contained in:
Kim Kulling
2021-09-14 23:33:34 +02:00
committed by GitHub
126 changed files with 2977 additions and 3511 deletions

View File

@@ -114,13 +114,15 @@ bool XGLImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool c
if (extension == "xgl" || extension == "zgl") {
return true;
} else if (extension == "xml" || checkSig) {
ai_assert(pIOHandler != NULL);
}
if (extension == "xml" || checkSig) {
ai_assert(pIOHandler != nullptr);
const char *tokens[] = { "<world>", "<World>", "<WORLD>" };
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 3);
}
return false;
return false;
}
// ------------------------------------------------------------------------------------------------
@@ -453,12 +455,12 @@ aiMesh *XGLImporter::ToOutputMesh(const TempMaterialMesh &m) {
mesh->mVertices = new aiVector3D[mesh->mNumVertices];
std::copy(m.positions.begin(), m.positions.end(), mesh->mVertices);
if (m.normals.size()) {
if (!m.normals.empty()) {
mesh->mNormals = new aiVector3D[mesh->mNumVertices];
std::copy(m.normals.begin(), m.normals.end(), mesh->mNormals);
}
if (m.uvs.size()) {
if (!m.uvs.empty()) {
mesh->mNumUVComponents[0] = 2;
mesh->mTextureCoords[0] = new aiVector3D[mesh->mNumVertices];
@@ -594,7 +596,7 @@ bool XGLImporter::ReadMesh(XmlNode &node, TempScope &scope) {
}
// finally extract output meshes and add them to the scope
typedef std::pair<const unsigned int, TempMaterialMesh> pairt;
using pairt = std::pair<const unsigned int, TempMaterialMesh>;
for (const pairt &p : bymat) {
aiMesh *const m = ToOutputMesh(p.second);
scope.meshes_linear.push_back(m);
@@ -619,7 +621,7 @@ unsigned int XGLImporter::ResolveMaterialRef(XmlNode &node, TempScope &scope) {
const int id = ReadIndexFromText(node);
std::map<unsigned int, aiMaterial *>::iterator it = scope.materials.find(id), end = scope.materials.end();
auto it = scope.materials.find(id), end = scope.materials.end();
if (it == end) {
ThrowException("<matref> index out of range");
}
@@ -643,7 +645,7 @@ unsigned int XGLImporter::ResolveMaterialRef(XmlNode &node, TempScope &scope) {
void XGLImporter::ReadMaterial(XmlNode &node, TempScope &scope) {
const unsigned int mat_id = ReadIDAttr(node);
aiMaterial *mat(new aiMaterial);
auto *mat(new aiMaterial);
for (XmlNode &child : node.children()) {
const std::string &s = ai_stdStrToLower(child.name());
if (s == "amb") {