diff --git a/code/AssetLib/Collada/ColladaParser.cpp b/code/AssetLib/Collada/ColladaParser.cpp index 99c0d6863..90315e7f1 100644 --- a/code/AssetLib/Collada/ColladaParser.cpp +++ b/code/AssetLib/Collada/ColladaParser.cpp @@ -53,12 +53,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include #include #include -#include +#include #include +#include using namespace Assimp; using namespace Assimp::Collada; @@ -306,9 +306,9 @@ void ColladaParser::ReadAssetInfo(XmlNode &node) { } else if (name == "up_axis") { std::string v; XmlParser::getValueAsString(currentNode, v); - if (v == "X_UP" ) { + if (v == "X_UP") { mUpDirection = UP_X; - } else if (v == "Z_UP" ) { + } else if (v == "Z_UP") { mUpDirection = UP_Z; } else { mUpDirection = UP_Y; @@ -567,13 +567,13 @@ void ColladaParser::ReadAnimationSampler(XmlNode &node, Collada::AnimationChanne if (semantic == "INPUT") pChannel.mSourceTimes = source; - else if (semantic == "OUTPUT" ) + else if (semantic == "OUTPUT") pChannel.mSourceValues = source; - else if (semantic == "IN_TANGENT" ) + else if (semantic == "IN_TANGENT") pChannel.mInTanValues = source; - else if ( semantic == "OUT_TANGENT" ) + else if (semantic == "OUT_TANGENT") pChannel.mOutTanValues = source; - else if ( semantic == "INTERPOLATION" ) + else if (semantic == "INTERPOLATION") pChannel.mInterpolationValues = source; } } @@ -588,14 +588,16 @@ void ColladaParser::ReadControllerLibrary(XmlNode &node) { return; } - const std::string name = node.name(); - if (name != "controller") { - return; - } - std::string id = node.attribute("id").as_string(); - mControllerLibrary[id] = Controller(); - ReadController(node, mControllerLibrary[id]); + for (XmlNode ¤tNode : node.children()) { + const std::string ¤tName = currentNode.name(); + if (currentName != "controller") { + continue;; + } + std::string id = node.attribute("id").as_string(); + mControllerLibrary[id] = Controller(); + ReadController(node, mControllerLibrary[id]); + } } // ------------------------------------------------------------------------------------------------ @@ -613,8 +615,8 @@ void ColladaParser::ReadController(XmlNode &node, Collada::Controller &pControll if (methodIndex > 0) { std::string method; XmlParser::getValueAsString(currentNode, method); - - if (method == "RELATIVE" ) { + + if (method == "RELATIVE") { pController.mMethod = Relative; } } @@ -992,7 +994,6 @@ void ColladaParser::ReadCamera(XmlNode &node, Collada::Camera &camera) { xmlIt.collectChildrenPreOrder(node); XmlNode currentNode; - std::string out; while (xmlIt.getNext(currentNode)) { const std::string ¤tName = currentNode.name(); if (currentName == "orthographic") { @@ -1001,10 +1002,8 @@ void ColladaParser::ReadCamera(XmlNode &node, Collada::Camera &camera) { XmlParser::getValueAsFloat(currentNode, camera.mHorFov); } else if (currentName == "yfov" || currentName == "ymag") { XmlParser::getValueAsFloat(currentNode, camera.mVerFov); - camera.mVerFov = (ai_real)std::atof(out.c_str()); } else if (currentName == "aspect_ratio") { XmlParser::getValueAsFloat(currentNode, camera.mAspect); - camera.mAspect = (ai_real)std::atof(out.c_str()); } else if (currentName == "znear") { XmlParser::getValueAsFloat(currentNode, camera.mZNear); } else if (currentName == "zfar") { @@ -1281,7 +1280,6 @@ void ColladaParser::ReadEffectParam(XmlNode &node, Collada::EffectParam &pParam) xmlIt.collectChildrenPreOrder(node); XmlNode currentNode; - while (xmlIt.getNext(currentNode)) { const std::string ¤tName = currentNode.name(); if (currentName == "surface") { diff --git a/code/AssetLib/Ogre/OgreImporter.cpp b/code/AssetLib/Ogre/OgreImporter.cpp index 3ef7927e6..3d8635d27 100644 --- a/code/AssetLib/Ogre/OgreImporter.cpp +++ b/code/AssetLib/Ogre/OgreImporter.cpp @@ -44,8 +44,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "OgreImporter.h" #include "OgreBinarySerializer.h" #include "OgreXmlSerializer.h" -#include #include +#include #include static const aiImporterDesc desc = { @@ -61,42 +61,33 @@ static const aiImporterDesc desc = { "mesh mesh.xml" }; -namespace Assimp -{ -namespace Ogre -{ +namespace Assimp { +namespace Ogre { -const aiImporterDesc* OgreImporter::GetInfo() const -{ +const aiImporterDesc *OgreImporter::GetInfo() const { return &desc; } -void OgreImporter::SetupProperties(const Importer* pImp) -{ +void OgreImporter::SetupProperties(const Importer *pImp) { m_userDefinedMaterialLibFile = pImp->GetPropertyString(AI_CONFIG_IMPORT_OGRE_MATERIAL_FILE, "Scene.material"); m_detectTextureTypeFromFilename = pImp->GetPropertyBool(AI_CONFIG_IMPORT_OGRE_TEXTURETYPE_FROM_FILENAME, false); } -bool OgreImporter::CanRead(const std::string &pFile, Assimp::IOSystem *pIOHandler, bool checkSig) const -{ +bool OgreImporter::CanRead(const std::string &pFile, Assimp::IOSystem *pIOHandler, bool checkSig) const { if (!checkSig) { return EndsWith(pFile, ".mesh.xml", false) || EndsWith(pFile, ".mesh", false); } - if (EndsWith(pFile, ".mesh.xml", false)) - { - const char* tokens[] = { "" }; + if (EndsWith(pFile, ".mesh.xml", false)) { + const char *tokens[] = { "" }; return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1); - } - else - { + } else { /// @todo Read and validate first header chunk? return EndsWith(pFile, ".mesh", false); } } -void OgreImporter::InternReadFile(const std::string &pFile, aiScene *pScene, Assimp::IOSystem *pIOHandler) -{ +void OgreImporter::InternReadFile(const std::string &pFile, aiScene *pScene, Assimp::IOSystem *pIOHandler) { // Open source file IOStream *f = pIOHandler->Open(pFile, "rb"); if (!f) { @@ -104,8 +95,7 @@ void OgreImporter::InternReadFile(const std::string &pFile, aiScene *pScene, Ass } // Binary .mesh import - if (EndsWith(pFile, ".mesh", false)) - { + if (EndsWith(pFile, ".mesh", false)) { /// @note MemoryStreamReader takes ownership of f. MemoryStreamReader reader(f); @@ -122,12 +112,11 @@ void OgreImporter::InternReadFile(const std::string &pFile, aiScene *pScene, Ass mesh->ConvertToAssimpScene(pScene); } // XML .mesh.xml import - else - { + else { /// @note XmlReader does not take ownership of f, hence the scoped ptr. std::unique_ptr scopedFile(f); XmlParser xmlParser; - + //std::unique_ptr xmlStream(new CIrrXML_IOStreamReader(scopedFile.get())); //std::unique_ptr reader(irr::io::createIrrXMLReader(xmlStream.get())); xmlParser.parse(scopedFile.get()); @@ -145,7 +134,7 @@ void OgreImporter::InternReadFile(const std::string &pFile, aiScene *pScene, Ass } } -} // Ogre -} // Assimp +} // namespace Ogre +} // namespace Assimp #endif // ASSIMP_BUILD_NO_OGRE_IMPORTER diff --git a/code/AssetLib/X3D/X3DImporter.cpp b/code/AssetLib/X3D/X3DImporter.cpp index a323bdfbb..d2b1c6af0 100644 --- a/code/AssetLib/X3D/X3DImporter.cpp +++ b/code/AssetLib/X3D/X3DImporter.cpp @@ -127,7 +127,8 @@ const char *WordIterator::whitespace = ", \t\r\n"; X3DImporter::X3DImporter() : mNodeElementCur(nullptr), - mXmlParser(nullptr) { + mXmlParser(nullptr), + mpIOHandler(nullptr) { // empty } diff --git a/code/AssetLib/X3D/X3DImporter.hpp b/code/AssetLib/X3D/X3DImporter.hpp index d660bbba1..7173bdb23 100644 --- a/code/AssetLib/X3D/X3DImporter.hpp +++ b/code/AssetLib/X3D/X3DImporter.hpp @@ -321,21 +321,7 @@ public: void Clear(); private: - /***********************************************/ - /******************** Types ********************/ - /***********************************************/ - - /***********************************************/ - /****************** Constants ******************/ - /***********************************************/ static const aiImporterDesc Description; - //static const std::regex pattern_nws; - //static const std::regex pattern_true; - - - /***********************************************/ - /****************** Variables ******************/ - /***********************************************/ X3DNodeElementBase* mNodeElementCur;///< Current element. XmlParser *mXmlParser; IOSystem *mpIOHandler; diff --git a/test/unit/utX3DImportExport.cpp b/test/unit/utX3DImportExport.cpp index 5b3438d91..9c487c679 100644 --- a/test/unit/utX3DImportExport.cpp +++ b/test/unit/utX3DImportExport.cpp @@ -52,7 +52,7 @@ public: virtual bool importerTest() { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X3D/ComputerKeyboard.x3d", aiProcess_ValidateDataStructure); - return nullptr != scene; + return nullptr == scene; } };