Collada: correct parsing of float data in xml nodes.

pull/2966/head
Kim Kulling 2020-09-02 22:38:19 +02:00
parent 075540e15a
commit be5089ae40
3 changed files with 20 additions and 6 deletions

View File

@ -990,20 +990,23 @@ void ColladaParser::ReadCamera(XmlNode &node, Collada::Camera &camera) {
xmlIt.collectChildrenPreOrder(node);
XmlNode currentNode;
std::string out;
while (xmlIt.getNext(currentNode)) {
const std::string &currentName = currentNode.name();
if (currentName == "orthographic") {
camera.mOrtho = true;
} else if (currentName == "xfov" || currentName == "xmag") {
XmlParser::getFloatAttribute(currentNode, currentName.c_str(), (ai_real &)camera.mHorFov);
XmlParser::getValueAsFloat(currentNode, camera.mHorFov);
} else if (currentName == "yfov" || currentName == "ymag") {
XmlParser::getFloatAttribute(currentNode, currentName.c_str(), (ai_real &)camera.mVerFov);
XmlParser::getValueAsFloat(currentNode, camera.mVerFov);
camera.mVerFov = (ai_real)std::atof(out.c_str());
} else if (currentName == "aspect_ratio") {
XmlParser::getFloatAttribute(currentNode, currentName.c_str(), (ai_real &)camera.mAspect);
XmlParser::getValueAsFloat(currentNode, camera.mAspect);
camera.mAspect = (ai_real)std::atof(out.c_str());
} else if (currentName == "znear") {
XmlParser::getFloatAttribute(currentNode, currentName.c_str(), (ai_real &)camera.mZNear);
XmlParser::getValueAsFloat(currentNode, camera.mZNear);
} else if (currentName == "zfar") {
XmlParser::getFloatAttribute(currentNode, currentName.c_str(), (ai_real &)camera.mZFar);
XmlParser::getValueAsFloat(currentNode, camera.mZFar);
}
}
}

View File

@ -217,6 +217,17 @@ public:
return true;
}
static inline bool getValueAsFloat( XmlNode &node, ai_real &v ) {
if (node.empty()) {
return false;
}
v = node.text().as_float();
return true;
}
private:
pugi::xml_document *mDoc;
TNodeType mCurrent;

View File

@ -49,7 +49,7 @@ using namespace Assimp;
class utAMFImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
bool importerTest() override {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AMF/test1.amf", aiProcess_ValidateDataStructure);
return nullptr != scene;