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) :