Fix parsing <instance_image> in <sampler2D>.

The regression was introduced in 904f17f.

Since all the cases are now fully handled at the child level,
visiting the whole subtree is changed into iteration over the children.
pull/5305/head^2
Wojciech Matyjewicz 2023-10-23 10:48:59 +02:00 committed by Kim Kulling
parent 8648c2af45
commit 2235518b3c
1 changed files with 17 additions and 17 deletions

View File

@ -1274,9 +1274,7 @@ void ColladaParser::ReadEffectParam(XmlNode &node, Collada::EffectParam &pParam)
return; return;
} }
XmlNodeIterator xmlIt(node, XmlNodeIterator::PreOrderMode); for (XmlNode &currentNode : node.children()) {
XmlNode currentNode;
while (xmlIt.getNext(currentNode)) {
const std::string &currentName = currentNode.name(); const std::string &currentName = currentNode.name();
if (currentName == "surface") { if (currentName == "surface") {
// image ID given inside <init_from> tags // image ID given inside <init_from> tags
@ -1289,22 +1287,24 @@ void ColladaParser::ReadEffectParam(XmlNode &node, Collada::EffectParam &pParam)
} }
} else if (currentName == "sampler2D" && (FV_1_4_n == mFormat || FV_1_3_n == mFormat)) { } else if (currentName == "sampler2D" && (FV_1_4_n == mFormat || FV_1_3_n == mFormat)) {
// surface ID is given inside <source> tags // surface ID is given inside <source> tags
const char *content = currentNode.value(); XmlNode source = currentNode.child("source");
pParam.mType = Param_Sampler; if (source) {
pParam.mReference = content; std::string v;
XmlParser::getValueAsString(source, v);
pParam.mType = Param_Sampler;
pParam.mReference = v.c_str();
}
} else if (currentName == "sampler2D") { } else if (currentName == "sampler2D") {
// surface ID is given inside <instance_image> tags // surface ID is given inside <instance_image> tags
std::string url; XmlNode instance_image = currentNode.child("instance_image");
XmlParser::getStdStrAttribute(currentNode, "url", url); if (instance_image) {
if (url[0] != '#') { std::string url;
throw DeadlyImportError("Unsupported URL format in instance_image"); XmlParser::getStdStrAttribute(instance_image, "url", url);
} if (url[0] != '#') {
pParam.mType = Param_Sampler; throw DeadlyImportError("Unsupported URL format in instance_image");
pParam.mReference = url.c_str() + 1; }
} else if (currentName == "source") { pParam.mType = Param_Sampler;
const char *source = currentNode.child_value(); pParam.mReference = url.c_str() + 1;
if (nullptr != source) {
pParam.mReference = source;
} }
} }
} }