From f8e1dcb102216f88bc1b635037e088b1ac1a2309 Mon Sep 17 00:00:00 2001 From: Jonne Nauha Date: Wed, 21 May 2014 04:06:22 +0300 Subject: [PATCH] OgreImporter: Mirror bool return for XmlSerializer as it is in BinarySerializer. Document its meaning. --- code/OgreBinarySerializer.h | 3 ++- code/OgreXmlSerializer.cpp | 27 ++++++++++++++------------- code/OgreXmlSerializer.h | 7 ++++--- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/code/OgreBinarySerializer.h b/code/OgreBinarySerializer.h index 30d4c9d7a..69db4b722 100644 --- a/code/OgreBinarySerializer.h +++ b/code/OgreBinarySerializer.h @@ -62,7 +62,8 @@ public: /// Imports skeleton to @c mesh into Mesh::skeleton. /** If mesh does not have a skeleton reference or the skeleton file - cannot be found it is not a fatal DeadlyImportError. */ + cannot be found it is not a fatal DeadlyImportError. + @return If skeleton import was successful. */ static bool ImportSkeleton(Assimp::IOSystem *pIOHandler, Mesh *mesh); static bool ImportSkeleton(Assimp::IOSystem *pIOHandler, MeshXml *mesh); diff --git a/code/OgreXmlSerializer.cpp b/code/OgreXmlSerializer.cpp index 73802aca6..3e82176c5 100644 --- a/code/OgreXmlSerializer.cpp +++ b/code/OgreXmlSerializer.cpp @@ -675,49 +675,50 @@ void OgreXmlSerializer::ReadBoneAssignments(VertexDataXml *dest) // Skeleton -void OgreXmlSerializer::ImportSkeleton(Assimp::IOSystem *pIOHandler, MeshXml *mesh) +bool OgreXmlSerializer::ImportSkeleton(Assimp::IOSystem *pIOHandler, MeshXml *mesh) { if (!mesh || mesh->skeletonRef.empty()) - return; + return false; // Highly unusual to see in read world cases but support // XML mesh referencing a binary skeleton file. if (EndsWith(mesh->skeletonRef, ".skeleton", false)) { if (OgreBinarySerializer::ImportSkeleton(pIOHandler, mesh)) - return; - - /** Last fallback if .skeleton failed to be read. - Try reading from .skeleton.xml even if the XML file - referenced a binary skeleton. - @note This logic was in the previous version and - I don't want to break old code that depends on it. */ + return true; + + /** Last fallback if .skeleton failed to be read. Try reading from + .skeleton.xml even if the XML file referenced a binary skeleton. + @note This logic was in the previous version and I don't want to break + old code that might depends on it. */ mesh->skeletonRef = mesh->skeletonRef + ".xml"; } XmlReaderPtr reader = OpenReader(pIOHandler, mesh->skeletonRef); if (!reader.get()) - return; + return false; Skeleton *skeleton = new Skeleton(); OgreXmlSerializer serializer(reader.get()); serializer.ReadSkeleton(skeleton); mesh->skeleton = skeleton; + return true; } -void OgreXmlSerializer::ImportSkeleton(Assimp::IOSystem *pIOHandler, Mesh *mesh) +bool OgreXmlSerializer::ImportSkeleton(Assimp::IOSystem *pIOHandler, Mesh *mesh) { if (!mesh || mesh->skeletonRef.empty()) - return; + return false; XmlReaderPtr reader = OpenReader(pIOHandler, mesh->skeletonRef); if (!reader.get()) - return; + return false; Skeleton *skeleton = new Skeleton(); OgreXmlSerializer serializer(reader.get()); serializer.ReadSkeleton(skeleton); mesh->skeleton = skeleton; + return true; } XmlReaderPtr OgreXmlSerializer::OpenReader(Assimp::IOSystem *pIOHandler, const std::string &filename) diff --git a/code/OgreXmlSerializer.h b/code/OgreXmlSerializer.h index 1813a2949..62257f81c 100644 --- a/code/OgreXmlSerializer.h +++ b/code/OgreXmlSerializer.h @@ -63,9 +63,10 @@ public: /// Imports skeleton to @c mesh. /** If mesh does not have a skeleton reference or the skeleton file - cannot be found it is not a fatal DeadlyImportError. */ - static void ImportSkeleton(Assimp::IOSystem *pIOHandler, MeshXml *mesh); - static void ImportSkeleton(Assimp::IOSystem *pIOHandler, Mesh *mesh); + cannot be found it is not a fatal DeadlyImportError. + @return If skeleton import was successful. */ + static bool ImportSkeleton(Assimp::IOSystem *pIOHandler, MeshXml *mesh); + static bool ImportSkeleton(Assimp::IOSystem *pIOHandler, Mesh *mesh); private: OgreXmlSerializer(XmlReader *reader) :