Merge branch 'master' into fix_android
commit
1a1d96d3e2
|
@ -92,6 +92,12 @@ struct Error : DeadlyImportError {
|
||||||
* descendents. It serves as base class for all data structure fields. */
|
* descendents. It serves as base class for all data structure fields. */
|
||||||
// -------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------
|
||||||
struct ElemBase {
|
struct ElemBase {
|
||||||
|
ElemBase()
|
||||||
|
: dna_type(nullptr)
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~ElemBase() {
|
virtual ~ElemBase() {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,9 @@ template <> void Structure :: Convert<Object> (
|
||||||
{
|
{
|
||||||
|
|
||||||
ReadField<ErrorPolicy_Fail>(dest.id,"id",db);
|
ReadField<ErrorPolicy_Fail>(dest.id,"id",db);
|
||||||
ReadField<ErrorPolicy_Fail>((int&)dest.type,"type",db);
|
int temp = 0;
|
||||||
|
ReadField<ErrorPolicy_Fail>(temp,"type",db);
|
||||||
|
dest.type = static_cast<Assimp::Blender::Object::Type>(temp);
|
||||||
ReadFieldArray2<ErrorPolicy_Warn>(dest.obmat,"obmat",db);
|
ReadFieldArray2<ErrorPolicy_Warn>(dest.obmat,"obmat",db);
|
||||||
ReadFieldArray2<ErrorPolicy_Warn>(dest.parentinv,"parentinv",db);
|
ReadFieldArray2<ErrorPolicy_Warn>(dest.parentinv,"parentinv",db);
|
||||||
ReadFieldArray<ErrorPolicy_Warn>(dest.parsubstr,"parsubstr",db);
|
ReadFieldArray<ErrorPolicy_Warn>(dest.parsubstr,"parsubstr",db);
|
||||||
|
@ -100,14 +102,21 @@ template <> void Structure :: Convert<MTex> (
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
|
|
||||||
ReadField<ErrorPolicy_Igno>((short&)dest.mapto,"mapto",db);
|
int temp_short = 0;
|
||||||
ReadField<ErrorPolicy_Igno>((int&)dest.blendtype,"blendtype",db);
|
ReadField<ErrorPolicy_Igno>(temp_short,"mapto",db);
|
||||||
|
dest.mapto = static_cast<Assimp::Blender::MTex::MapType>(temp_short);
|
||||||
|
int temp = 0;
|
||||||
|
ReadField<ErrorPolicy_Igno>(temp,"blendtype",db);
|
||||||
|
dest.blendtype = static_cast<Assimp::Blender::MTex::BlendType>(temp);
|
||||||
ReadFieldPtr<ErrorPolicy_Igno>(dest.object,"*object",db);
|
ReadFieldPtr<ErrorPolicy_Igno>(dest.object,"*object",db);
|
||||||
ReadFieldPtr<ErrorPolicy_Igno>(dest.tex,"*tex",db);
|
ReadFieldPtr<ErrorPolicy_Igno>(dest.tex,"*tex",db);
|
||||||
ReadFieldArray<ErrorPolicy_Igno>(dest.uvname,"uvname",db);
|
ReadFieldArray<ErrorPolicy_Igno>(dest.uvname,"uvname",db);
|
||||||
ReadField<ErrorPolicy_Igno>((int&)dest.projx,"projx",db);
|
ReadField<ErrorPolicy_Igno>(temp,"projx",db);
|
||||||
ReadField<ErrorPolicy_Igno>((int&)dest.projy,"projy",db);
|
dest.projx = static_cast<Assimp::Blender::MTex::Projection>(temp);
|
||||||
ReadField<ErrorPolicy_Igno>((int&)dest.projz,"projz",db);
|
ReadField<ErrorPolicy_Igno>(temp,"projy",db);
|
||||||
|
dest.projy = static_cast<Assimp::Blender::MTex::Projection>(temp);
|
||||||
|
ReadField<ErrorPolicy_Igno>(temp,"projz",db);
|
||||||
|
dest.projx = static_cast<Assimp::Blender::MTex::Projection>(temp);
|
||||||
ReadField<ErrorPolicy_Igno>(dest.mapping,"mapping",db);
|
ReadField<ErrorPolicy_Igno>(dest.mapping,"mapping",db);
|
||||||
ReadFieldArray<ErrorPolicy_Igno>(dest.ofs,"ofs",db);
|
ReadFieldArray<ErrorPolicy_Igno>(dest.ofs,"ofs",db);
|
||||||
ReadFieldArray<ErrorPolicy_Igno>(dest.size,"size",db);
|
ReadFieldArray<ErrorPolicy_Igno>(dest.size,"size",db);
|
||||||
|
@ -190,7 +199,9 @@ template <> void Structure :: Convert<Lamp> (
|
||||||
{
|
{
|
||||||
|
|
||||||
ReadField<ErrorPolicy_Fail>(dest.id,"id",db);
|
ReadField<ErrorPolicy_Fail>(dest.id,"id",db);
|
||||||
ReadField<ErrorPolicy_Fail>((int&)dest.type,"type",db);
|
int temp = 0;
|
||||||
|
ReadField<ErrorPolicy_Fail>(temp,"type",db);
|
||||||
|
dest.type = static_cast<Assimp::Blender::Lamp::Type>(temp);
|
||||||
ReadField<ErrorPolicy_Igno>(dest.flags,"flags",db);
|
ReadField<ErrorPolicy_Igno>(dest.flags,"flags",db);
|
||||||
ReadField<ErrorPolicy_Igno>(dest.colormodel,"colormodel",db);
|
ReadField<ErrorPolicy_Igno>(dest.colormodel,"colormodel",db);
|
||||||
ReadField<ErrorPolicy_Igno>(dest.totex,"totex",db);
|
ReadField<ErrorPolicy_Igno>(dest.totex,"totex",db);
|
||||||
|
@ -204,7 +215,8 @@ template <> void Structure :: Convert<Lamp> (
|
||||||
ReadField<ErrorPolicy_Igno>(dest.spotblend,"spotblend",db);
|
ReadField<ErrorPolicy_Igno>(dest.spotblend,"spotblend",db);
|
||||||
ReadField<ErrorPolicy_Igno>(dest.att1,"att1",db);
|
ReadField<ErrorPolicy_Igno>(dest.att1,"att1",db);
|
||||||
ReadField<ErrorPolicy_Igno>(dest.att2,"att2",db);
|
ReadField<ErrorPolicy_Igno>(dest.att2,"att2",db);
|
||||||
ReadField<ErrorPolicy_Igno>((int&)dest.falloff_type,"falloff_type",db);
|
ReadField<ErrorPolicy_Igno>(temp,"falloff_type",db);
|
||||||
|
dest.falloff_type = static_cast<Assimp::Blender::Lamp::FalloffType>(temp);
|
||||||
ReadField<ErrorPolicy_Igno>(dest.sun_brightness,"sun_brightness",db);
|
ReadField<ErrorPolicy_Igno>(dest.sun_brightness,"sun_brightness",db);
|
||||||
ReadField<ErrorPolicy_Igno>(dest.area_size,"area_size",db);
|
ReadField<ErrorPolicy_Igno>(dest.area_size,"area_size",db);
|
||||||
ReadField<ErrorPolicy_Igno>(dest.area_sizey,"area_sizey",db);
|
ReadField<ErrorPolicy_Igno>(dest.area_sizey,"area_sizey",db);
|
||||||
|
@ -693,8 +705,12 @@ template <> void Structure :: Convert<Tex> (
|
||||||
const FileDatabase& db
|
const FileDatabase& db
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
ReadField<ErrorPolicy_Igno>((short&)dest.imaflag,"imaflag",db);
|
short temp_short = 0;
|
||||||
ReadField<ErrorPolicy_Fail>((int&)dest.type,"type",db);
|
ReadField<ErrorPolicy_Igno>(temp_short,"imaflag",db);
|
||||||
|
dest.imaflag = static_cast<Assimp::Blender::Tex::ImageFlags>(temp_short);
|
||||||
|
int temp = 0;
|
||||||
|
ReadField<ErrorPolicy_Fail>(temp,"type",db);
|
||||||
|
dest.type = static_cast<Assimp::Blender::Tex::Type>(temp);
|
||||||
ReadFieldPtr<ErrorPolicy_Warn>(dest.ima,"*ima",db);
|
ReadFieldPtr<ErrorPolicy_Warn>(dest.ima,"*ima",db);
|
||||||
|
|
||||||
db.reader->IncPtr(size);
|
db.reader->IncPtr(size);
|
||||||
|
@ -708,8 +724,11 @@ template <> void Structure :: Convert<Camera> (
|
||||||
{
|
{
|
||||||
|
|
||||||
ReadField<ErrorPolicy_Fail>(dest.id,"id",db);
|
ReadField<ErrorPolicy_Fail>(dest.id,"id",db);
|
||||||
ReadField<ErrorPolicy_Warn>((int&)dest.type,"type",db);
|
int temp = 0;
|
||||||
ReadField<ErrorPolicy_Warn>((int&)dest.flag,"flag",db);
|
ReadField<ErrorPolicy_Warn>(temp,"type",db);
|
||||||
|
dest.type = static_cast<Assimp::Blender::Camera::Type>(temp);
|
||||||
|
ReadField<ErrorPolicy_Warn>(temp,"flag",db);
|
||||||
|
dest.flag = static_cast<Assimp::Blender::Camera::Type>(temp);
|
||||||
ReadField<ErrorPolicy_Warn>(dest.lens,"lens",db);
|
ReadField<ErrorPolicy_Warn>(dest.lens,"lens",db);
|
||||||
ReadField<ErrorPolicy_Warn>(dest.sensor_x,"sensor_x",db);
|
ReadField<ErrorPolicy_Warn>(dest.sensor_x,"sensor_x",db);
|
||||||
ReadField<ErrorPolicy_Igno>(dest.clipsta,"clipsta",db);
|
ReadField<ErrorPolicy_Igno>(dest.clipsta,"clipsta",db);
|
||||||
|
|
|
@ -225,6 +225,14 @@ struct TFace : ElemBase {
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------
|
||||||
struct MTFace : ElemBase {
|
struct MTFace : ElemBase {
|
||||||
|
MTFace()
|
||||||
|
: flag(0)
|
||||||
|
, mode(0)
|
||||||
|
, tile(0)
|
||||||
|
, unwrap(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
float uv[4][2] FAIL;
|
float uv[4][2] FAIL;
|
||||||
char flag;
|
char flag;
|
||||||
short mode;
|
short mode;
|
||||||
|
|
|
@ -487,7 +487,9 @@ struct FIFloatDecoder: public FIDecoder {
|
||||||
value.reserve(numFloats);
|
value.reserve(numFloats);
|
||||||
for (size_t i = 0; i < numFloats; ++i) {
|
for (size_t i = 0; i < numFloats; ++i) {
|
||||||
int v = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3];
|
int v = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3];
|
||||||
value.push_back(*(float*)&v);
|
float f;
|
||||||
|
memcpy(&f, &v, 4);
|
||||||
|
value.push_back(f);
|
||||||
data += 4;
|
data += 4;
|
||||||
}
|
}
|
||||||
return FIFloatValue::create(std::move(value));
|
return FIFloatValue::create(std::move(value));
|
||||||
|
@ -505,7 +507,9 @@ struct FIDoubleDecoder: public FIDecoder {
|
||||||
for (size_t i = 0; i < numDoubles; ++i) {
|
for (size_t i = 0; i < numDoubles; ++i) {
|
||||||
long long b0 = data[0], b1 = data[1], b2 = data[2], b3 = data[3], b4 = data[4], b5 = data[5], b6 = data[6], b7 = data[7];
|
long long b0 = data[0], b1 = data[1], b2 = data[2], b3 = data[3], b4 = data[4], b5 = data[5], b6 = data[6], b7 = data[7];
|
||||||
long long v = (b0 << 56) | (b1 << 48) | (b2 << 40) | (b3 << 32) | (b4 << 24) | (b5 << 16) | (b6 << 8) | b7;
|
long long v = (b0 << 56) | (b1 << 48) | (b2 << 40) | (b3 << 32) | (b4 << 24) | (b5 << 16) | (b6 << 8) | b7;
|
||||||
value.push_back(*(double*)&v);
|
double f;
|
||||||
|
memcpy(&f, &v, 8);
|
||||||
|
value.push_back(f);
|
||||||
data += 8;
|
data += 8;
|
||||||
}
|
}
|
||||||
return FIDoubleValue::create(std::move(value));
|
return FIDoubleValue::create(std::move(value));
|
||||||
|
|
|
@ -665,7 +665,9 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7(
|
||||||
if (0.0f != pcMatIn->Power)
|
if (0.0f != pcMatIn->Power)
|
||||||
{
|
{
|
||||||
iShadingMode = (int)aiShadingMode_Phong;
|
iShadingMode = (int)aiShadingMode_Phong;
|
||||||
pcMatOut->AddProperty<float>(&pcMatIn->Power,1,AI_MATKEY_SHININESS);
|
// pcMatIn is packed, we can't form pointers to its members
|
||||||
|
float power = pcMatIn->Power;
|
||||||
|
pcMatOut->AddProperty<float>(&power,1,AI_MATKEY_SHININESS);
|
||||||
}
|
}
|
||||||
pcMatOut->AddProperty<int>(&iShadingMode,1,AI_MATKEY_SHADING_MODEL);
|
pcMatOut->AddProperty<int>(&iShadingMode,1,AI_MATKEY_SHADING_MODEL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -334,28 +334,28 @@ void ValidateDSProcess::Validate( const aiMesh* pMesh)
|
||||||
case 1:
|
case 1:
|
||||||
if (0 == (pMesh->mPrimitiveTypes & aiPrimitiveType_POINT))
|
if (0 == (pMesh->mPrimitiveTypes & aiPrimitiveType_POINT))
|
||||||
{
|
{
|
||||||
ReportError("aiMesh::mFaces[%i] is a POINT but aiMesh::mPrimtiveTypes "
|
ReportError("aiMesh::mFaces[%i] is a POINT but aiMesh::mPrimitiveTypes "
|
||||||
"does not report the POINT flag",i);
|
"does not report the POINT flag",i);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (0 == (pMesh->mPrimitiveTypes & aiPrimitiveType_LINE))
|
if (0 == (pMesh->mPrimitiveTypes & aiPrimitiveType_LINE))
|
||||||
{
|
{
|
||||||
ReportError("aiMesh::mFaces[%i] is a LINE but aiMesh::mPrimtiveTypes "
|
ReportError("aiMesh::mFaces[%i] is a LINE but aiMesh::mPrimitiveTypes "
|
||||||
"does not report the LINE flag",i);
|
"does not report the LINE flag",i);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (0 == (pMesh->mPrimitiveTypes & aiPrimitiveType_TRIANGLE))
|
if (0 == (pMesh->mPrimitiveTypes & aiPrimitiveType_TRIANGLE))
|
||||||
{
|
{
|
||||||
ReportError("aiMesh::mFaces[%i] is a TRIANGLE but aiMesh::mPrimtiveTypes "
|
ReportError("aiMesh::mFaces[%i] is a TRIANGLE but aiMesh::mPrimitiveTypes "
|
||||||
"does not report the TRIANGLE flag",i);
|
"does not report the TRIANGLE flag",i);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (0 == (pMesh->mPrimitiveTypes & aiPrimitiveType_POLYGON))
|
if (0 == (pMesh->mPrimitiveTypes & aiPrimitiveType_POLYGON))
|
||||||
{
|
{
|
||||||
this->ReportError("aiMesh::mFaces[%i] is a POLYGON but aiMesh::mPrimtiveTypes "
|
this->ReportError("aiMesh::mFaces[%i] is a POLYGON but aiMesh::mPrimitiveTypes "
|
||||||
"does not report the POLYGON flag",i);
|
"does not report the POLYGON flag",i);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -231,7 +231,8 @@ namespace o3dgc
|
||||||
float ReadFloat32Bin(unsigned long & position) const
|
float ReadFloat32Bin(unsigned long & position) const
|
||||||
{
|
{
|
||||||
unsigned long value = ReadUInt32Bin(position);
|
unsigned long value = ReadUInt32Bin(position);
|
||||||
float fvalue = *((float *)(&value));
|
float fvalue;
|
||||||
|
memcpy(&fvalue, &value, 4);
|
||||||
return fvalue;
|
return fvalue;
|
||||||
}
|
}
|
||||||
unsigned long ReadUInt32Bin(unsigned long & position) const
|
unsigned long ReadUInt32Bin(unsigned long & position) const
|
||||||
|
@ -261,7 +262,8 @@ namespace o3dgc
|
||||||
|
|
||||||
void WriteFloat32ASCII(float value)
|
void WriteFloat32ASCII(float value)
|
||||||
{
|
{
|
||||||
unsigned long uiValue = *((unsigned long *)(&value));
|
unsigned long uiValue;
|
||||||
|
memcpy(&uiValue, &value, 4);
|
||||||
WriteUInt32ASCII(uiValue);
|
WriteUInt32ASCII(uiValue);
|
||||||
}
|
}
|
||||||
void WriteUInt32ASCII(unsigned long position, unsigned long value)
|
void WriteUInt32ASCII(unsigned long position, unsigned long value)
|
||||||
|
@ -314,7 +316,8 @@ namespace o3dgc
|
||||||
float ReadFloat32ASCII(unsigned long & position) const
|
float ReadFloat32ASCII(unsigned long & position) const
|
||||||
{
|
{
|
||||||
unsigned long value = ReadUInt32ASCII(position);
|
unsigned long value = ReadUInt32ASCII(position);
|
||||||
float fvalue = *((float *)(&value));
|
float fvalue;
|
||||||
|
memcpy(&fvalue, &value, 4);
|
||||||
return fvalue;
|
return fvalue;
|
||||||
}
|
}
|
||||||
unsigned long ReadUInt32ASCII(unsigned long & position) const
|
unsigned long ReadUInt32ASCII(unsigned long & position) const
|
||||||
|
|
|
@ -294,12 +294,12 @@ TEST_F(utObjImportExport, relative_indices_Test) {
|
||||||
const aiScene *scene = myimporter.ReadFileFromMemory(ObjModel.c_str(), ObjModel.size(), aiProcess_ValidateDataStructure);
|
const aiScene *scene = myimporter.ReadFileFromMemory(ObjModel.c_str(), ObjModel.size(), aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
|
|
||||||
EXPECT_EQ(scene->mNumMeshes, 1);
|
EXPECT_EQ(scene->mNumMeshes, 1U);
|
||||||
const aiMesh *mesh = scene->mMeshes[0];
|
const aiMesh *mesh = scene->mMeshes[0];
|
||||||
EXPECT_EQ(mesh->mNumVertices, 4);
|
EXPECT_EQ(mesh->mNumVertices, 4U);
|
||||||
EXPECT_EQ(mesh->mNumFaces, 1);
|
EXPECT_EQ(mesh->mNumFaces, 1U);
|
||||||
const aiFace face = mesh->mFaces[0];
|
const aiFace face = mesh->mFaces[0];
|
||||||
EXPECT_EQ(face.mNumIndices, 4);
|
EXPECT_EQ(face.mNumIndices, 4U);
|
||||||
for (unsigned int i = 0; i < face.mNumIndices; ++i)
|
for (unsigned int i = 0; i < face.mNumIndices; ++i)
|
||||||
{
|
{
|
||||||
EXPECT_EQ(face.mIndices[i], i);
|
EXPECT_EQ(face.mIndices[i], i);
|
||||||
|
@ -318,12 +318,12 @@ TEST_F(utObjImportExport, homogeneous_coordinates_Test) {
|
||||||
const aiScene *scene = myimporter.ReadFileFromMemory(ObjModel.c_str(), ObjModel.size(), aiProcess_ValidateDataStructure);
|
const aiScene *scene = myimporter.ReadFileFromMemory(ObjModel.c_str(), ObjModel.size(), aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
|
|
||||||
EXPECT_EQ(scene->mNumMeshes, 1);
|
EXPECT_EQ(scene->mNumMeshes, 1U);
|
||||||
const aiMesh *mesh = scene->mMeshes[0];
|
const aiMesh *mesh = scene->mMeshes[0];
|
||||||
EXPECT_EQ(mesh->mNumVertices, 3);
|
EXPECT_EQ(mesh->mNumVertices, 3U);
|
||||||
EXPECT_EQ(mesh->mNumFaces, 1);
|
EXPECT_EQ(mesh->mNumFaces, 1U);
|
||||||
const aiFace face = mesh->mFaces[0];
|
const aiFace face = mesh->mFaces[0];
|
||||||
EXPECT_EQ(face.mNumIndices, 3);
|
EXPECT_EQ(face.mNumIndices, 3U);
|
||||||
const aiVector3D vertice = mesh->mVertices[0];
|
const aiVector3D vertice = mesh->mVertices[0];
|
||||||
EXPECT_EQ(vertice.x, -1.0f);
|
EXPECT_EQ(vertice.x, -1.0f);
|
||||||
EXPECT_EQ(vertice.y, 0.0f);
|
EXPECT_EQ(vertice.y, 0.0f);
|
||||||
|
|
|
@ -177,6 +177,17 @@ inline uint32_t Write<aiVector3D>(const aiVector3D& v)
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------
|
||||||
|
// Serialize a color value
|
||||||
|
template <>
|
||||||
|
inline uint32_t Write<aiColor3D>(const aiColor3D& v)
|
||||||
|
{
|
||||||
|
uint32_t t = Write<float>(v.r);
|
||||||
|
t += Write<float>(v.g);
|
||||||
|
t += Write<float>(v.b);
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------
|
||||||
// Serialize a color value
|
// Serialize a color value
|
||||||
template <>
|
template <>
|
||||||
|
@ -566,9 +577,9 @@ uint32_t WriteBinaryLight(const aiLight* l)
|
||||||
len += Write<float>(l->mAttenuationQuadratic);
|
len += Write<float>(l->mAttenuationQuadratic);
|
||||||
}
|
}
|
||||||
|
|
||||||
len += Write<aiVector3D>((const aiVector3D&)l->mColorDiffuse);
|
len += Write<aiColor3D>(l->mColorDiffuse);
|
||||||
len += Write<aiVector3D>((const aiVector3D&)l->mColorSpecular);
|
len += Write<aiColor3D>(l->mColorSpecular);
|
||||||
len += Write<aiVector3D>((const aiVector3D&)l->mColorAmbient);
|
len += Write<aiColor3D>(l->mColorAmbient);
|
||||||
|
|
||||||
if (l->mType == aiLightSource_SPOT) {
|
if (l->mType == aiLightSource_SPOT) {
|
||||||
len += Write<float>(l->mAngleInnerCone);
|
len += Write<float>(l->mAngleInnerCone);
|
||||||
|
|
Loading…
Reference in New Issue