Merge branch 'master' into coverity_scan
commit
1f22e33b96
|
@ -123,8 +123,7 @@ namespace Blender {
|
||||||
|
|
||||||
struct ObjectCompare {
|
struct ObjectCompare {
|
||||||
bool operator() (const Object* left, const Object* right) const {
|
bool operator() (const Object* left, const Object* right) const {
|
||||||
printf( "left: %s, right: %s\n", left->id.name, right->id.name );
|
return ::strncmp(left->id.name, right->id.name, strlen( left->id.name ) ) == -1;
|
||||||
return ::strncmp(left->id.name, right->id.name, strlen( left->id.name ) ) == 0;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -145,8 +144,7 @@ namespace Blender {
|
||||||
|
|
||||||
struct ObjectCompare {
|
struct ObjectCompare {
|
||||||
bool operator() (const Object* left, const Object* right) const {
|
bool operator() (const Object* left, const Object* right) const {
|
||||||
printf( "left: %s, right: %s\n", left->id.name, right->id.name );
|
return ::strncmp( left->id.name, right->id.name, strlen( left->id.name ) ) == -1;
|
||||||
return ::strncmp( left->id.name, right->id.name, strlen( left->id.name ) ) == 0;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -437,7 +437,7 @@ void ComputeUVMappingProcess::Execute( aiScene* pScene)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int idx;
|
unsigned int idx( 99999999 );
|
||||||
|
|
||||||
// Check whether we have this mapping mode already
|
// Check whether we have this mapping mode already
|
||||||
std::list<MappingInfo>::iterator it = std::find (mappingStack.begin(),mappingStack.end(), info);
|
std::list<MappingInfo>::iterator it = std::find (mappingStack.begin(),mappingStack.end(), info);
|
||||||
|
|
|
@ -715,14 +715,14 @@ void FindAdjacentContours(ContourVector::iterator current, const ContourVector&
|
||||||
const Contour& mcontour = (*it).contour;
|
const Contour& mcontour = (*it).contour;
|
||||||
|
|
||||||
for (size_t n = 0; n < ncontour.size(); ++n) {
|
for (size_t n = 0; n < ncontour.size(); ++n) {
|
||||||
const IfcVector2& n0 = ncontour[n];
|
const IfcVector2 n0 = ncontour[n];
|
||||||
const IfcVector2& n1 = ncontour[(n+1) % ncontour.size()];
|
const IfcVector2 n1 = ncontour[(n+1) % ncontour.size()];
|
||||||
|
|
||||||
for (size_t m = 0, mend = (is_me ? n : mcontour.size()); m < mend; ++m) {
|
for (size_t m = 0, mend = (is_me ? n : mcontour.size()); m < mend; ++m) {
|
||||||
ai_assert(&mcontour != &ncontour || m < n);
|
ai_assert(&mcontour != &ncontour || m < n);
|
||||||
|
|
||||||
const IfcVector2& m0 = mcontour[m];
|
const IfcVector2 m0 = mcontour[m];
|
||||||
const IfcVector2& m1 = mcontour[(m+1) % mcontour.size()];
|
const IfcVector2 m1 = mcontour[(m+1) % mcontour.size()];
|
||||||
|
|
||||||
IfcVector2 isect0, isect1;
|
IfcVector2 isect0, isect1;
|
||||||
if (IntersectingLineSegments(n0,n1, m0, m1, isect0, isect1)) {
|
if (IntersectingLineSegments(n0,n1, m0, m1, isect0, isect1)) {
|
||||||
|
|
|
@ -116,6 +116,16 @@ const aiImporterDesc* IRRMeshImporter::GetInfo () const
|
||||||
return &desc;
|
return &desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void releaseMaterial( aiMaterial **mat ) {
|
||||||
|
delete mat;
|
||||||
|
*mat = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void releaseMesh( aiMesh **mesh ) {
|
||||||
|
delete mesh;
|
||||||
|
*mesh = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Imports the given file into the given scene structure.
|
// Imports the given file into the given scene structure.
|
||||||
void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
||||||
|
@ -135,7 +145,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
||||||
std::vector<aiMaterial*> materials;
|
std::vector<aiMaterial*> materials;
|
||||||
std::vector<aiMesh*> meshes;
|
std::vector<aiMesh*> meshes;
|
||||||
materials.reserve (5);
|
materials.reserve (5);
|
||||||
meshes.reserve (5);
|
meshes.reserve(5);
|
||||||
|
|
||||||
// temporary data - current mesh buffer
|
// temporary data - current mesh buffer
|
||||||
aiMaterial* curMat = NULL;
|
aiMaterial* curMat = NULL;
|
||||||
|
@ -160,10 +170,9 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
||||||
// end of previous buffer. A material and a mesh should be there
|
// end of previous buffer. A material and a mesh should be there
|
||||||
if ( !curMat || !curMesh) {
|
if ( !curMat || !curMesh) {
|
||||||
DefaultLogger::get()->error("IRRMESH: A buffer must contain a mesh and a material");
|
DefaultLogger::get()->error("IRRMESH: A buffer must contain a mesh and a material");
|
||||||
delete curMat;
|
releaseMaterial( &curMat );
|
||||||
delete curMesh;
|
releaseMesh( &curMesh );
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
materials.push_back(curMat);
|
materials.push_back(curMat);
|
||||||
meshes.push_back(curMesh);
|
meshes.push_back(curMesh);
|
||||||
}
|
}
|
||||||
|
@ -183,7 +192,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
||||||
if (!ASSIMP_stricmp(reader->getNodeName(),"material")) {
|
if (!ASSIMP_stricmp(reader->getNodeName(),"material")) {
|
||||||
if (curMat) {
|
if (curMat) {
|
||||||
DefaultLogger::get()->warn("IRRMESH: Only one material description per buffer, please");
|
DefaultLogger::get()->warn("IRRMESH: Only one material description per buffer, please");
|
||||||
delete curMat;curMat = NULL;
|
releaseMaterial( &curMat );
|
||||||
}
|
}
|
||||||
curMat = ParseMaterial(curMatFlags);
|
curMat = ParseMaterial(curMatFlags);
|
||||||
}
|
}
|
||||||
|
@ -195,17 +204,16 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
||||||
// This is possible ... remove the mesh from the list and skip further reading
|
// This is possible ... remove the mesh from the list and skip further reading
|
||||||
DefaultLogger::get()->warn("IRRMESH: Found mesh with zero vertices");
|
DefaultLogger::get()->warn("IRRMESH: Found mesh with zero vertices");
|
||||||
|
|
||||||
delete curMat;curMat = NULL;
|
releaseMaterial( &curMat );
|
||||||
|
releaseMesh( &curMesh );
|
||||||
curMesh = NULL;
|
|
||||||
textMeaning = 0;
|
textMeaning = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
curVertices.reserve (num);
|
curVertices.reserve(num);
|
||||||
curNormals.reserve (num);
|
curNormals.reserve(num);
|
||||||
curColors.reserve (num);
|
curColors.reserve(num);
|
||||||
curUVs.reserve (num);
|
curUVs.reserve(num);
|
||||||
|
|
||||||
// Determine the file format
|
// Determine the file format
|
||||||
const char* t = reader->getAttributeValueSafe("type");
|
const char* t = reader->getAttributeValueSafe("type");
|
||||||
|
@ -240,7 +248,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
||||||
vertexFormat = 2;
|
vertexFormat = 2;
|
||||||
}
|
}
|
||||||
else if (ASSIMP_stricmp("standard", t)) {
|
else if (ASSIMP_stricmp("standard", t)) {
|
||||||
delete curMat;
|
releaseMaterial( &curMat );
|
||||||
DefaultLogger::get()->warn("IRRMESH: Unknown vertex format");
|
DefaultLogger::get()->warn("IRRMESH: Unknown vertex format");
|
||||||
}
|
}
|
||||||
else vertexFormat = 0;
|
else vertexFormat = 0;
|
||||||
|
@ -248,7 +256,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
||||||
}
|
}
|
||||||
else if (!ASSIMP_stricmp(reader->getNodeName(),"indices")) {
|
else if (!ASSIMP_stricmp(reader->getNodeName(),"indices")) {
|
||||||
if (curVertices.empty() && curMat) {
|
if (curVertices.empty() && curMat) {
|
||||||
delete curMat;
|
releaseMaterial( &curMat );
|
||||||
throw DeadlyImportError("IRRMESH: indices must come after vertices");
|
throw DeadlyImportError("IRRMESH: indices must come after vertices");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,10 +272,10 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
||||||
DefaultLogger::get()->warn("IRRMESH: Found mesh with zero indices");
|
DefaultLogger::get()->warn("IRRMESH: Found mesh with zero indices");
|
||||||
|
|
||||||
// mesh - away
|
// mesh - away
|
||||||
delete curMesh; curMesh = NULL;
|
releaseMesh( &curMesh );
|
||||||
|
|
||||||
// material - away
|
// material - away
|
||||||
delete curMat;curMat = NULL;
|
releaseMaterial( &curMat );
|
||||||
|
|
||||||
textMeaning = 0;
|
textMeaning = 0;
|
||||||
continue;
|
continue;
|
||||||
|
@ -469,7 +477,6 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
// GCC complains here ...
|
// GCC complains here ...
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -480,8 +487,8 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
||||||
if (curMat || curMesh) {
|
if (curMat || curMesh) {
|
||||||
if ( !curMat || !curMesh) {
|
if ( !curMat || !curMesh) {
|
||||||
DefaultLogger::get()->error("IRRMESH: A buffer must contain a mesh and a material");
|
DefaultLogger::get()->error("IRRMESH: A buffer must contain a mesh and a material");
|
||||||
delete curMat;
|
releaseMaterial( &curMat );
|
||||||
delete curMesh;
|
releaseMesh( &curMesh );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
materials.push_back(curMat);
|
materials.push_back(curMat);
|
||||||
|
|
|
@ -74,20 +74,22 @@ static const aiImporterDesc desc = {
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructor to be privately used by Importer
|
// Constructor to be privately used by Importer
|
||||||
SMDImporter::SMDImporter()
|
SMDImporter::SMDImporter()
|
||||||
: configFrameID(),
|
: configFrameID(),
|
||||||
mBuffer(),
|
mBuffer(),
|
||||||
pScene(),
|
pScene( nullptr ),
|
||||||
iFileSize(),
|
iFileSize( 0 ),
|
||||||
iSmallestFrame(),
|
iSmallestFrame( -1 ),
|
||||||
dLengthOfAnim(),
|
dLengthOfAnim( 0.0 ),
|
||||||
bHasUVs(),
|
bHasUVs(false ),
|
||||||
iLineNumber()
|
iLineNumber(-1) {
|
||||||
{}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Destructor, private as well
|
// Destructor, private as well
|
||||||
SMDImporter::~SMDImporter()
|
SMDImporter::~SMDImporter() {
|
||||||
{}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the class can handle the format of the given file.
|
// Returns whether the class can handle the format of the given file.
|
||||||
|
@ -133,9 +135,8 @@ void SMDImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS
|
||||||
// Allocate storage and copy the contents of the file to a memory buffer
|
// Allocate storage and copy the contents of the file to a memory buffer
|
||||||
this->pScene = pScene;
|
this->pScene = pScene;
|
||||||
|
|
||||||
std::vector<char> buff(iFileSize+1);
|
mBuffer.resize( iFileSize + 1 );
|
||||||
TextFileToBuffer(file.get(),buff);
|
TextFileToBuffer(file.get(), mBuffer );
|
||||||
mBuffer = &buff[0];
|
|
||||||
|
|
||||||
iSmallestFrame = (1 << 31);
|
iSmallestFrame = (1 << 31);
|
||||||
bHasUVs = true;
|
bHasUVs = true;
|
||||||
|
@ -694,7 +695,7 @@ void SMDImporter::CreateOutputMaterials()
|
||||||
// Parse the file
|
// Parse the file
|
||||||
void SMDImporter::ParseFile()
|
void SMDImporter::ParseFile()
|
||||||
{
|
{
|
||||||
const char* szCurrent = mBuffer;
|
const char* szCurrent = &mBuffer[0];
|
||||||
|
|
||||||
// read line per line ...
|
// read line per line ...
|
||||||
for ( ;; )
|
for ( ;; )
|
||||||
|
|
|
@ -372,7 +372,7 @@ private:
|
||||||
unsigned int configFrameID;
|
unsigned int configFrameID;
|
||||||
|
|
||||||
/** Buffer to hold the loaded file */
|
/** Buffer to hold the loaded file */
|
||||||
const char* mBuffer;
|
std::vector<char> mBuffer;
|
||||||
|
|
||||||
/** Output scene to be filled
|
/** Output scene to be filled
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue