update assimp
This commit is contained in:
@@ -100,7 +100,6 @@ XGLImporter::XGLImporter() :
|
||||
// Destructor, private as well
|
||||
XGLImporter::~XGLImporter() {
|
||||
delete mXmlParser;
|
||||
mXmlParser = nullptr;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@@ -115,13 +114,15 @@ bool XGLImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool c
|
||||
|
||||
if (extension == "xgl" || extension == "zgl") {
|
||||
return true;
|
||||
} else if (extension == "xml" || checkSig) {
|
||||
ai_assert(pIOHandler != NULL);
|
||||
}
|
||||
|
||||
const char *tokens[] = { "<world>", "<World>", "<WORLD>" };
|
||||
if (extension == "xml" || checkSig) {
|
||||
ai_assert(pIOHandler != nullptr);
|
||||
static const char * const tokens[] = { "<world>", "<World>", "<WORLD>" };
|
||||
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 3);
|
||||
}
|
||||
return false;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@@ -142,7 +143,7 @@ void XGLImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||
|
||||
// check whether we can read from the file
|
||||
if (stream.get() == NULL) {
|
||||
throw DeadlyImportError("Failed to open XGL/ZGL file " + pFile + "");
|
||||
throw DeadlyImportError("Failed to open XGL/ZGL file " + pFile);
|
||||
}
|
||||
|
||||
// see if its compressed, if so uncompress it
|
||||
@@ -200,7 +201,7 @@ void XGLImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||
// parse the XML file
|
||||
mXmlParser = new XmlParser;
|
||||
if (!mXmlParser->parse(stream.get())) {
|
||||
return;
|
||||
throw DeadlyImportError("XML parse error while loading XGL file ", pFile);
|
||||
}
|
||||
|
||||
TempScope scope;
|
||||
@@ -240,7 +241,7 @@ void XGLImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||
void XGLImporter::ReadWorld(XmlNode &node, TempScope &scope) {
|
||||
for (XmlNode ¤tNode : node.children()) {
|
||||
const std::string &s = ai_stdStrToLower(currentNode.name());
|
||||
|
||||
|
||||
// XXX right now we'd skip <lighting> if it comes after
|
||||
// <object> or <mesh>
|
||||
if (s == "lighting") {
|
||||
@@ -250,7 +251,7 @@ void XGLImporter::ReadWorld(XmlNode &node, TempScope &scope) {
|
||||
}
|
||||
}
|
||||
|
||||
aiNode *const nd = ReadObject(node, scope, true);
|
||||
aiNode *const nd = ReadObject(node, scope);
|
||||
if (!nd) {
|
||||
ThrowException("failure reading <world>");
|
||||
}
|
||||
@@ -296,16 +297,13 @@ aiLight *XGLImporter::ReadDirectionalLight(XmlNode &node) {
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
aiNode *XGLImporter::ReadObject(XmlNode &node, TempScope &scope, bool skipFirst/*, const char *closetag */) {
|
||||
aiNode *XGLImporter::ReadObject(XmlNode &node, TempScope &scope) {
|
||||
aiNode *nd = new aiNode;
|
||||
std::vector<aiNode *> children;
|
||||
std::vector<unsigned int> meshes;
|
||||
|
||||
try {
|
||||
for (XmlNode &child : node.children()) {
|
||||
|
||||
skipFirst = false;
|
||||
|
||||
const std::string &s = ai_stdStrToLower(child.name());
|
||||
if (s == "mesh") {
|
||||
const size_t prev = scope.meshes_linear.size();
|
||||
@@ -457,12 +455,12 @@ aiMesh *XGLImporter::ToOutputMesh(const TempMaterialMesh &m) {
|
||||
mesh->mVertices = new aiVector3D[mesh->mNumVertices];
|
||||
std::copy(m.positions.begin(), m.positions.end(), mesh->mVertices);
|
||||
|
||||
if (m.normals.size()) {
|
||||
if (!m.normals.empty()) {
|
||||
mesh->mNormals = new aiVector3D[mesh->mNumVertices];
|
||||
std::copy(m.normals.begin(), m.normals.end(), mesh->mNormals);
|
||||
}
|
||||
|
||||
if (m.uvs.size()) {
|
||||
if (!m.uvs.empty()) {
|
||||
mesh->mNumUVComponents[0] = 2;
|
||||
mesh->mTextureCoords[0] = new aiVector3D[mesh->mNumVertices];
|
||||
|
||||
@@ -598,7 +596,7 @@ bool XGLImporter::ReadMesh(XmlNode &node, TempScope &scope) {
|
||||
}
|
||||
|
||||
// finally extract output meshes and add them to the scope
|
||||
typedef std::pair<const unsigned int, TempMaterialMesh> pairt;
|
||||
using pairt = std::pair<const unsigned int, TempMaterialMesh>;
|
||||
for (const pairt &p : bymat) {
|
||||
aiMesh *const m = ToOutputMesh(p.second);
|
||||
scope.meshes_linear.push_back(m);
|
||||
@@ -623,7 +621,7 @@ unsigned int XGLImporter::ResolveMaterialRef(XmlNode &node, TempScope &scope) {
|
||||
|
||||
const int id = ReadIndexFromText(node);
|
||||
|
||||
std::map<unsigned int, aiMaterial *>::iterator it = scope.materials.find(id), end = scope.materials.end();
|
||||
auto it = scope.materials.find(id), end = scope.materials.end();
|
||||
if (it == end) {
|
||||
ThrowException("<matref> index out of range");
|
||||
}
|
||||
@@ -647,7 +645,7 @@ unsigned int XGLImporter::ResolveMaterialRef(XmlNode &node, TempScope &scope) {
|
||||
void XGLImporter::ReadMaterial(XmlNode &node, TempScope &scope) {
|
||||
const unsigned int mat_id = ReadIDAttr(node);
|
||||
|
||||
aiMaterial *mat(new aiMaterial);
|
||||
auto *mat(new aiMaterial);
|
||||
for (XmlNode &child : node.children()) {
|
||||
const std::string &s = ai_stdStrToLower(child.name());
|
||||
if (s == "amb") {
|
||||
|
||||
Reference in New Issue
Block a user