Merge branch 'master' into master

pull/4693/head
Kim Kulling 2022-08-23 21:14:45 +02:00 committed by GitHub
commit 87f601531c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 85 additions and 128 deletions

View File

@ -130,7 +130,7 @@ inline size_t Write<double>(IOStream *stream, const double &f) {
// Serialize a vec3 // Serialize a vec3
template <> template <>
inline size_t Write<aiVector3D>(IOStream *stream, const aiVector3D &v) { inline size_t Write<aiVector3D>(IOStream *stream, const aiVector3D &v) {
size_t t = Write<float>(stream, v.x); size_t t = Write<ai_real>(stream, v.x);
t += Write<float>(stream, v.y); t += Write<float>(stream, v.y);
t += Write<float>(stream, v.z); t += Write<float>(stream, v.z);
@ -141,7 +141,7 @@ inline size_t Write<aiVector3D>(IOStream *stream, const aiVector3D &v) {
// Serialize a color value // Serialize a color value
template <> template <>
inline size_t Write<aiColor3D>(IOStream *stream, const aiColor3D &v) { inline size_t Write<aiColor3D>(IOStream *stream, const aiColor3D &v) {
size_t t = Write<float>(stream, v.r); size_t t = Write<ai_real>(stream, v.r);
t += Write<float>(stream, v.g); t += Write<float>(stream, v.g);
t += Write<float>(stream, v.b); t += Write<float>(stream, v.b);
@ -152,7 +152,7 @@ inline size_t Write<aiColor3D>(IOStream *stream, const aiColor3D &v) {
// Serialize a color value // Serialize a color value
template <> template <>
inline size_t Write<aiColor4D>(IOStream *stream, const aiColor4D &v) { inline size_t Write<aiColor4D>(IOStream *stream, const aiColor4D &v) {
size_t t = Write<float>(stream, v.r); size_t t = Write<ai_real>(stream, v.r);
t += Write<float>(stream, v.g); t += Write<float>(stream, v.g);
t += Write<float>(stream, v.b); t += Write<float>(stream, v.b);
t += Write<float>(stream, v.a); t += Write<float>(stream, v.a);
@ -164,7 +164,7 @@ inline size_t Write<aiColor4D>(IOStream *stream, const aiColor4D &v) {
// Serialize a quaternion // Serialize a quaternion
template <> template <>
inline size_t Write<aiQuaternion>(IOStream *stream, const aiQuaternion &v) { inline size_t Write<aiQuaternion>(IOStream *stream, const aiQuaternion &v) {
size_t t = Write<float>(stream, v.w); size_t t = Write<ai_real>(stream, v.w);
t += Write<float>(stream, v.x); t += Write<float>(stream, v.x);
t += Write<float>(stream, v.y); t += Write<float>(stream, v.y);
t += Write<float>(stream, v.z); t += Write<float>(stream, v.z);
@ -190,7 +190,7 @@ template <>
inline size_t Write<aiMatrix4x4>(IOStream *stream, const aiMatrix4x4 &m) { inline size_t Write<aiMatrix4x4>(IOStream *stream, const aiMatrix4x4 &m) {
for (unsigned int i = 0; i < 4; ++i) { for (unsigned int i = 0; i < 4; ++i) {
for (unsigned int i2 = 0; i2 < 4; ++i2) { for (unsigned int i2 = 0; i2 < 4; ++i2) {
Write<float>(stream, m[i][i2]); Write<ai_real>(stream, m[i][i2]);
} }
} }

View File

@ -416,10 +416,10 @@ template <>
struct Structure::_defaultInitializer<ErrorPolicy_Fail> { struct Structure::_defaultInitializer<ErrorPolicy_Fail> {
template <typename T> template <typename T>
void operator()(T & /*out*/, const char * = "") { void operator()(T & /*out*/, const char *message = "") {
// obviously, it is crucial that _DefaultInitializer is used // obviously, it is crucial that _DefaultInitializer is used
// only from within a catch clause. // only from within a catch clause.
throw DeadlyImportError("Constructing BlenderDNA Structure encountered an error"); throw DeadlyImportError("Constructing BlenderDNA Structure encountered an error: ", message);
} }
}; };

View File

@ -71,10 +71,6 @@ static const fpCreateModifier creators[] = {
nullptr // sentinel nullptr // sentinel
}; };
// ------------------------------------------------------------------------------------------------
struct SharedModifierData : ElemBase {
ModifierData modifier;
};
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void BlenderModifierShowcase::ApplyModifiers(aiNode &out, ConversionData &conv_data, const Scene &in, const Object &orig_object) { void BlenderModifierShowcase::ApplyModifiers(aiNode &out, ConversionData &conv_data, const Scene &in, const Object &orig_object) {
@ -157,6 +153,7 @@ void BlenderModifier_Mirror ::DoIt(aiNode &out, ConversionData &conv_data, const
// hijacking the ABI, see the big note in BlenderModifierShowcase::ApplyModifiers() // hijacking the ABI, see the big note in BlenderModifierShowcase::ApplyModifiers()
const MirrorModifierData &mir = static_cast<const MirrorModifierData &>(orig_modifier); const MirrorModifierData &mir = static_cast<const MirrorModifierData &>(orig_modifier);
ai_assert(mir.modifier.type == ModifierData::eModifierType_Mirror); ai_assert(mir.modifier.type == ModifierData::eModifierType_Mirror);
std::shared_ptr<Object> mirror_ob = mir.mirror_ob.lock();
conv_data.meshes->reserve(conv_data.meshes->size() + out.mNumMeshes); conv_data.meshes->reserve(conv_data.meshes->size() + out.mNumMeshes);
@ -171,8 +168,8 @@ void BlenderModifier_Mirror ::DoIt(aiNode &out, ConversionData &conv_data, const
const float ys = mir.flag & MirrorModifierData::Flags_AXIS_Y ? -1.f : 1.f; const float ys = mir.flag & MirrorModifierData::Flags_AXIS_Y ? -1.f : 1.f;
const float zs = mir.flag & MirrorModifierData::Flags_AXIS_Z ? -1.f : 1.f; const float zs = mir.flag & MirrorModifierData::Flags_AXIS_Z ? -1.f : 1.f;
if (mir.mirror_ob) { if (mirror_ob) {
const aiVector3D center(mir.mirror_ob->obmat[3][0], mir.mirror_ob->obmat[3][1], mir.mirror_ob->obmat[3][2]); const aiVector3D center(mirror_ob->obmat[3][0], mirror_ob->obmat[3][1], mirror_ob->obmat[3][2]);
for (unsigned int j = 0; j < mesh->mNumVertices; ++j) { for (unsigned int j = 0; j < mesh->mNumVertices; ++j) {
aiVector3D &v = mesh->mVertices[j]; aiVector3D &v = mesh->mVertices[j];

View File

@ -624,7 +624,9 @@ void Structure ::Convert<ListBase>(
const FileDatabase &db) const { const FileDatabase &db) const {
ReadFieldPtr<ErrorPolicy_Igno>(dest.first, "*first", db); ReadFieldPtr<ErrorPolicy_Igno>(dest.first, "*first", db);
ReadFieldPtr<ErrorPolicy_Igno>(dest.last, "*last", db); std::shared_ptr<ElemBase> last;
ReadFieldPtr<ErrorPolicy_Igno>(last, "*last", db);
dest.last = last;
db.reader->IncPtr(size); db.reader->IncPtr(size);
} }
@ -648,7 +650,9 @@ void Structure ::Convert<ModifierData>(
const FileDatabase &db) const { const FileDatabase &db) const {
ReadFieldPtr<ErrorPolicy_Warn>(dest.next, "*next", db); ReadFieldPtr<ErrorPolicy_Warn>(dest.next, "*next", db);
ReadFieldPtr<ErrorPolicy_Warn>(dest.prev, "*prev", db); std::shared_ptr<ElemBase> prev;
ReadFieldPtr<ErrorPolicy_Warn>(prev, "*prev", db);
dest.prev = prev;
ReadField<ErrorPolicy_Igno>(dest.type, "type", db); ReadField<ErrorPolicy_Igno>(dest.type, "type", db);
ReadField<ErrorPolicy_Igno>(dest.mode, "mode", db); ReadField<ErrorPolicy_Igno>(dest.mode, "mode", db);
ReadFieldArray<ErrorPolicy_Igno>(dest.name, "name", db); ReadFieldArray<ErrorPolicy_Igno>(dest.name, "name", db);
@ -772,7 +776,9 @@ void Structure ::Convert<MirrorModifierData>(
ReadField<ErrorPolicy_Igno>(dest.axis, "axis", db); ReadField<ErrorPolicy_Igno>(dest.axis, "axis", db);
ReadField<ErrorPolicy_Igno>(dest.flag, "flag", db); ReadField<ErrorPolicy_Igno>(dest.flag, "flag", db);
ReadField<ErrorPolicy_Igno>(dest.tolerance, "tolerance", db); ReadField<ErrorPolicy_Igno>(dest.tolerance, "tolerance", db);
ReadFieldPtr<ErrorPolicy_Igno>(dest.mirror_ob, "*mirror_ob", db); std::shared_ptr<Object> mirror_ob;
ReadFieldPtr<ErrorPolicy_Igno>(mirror_ob, "*mirror_ob", db);
dest.mirror_ob = mirror_ob;
db.reader->IncPtr(size); db.reader->IncPtr(size);
} }
@ -833,9 +839,9 @@ void Structure::Convert<CustomDataLayer>(
ReadField<ErrorPolicy_Fail>(dest.flag, "flag", db); ReadField<ErrorPolicy_Fail>(dest.flag, "flag", db);
ReadField<ErrorPolicy_Fail>(dest.active, "active", db); ReadField<ErrorPolicy_Fail>(dest.active, "active", db);
ReadField<ErrorPolicy_Fail>(dest.active_rnd, "active_rnd", db); ReadField<ErrorPolicy_Fail>(dest.active_rnd, "active_rnd", db);
ReadField<ErrorPolicy_Fail>(dest.active_clone, "active_clone", db); ReadField<ErrorPolicy_Warn>(dest.active_clone, "active_clone", db);
ReadField<ErrorPolicy_Fail>(dest.active_mask, "active_mask", db); ReadField<ErrorPolicy_Warn>(dest.active_mask, "active_mask", db);
ReadField<ErrorPolicy_Fail>(dest.uid, "uid", db); ReadField<ErrorPolicy_Warn>(dest.uid, "uid", db);
ReadFieldArray<ErrorPolicy_Warn>(dest.name, "name", db); ReadFieldArray<ErrorPolicy_Warn>(dest.name, "name", db);
ReadCustomDataPtr<ErrorPolicy_Fail>(dest.data, dest.type, "*data", db); ReadCustomDataPtr<ErrorPolicy_Fail>(dest.data, dest.type, "*data", db);

View File

@ -124,7 +124,7 @@ struct ID : ElemBase {
// ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
struct ListBase : ElemBase { struct ListBase : ElemBase {
std::shared_ptr<ElemBase> first; std::shared_ptr<ElemBase> first;
std::shared_ptr<ElemBase> last; std::weak_ptr<ElemBase> last;
}; };
// ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
@ -642,14 +642,21 @@ struct ModifierData : ElemBase {
}; };
std::shared_ptr<ElemBase> next WARN; std::shared_ptr<ElemBase> next WARN;
std::shared_ptr<ElemBase> prev WARN; std::weak_ptr<ElemBase> prev WARN;
int type, mode; int type, mode;
char name[32]; char name[32];
}; };
// ------------------------------------------------------------------------------------------------
struct SharedModifierData : ElemBase {
ModifierData modifier;
};
// ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
struct SubsurfModifierData : ElemBase { struct SubsurfModifierData : SharedModifierData {
enum Type { enum Type {
@ -662,7 +669,6 @@ struct SubsurfModifierData : ElemBase {
FLAGS_SubsurfUV = 1 << 3 FLAGS_SubsurfUV = 1 << 3
}; };
ModifierData modifier FAIL;
short subdivType WARN; short subdivType WARN;
short levels FAIL; short levels FAIL;
short renderLevels; short renderLevels;
@ -670,7 +676,7 @@ struct SubsurfModifierData : ElemBase {
}; };
// ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
struct MirrorModifierData : ElemBase { struct MirrorModifierData : SharedModifierData {
enum Flags { enum Flags {
Flags_CLIPPING = 1 << 0, Flags_CLIPPING = 1 << 0,
@ -682,11 +688,9 @@ struct MirrorModifierData : ElemBase {
Flags_VGROUP = 1 << 6 Flags_VGROUP = 1 << 6
}; };
ModifierData modifier FAIL;
short axis, flag; short axis, flag;
float tolerance; float tolerance;
std::shared_ptr<Object> mirror_ob; std::weak_ptr<Object> mirror_ob;
}; };
// ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------

View File

@ -707,12 +707,10 @@ void LWOImporter::LoadNodalBlocks(unsigned int size) {
if (mFileBuffer + head.length > end) { if (mFileBuffer + head.length > end) {
throw DeadlyImportError("LWO3: cannot read length; LoadNodalBlocks"); throw DeadlyImportError("LWO3: cannot read length; LoadNodalBlocks");
} }
int node_idx = 0;
uint8_t *const next = mFileBuffer + head.length; uint8_t *const next = mFileBuffer + head.length;
mFileBuffer += bufOffset; mFileBuffer += bufOffset;
switch (head.type) { switch (head.type) {
case AI_LWO_NNDS: case AI_LWO_NNDS:
node_idx++;
LoadNodes(head.length); LoadNodes(head.length);
break; break;
} }

View File

@ -516,7 +516,7 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
std::list<LWS::NodeDesc> nodes; std::list<LWS::NodeDesc> nodes;
unsigned int cur_light = 0, cur_camera = 0, cur_object = 0; unsigned int cur_light = 0, cur_camera = 0, cur_object = 0;
unsigned int num_light = 0, num_camera = 0, num_object = 0; unsigned int num_light = 0, num_camera = 0;
// check magic identifier, 'LWSC' // check magic identifier, 'LWSC'
bool motion_file = false; bool motion_file = false;
@ -586,7 +586,6 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
d.id = batch.AddLoadRequest(path, 0, &props); d.id = batch.AddLoadRequest(path, 0, &props);
nodes.push_back(d); nodes.push_back(d);
++num_object;
} else if ((*it).tokens[0] == "LoadObject") { // 'LoadObject': load a LWO file into the scene-graph } else if ((*it).tokens[0] == "LoadObject") { // 'LoadObject': load a LWO file into the scene-graph
// add node to list // add node to list
@ -604,7 +603,6 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
d.path = path; d.path = path;
nodes.push_back(d); nodes.push_back(d);
++num_object;
} else if ((*it).tokens[0] == "AddNullObject") { // 'AddNullObject': add a dummy node to the hierarchy } else if ((*it).tokens[0] == "AddNullObject") { // 'AddNullObject': add a dummy node to the hierarchy
// add node to list // add node to list
@ -618,8 +616,6 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
} }
d.name = c; d.name = c;
nodes.push_back(d); nodes.push_back(d);
num_object++;
} }
// 'NumChannels': Number of envelope channels assigned to last layer // 'NumChannels': Number of envelope channels assigned to last layer
else if ((*it).tokens[0] == "NumChannels") { else if ((*it).tokens[0] == "NumChannels") {

View File

@ -112,7 +112,6 @@ ObjFile::Model *ObjFileParser::GetModel() const {
void ObjFileParser::parseFile(IOStreamBuffer<char> &streamBuffer) { void ObjFileParser::parseFile(IOStreamBuffer<char> &streamBuffer) {
// only update every 100KB or it'll be too slow // only update every 100KB or it'll be too slow
//const unsigned int updateProgressEveryBytes = 100 * 1024; //const unsigned int updateProgressEveryBytes = 100 * 1024;
unsigned int progressCounter = 0;
const unsigned int bytesToProcess = static_cast<unsigned int>(streamBuffer.size()); const unsigned int bytesToProcess = static_cast<unsigned int>(streamBuffer.size());
const unsigned int progressTotal = bytesToProcess; const unsigned int progressTotal = bytesToProcess;
unsigned int processed = 0; unsigned int processed = 0;
@ -129,7 +128,6 @@ void ObjFileParser::parseFile(IOStreamBuffer<char> &streamBuffer) {
if (lastFilePos < filePos) { if (lastFilePos < filePos) {
processed = static_cast<unsigned int>(filePos); processed = static_cast<unsigned int>(filePos);
lastFilePos = filePos; lastFilePos = filePos;
progressCounter++;
m_progress->UpdateFileRead(processed, progressTotal); m_progress->UpdateFileRead(processed, progressTotal);
} }

View File

@ -147,10 +147,8 @@ void SMDImporter::InternReadFile( const std::string& pFile, aiScene* scene, IOSy
if (!asBones.empty()) { if (!asBones.empty()) {
// Check whether all bones have been initialized // Check whether all bones have been initialized
for (std::vector<SMD::Bone>::const_iterator for (const auto &asBone : asBones) {
i = asBones.begin(); if (!asBone.mName.length()) {
i != asBones.end();++i) {
if (!(*i).mName.length()) {
ASSIMP_LOG_WARN("SMD: Not all bones have been initialized"); ASSIMP_LOG_WARN("SMD: Not all bones have been initialized");
break; break;
} }
@ -210,14 +208,10 @@ void SMDImporter::LogWarning(const char* msg) {
void SMDImporter::FixTimeValues() { void SMDImporter::FixTimeValues() {
double dDelta = (double)iSmallestFrame; double dDelta = (double)iSmallestFrame;
double dMax = 0.0f; double dMax = 0.0f;
for (std::vector<SMD::Bone>::iterator for (auto &asBone : asBones) {
iBone = asBones.begin(); for (auto &asKey : asBone.sAnim.asKeys) {
iBone != asBones.end();++iBone) { asKey.dTime -= dDelta;
for (std::vector<SMD::Bone::Animation::MatrixKey>::iterator dMax = std::max(dMax, asKey.dTime);
iKey = (*iBone).sAnim.asKeys.begin();
iKey != (*iBone).sAnim.asKeys.end();++iKey) {
(*iKey).dTime -= dDelta;
dMax = std::max(dMax, (*iKey).dTime);
} }
} }
dLengthOfAnim = dMax; dLengthOfAnim = dMax;
@ -237,7 +231,7 @@ void SMDImporter::CreateOutputMeshes() {
pScene->mMeshes = new aiMesh*[pScene->mNumMeshes]; pScene->mMeshes = new aiMesh*[pScene->mNumMeshes];
typedef std::vector<unsigned int> FaceList; typedef std::vector<unsigned int> FaceList;
FaceList* aaiFaces = new FaceList[pScene->mNumMeshes]; std::unique_ptr<FaceList[]> aaiFaces(new FaceList[pScene->mNumMeshes]);
// approximate the space that will be required // approximate the space that will be required
unsigned int iNum = (unsigned int)asTriangles.size() / pScene->mNumMeshes; unsigned int iNum = (unsigned int)asTriangles.size() / pScene->mNumMeshes;
@ -248,17 +242,14 @@ void SMDImporter::CreateOutputMeshes() {
// collect all faces // collect all faces
iNum = 0; iNum = 0;
for (std::vector<SMD::Face>::const_iterator for (const auto &asTriangle : asTriangles) {
iFace = asTriangles.begin(); if (asTriangle.iTexture >= aszTextures.size()) {
iFace != asTriangles.end();++iFace,++iNum) {
if (UINT_MAX == (*iFace).iTexture) {
aaiFaces[(*iFace).iTexture].push_back( 0 );
} else if ((*iFace).iTexture >= aszTextures.size()) {
ASSIMP_LOG_INFO("[SMD/VTA] Material index overflow in face"); ASSIMP_LOG_INFO("[SMD/VTA] Material index overflow in face");
aaiFaces[(*iFace).iTexture].push_back((unsigned int)aszTextures.size()-1); aaiFaces[asTriangle.iTexture].push_back((unsigned int)aszTextures.size()-1);
} else { } else {
aaiFaces[(*iFace).iTexture].push_back(iNum); aaiFaces[asTriangle.iTexture].push_back(iNum);
} }
++iNum;
} }
// now create the output meshes // now create the output meshes
@ -275,7 +266,7 @@ void SMDImporter::CreateOutputMeshes() {
typedef std::pair<unsigned int,float> TempWeightListEntry; typedef std::pair<unsigned int,float> TempWeightListEntry;
typedef std::vector< TempWeightListEntry > TempBoneWeightList; typedef std::vector< TempWeightListEntry > TempBoneWeightList;
TempBoneWeightList* aaiBones = new TempBoneWeightList[asBones.size()](); std::unique_ptr<TempBoneWeightList[]> aaiBones(new TempBoneWeightList[asBones.size()]());
// try to reserve enough memory without wasting too much // try to reserve enough memory without wasting too much
for (unsigned int iBone = 0; iBone < asBones.size();++iBone) { for (unsigned int iBone = 0; iBone < asBones.size();++iBone) {
@ -351,8 +342,7 @@ void SMDImporter::CreateOutputMeshes() {
if (fSum) { if (fSum) {
fSum = 1 / fSum; fSum = 1 / fSum;
for (unsigned int iBone = 0;iBone < face.avVertices[iVert].aiBoneLinks.size();++iBone) { for (auto &pairval : face.avVertices[iVert].aiBoneLinks) {
TempWeightListEntry& pairval = face.avVertices[iVert].aiBoneLinks[iBone];
if (pairval.first >= asBones.size()) { if (pairval.first >= asBones.size()) {
continue; continue;
} }
@ -398,9 +388,7 @@ void SMDImporter::CreateOutputMeshes() {
++iNum; ++iNum;
} }
} }
delete[] aaiBones;
} }
delete[] aaiFaces;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -411,8 +399,7 @@ void SMDImporter::AddBoneChildren(aiNode* pcNode, uint32_t iParent) {
ai_assert( nullptr == pcNode->mChildren); ai_assert( nullptr == pcNode->mChildren);
// first count ... // first count ...
for (unsigned int i = 0; i < asBones.size();++i) { for (auto &bone : asBones) {
SMD::Bone& bone = asBones[i];
if (bone.iParent == iParent) { if (bone.iParent == iParent) {
++pcNode->mNumChildren; ++pcNode->mNumChildren;
} }
@ -516,27 +503,25 @@ void SMDImporter::CreateOutputAnimation(int index, const std::string &name) {
// now build valid keys // now build valid keys
unsigned int a = 0; unsigned int a = 0;
for (std::vector<SMD::Bone>::const_iterator i = asBones.begin(); i != asBones.end(); ++i) { for (const auto &asBone : asBones) {
aiNodeAnim* p = pp[a] = new aiNodeAnim(); aiNodeAnim* p = pp[a] = new aiNodeAnim();
// copy the name of the bone // copy the name of the bone
p->mNodeName.Set(i->mName); p->mNodeName.Set(asBone.mName);
p->mNumRotationKeys = (unsigned int)(*i).sAnim.asKeys.size(); p->mNumRotationKeys = (unsigned int)asBone.sAnim.asKeys.size();
if (p->mNumRotationKeys){ if (p->mNumRotationKeys){
p->mNumPositionKeys = p->mNumRotationKeys; p->mNumPositionKeys = p->mNumRotationKeys;
aiVectorKey* pVecKeys = p->mPositionKeys = new aiVectorKey[p->mNumRotationKeys]; aiVectorKey* pVecKeys = p->mPositionKeys = new aiVectorKey[p->mNumRotationKeys];
aiQuatKey* pRotKeys = p->mRotationKeys = new aiQuatKey[p->mNumRotationKeys]; aiQuatKey* pRotKeys = p->mRotationKeys = new aiQuatKey[p->mNumRotationKeys];
for (std::vector<SMD::Bone::Animation::MatrixKey>::const_iterator for (const auto &asKey : asBone.sAnim.asKeys) {
qq = (*i).sAnim.asKeys.begin(); pRotKeys->mTime = pVecKeys->mTime = asKey.dTime;
qq != (*i).sAnim.asKeys.end(); ++qq) {
pRotKeys->mTime = pVecKeys->mTime = (*qq).dTime;
// compute the rotation quaternion from the euler angles // compute the rotation quaternion from the euler angles
// aiQuaternion: The order of the parameters is yzx? // aiQuaternion: The order of the parameters is yzx?
pRotKeys->mValue = aiQuaternion((*qq).vRot.y, (*qq).vRot.z, (*qq).vRot.x); pRotKeys->mValue = aiQuaternion(asKey.vRot.y, asKey.vRot.z, asKey.vRot.x);
pVecKeys->mValue = (*qq).vPos; pVecKeys->mValue = asKey.vPos;
++pVecKeys; ++pRotKeys; ++pVecKeys; ++pRotKeys;
} }
@ -982,8 +967,8 @@ void SMDImporter::ParseTriangle(const char* szCurrent, const char** szCurrentOut
SkipSpacesAndLineEnd(szCurrent,&szCurrent); SkipSpacesAndLineEnd(szCurrent,&szCurrent);
// load three vertices // load three vertices
for (unsigned int iVert = 0; iVert < 3;++iVert) { for (auto &avVertex : face.avVertices) {
ParseVertex(szCurrent,&szCurrent, face.avVertices[iVert]); ParseVertex(szCurrent,&szCurrent, avVertex);
} }
*szCurrentOut = szCurrent; *szCurrentOut = szCurrent;
} }
@ -1080,13 +1065,11 @@ void SMDImporter::ParseVertex(const char* szCurrent,
} }
vertex.aiBoneLinks.resize(iSize,std::pair<unsigned int, float>(0,0.0f)); vertex.aiBoneLinks.resize(iSize,std::pair<unsigned int, float>(0,0.0f));
for (std::vector<std::pair<unsigned int, float> >::iterator for (auto &aiBoneLink : vertex.aiBoneLinks) {
i = vertex.aiBoneLinks.begin(); if(!ParseUnsignedInt(szCurrent,&szCurrent,aiBoneLink.first)) {
i != vertex.aiBoneLinks.end();++i) {
if(!ParseUnsignedInt(szCurrent,&szCurrent,(*i).first)) {
SMDI_PARSE_RETURN; SMDI_PARSE_RETURN;
} }
if(!ParseFloat(szCurrent,&szCurrent,(*i).second)) { if(!ParseFloat(szCurrent,&szCurrent,aiBoneLink.second)) {
SMDI_PARSE_RETURN; SMDI_PARSE_RETURN;
} }
} }

View File

@ -477,9 +477,6 @@ void X3DImporter::ParseHelper_Node_Exit() {
// check if we can walk up. // check if we can walk up.
if (mNodeElementCur != nullptr) { if (mNodeElementCur != nullptr) {
mNodeElementCur = mNodeElementCur->Parent; mNodeElementCur = mNodeElementCur->Parent;
} else {
int i = 0;
++i;
} }
} }

View File

@ -118,10 +118,8 @@ void ScenePreprocessor::ProcessMesh(aiMesh *mesh) {
// as if they were 2D channels .. just in case an application doesn't handle // as if they were 2D channels .. just in case an application doesn't handle
// this case // this case
if (2 == mesh->mNumUVComponents[i]) { if (2 == mesh->mNumUVComponents[i]) {
size_t num = 0;
for (; p != end; ++p) { for (; p != end; ++p) {
p->z = 0.f; p->z = 0.f;
num++;
} }
} else if (1 == mesh->mNumUVComponents[i]) { } else if (1 == mesh->mNumUVComponents[i]) {
for (; p != end; ++p) { for (; p != end; ++p) {

View File

@ -647,12 +647,9 @@ char *OpenDDLParser::parseBooleanLiteral(char *in, char *end, Value **boolean) {
in = lookForNextToken(in, end); in = lookForNextToken(in, end);
char *start(in); char *start(in);
size_t len(0);
while (!isSeparator(*in) && in != end) { while (!isSeparator(*in) && in != end) {
++in; ++in;
++len;
} }
++len;
int res = ::strncmp(Grammar::BoolTrue, start, strlen(Grammar::BoolTrue)); int res = ::strncmp(Grammar::BoolTrue, start, strlen(Grammar::BoolTrue));
if (0 != res) { if (0 != res) {
res = ::strncmp(Grammar::BoolFalse, start, strlen(Grammar::BoolFalse)); res = ::strncmp(Grammar::BoolFalse, start, strlen(Grammar::BoolFalse));

View File

@ -64,8 +64,7 @@ TEST_F(utBlenderImporterExporter, importBlenFromFileTest) {
TEST(utBlenderImporter, import4cubes) { TEST(utBlenderImporter, import4cubes) {
Assimp::Importer importer; Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/4Cubes4Mats_248.blend", aiProcess_ValidateDataStructure); const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/4Cubes4Mats_248.blend", aiProcess_ValidateDataStructure);
// FIXME: this is probably not right, loading this should succeed ASSERT_NE(nullptr, scene);
ASSERT_EQ(nullptr, scene);
} }
TEST(utBlenderImporter, import269_regress1) { TEST(utBlenderImporter, import269_regress1) {
@ -77,22 +76,19 @@ TEST(utBlenderImporter, import269_regress1) {
TEST(utBlenderImporter, importBlenderDefault248) { TEST(utBlenderImporter, importBlenderDefault248) {
Assimp::Importer importer; Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_248.blend", aiProcess_ValidateDataStructure); const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_248.blend", aiProcess_ValidateDataStructure);
// FIXME: this is probably not right, loading this should succeed ASSERT_NE(nullptr, scene);
ASSERT_EQ(nullptr, scene);
} }
TEST(utBlenderImporter, importBlenderDefault250) { TEST(utBlenderImporter, importBlenderDefault250) {
Assimp::Importer importer; Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_250.blend", aiProcess_ValidateDataStructure); const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_250.blend", aiProcess_ValidateDataStructure);
// FIXME: this is probably not right, loading this should succeed ASSERT_NE(nullptr, scene);
ASSERT_EQ(nullptr, scene);
} }
TEST(utBlenderImporter, importBlenderDefault250Compressed) { TEST(utBlenderImporter, importBlenderDefault250Compressed) {
Assimp::Importer importer; Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_250_Compressed.blend", aiProcess_ValidateDataStructure); const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_250_Compressed.blend", aiProcess_ValidateDataStructure);
// FIXME: this is probably not right, loading this should succeed ASSERT_NE(nullptr, scene);
ASSERT_EQ(nullptr, scene);
} }
TEST(utBlenderImporter, importBlenderDefault262) { TEST(utBlenderImporter, importBlenderDefault262) {
@ -123,92 +119,79 @@ TEST(utBlenderImporter, importBlenderDefault293) {
TEST(utBlenderImporter, importCubeHierarchy_248) { TEST(utBlenderImporter, importCubeHierarchy_248) {
Assimp::Importer importer; Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/CubeHierarchy_248.blend", aiProcess_ValidateDataStructure); const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/CubeHierarchy_248.blend", aiProcess_ValidateDataStructure);
// FIXME: this is probably not right, loading this should succeed ASSERT_NE(nullptr, scene);
ASSERT_EQ(nullptr, scene);
} }
TEST(utBlenderImporter, importHuman) { TEST(utBlenderImporter, importHuman) {
Assimp::Importer importer; Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/HUMAN.blend", aiProcess_ValidateDataStructure); const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/HUMAN.blend", aiProcess_ValidateDataStructure);
// FIXME: this is probably not right, loading this should succeed ASSERT_NE(nullptr, scene);
ASSERT_EQ(nullptr, scene);
} }
TEST(utBlenderImporter, importMirroredCube_252) { TEST(utBlenderImporter, importMirroredCube_252) {
Assimp::Importer importer; Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/MirroredCube_252.blend", aiProcess_ValidateDataStructure); const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/MirroredCube_252.blend", aiProcess_ValidateDataStructure);
// FIXME: this is probably not right, loading this should succeed ASSERT_NE(nullptr, scene);
ASSERT_EQ(nullptr, scene);
} }
TEST(utBlenderImporter, importNoisyTexturedCube_VoronoiGlob_248) { TEST(utBlenderImporter, importNoisyTexturedCube_VoronoiGlob_248) {
Assimp::Importer importer; Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/NoisyTexturedCube_VoronoiGlob_248.blend", aiProcess_ValidateDataStructure); const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/NoisyTexturedCube_VoronoiGlob_248.blend", aiProcess_ValidateDataStructure);
// FIXME: this is probably not right, loading this should succeed ASSERT_NE(nullptr, scene);
ASSERT_EQ(nullptr, scene);
} }
TEST(utBlenderImporter, importSmoothVsSolidCube_248) { TEST(utBlenderImporter, importSmoothVsSolidCube_248) {
Assimp::Importer importer; Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/SmoothVsSolidCube_248.blend", aiProcess_ValidateDataStructure); const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/SmoothVsSolidCube_248.blend", aiProcess_ValidateDataStructure);
// FIXME: this is probably not right, loading this should succeed ASSERT_NE(nullptr, scene);
ASSERT_EQ(nullptr, scene);
} }
TEST(utBlenderImporter, importSuzanne_248) { TEST(utBlenderImporter, importSuzanne_248) {
Assimp::Importer importer; Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/Suzanne_248.blend", aiProcess_ValidateDataStructure); const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/Suzanne_248.blend", aiProcess_ValidateDataStructure);
// FIXME: this is probably not right, loading this should succeed ASSERT_NE(nullptr, scene);
ASSERT_EQ(nullptr, scene);
} }
TEST(utBlenderImporter, importSuzanneSubdiv_252) { TEST(utBlenderImporter, importSuzanneSubdiv_252) {
Assimp::Importer importer; Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/SuzanneSubdiv_252.blend", aiProcess_ValidateDataStructure); const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/SuzanneSubdiv_252.blend", aiProcess_ValidateDataStructure);
// FIXME: this is probably not right, loading this should succeed ASSERT_NE(nullptr, scene);
ASSERT_EQ(nullptr, scene);
} }
TEST(utBlenderImporter, importTexturedCube_ImageGlob_248) { TEST(utBlenderImporter, importTexturedCube_ImageGlob_248) {
Assimp::Importer importer; Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/TexturedCube_ImageGlob_248.blend", aiProcess_ValidateDataStructure); const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/TexturedCube_ImageGlob_248.blend", aiProcess_ValidateDataStructure);
// FIXME: this is probably not right, loading this should succeed ASSERT_NE(nullptr, scene);
ASSERT_EQ(nullptr, scene);
} }
TEST(utBlenderImporter, importTexturedPlane_ImageUv_248) { TEST(utBlenderImporter, importTexturedPlane_ImageUv_248) {
Assimp::Importer importer; Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/TexturedPlane_ImageUv_248.blend", aiProcess_ValidateDataStructure); const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/TexturedPlane_ImageUv_248.blend", aiProcess_ValidateDataStructure);
// FIXME: this is probably not right, loading this should succeed ASSERT_NE(nullptr, scene);
ASSERT_EQ(nullptr, scene);
} }
TEST(utBlenderImporter, importTexturedPlane_ImageUvPacked_248) { TEST(utBlenderImporter, importTexturedPlane_ImageUvPacked_248) {
Assimp::Importer importer; Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/TexturedPlane_ImageUvPacked_248.blend", aiProcess_ValidateDataStructure); const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/TexturedPlane_ImageUvPacked_248.blend", aiProcess_ValidateDataStructure);
// FIXME: this is probably not right, loading this should succeed ASSERT_NE(nullptr, scene);
ASSERT_EQ(nullptr, scene);
} }
TEST(utBlenderImporter, importTorusLightsCams_250_compressed) { TEST(utBlenderImporter, importTorusLightsCams_250_compressed) {
Assimp::Importer importer; Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/TorusLightsCams_250_compressed.blend", aiProcess_ValidateDataStructure); const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/TorusLightsCams_250_compressed.blend", aiProcess_ValidateDataStructure);
// FIXME: this is probably not right, loading this should succeed ASSERT_NE(nullptr, scene);
ASSERT_EQ(nullptr, scene);
} }
TEST(utBlenderImporter, import_yxa_1) { TEST(utBlenderImporter, import_yxa_1) {
Assimp::Importer importer; Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/yxa_1.blend", aiProcess_ValidateDataStructure); const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/yxa_1.blend", aiProcess_ValidateDataStructure);
// FIXME: this is probably not right, loading this should succeed ASSERT_NE(nullptr, scene);
ASSERT_EQ(nullptr, scene);
} }
TEST(utBlenderImporter, importBob) { TEST(utBlenderImporter, importBob) {
Assimp::Importer importer; Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/BLEND/Bob.blend", aiProcess_ValidateDataStructure); const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/BLEND/Bob.blend", aiProcess_ValidateDataStructure);
// FIXME: this is probably not right, loading this should succeed ASSERT_NE(nullptr, scene);
ASSERT_EQ(nullptr, scene);
} }
TEST(utBlenderImporter, importFleurOptonl) { TEST(utBlenderImporter, importFleurOptonl) {

View File

@ -286,12 +286,6 @@ void PrintHierarchy(
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Implementation of the assimp info utility to print basic file info // Implementation of the assimp info utility to print basic file info
int Assimp_Info(const char *const *params, unsigned int num) { int Assimp_Info(const char *const *params, unsigned int num) {
// --help
if (!strcmp(params[0], "-h") || !strcmp(params[0], "--help") || !strcmp(params[0], "-?")) {
printf("%s", AICMD_MSG_INFO_HELP_E);
return AssimpCmdError::Success;
}
// asssimp info <file> [-r] // asssimp info <file> [-r]
if (num < 1) { if (num < 1) {
printf("assimp info: Invalid number of arguments. " printf("assimp info: Invalid number of arguments. "
@ -299,6 +293,12 @@ int Assimp_Info(const char *const *params, unsigned int num) {
return AssimpCmdError::InvalidNumberOfArguments; return AssimpCmdError::InvalidNumberOfArguments;
} }
// --help
if (!strcmp(params[0], "-h") || !strcmp(params[0], "--help") || !strcmp(params[0], "-?")) {
printf("%s", AICMD_MSG_INFO_HELP_E);
return AssimpCmdError::Success;
}
const std::string in = std::string(params[0]); const std::string in = std::string(params[0]);
// get -r and -v arguments // get -r and -v arguments