closes https://github.com/assimp/assimp/issues/2056: use correc exception type in MMD-loader.

This commit is contained in:
Kim Kulling
2018-07-18 20:29:05 +02:00
parent 54f3043728
commit 8a3daa1a24
6 changed files with 51 additions and 76 deletions

View File

@@ -41,6 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <utility>
#include "MMDPmxParser.h"
#include <assimp/StringUtils.h>
#include "../contrib/utf8cpp/source/utf8.h"
#include <assimp/Exceptional.h>
@@ -118,7 +119,7 @@ namespace pmx
stream->read((char*) &count, sizeof(uint8_t));
if (count < 8)
{
throw;
throw DeadlyImportError("MMD: invalid size");
}
stream->read((char*) &encoding, sizeof(uint8_t));
stream->read((char*) &uv, sizeof(uint8_t));
@@ -395,7 +396,7 @@ namespace pmx
}
break;
default:
throw;
throw DeadlyImportError("MMD: unknown morth type");
}
}
@@ -476,8 +477,8 @@ namespace pmx
{
// 未実装
std::cerr << "Not Implemented Exception" << std::endl;
throw;
}
throw DeadlyImportError("MMD: Not Implemented Exception");
}
void PmxModel::Init()
{
@@ -516,15 +517,15 @@ namespace pmx
if (magic[0] != 0x50 || magic[1] != 0x4d || magic[2] != 0x58 || magic[3] != 0x20)
{
std::cerr << "invalid magic number." << std::endl;
throw;
}
throw DeadlyImportError("MMD: invalid magic number.");
}
// バージョン
stream->read((char*) &version, sizeof(float));
if (version != 2.0f && version != 2.1f)
{
std::cerr << "this is not ver2.0 or ver2.1 but " << version << "." << std::endl;
throw;
}
throw DeadlyImportError("MMD: this is not ver2.0 or ver2.1 but " + to_string(version));
}
// ファイル設定
this->setting.Read(stream);
@@ -605,34 +606,5 @@ namespace pmx
{
this->joints[i].Read(stream, &setting);
}
//if (this->version == 2.1f)
//{
// stream->read((char*) &this->soft_body_count, sizeof(int));
// this->soft_bodies = mmd::make_unique<PmxSoftBody []>(this->soft_body_count);
// for (int i = 0; i < this->soft_body_count; i++)
// {
// this->soft_bodies[i].Read(stream, &setting);
// }
//}
}
//std::unique_ptr<PmxModel> ReadFromFile(const char *filename)
//{
// auto stream = std::ifstream(filename, std::ios_base::binary);
// auto pmx = PmxModel::ReadFromStream(&stream);
// if (!stream.eof())
// {
// std::cerr << "don't reach the end of file." << std::endl;
// }
// stream.close();
// return pmx;
//}
//std::unique_ptr<PmxModel> ReadFromStream(std::istream *stream)
//{
// auto pmx = mmd::make_unique<PmxModel>();
// pmx->Read(stream);
// return pmx;
//}
}