Read matrix and input (shared) correctly

<matrix> may have leading and trailing whitespace
<input/> set attribute is unsigned. It is also optional, default 0
pull/3988/head
RichardTea 2021-07-13 16:50:09 +01:00
parent 206b2436d4
commit bff1d012bd
3 changed files with 120 additions and 101 deletions

View File

@ -1674,11 +1674,8 @@ void ColladaParser::ReadInputChannel(XmlNode &node, std::vector<InputChannel> &p
// read set if texture coordinates // read set if texture coordinates
if (channel.mType == IT_Texcoord || channel.mType == IT_Color) { if (channel.mType == IT_Texcoord || channel.mType == IT_Color) {
int attrSet = -1; unsigned int attrSet = 0;
if (XmlParser::hasAttribute(node, "set")) { if (XmlParser::getUIntAttribute(node, "set", attrSet))
XmlParser::getIntAttribute(node, "set", attrSet);
}
channel.mIndex = attrSet; channel.mIndex = attrSet;
} }
@ -2170,10 +2167,10 @@ void ColladaParser::ReadNodeTransformation(XmlNode &node, Node *pNode, Transform
// read as many parameters and store in the transformation // read as many parameters and store in the transformation
for (unsigned int a = 0; a < sNumParameters[pType]; a++) { for (unsigned int a = 0; a < sNumParameters[pType]; a++) {
// skip whitespace before the number
SkipSpacesAndLineEnd(&content);
// read a number // read a number
content = fast_atoreal_move<ai_real>(content, tf.f[a]); content = fast_atoreal_move<ai_real>(content, tf.f[a]);
// skip whitespace after it
SkipSpacesAndLineEnd(&content);
} }
// place the transformation at the queue of the node // place the transformation at the queue of the node

Binary file not shown.

View File

@ -382,3 +382,25 @@ public:
TEST_F(utColladaZaeImportExport, importBlenFromFileTest) { TEST_F(utColladaZaeImportExport, importBlenFromFileTest) {
EXPECT_TRUE(importerTest()); EXPECT_TRUE(importerTest());
} }
TEST_F(utColladaZaeImportExport, importMakeHumanTest) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/human.zae", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
// Expected number of items
EXPECT_EQ(scene->mNumMeshes, 2u);
EXPECT_EQ(scene->mNumMaterials, 2u);
EXPECT_EQ(scene->mNumAnimations, 0u);
EXPECT_EQ(scene->mNumTextures, 2u);
EXPECT_EQ(scene->mNumLights, 0u);
EXPECT_EQ(scene->mNumCameras, 0u);
// Expected common metadata
aiString value;
EXPECT_TRUE(scene->mMetaData->Get(AI_METADATA_SOURCE_FORMAT, value)) << "No importer format metadata";
EXPECT_STREQ("Collada Importer", value.C_Str());
EXPECT_TRUE(scene->mMetaData->Get(AI_METADATA_SOURCE_FORMAT_VERSION, value)) << "No format version metadata";
EXPECT_STREQ("1.4.1", value.C_Str());
}