Remove debugging code, clean up some notes

pull/5166/head
PencilAmazing 2023-06-30 19:57:09 -04:00
parent 19da9cc84d
commit 0bacc7134d
3 changed files with 30 additions and 53 deletions

View File

@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* @brief Implementation of the Irr importer class * @brief Implementation of the Irr importer class
*/ */
#include "assimp/Exceptional.h"
#include "assimp/StringComparison.h" #include "assimp/StringComparison.h"
#ifndef ASSIMP_BUILD_NO_IRR_IMPORTER #ifndef ASSIMP_BUILD_NO_IRR_IMPORTER
@ -63,10 +64,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/DefaultLogger.hpp> #include <assimp/DefaultLogger.hpp>
#include <assimp/IOSystem.hpp> #include <assimp/IOSystem.hpp>
#include <csignal>
#include <iostream>
#include <memory>
using namespace Assimp; using namespace Assimp;
static const aiImporterDesc desc = { static const aiImporterDesc desc = {
@ -1160,45 +1157,37 @@ IRRImporter::Node *IRRImporter::ParseNode(pugi::xml_node &node, BatchLoader &bat
} }
// TODO: consolidate all into one loop // TODO: consolidate all into one loop
// Collect node attributes first for (pugi::xml_node subNode : node.children()) {
for (pugi::xml_node attr_node : node.children()) { // Collect node attributes first
if (!ASSIMP_stricmp(attr_node.name(), "attributes")) { if (!ASSIMP_stricmp(subNode.name(), "attributes")) {
ParseNodeAttributes(attr_node, nd, batch); // Parse attributes into this node ParseNodeAttributes(subNode, nd, batch); // Parse attributes into this node
} } else if (!ASSIMP_stricmp(subNode.name(), "animators")) {
} // Then parse any animators
// All animators should contain an <attributes> tag
// Then parse any materials // This is an animation path - add a new animator
// Materials are available to almost all node types // to the list.
if (nd->type != Node::DUMMY) { ParseAnimators(subNode, nd); // Function modifies nd's animator vector
for (pugi::xml_node materialNode : node.children()) { guessedAnimCnt += 1;
if (!ASSIMP_stricmp(materialNode.name(), "materials")) { }
// Then parse any materials
// Materials are available to almost all node types
if (nd->type != Node::DUMMY) {
if (!ASSIMP_stricmp(subNode.name(), "materials")) {
// Parse material description directly // Parse material description directly
// Each material should contain an <attributes> node // Each material should contain an <attributes> node
// with everything specified // with everything specified
nd->materials.emplace_back(); nd->materials.emplace_back();
std::pair<aiMaterial *, unsigned int> &p = nd->materials.back(); std::pair<aiMaterial *, unsigned int> &p = nd->materials.back();
p.first = ParseMaterial(materialNode, p.second); p.first = ParseMaterial(subNode, p.second);
guessedMatCnt += 1; guessedMatCnt += 1;
} }
} }
} }
// Then parse any animators
for (pugi::xml_node animatorNode : node.children()) {
if (!ASSIMP_stricmp(animatorNode.name(), "animators")) {
// All animators should contain an <attributes> tag
// This is an animation path - add a new animator
// to the list.
ParseAnimators(animatorNode, nd); // Function modifies nd's animator vector
guessedAnimCnt += 1;
}
}
// Then parse any child nodes // Then parse any child nodes
/* Attach the newly created node to the scene-graph // Attach the newly created node to the scene-graph
*/
// curNode = nd;
// nd->parent = curParent;
// curParent->children.push_back(nd);
for (pugi::xml_node child : node.children()) { for (pugi::xml_node child : node.children()) {
if (!ASSIMP_stricmp(child.name(), "node")) { // Is a child node if (!ASSIMP_stricmp(child.name(), "node")) { // Is a child node
Node *childNd = ParseNode(child, batch); // Repeat this function for all children Node *childNd = ParseNode(child, batch); // Repeat this function for all children
@ -1206,6 +1195,7 @@ IRRImporter::Node *IRRImporter::ParseNode(pugi::xml_node &node, BatchLoader &bat
}; };
} }
// Return fully specified node
return nd; return nd;
} }
@ -1223,17 +1213,9 @@ void IRRImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
if (!st.parse(file.get())) { if (!st.parse(file.get())) {
throw DeadlyImportError("XML parse error while loading IRR file ", pFile); throw DeadlyImportError("XML parse error while loading IRR file ", pFile);
} }
pugi::xml_node rootElement = st.getRootNode(); pugi::xml_node documentRoot = st.getRootNode();
std::stringstream ss;
ss << "Document name: " << rootElement.name() << std::endl;
ss << "Document content: " << std::endl;
rootElement.print(ss);
ss << std::endl;
std::cout << "IrrImporter with";
std::cout << ss.str() << std::endl;
// The root node of the scene // The root node of the scene
// TODO: Appearantly root node is specified somewhere?
Node *root = new Node(Node::DUMMY); Node *root = new Node(Node::DUMMY);
root->parent = nullptr; root->parent = nullptr;
root->name = "<IRRSceneRoot>"; root->name = "<IRRSceneRoot>";
@ -1250,18 +1232,13 @@ void IRRImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
this->guessedMatCnt = 0; this->guessedMatCnt = 0;
// Parse the XML // Parse the XML
// First node is the xml header. Awkwardly skip to sibling's children // Find the scene root from document root.
// I don't like recursion const pugi::xml_node &sceneRoot = documentRoot.child("irr_scene");
// TODO clean up if (!sceneRoot) throw new DeadlyImportError("IRR: <irr_scene> not found in file");
std::vector<pugi::xml_node> nextNodes; for (pugi::xml_node &child : sceneRoot.children()) {
for (auto &node : rootElement.children().begin()->next_sibling().children()) {
nextNodes.push_back(node); // Find second node, <irr_scene>, and push it's children to queue
}
for (pugi::xml_node &child : nextNodes) {
if (child.type() != pugi::node_element) continue; // Only semantically valuable nodes
// XML elements are either nodes, animators, attributes, or materials // XML elements are either nodes, animators, attributes, or materials
if (!ASSIMP_stricmp(child.name(), "node")) { if (!ASSIMP_stricmp(child.name(), "node")) {
// Recursive ollect subtree children // Recursive collect subtree children
Node *nd = ParseNode(child, batch); Node *nd = ParseNode(child, batch);
// Attach to root // Attach to root
root->children.push_back(nd); root->children.push_back(nd);

View File

@ -157,8 +157,8 @@ void IRRMeshImporter::InternReadFile(const std::string &pFile,
*/ */
// Parse the XML file // Parse the XML file
// FIXME get <mesh> not root pugi::xml_node const &meshNode = root.child("mesh");
for (pugi::xml_node bufferNode : root.children()) { for (pugi::xml_node bufferNode : meshNode.children()) {
if (ASSIMP_stricmp(bufferNode.name(), "buffer")) { if (ASSIMP_stricmp(bufferNode.name(), "buffer")) {
// Might be a useless warning // Might be a useless warning
ASSIMP_LOG_WARN("IRRMESH: Ignoring non buffer node <", bufferNode.name(), "> in mesh declaration"); ASSIMP_LOG_WARN("IRRMESH: Ignoring non buffer node <", bufferNode.name(), "> in mesh declaration");

View File

@ -92,7 +92,7 @@ protected:
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Read a property of the specified type from the current XML element. /** Read a property of the specified type from the current XML element.
* @param out Receives output data * @param out Receives output data
* @param node XML attribute element data * @param node XML attribute element containing data
*/ */
void ReadHexProperty(HexProperty &out, pugi::xml_node& hexnode); void ReadHexProperty(HexProperty &out, pugi::xml_node& hexnode);
void ReadStringProperty(StringProperty &out, pugi::xml_node& stringnode); void ReadStringProperty(StringProperty &out, pugi::xml_node& stringnode);