OgreImporter: Mirror bool return for XmlSerializer as it is in BinarySerializer. Document its meaning.

pull/280/head
Jonne Nauha 2014-05-21 04:06:22 +03:00
parent 1129ae5a6e
commit f8e1dcb102
3 changed files with 20 additions and 17 deletions

View File

@ -62,7 +62,8 @@ public:
/// Imports skeleton to @c mesh into Mesh::skeleton. /// Imports skeleton to @c mesh into Mesh::skeleton.
/** If mesh does not have a skeleton reference or the skeleton file /** 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, Mesh *mesh);
static bool ImportSkeleton(Assimp::IOSystem *pIOHandler, MeshXml *mesh); static bool ImportSkeleton(Assimp::IOSystem *pIOHandler, MeshXml *mesh);

View File

@ -675,49 +675,50 @@ void OgreXmlSerializer::ReadBoneAssignments(VertexDataXml *dest)
// Skeleton // Skeleton
void OgreXmlSerializer::ImportSkeleton(Assimp::IOSystem *pIOHandler, MeshXml *mesh) bool OgreXmlSerializer::ImportSkeleton(Assimp::IOSystem *pIOHandler, MeshXml *mesh)
{ {
if (!mesh || mesh->skeletonRef.empty()) if (!mesh || mesh->skeletonRef.empty())
return; return false;
// Highly unusual to see in read world cases but support // Highly unusual to see in read world cases but support
// XML mesh referencing a binary skeleton file. // XML mesh referencing a binary skeleton file.
if (EndsWith(mesh->skeletonRef, ".skeleton", false)) if (EndsWith(mesh->skeletonRef, ".skeleton", false))
{ {
if (OgreBinarySerializer::ImportSkeleton(pIOHandler, mesh)) if (OgreBinarySerializer::ImportSkeleton(pIOHandler, mesh))
return; return true;
/** Last fallback if .skeleton failed to be read. /** Last fallback if .skeleton failed to be read. Try reading from
Try reading from .skeleton.xml even if the XML file .skeleton.xml even if the XML file referenced a binary skeleton.
referenced a binary skeleton. @note This logic was in the previous version and I don't want to break
@note This logic was in the previous version and old code that might depends on it. */
I don't want to break old code that depends on it. */
mesh->skeletonRef = mesh->skeletonRef + ".xml"; mesh->skeletonRef = mesh->skeletonRef + ".xml";
} }
XmlReaderPtr reader = OpenReader(pIOHandler, mesh->skeletonRef); XmlReaderPtr reader = OpenReader(pIOHandler, mesh->skeletonRef);
if (!reader.get()) if (!reader.get())
return; return false;
Skeleton *skeleton = new Skeleton(); Skeleton *skeleton = new Skeleton();
OgreXmlSerializer serializer(reader.get()); OgreXmlSerializer serializer(reader.get());
serializer.ReadSkeleton(skeleton); serializer.ReadSkeleton(skeleton);
mesh->skeleton = 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()) if (!mesh || mesh->skeletonRef.empty())
return; return false;
XmlReaderPtr reader = OpenReader(pIOHandler, mesh->skeletonRef); XmlReaderPtr reader = OpenReader(pIOHandler, mesh->skeletonRef);
if (!reader.get()) if (!reader.get())
return; return false;
Skeleton *skeleton = new Skeleton(); Skeleton *skeleton = new Skeleton();
OgreXmlSerializer serializer(reader.get()); OgreXmlSerializer serializer(reader.get());
serializer.ReadSkeleton(skeleton); serializer.ReadSkeleton(skeleton);
mesh->skeleton = skeleton; mesh->skeleton = skeleton;
return true;
} }
XmlReaderPtr OgreXmlSerializer::OpenReader(Assimp::IOSystem *pIOHandler, const std::string &filename) XmlReaderPtr OgreXmlSerializer::OpenReader(Assimp::IOSystem *pIOHandler, const std::string &filename)

View File

@ -63,9 +63,10 @@ public:
/// Imports skeleton to @c mesh. /// Imports skeleton to @c mesh.
/** If mesh does not have a skeleton reference or the skeleton file /** 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.
static void ImportSkeleton(Assimp::IOSystem *pIOHandler, MeshXml *mesh); @return If skeleton import was successful. */
static void ImportSkeleton(Assimp::IOSystem *pIOHandler, Mesh *mesh); static bool ImportSkeleton(Assimp::IOSystem *pIOHandler, MeshXml *mesh);
static bool ImportSkeleton(Assimp::IOSystem *pIOHandler, Mesh *mesh);
private: private:
OgreXmlSerializer(XmlReader *reader) : OgreXmlSerializer(XmlReader *reader) :