Fix compiler warnings: var declarations hides other var.

pull/2371/head
kkulling 2019-03-13 16:58:18 +01:00
parent 0dc2e9197a
commit 650fadebe9
6 changed files with 75 additions and 71 deletions

View File

@ -178,30 +178,30 @@ void FindInstancesProcess::Execute( aiScene* pScene)
// use a constant epsilon for colors and UV coordinates // use a constant epsilon for colors and UV coordinates
static const float uvEpsilon = 10e-4f; static const float uvEpsilon = 10e-4f;
{ {
unsigned int i, end = orig->GetNumUVChannels(); unsigned int j, end = orig->GetNumUVChannels();
for(i = 0; i < end; ++i) { for(j = 0; j < end; ++j) {
if (!orig->mTextureCoords[i]) { if (!orig->mTextureCoords[j]) {
continue; continue;
} }
if(!CompareArrays(orig->mTextureCoords[i],inst->mTextureCoords[i],orig->mNumVertices,uvEpsilon)) { if(!CompareArrays(orig->mTextureCoords[j],inst->mTextureCoords[j],orig->mNumVertices,uvEpsilon)) {
break; break;
} }
} }
if (i != end) { if (j != end) {
continue; continue;
} }
} }
{ {
unsigned int i, end = orig->GetNumColorChannels(); unsigned int j, end = orig->GetNumColorChannels();
for(i = 0; i < end; ++i) { for(j = 0; j < end; ++j) {
if (!orig->mColors[i]) { if (!orig->mColors[j]) {
continue; continue;
} }
if(!CompareArrays(orig->mColors[i],inst->mColors[i],orig->mNumVertices,uvEpsilon)) { if(!CompareArrays(orig->mColors[j],inst->mColors[j],orig->mNumVertices,uvEpsilon)) {
break; break;
} }
} }
if (i != end) { if (j != end) {
continue; continue;
} }
} }

View File

@ -303,12 +303,12 @@ inline void Vec3NormalToLatLng( const aiVector3D& p_vIn, uint16_t& p_iOut )
b = int(57.2957795f * ( std::acos( p_vIn[2] ) ) * ( 255.0f / 360.0f )); b = int(57.2957795f * ( std::acos( p_vIn[2] ) ) * ( 255.0f / 360.0f ));
b &= 0xff; b &= 0xff;
((unsigned char*)&p_iOut)[0] = b; // longitude ((unsigned char*)&p_iOut)[0] = (unsigned char) b; // longitude
((unsigned char*)&p_iOut)[1] = a; // latitude ((unsigned char*)&p_iOut)[1] = (unsigned char) a; // latitude
} }
} }
} } // Namespace MD3
} } // Namespace Assimp
#endif // !! AI_MD3FILEHELPER_H_INC #endif // !! AI_MD3FILEHELPER_H_INC

View File

@ -258,10 +258,10 @@ bool Q3Shader::LoadSkin(SkinData& fill, const std::string& pFile,IOSystem* io)
continue; continue;
fill.textures.push_back(SkinData::TextureEntry()); fill.textures.push_back(SkinData::TextureEntry());
SkinData::TextureEntry& s = fill.textures.back(); SkinData::TextureEntry &entry = fill.textures.back();
s.first = ss; entry.first = ss;
s.second = GetNextToken(buff); entry.second = GetNextToken(buff);
} }
return true; return true;
} }
@ -730,11 +730,13 @@ void MD3Importer::InternReadFile( const std::string& pFile,
std::string::size_type s = mFile.find_last_of("/\\"); std::string::size_type s = mFile.find_last_of("/\\");
if (s == std::string::npos) { if (s == std::string::npos) {
s = 0; s = 0;
} else {
++s;
}
filename = mFile.substr(s), path = mFile.substr(0, s);
for (std::string::iterator it = filename.begin(); it != filename.end(); ++it) {
*it = static_cast<char>( tolower(*it) );
} }
else ++s;
filename = mFile.substr(s), path = mFile.substr(0,s);
for( std::string::iterator it = filename .begin(); it != filename.end(); ++it)
*it = tolower( *it);
// Load multi-part model file, if necessary // Load multi-part model file, if necessary
if (configHandleMP) { if (configHandleMP) {
@ -905,15 +907,15 @@ void MD3Importer::InternReadFile( const std::string& pFile,
// Now search the current shader for a record with this name ( // Now search the current shader for a record with this name (
// excluding texture file extension) // excluding texture file extension)
if (!shaders.blocks.empty()) { if (!shaders.blocks.empty()) {
std::string::size_type sh = convertedPath.find_last_of('.');
std::string::size_type s = convertedPath.find_last_of('.'); if (sh == std::string::npos) {
if (s == std::string::npos) sh = convertedPath.length();
s = convertedPath.length(); }
const std::string without_ext = convertedPath.substr(0,s); const std::string without_ext = convertedPath.substr(0,s);
std::list< Q3Shader::ShaderDataBlock >::const_iterator dit = std::find(shaders.blocks.begin(),shaders.blocks.end(),without_ext); std::list< Q3Shader::ShaderDataBlock >::const_iterator dit = std::find(shaders.blocks.begin(),shaders.blocks.end(),without_ext);
if (dit != shaders.blocks.end()) { if (dit != shaders.blocks.end()) {
// Hurra, wir haben einen. Tolle Sache. // We made it!
shader = &*dit; shader = &*dit;
ASSIMP_LOG_INFO("Found shader record for " +without_ext ); ASSIMP_LOG_INFO("Found shader record for " +without_ext );
} else { } else {

View File

@ -228,36 +228,37 @@ void SortByPTypeProcess::Execute( aiScene* pScene) {
out->mNumVertices = (3 == real ? numPolyVerts : out->mNumFaces * (real+1)); out->mNumVertices = (3 == real ? numPolyVerts : out->mNumFaces * (real+1));
aiVector3D *vert(NULL), *nor(NULL), *tan(NULL), *bit(NULL); aiVector3D *vert(nullptr), *nor(nullptr), *tan(nullptr), *bit(nullptr);
aiVector3D *uv [AI_MAX_NUMBER_OF_TEXTURECOORDS]; aiVector3D *uv [AI_MAX_NUMBER_OF_TEXTURECOORDS];
aiColor4D *cols [AI_MAX_NUMBER_OF_COLOR_SETS]; aiColor4D *cols [AI_MAX_NUMBER_OF_COLOR_SETS];
if (mesh->mVertices) if (mesh->mVertices) {
vert = out->mVertices = new aiVector3D[out->mNumVertices]; vert = out->mVertices = new aiVector3D[out->mNumVertices];
}
if (mesh->mNormals) if (mesh->mNormals) {
nor = out->mNormals = new aiVector3D[out->mNumVertices]; nor = out->mNormals = new aiVector3D[out->mNumVertices];
}
if (mesh->mTangents) if (mesh->mTangents) {
{
tan = out->mTangents = new aiVector3D[out->mNumVertices]; tan = out->mTangents = new aiVector3D[out->mNumVertices];
bit = out->mBitangents = new aiVector3D[out->mNumVertices]; bit = out->mBitangents = new aiVector3D[out->mNumVertices];
} }
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS;++i) for (unsigned int j = 0; j < AI_MAX_NUMBER_OF_TEXTURECOORDS;++j) {
{ uv[j] = nullptr;
if (mesh->mTextureCoords[i]) if (mesh->mTextureCoords[j]) {
uv[i] = out->mTextureCoords[i] = new aiVector3D[out->mNumVertices]; uv[j] = out->mTextureCoords[j] = new aiVector3D[out->mNumVertices];
else uv[i] = NULL;
out->mNumUVComponents[i] = mesh->mNumUVComponents[i];
} }
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_COLOR_SETS;++i) out->mNumUVComponents[j] = mesh->mNumUVComponents[j];
{ }
if (mesh->mColors[i])
cols[i] = out->mColors[i] = new aiColor4D[out->mNumVertices]; for (unsigned int j = 0; j < AI_MAX_NUMBER_OF_COLOR_SETS;++j) {
else cols[i] = NULL; cols[j] = nullptr;
if (mesh->mColors[j]) {
cols[j] = out->mColors[j] = new aiColor4D[out->mNumVertices];
}
} }
typedef std::vector< aiVertexWeight > TempBoneInfo; typedef std::vector< aiVertexWeight > TempBoneInfo;
@ -323,7 +324,7 @@ void SortByPTypeProcess::Execute( aiScene* pScene) {
in.mIndices[q] = outIdx++; in.mIndices[q] = outIdx++;
} }
in.mIndices = NULL; in.mIndices = nullptr;
++outFaces; ++outFaces;
} }
ai_assert(outFaces == out->mFaces + out->mNumFaces); ai_assert(outFaces == out->mFaces + out->mNumFaces);

View File

@ -127,8 +127,7 @@ aiMesh* StandardShapes::MakeMesh(const std::vector<aiVector3D>& positions,
// Determine which kinds of primitives the mesh consists of // Determine which kinds of primitives the mesh consists of
aiMesh* out = new aiMesh(); aiMesh* out = new aiMesh();
switch (numIndices) switch (numIndices) {
{
case 1: case 1:
out->mPrimitiveTypes = aiPrimitiveType_POINT; out->mPrimitiveTypes = aiPrimitiveType_POINT;
break; break;
@ -145,17 +144,18 @@ aiMesh* StandardShapes::MakeMesh(const std::vector<aiVector3D>& positions,
out->mNumFaces = (unsigned int)positions.size() / numIndices; out->mNumFaces = (unsigned int)positions.size() / numIndices;
out->mFaces = new aiFace[out->mNumFaces]; out->mFaces = new aiFace[out->mNumFaces];
for (unsigned int i = 0, a = 0; i < out->mNumFaces;++i) for (unsigned int i = 0, a = 0; i < out->mNumFaces;++i) {
{
aiFace& f = out->mFaces[i]; aiFace& f = out->mFaces[i];
f.mNumIndices = numIndices; f.mNumIndices = numIndices;
f.mIndices = new unsigned int[numIndices]; f.mIndices = new unsigned int[numIndices];
for (unsigned int i = 0; i < numIndices;++i,++a) for (unsigned int j = 0; i < numIndices; ++i, ++a) {
f.mIndices[i] = a; f.mIndices[j] = a;
}
} }
out->mNumVertices = (unsigned int)positions.size(); out->mNumVertices = (unsigned int)positions.size();
out->mVertices = new aiVector3D[out->mNumVertices]; out->mVertices = new aiVector3D[out->mNumVertices];
::memcpy(out->mVertices,&positions[0],out->mNumVertices*sizeof(aiVector3D)); ::memcpy(out->mVertices,&positions[0],out->mNumVertices*sizeof(aiVector3D));
return out; return out;
} }
@ -466,8 +466,8 @@ void StandardShapes::MakeCone(ai_real height,ai_real radius1,
// Need to flip face order? // Need to flip face order?
if ( SIZE_MAX != old ) { if ( SIZE_MAX != old ) {
for (size_t s = old; s < positions.size();s += 3) { for (size_t p = old; p < positions.size();p += 3) {
std::swap(positions[s],positions[s+1]); std::swap(positions[p],positions[p+1]);
} }
} }
} }

View File

@ -577,15 +577,16 @@ void ValidateDSProcess::SearchForInvalidTextures(const aiMaterial* pMaterial,
int iNumIndices = 0; int iNumIndices = 0;
int iIndex = -1; int iIndex = -1;
for (unsigned int i = 0; i < pMaterial->mNumProperties;++i) for (unsigned int i = 0; i < pMaterial->mNumProperties;++i) {
{ aiMaterialProperty* prop = pMaterial->mProperties[ i ];
aiMaterialProperty* prop = pMaterial->mProperties[i]; ai_assert(nullptr != prop);
if (!::strcmp(prop->mKey.data,"$tex.file") && prop->mSemantic == type) { if ( !::strcmp(prop->mKey.data,"$tex.file") && prop->mSemantic == static_cast<unsigned int>(type)) {
iIndex = std::max(iIndex, (int) prop->mIndex); iIndex = std::max(iIndex, (int) prop->mIndex);
++iNumIndices; ++iNumIndices;
if (aiPTI_String != prop->mType) if (aiPTI_String != prop->mType) {
ReportError("Material property %s is expected to be a string",prop->mKey.data); ReportError("Material property %s is expected to be a string", prop->mKey.data);
}
} }
} }
if (iIndex +1 != iNumIndices) { if (iIndex +1 != iNumIndices) {