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.
/** 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);

View File

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

View File

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