diff --git a/code/ASEParser.cpp b/code/ASEParser.cpp index 280dfdfc3..647c721f8 100644 --- a/code/ASEParser.cpp +++ b/code/ASEParser.cpp @@ -1887,7 +1887,7 @@ void Parser::ParseLV3MeshNormalListBlock(ASE::Mesh& sMesh) // Allocate enough storage for the normals sMesh.mNormals.resize(sMesh.mFaces.size()*3,aiVector3D( 0.f, 0.f, 0.f )); - unsigned int index, faceIdx = 0xffffffff; + unsigned int index, faceIdx = UINT_MAX; // FIXME: rewrite this and find out how to interpret the normals // correctly. This is crap. @@ -1897,7 +1897,7 @@ void Parser::ParseLV3MeshNormalListBlock(ASE::Mesh& sMesh) while (true) { if ('*' == *filePtr) { ++filePtr; - if (faceIdx != 0xffffffff && TokenMatch(filePtr,"MESH_VERTEXNORMAL",17)) { + if (faceIdx != UINT_MAX && TokenMatch(filePtr,"MESH_VERTEXNORMAL",17)) { aiVector3D vNormal; ParseLV4MeshFloatTriple(&vNormal.x,index); if (faceIdx >= sMesh.mFaces.size()) diff --git a/code/COBScene.h b/code/COBScene.h index 8620f564d..1b7f533bf 100644 --- a/code/COBScene.h +++ b/code/COBScene.h @@ -71,7 +71,7 @@ struct Face /** COB chunk header information */ struct ChunkInfo { - enum {NO_SIZE=0xffffffff}; + enum {NO_SIZE=UINT_MAX}; ChunkInfo () : id (0) @@ -218,7 +218,7 @@ struct Material : ChunkInfo }; Material() : alpha(),exp(),ior(),ka(),ks(1.f), - matnum(0xffffffff), + matnum(UINT_MAX), shader(FLAT),autofacet(FACETED), autofacet_angle() {} diff --git a/code/ColladaHelper.h b/code/ColladaHelper.h index d45647f9b..eca835598 100644 --- a/code/ColladaHelper.h +++ b/code/ColladaHelper.h @@ -429,7 +429,7 @@ struct Sampler , mMirrorU () , mMirrorV () , mOp (aiTextureOp_Multiply) - , mUVId (0xffffffff) + , mUVId (UINT_MAX) , mWeighting (1.f) , mMixWithPrevious (1.f) {} @@ -466,7 +466,7 @@ struct Sampler */ std::string mUVChannel; - /** Resolved UV channel index or 0xffffffff if not known + /** Resolved UV channel index or UINT_MAX if not known */ unsigned int mUVId; diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index 7a1ddc169..5059b54b6 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -948,13 +948,14 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars } // determine which transform step is affected by this channel - entry.mTransformIndex = 0xffffffff; + entry.mTransformIndex = SIZE_MAX; for( size_t a = 0; a < srcNode->mTransforms.size(); ++a) if( srcNode->mTransforms[a].mID == entry.mTransformId) entry.mTransformIndex = a; - if( entry.mTransformIndex == 0xffffffff) + if( entry.mTransformIndex == SIZE_MAX) { continue; + } entry.mChannel = &(*cit); entries.push_back( entry); @@ -1154,12 +1155,12 @@ void ColladaLoader::AddTexture ( Assimp::MaterialHelper& mat, const ColladaParse mat.AddProperty((float*)&sampler.mWeighting , 1, _AI_MATKEY_TEXBLEND_BASE, type, idx); - // UV source index ... if we didn't resolve the mapping it is actually just + // UV source index ... if we didn't resolve the mapping, it is actually just // a guess but it works in most cases. We search for the frst occurence of a // number in the channel name. We assume it is the zero-based index into the // UV channel array of all corresponding meshes. It could also be one-based // for some exporters, but we won't care of it unless someone complains about. - if (sampler.mUVId != 0xffffffff) + if (sampler.mUVId != UINT_MAX) map = sampler.mUVId; else { map = -1; @@ -1289,16 +1290,6 @@ void ColladaLoader::BuildMaterials( const ColladaParser& pParser, aiScene* pScen aiString name( matIt->first); mat->AddProperty(&name,AI_MATKEY_NAME); - // MEGA SUPER MONSTER HACK by Alex ... It's all my fault, yes. - // We store the reference to the effect in the material and - // return ... we'll add the actual material properties later - // after we processed all meshes. During mesh processing, - // we evaluate vertex input mappings. Afterwards we should be - // able to correctly setup source UV channels for textures. - - // ... moved to ColladaLoader::FillMaterials() - // *duck* - // store the material mMaterialIndexByName[matIt->first] = newMats.size(); newMats.push_back( std::pair(const_cast(&effect),mat) ); diff --git a/code/ColladaParser.cpp b/code/ColladaParser.cpp index c47df2fc5..9ec05fdd3 100644 --- a/code/ColladaParser.cpp +++ b/code/ColladaParser.cpp @@ -1968,7 +1968,7 @@ void ColladaParser::ReadPrimitives( Mesh* pMesh, std::vector& pPer // determine number of indices coming per vertex // find the offset index for all per-vertex channels size_t numOffsets = 1; - size_t perVertexOffset = 0xffffffff; // invalid value + size_t perVertexOffset = SIZE_MAX; // invalid value BOOST_FOREACH( const InputChannel& channel, pPerIndexChannels) { numOffsets = std::max( numOffsets, channel.mOffset+1); diff --git a/code/ComputeUVMappingProcess.cpp b/code/ComputeUVMappingProcess.cpp index 04231afc9..7ca37765d 100644 --- a/code/ComputeUVMappingProcess.cpp +++ b/code/ComputeUVMappingProcess.cpp @@ -98,7 +98,7 @@ inline unsigned int FindEmptyUVChannel (aiMesh* mesh) if (!mesh->mTextureCoords[m])return m; DefaultLogger::get()->error("Unable to compute UV coordinates, no free UV slot found"); - return 0xffffffff; + return UINT_MAX; } // ------------------------------------------------------------------------------------------------ @@ -455,7 +455,7 @@ void ComputeUVMappingProcess::Execute( aiScene* pScene) { aiMesh* mesh = pScene->mMeshes[m]; unsigned int outIdx; - if ( mesh->mMaterialIndex != i || ( outIdx = FindEmptyUVChannel(mesh) ) == 0xffffffff || + if ( mesh->mMaterialIndex != i || ( outIdx = FindEmptyUVChannel(mesh) ) == UINT_MAX || !mesh->mNumVertices) { continue; diff --git a/code/DefaultIOStream.cpp b/code/DefaultIOStream.cpp index 2457d0cc8..ba0f17d8c 100644 --- a/code/DefaultIOStream.cpp +++ b/code/DefaultIOStream.cpp @@ -108,7 +108,7 @@ size_t DefaultIOStream::FileSize() const return 0; } - if (0xffffffff == cachedSize) { + if (SIZE_MAX == cachedSize) { // TODO: Is that really faster if we're already owning a handle to the file? #if defined _WIN32 && !defined __GNUC__ diff --git a/code/DefaultIOStream.h b/code/DefaultIOStream.h index 0be908931..bcb6244d8 100644 --- a/code/DefaultIOStream.h +++ b/code/DefaultIOStream.h @@ -110,7 +110,7 @@ private: inline DefaultIOStream::DefaultIOStream () : mFile (NULL), mFilename (""), - cachedSize (0xffffffff) + cachedSize (SIZE_MAX) { // empty } @@ -121,7 +121,7 @@ inline DefaultIOStream::DefaultIOStream (FILE* pFile, const std::string &strFilename) : mFile(pFile), mFilename(strFilename), - cachedSize (0xffffffff) + cachedSize (SIZE_MAX) { // empty } diff --git a/code/FileSystemFilter.h b/code/FileSystemFilter.h index 4db72147b..dccb82225 100644 --- a/code/FileSystemFilter.h +++ b/code/FileSystemFilter.h @@ -50,6 +50,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "ParsingUtils.h" namespace Assimp { +inline bool IsHex(char s) { + return (s>='0' && s<='9') || (s>='a' && s<='f') || (s>='A' && s<='F'); +} + // --------------------------------------------------------------------------- /** File system filter */ @@ -226,9 +230,8 @@ private: else if (*it == '%' && in.end() - it > 2) { // Hex sequence in URIs - uint32_t tmp; - if( 0xffffffff != (tmp = HexOctetToDecimal(&*it))) { - *it = (char)tmp; + if( IsHex((&*it)[0]) && IsHex((&*it)[1]) ) { + *it = HexOctetToDecimal(&*it); it = in.erase(it+1,it+2); --it; } diff --git a/code/FindInvalidDataProcess.cpp b/code/FindInvalidDataProcess.cpp index a90396f18..9a0d42ac5 100644 --- a/code/FindInvalidDataProcess.cpp +++ b/code/FindInvalidDataProcess.cpp @@ -90,7 +90,7 @@ void UpdateMeshReferences(aiNode* node, const std::vector& meshMap for (unsigned int a = 0; a < node->mNumMeshes;++a) { register unsigned int ref = node->mMeshes[a]; - if (0xffffffff != (ref = meshMapping[ref])) { + if (UINT_MAX != (ref = meshMapping[ref])) { node->mMeshes[out++] = ref; } } @@ -130,7 +130,7 @@ void FindInvalidDataProcess::Execute( aiScene* pScene) delete pScene->mMeshes[a]; AI_DEBUG_INVALIDATE_PTR(pScene->mMeshes[a]); - meshMapping[a] = 0xffffffff; + meshMapping[a] = UINT_MAX; continue; } } diff --git a/code/IRRLoader.cpp b/code/IRRLoader.cpp index 4889a6c34..5decba167 100644 --- a/code/IRRLoader.cpp +++ b/code/IRRLoader.cpp @@ -243,7 +243,7 @@ void IRRImporter::CopyMaterial(std::vector& materials, { if (inmaterials.empty()) { // Do we have a default material? If not we need to create one - if (0xffffffff == defMatIdx) + if (UINT_MAX == defMatIdx) { defMatIdx = (unsigned int)materials.size(); MaterialHelper* mat = new MaterialHelper(); @@ -1397,7 +1397,7 @@ void IRRImporter::InternReadFile( const std::string& pFile, /* Now process our scenegraph recursively: generate final * meshes and generate animation channels for all nodes. */ - unsigned int defMatIdx = 0xffffffff; + unsigned int defMatIdx = UINT_MAX; GenerateGraph(root,tempScene->mRootNode, tempScene, batch, meshes, anims, attach, materials, defMatIdx); diff --git a/code/IRRLoader.h b/code/IRRLoader.h index 253d3c7fc..abb186957 100644 --- a/code/IRRLoader.h +++ b/code/IRRLoader.h @@ -279,7 +279,7 @@ private: * * @param materials Receives an output material * @param inmaterials List of input materials - * @param defMatIdx Default material index - 0xffffffff if not there + * @param defMatIdx Default material index - UINT_MAX if not present * @param mesh Mesh to work on */ void CopyMaterial(std::vector& materials, diff --git a/code/LWOFileData.h b/code/LWOFileData.h index a66bb7268..682835164 100644 --- a/code/LWOFileData.h +++ b/code/LWOFileData.h @@ -431,10 +431,10 @@ struct Texture }; Texture() - : mClipIdx(0xffffffff) + : mClipIdx(UINT_MAX) , mStrength (1.0f) , mUVChannelIndex ("unknown") - , mRealUVIndex (0xffffffff) + , mRealUVIndex (UINT_MAX) , enabled (true) , blendType (Additive) , bCanUse (true) @@ -645,7 +645,7 @@ struct Layer PointList mTempPoints; /** Lists for every point the index of another point - that has been copied from *this* point or 0xffffffff if + that has been copied from *this* point or UINT_MAX if no copy of the point has been made */ ReferrerList mPointReferrers; diff --git a/code/LWOLoader.cpp b/code/LWOLoader.cpp index 53600d6c4..a1f998dc4 100644 --- a/code/LWOLoader.cpp +++ b/code/LWOLoader.cpp @@ -91,7 +91,7 @@ bool LWOImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool void LWOImporter::SetupProperties(const Importer* pImp) { configSpeedFlag = ( 0 != pImp->GetPropertyInteger(AI_CONFIG_FAVOUR_SPEED,0) ? true : false); - configLayerIndex = pImp->GetPropertyInteger (AI_CONFIG_IMPORT_LWO_ONE_LAYER_ONLY,0xffffffff); + configLayerIndex = pImp->GetPropertyInteger (AI_CONFIG_IMPORT_LWO_ONE_LAYER_ONLY,UINT_MAX); configLayerName = pImp->GetPropertyString (AI_CONFIG_IMPORT_LWO_ONE_LAYER_ONLY,""); } @@ -181,7 +181,7 @@ void LWOImporter::InternReadFile( const std::string& pFile, // The newer lightwave format allows the user to configure the // loader that just one layer is used. If this is the case // we need to check now whether the requested layer has been found. - if (0xffffffff != configLayerIndex && configLayerIndex > mLayers->size()) + if (UINT_MAX != configLayerIndex && configLayerIndex > mLayers->size()) throw DeadlyImportError("LWO2: The requested layer was not found"); if (configLayerName.length() && !hasNamedLayer) { @@ -200,7 +200,7 @@ void LWOImporter::InternReadFile( const std::string& pFile, apcNodes. reserve(mLayers->size()); apcMeshes.reserve(mLayers->size()*std::min(((unsigned int)mSurfaces->size()/2u), 1u)); - unsigned int iDefaultSurface = 0xffffffff; // index of the default surface + unsigned int iDefaultSurface = UINT_MAX; // index of the default surface for (LayerList::iterator lit = mLayers->begin(), lend = mLayers->end();lit != lend;++lit) { LWO::Layer& layer = *lit; if (layer.skip) @@ -225,10 +225,10 @@ void LWOImporter::InternReadFile( const std::string& pFile, if (idx >= mTags->size()) { DefaultLogger::get()->warn("LWO: Invalid face surface index"); - idx = 0xffffffff; + idx = UINT_MAX; } - if(0xffffffff == idx || 0xffffffff == (idx = _mMapping[idx])) { - if (0xffffffff == iDefaultSurface) { + if(UINT_MAX == idx || UINT_MAX == (idx = _mMapping[idx])) { + if (UINT_MAX == iDefaultSurface) { iDefaultSurface = (unsigned int)mSurfaces->size(); mSurfaces->push_back(LWO::Surface()); LWO::Surface& surf = mSurfaces->back(); @@ -239,7 +239,7 @@ void LWOImporter::InternReadFile( const std::string& pFile, } pSorted[idx].push_back(i); } - if (0xffffffff == iDefaultSurface) { + if (UINT_MAX == iDefaultSurface) { pSorted.erase(pSorted.end()-1); } for (unsigned int p = 0,i = 0;i < mSurfaces->size();++i) { @@ -268,10 +268,12 @@ void LWOImporter::InternReadFile( const std::string& pFile, unsigned int vVColorIndices[AI_MAX_NUMBER_OF_COLOR_SETS]; #if _DEBUG - for (unsigned int mui = 0; mui < AI_MAX_NUMBER_OF_TEXTURECOORDS;++mui ) - vUVChannelIndices[mui] = 0xffffffff; - for (unsigned int mui = 0; mui < AI_MAX_NUMBER_OF_COLOR_SETS;++mui ) - vVColorIndices[mui] = 0xffffffff; + for (unsigned int mui = 0; mui < AI_MAX_NUMBER_OF_TEXTURECOORDS;++mui ) { + vUVChannelIndices[mui] = UINT_MAX; + } + for (unsigned int mui = 0; mui < AI_MAX_NUMBER_OF_COLOR_SETS;++mui ) { + vVColorIndices[mui] = UINT_MAX; + } #endif FindUVChannels(_mSurfaces[i],sorted,layer,vUVChannelIndices); @@ -280,8 +282,9 @@ void LWOImporter::InternReadFile( const std::string& pFile, // allocate storage for UV and CV channels aiVector3D* pvUV[AI_MAX_NUMBER_OF_TEXTURECOORDS]; for (unsigned int mui = 0; mui < AI_MAX_NUMBER_OF_TEXTURECOORDS;++mui ) { - if (0xffffffff == vUVChannelIndices[mui]) + if (UINT_MAX == vUVChannelIndices[mui]) { break; + } pvUV[mui] = mesh->mTextureCoords[mui] = new aiVector3D[mesh->mNumVertices]; @@ -294,7 +297,7 @@ void LWOImporter::InternReadFile( const std::string& pFile, aiColor4D* pvVC[AI_MAX_NUMBER_OF_COLOR_SETS]; for (unsigned int mui = 0; mui < AI_MAX_NUMBER_OF_COLOR_SETS;++mui) { - if (0xffffffff == vVColorIndices[mui]) { + if (UINT_MAX == vVColorIndices[mui]) { break; } pvVC[mui] = mesh->mColors[mui] = new aiColor4D[mesh->mNumVertices]; @@ -319,8 +322,9 @@ void LWOImporter::InternReadFile( const std::string& pFile, // process UV coordinates for (unsigned int w = 0; w < AI_MAX_NUMBER_OF_TEXTURECOORDS;++w) { - if (0xffffffff == vUVChannelIndices[w]) + if (UINT_MAX == vUVChannelIndices[w]) { break; + } aiVector3D*& pp = pvUV[w]; const aiVector2D& src = ((aiVector2D*)&layer.mUVChannels[vUVChannelIndices[w]].rawData[0])[idx]; pp->x = src.x; @@ -337,8 +341,9 @@ void LWOImporter::InternReadFile( const std::string& pFile, // process vertex colors for (unsigned int w = 0; w < AI_MAX_NUMBER_OF_COLOR_SETS;++w) { - if (0xffffffff == vVColorIndices[w]) + if (UINT_MAX == vVColorIndices[w]) { break; + } *pvVC[w] = ((aiColor4D*)&layer.mVColorChannels[vVColorIndices[w]].rawData[0])[idx]; // If a RGB color map is explicitly requested delete the @@ -614,7 +619,7 @@ void LWOImporter::GenerateNodeGraph(std::vector& apcNodes) void LWOImporter::ResolveTags() { // --- this function is used for both LWO2 and LWOB - mMapping->resize(mTags->size(),0xffffffff); + mMapping->resize(mTags->size(), UINT_MAX); for (unsigned int a = 0; a < mTags->size();++a) { const std::string& c = (*mTags)[a]; @@ -711,7 +716,7 @@ void LWOImporter::LoadLWOPoints(unsigned int length) // initialize all point referrers with the default values mCurLayer->mPointReferrers.reserve ( regularSize + (regularSize>>2u) ); - mCurLayer->mPointReferrers.resize ( regularSize, 0xffffffff ); + mCurLayer->mPointReferrers.resize ( regularSize, UINT_MAX ); } else mCurLayer->mTempPoints.resize( regularSize ); @@ -897,7 +902,7 @@ inline void LWOImporter::DoRecursiveVMAPAssignment(VMapEntry* base, unsigned int base->rawData[idx*base->dims+i]= data[i]; } - if (0xffffffff != (i = refList[idx])) { + if (UINT_MAX != (i = refList[idx])) { DoRecursiveVMAPAssignment(base,numRead,i,data); } } @@ -905,7 +910,7 @@ inline void LWOImporter::DoRecursiveVMAPAssignment(VMapEntry* base, unsigned int // ------------------------------------------------------------------------------------------------ inline void AddToSingleLinkedList(ReferrerList& refList, unsigned int srcIdx, unsigned int destIdx) { - if(0xffffffff == refList[srcIdx]) { + if(UINT_MAX == refList[srcIdx]) { refList[srcIdx] = destIdx; return; } @@ -1030,12 +1035,13 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly) if (tmp == srcIdx) break; } - while ((tmp = refList[tmp]) != 0xffffffff); - if (tmp == 0xffffffff) + while ((tmp = refList[tmp]) != UINT_MAX); + if (tmp == UINT_MAX) { continue; + } had = true; - refList.resize(refList.size()+1, 0xffffffff); + refList.resize(refList.size()+1, UINT_MAX); idx = (unsigned int)pointList.size(); src.mIndices[i] = (unsigned int)pointList.size(); @@ -1282,7 +1288,7 @@ void LWOImporter::LoadLWO2File() // Continue loading this layer or ignore it? Check the layer index property // NOTE: The first layer is the default layer, so the layer index is one-based now - if (0xffffffff != configLayerIndex && configLayerIndex != mLayers->size()-1) { + if (UINT_MAX != configLayerIndex && configLayerIndex != mLayers->size()-1) { skip = true; } else skip = false; diff --git a/code/LWOLoader.h b/code/LWOLoader.h index 4faa631d5..60260e11e 100644 --- a/code/LWOLoader.h +++ b/code/LWOLoader.h @@ -227,13 +227,13 @@ private: unsigned int& faces, uint16_t*& cursor, const uint16_t* const end, - unsigned int max = 0xffffffff); + unsigned int max = UINT_MAX); void CountVertsAndFacesLWOB(unsigned int& verts, unsigned int& faces, LE_NCONST uint16_t*& cursor, const uint16_t* const end, - unsigned int max = 0xffffffff); + unsigned int max = UINT_MAX); // ------------------------------------------------------------------- /** Read vertices and faces in a LWOB/LWO2 file @@ -246,7 +246,7 @@ private: void CopyFaceIndicesLWOB(LWO::FaceList::iterator& it, LE_NCONST uint16_t*& cursor, const uint16_t* const end, - unsigned int max = 0xffffffff); + unsigned int max = UINT_MAX); // ------------------------------------------------------------------- /** Resolve the tag and surface lists that have been loaded. @@ -376,7 +376,7 @@ protected: TagList* mTags; /** Mapping table to convert from tag to surface indices. - 0xffffffff indicates that a no corresponding surface is available */ + UINT_MAX indicates that a no corresponding surface is available */ TagMappingTable* mMapping; /** Temporary surface list from the file */ diff --git a/code/LWOMaterial.cpp b/code/LWOMaterial.cpp index 861524ff4..5fc2bd7e0 100644 --- a/code/LWOMaterial.cpp +++ b/code/LWOMaterial.cpp @@ -120,7 +120,7 @@ bool LWOImporter::HandleTextures(MaterialHelper* pcMat, const TextureList& in, a break; case LWO::Texture::UV: { - if( 0xffffffff == (*it).mRealUVIndex ) { + if( UINT_MAX == (*it).mRealUVIndex ) { // We have no UV index for this texture, so we can't display it continue; } @@ -390,7 +390,7 @@ char LWOImporter::FindUVChannels(LWO::TextureList& list, ret = 1; // got it. - if ((*it).mRealUVIndex == 0xffffffff || (*it).mRealUVIndex == next) + if ((*it).mRealUVIndex == UINT_MAX || (*it).mRealUVIndex == next) { (*it).mRealUVIndex = next; } @@ -467,7 +467,7 @@ void LWOImporter::FindUVChannels(LWO::Surface& surf, } } if (extra < AI_MAX_NUMBER_OF_TEXTURECOORDS) { - out[extra] = 0xffffffff; + out[extra] = UINT_MAX; } } @@ -515,7 +515,7 @@ void LWOImporter::FindVCChannels(const LWO::Surface& surf, LWO::SortedRep& sorte } } if (next != AI_MAX_NUMBER_OF_COLOR_SETS) { - out[next] = 0xffffffff; + out[next] = UINT_MAX; } } diff --git a/code/MD2Loader.cpp b/code/MD2Loader.cpp index a581cdff8..150d8aaa8 100644 --- a/code/MD2Loader.cpp +++ b/code/MD2Loader.cpp @@ -111,8 +111,8 @@ void MD2Importer::SetupProperties(const Importer* pImp) // The // AI_CONFIG_IMPORT_MD2_KEYFRAME option overrides the // AI_CONFIG_IMPORT_GLOBAL_KEYFRAME option. - configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_MD2_KEYFRAME,0xffffffff); - if(0xffffffff == configFrameID){ + configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_MD2_KEYFRAME,-1); + if(static_cast(-1) == configFrameID){ configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_GLOBAL_KEYFRAME,0); } } diff --git a/code/MD3Loader.cpp b/code/MD3Loader.cpp index 5562c9bdd..ef80ee4f7 100644 --- a/code/MD3Loader.cpp +++ b/code/MD3Loader.cpp @@ -431,8 +431,8 @@ void MD3Importer::SetupProperties(const Importer* pImp) // The // AI_CONFIG_IMPORT_MD3_KEYFRAME option overrides the // AI_CONFIG_IMPORT_GLOBAL_KEYFRAME option. - configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_MD3_KEYFRAME,0xffffffff); - if(0xffffffff == configFrameID) { + configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_MD3_KEYFRAME,-1); + if(static_cast(-1) == configFrameID) { configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_GLOBAL_KEYFRAME,0); } @@ -469,7 +469,7 @@ void MD3Importer::ReadSkin(Q3Shader::SkinData& fill) const void MD3Importer::ReadShader(Q3Shader::ShaderData& fill) const { // Determine Q3 model name from given path - std::string::size_type s = path.find_last_of("\\/",path.length()-2); + const std::string::size_type s = path.find_last_of("\\/",path.length()-2); const std::string model_file = path.substr(s+1,path.length()-(s+2)); // If no specific dir or file is given, use our default search behaviour @@ -481,7 +481,7 @@ void MD3Importer::ReadShader(Q3Shader::ShaderData& fill) const else { // If the given string specifies a file, load this file. // Otherwise it's a directory. - std::string::size_type st = configShaderFile.find_last_of('.'); + const std::string::size_type st = configShaderFile.find_last_of('.'); if (st == std::string::npos) { if(!Q3Shader::LoadShader(fill,configShaderFile + model_file + ".shader",mIOHandler)) { diff --git a/code/MD5Parser.cpp b/code/MD5Parser.cpp index e8961aa20..faae9cbc6 100644 --- a/code/MD5Parser.cpp +++ b/code/MD5Parser.cpp @@ -349,7 +349,7 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections) DefaultLogger::get()->debug("MD5AnimParser begin"); fFrameRate = 24.0f; - mNumAnimatedComponents = 0xffffffff; + mNumAnimatedComponents = UINT_MAX; for (SectionList::const_iterator iter = mSections.begin(), iterEnd = mSections.end();iter != iterEnd;++iter) { if ((*iter).mName == "hierarchy") { // "sheath" 0 63 6 @@ -398,8 +398,9 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections) desc.iIndex = strtoul10((*iter).mGlobalValue.c_str()); // we do already know how much storage we will presumably need - if (0xffffffff != mNumAnimatedComponents) + if (UINT_MAX != mNumAnimatedComponents) { desc.mValues.reserve(mNumAnimatedComponents); + } // now read all elements (continous list of floats) for (ElementList::const_iterator eit = (*iter).mElements.begin(), eitEnd = (*iter).mElements.end(); eit != eitEnd; ++eit){ @@ -418,8 +419,9 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections) mAnimatedBones.reserve(num); // try to guess the number of animated components if that element is not given - if (0xffffffff == mNumAnimatedComponents) + if (UINT_MAX == mNumAnimatedComponents) { mNumAnimatedComponents = num * 6; + } } else if((*iter).mName == "numAnimatedComponents") { mAnimatedBones.reserve( strtoul10((*iter).mGlobalValue.c_str())); diff --git a/code/MDCLoader.cpp b/code/MDCLoader.cpp index 4b8d3bd66..1b35a8322 100644 --- a/code/MDCLoader.cpp +++ b/code/MDCLoader.cpp @@ -187,10 +187,8 @@ void MDCImporter::SetupProperties(const Importer* pImp) { // The AI_CONFIG_IMPORT_MDC_KEYFRAME option overrides the // AI_CONFIG_IMPORT_GLOBAL_KEYFRAME option. - if(0xffffffff == (this->configFrameID = pImp->GetPropertyInteger( - AI_CONFIG_IMPORT_MDC_KEYFRAME,0xffffffff))) - { - this->configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_GLOBAL_KEYFRAME,0); + if(static_cast(-1) == (configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_MDC_KEYFRAME,-1))){ + configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_GLOBAL_KEYFRAME,0); } } @@ -251,7 +249,7 @@ void MDCImporter::InternReadFile( pScene->mMeshes[i] = NULL; // now read all surfaces - unsigned int iDefaultMatIndex = 0xffffffff; + unsigned int iDefaultMatIndex = UINT_MAX; for (unsigned int i = 0, iNum = 0; i < pcHeader->ulNumSurfaces;++i) { if (!pcSurface->ulNumVertices || !pcSurface->ulNumTriangles)continue; @@ -276,7 +274,7 @@ void MDCImporter::InternReadFile( ::strlen(pcShader->ucName),sizeof(pcShader->ucName)) )); } // need to create a default material - else if (0xffffffff == iDefaultMatIndex) + else if (UINT_MAX == iDefaultMatIndex) { pcMesh->mMaterialIndex = iDefaultMatIndex = (unsigned int)aszShaders.size(); aszShaders.push_back(std::string()); diff --git a/code/MDLLoader.cpp b/code/MDLLoader.cpp index 85bb59b4b..6f84c8240 100644 --- a/code/MDLLoader.cpp +++ b/code/MDLLoader.cpp @@ -101,12 +101,12 @@ bool MDLImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool // Setup configuration properties void MDLImporter::SetupProperties(const Importer* pImp) { - configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_MDL_KEYFRAME,0xffffffff); + configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_MDL_KEYFRAME,-1); // The // AI_CONFIG_IMPORT_MDL_KEYFRAME option overrides the // AI_CONFIG_IMPORT_GLOBAL_KEYFRAME option. - if(0xffffffff == configFrameID) { + if(static_cast(-1) == configFrameID) { configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_GLOBAL_KEYFRAME,0); } @@ -356,8 +356,8 @@ void MDLImporter::InternReadFile_Quake1( ) else { szCurrent += sizeof(uint32_t); - unsigned int iSkip = i ? 0xffffffff : 0; - this->CreateTexture_3DGS_MDL4(szCurrent,pcSkin->group,&iSkip); + unsigned int iSkip = i ? UINT_MAX : 0; + CreateTexture_3DGS_MDL4(szCurrent,pcSkin->group,&iSkip); szCurrent += iSkip; } } @@ -552,7 +552,7 @@ void MDLImporter::InternReadFile_3DGS_MDL345( ) pcSkin = (BE_NCONST MDL::Skin*)szCurrent; AI_SWAP4( pcSkin->group); // create one output image - unsigned int iSkip = i ? 0xffffffff : 0; + unsigned int iSkip = i ? UINT_MAX : 0; if (5 <= iGSFileVersion) { // MDL5 format could contain MIPmaps @@ -1240,14 +1240,14 @@ void MDLImporter::SortByMaterials_3DGS_MDL7( if (iMatIndex >= iNumMaterials) { // sometimes MED writes -1, but normally only if there is only // one skin assigned. No warning in this case - if(0xffffffff != iMatIndex) + if(UINT_MAX != iMatIndex) DefaultLogger::get()->warn("Index overflow in MDL7 material list [#1]"); iMatIndex = iNumMaterials-1; } unsigned int iMatIndex2 = groupData.pcFaces[iFace].iMatIndex[1]; unsigned int iNum = iMatIndex; - if (0xffffffff != iMatIndex2 && iMatIndex != iMatIndex2) { + if (UINT_MAX != iMatIndex2 && iMatIndex != iMatIndex2) { if (iMatIndex2 >= iNumMaterials) { // sometimes MED writes -1, but normally only if there is only // one skin assigned. No warning in this case @@ -1447,7 +1447,7 @@ void MDLImporter::InternReadFile_3DGS_MDL7( ) groupData.vPositions.resize(iNumVertices); groupData.vNormals.resize(iNumVertices); - if (sharedData.apcOutBones)groupData.aiBones.resize(iNumVertices,0xffffffff); + if (sharedData.apcOutBones)groupData.aiBones.resize(iNumVertices,UINT_MAX); // it is also possible that there are 0 UV coordinate sets if (groupInfo.pcGroup->num_stpts){ @@ -1847,7 +1847,7 @@ void MDLImporter::GenerateOutputMeshes_3DGS_MDL7( // iterate through all face indices for (unsigned int c = 0; c < 3;++c) { unsigned int iBone = groupData.aiBones[ oldFace.mIndices[c] ]; - if (0xffffffff != iBone) { + if (UINT_MAX != iBone) { if (iBone >= iNumOutBones) { DefaultLogger::get()->error("Bone index overflow. " "The bone index of a vertex exceeds the allowed range. "); diff --git a/code/MDLLoader.h b/code/MDLLoader.h index ab4197804..42a8c19a9 100644 --- a/code/MDLLoader.h +++ b/code/MDLLoader.h @@ -298,7 +298,7 @@ protected: * \param iType type of the texture data. No DDS or external * \param piSkip Receive the number of bytes to skip * \param pcNew Must point to fully initialized data. Width and - * height must be set. If pcNew->pcData is set to 0xffffffff, + * height must be set. If pcNew->pcData is set to UINT_MAX, * piSkip will receive the size of the texture, in bytes, but no * color data will be read. */ diff --git a/code/MDLMaterialLoader.cpp b/code/MDLMaterialLoader.cpp index 1a0ce542c..716d9afb5 100644 --- a/code/MDLMaterialLoader.cpp +++ b/code/MDLMaterialLoader.cpp @@ -49,6 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "MDLDefaultColorMap.h" using namespace Assimp; +static aiTexel* const bad_texel = reinterpret_cast(SIZE_MAX); // ------------------------------------------------------------------------------------------------ // Find a suitable pallette file or take teh default one @@ -177,14 +178,14 @@ void MDLImporter::CreateTexture_3DGS_MDL4(const unsigned char* szData, return; } - bool bNoRead = *piSkip == 0xffffffff; + const bool bNoRead = *piSkip == UINT_MAX; // allocate a new texture object aiTexture* pcNew = new aiTexture(); pcNew->mWidth = pcHeader->skinwidth; pcNew->mHeight = pcHeader->skinheight; - if (bNoRead)pcNew->pcData = (aiTexel*)0xffffffff; + if (bNoRead)pcNew->pcData = bad_texel; ParseTextureColorData(szData,iType,piSkip,pcNew); // store the texture @@ -221,9 +222,12 @@ void MDLImporter::ParseTextureColorData(const unsigned char* szData, unsigned int* piSkip, aiTexture* pcNew) { + const bool do_read = bad_texel != pcNew->pcData; + // allocate storage for the texture image - if ((aiTexel*)0xffffffff != pcNew->pcData) + if (do_read) { pcNew->pcData = new aiTexel[pcNew->mWidth * pcNew->mHeight]; + } // R5G6B5 format (with or without MIPs) // **************************************************************** @@ -233,7 +237,7 @@ void MDLImporter::ParseTextureColorData(const unsigned char* szData, // copy texture data unsigned int i; - if ((aiTexel*)0xffffffff != pcNew->pcData) + if (do_read) { for (i = 0; i < pcNew->mWidth*pcNew->mHeight;++i) { @@ -264,7 +268,7 @@ void MDLImporter::ParseTextureColorData(const unsigned char* szData, // copy texture data unsigned int i; - if ((aiTexel*)0xffffffff != pcNew->pcData) + if (do_read) { for (i = 0; i < pcNew->mWidth*pcNew->mHeight;++i) { @@ -295,7 +299,7 @@ void MDLImporter::ParseTextureColorData(const unsigned char* szData, // copy texture data unsigned int i; - if ((aiTexel*)0xffffffff != pcNew->pcData) + if (do_read) { for (i = 0; i < pcNew->mWidth*pcNew->mHeight;++i) { @@ -326,7 +330,7 @@ void MDLImporter::ParseTextureColorData(const unsigned char* szData, // copy texture data unsigned int i; - if ((aiTexel*)0xffffffff != pcNew->pcData) + if (do_read) { for (i = 0; i < pcNew->mWidth*pcNew->mHeight;++i) { @@ -355,11 +359,11 @@ void MDLImporter::ParseTextureColorData(const unsigned char* szData, // copy texture data unsigned int i; - if ((aiTexel*)0xffffffff != pcNew->pcData) + if (do_read) { const unsigned char* szColorMap; - this->SearchPalette(&szColorMap); + SearchPalette(&szColorMap); for (i = 0; i < pcNew->mWidth*pcNew->mHeight;++i) { @@ -388,7 +392,7 @@ void MDLImporter::CreateTexture_3DGS_MDL5(const unsigned char* szData, unsigned int* piSkip) { ai_assert(NULL != piSkip); - bool bNoRead = *piSkip == 0xffffffff; + bool bNoRead = *piSkip == UINT_MAX; // allocate a new texture object aiTexture* pcNew = new aiTexture(); @@ -404,12 +408,14 @@ void MDLImporter::CreateTexture_3DGS_MDL5(const unsigned char* szData, AI_SWAP4(pcNew->mHeight); szData += sizeof(uint32_t); - if (bNoRead)pcNew->pcData = (aiTexel*)0xffffffff; + if (bNoRead) { + pcNew->pcData = bad_texel; + } - // this should not occur - at least the docs say it shouldn't - // however, you can easily try out what MED does if you have + // this should not occur - at least the docs say it shouldn't. + // however, one can easily try out what MED does if you have // a model with a DDS texture and export it to MDL5 ... - // yes, you're right. It embedds the DDS texture ... :cry: + // yeah, it embedds the DDS file. if (6 == iType) { // this is a compressed texture in DDS format @@ -418,8 +424,7 @@ void MDLImporter::CreateTexture_3DGS_MDL5(const unsigned char* szData, if (!bNoRead) { - // place a hint and let the application know that it's - // a DDS file + // place a hint and let the application know that this is a DDS file pcNew->mHeight = 0; pcNew->achFormatHint[0] = 'd'; pcNew->achFormatHint[1] = 'd'; @@ -433,8 +438,7 @@ void MDLImporter::CreateTexture_3DGS_MDL5(const unsigned char* szData, else { // parse the color data of the texture - ParseTextureColorData(szData,iType, - piSkip,pcNew); + ParseTextureColorData(szData,iType,piSkip,pcNew); } *piSkip += sizeof(uint32_t) * 2; @@ -565,7 +569,7 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7( pcNew->mHeight = iHeight; unsigned int iSkip = 0; - this->ParseTextureColorData(szCurrent,iMasked,&iSkip,pcNew); + ParseTextureColorData(szCurrent,iMasked,&iSkip,pcNew); // skip length of texture data szCurrent += iSkip; @@ -576,7 +580,7 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7( // texture instead of material colors ... posssible they have // been converted to MDL7 from other formats, such as MDL5 aiColor4D clrTexture; - if (pcNew)clrTexture = this->ReplaceTextureWithColor(pcNew); + if (pcNew)clrTexture = ReplaceTextureWithColor(pcNew); else clrTexture.r = get_qnan(); // check whether a material definition is contained in the skin @@ -637,9 +641,9 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7( #undef COLOR_MULITPLY_RGB - // FIX: Take the opacity from the ambient color - // the doc says something else, but it is fact that MED exports the - // opacity like this .... ARRRGGHH! + // FIX: Take the opacity from the ambient color. + // The doc say something else, but it is fact that MED exports the + // opacity like this .... oh well. clrTemp.r = pcMatIn->Ambient.a; AI_SWAP4(clrTemp.r); if (is_not_qnan(clrTexture.r)) { @@ -670,7 +674,7 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7( pcNew = NULL; } - // if an ASCII effect description (HLSL?) is contained in the file, + // If an ASCII effect description (HLSL?) is contained in the file, // we can simply ignore it ... if (iType & AI_MDL7_SKINTYPE_MATERIAL_ASCDEF) { @@ -683,7 +687,7 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7( // If an embedded texture has been loaded setup the corresponding // data structures in the aiScene instance - if (pcNew && this->pScene->mNumTextures <= 999) + if (pcNew && pScene->mNumTextures <= 999) { // place this as diffuse texture @@ -698,21 +702,22 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7( pcMatOut->AddProperty(&szFile,AI_MATKEY_TEXTURE_DIFFUSE(0)); // store the texture - if (!this->pScene->mNumTextures) + if (!pScene->mNumTextures) { - this->pScene->mNumTextures = 1; - this->pScene->mTextures = new aiTexture*[1]; - this->pScene->mTextures[0] = pcNew; + pScene->mNumTextures = 1; + pScene->mTextures = new aiTexture*[1]; + pScene->mTextures[0] = pcNew; } else { - aiTexture** pc = this->pScene->mTextures; - this->pScene->mTextures = new aiTexture*[this->pScene->mNumTextures+1]; - for (unsigned int i = 0; i < this->pScene->mNumTextures;++i) - this->pScene->mTextures[i] = pc[i]; + aiTexture** pc = pScene->mTextures; + pScene->mTextures = new aiTexture*[pScene->mNumTextures+1]; + for (unsigned int i = 0; i < pScene->mNumTextures;++i) { + pScene->mTextures[i] = pc[i]; + } - this->pScene->mTextures[this->pScene->mNumTextures] = pcNew; - this->pScene->mNumTextures++; + pScene->mTextures[pScene->mNumTextures] = pcNew; + pScene->mNumTextures++; delete[] pc; } } @@ -730,7 +735,7 @@ void MDLImporter::SkipSkinLump_3DGS_MDL7( unsigned int iHeight) { // get the type of the skin - unsigned int iMasked = (unsigned int)(iType & 0xF); + const unsigned int iMasked = (unsigned int)(iType & 0xF); if (0x6 == iMasked) { @@ -745,15 +750,15 @@ void MDLImporter::SkipSkinLump_3DGS_MDL7( { if (iMasked || !iType || (iType && iWidth && iHeight)) { - // ParseTextureColorData(..., aiTexture::pcData == 0xffffffff) will simply + // ParseTextureColorData(..., aiTexture::pcData == bad_texel) will simply // return the size of the color data in bytes in iSkip unsigned int iSkip = 0; aiTexture tex; - tex.pcData = reinterpret_cast(0xffffffff); + tex.pcData = bad_texel; tex.mHeight = iHeight; tex.mWidth = iWidth; - this->ParseTextureColorData(szCurrent,iMasked,&iSkip,&tex); + ParseTextureColorData(szCurrent,iMasked,&iSkip,&tex); // FIX: Important, otherwise the destructor will crash tex.pcData = NULL; diff --git a/code/MS3DLoader.cpp b/code/MS3DLoader.cpp index 0b9c7d417..ca5236204 100644 --- a/code/MS3DLoader.cpp +++ b/code/MS3DLoader.cpp @@ -227,7 +227,7 @@ void MS3DImporter::InternReadFile( const std::string& pFile, v.bone_id[0] = stream.GetI1(); v.ref_cnt = stream.GetI1(); - v.bone_id[1] = v.bone_id[2] = v.bone_id[3] = 0xffffffff; + v.bone_id[1] = v.bone_id[2] = v.bone_id[3] = UINT_MAX; v.weights[1] = v.weights[2] = v.weights[3] = 0.f; v.weights[0] = 1.f; } @@ -279,7 +279,7 @@ void MS3DImporter::InternReadFile( const std::string& pFile, t.triangles[i] = stream.GetI2(); } t.mat = stream.GetI1(); - if (t.mat == 0xffffffff) { + if (t.mat == UINT_MAX) { need_default = true; } } @@ -402,7 +402,7 @@ void MS3DImporter::InternReadFile( const std::string& pFile, for (unsigned int i = 0; i < groups.size(); ++i) { TempGroup& g = groups[i]; - if (g.mat == 0xffffffff) { + if (g.mat == UINT_MAX) { g.mat = materials.size()-1; } } @@ -491,7 +491,7 @@ void MS3DImporter::InternReadFile( const std::string& pFile, const TempVertex& v = vertices[t.indices[i]]; for(unsigned int a = 0; a < 4; ++a) { - if (v.bone_id[a] != 0xffffffff) { + if (v.bone_id[a] != UINT_MAX) { if (v.bone_id[a] >= joints.size()) { throw DeadlyImportError("MS3D: Encountered invalid bone index, file is malformed"); } @@ -533,7 +533,7 @@ void MS3DImporter::InternReadFile( const std::string& pFile, const TempVertex& v = vertices[t.indices[i]]; for(unsigned int a = 0; a < 4; ++a) { const unsigned int bone = v.bone_id[a]; - if(bone==0xffffffff){ + if(bone==UINT_MAX){ continue; } diff --git a/code/MaterialSystem.cpp b/code/MaterialSystem.cpp index e83a5905c..b928ab1bf 100644 --- a/code/MaterialSystem.cpp +++ b/code/MaterialSystem.cpp @@ -71,8 +71,8 @@ aiReturn aiGetMaterialProperty(const aiMaterial* pMat, if (prop /* just for safety ... */ && 0 == strcmp( prop->mKey.data, pKey ) - && (0xffffffff == type || prop->mSemantic == type) /* 0xffffffff is a wildcard, but this is undocumented :-) */ - && (0xffffffff == index || prop->mIndex == index)) + && (UINT_MAX == type || prop->mSemantic == type) /* UINT_MAX is a wildcard, but this is undocumented :-) */ + && (UINT_MAX == index || prop->mIndex == index)) { *pPropOut = pMat->mProperties[i]; return AI_SUCCESS; @@ -469,7 +469,7 @@ aiReturn MaterialHelper::AddBinaryProperty (const void* pInput, ai_assert (0 != pSizeInBytes); // first search the list whether there is already an entry with this key - unsigned int iOutIndex = 0xffffffff; + unsigned int iOutIndex = UINT_MAX; for (unsigned int i = 0; i < mNumProperties;++i) { aiMaterialProperty* prop = mProperties[i]; @@ -497,7 +497,7 @@ aiReturn MaterialHelper::AddBinaryProperty (const void* pInput, ai_assert ( MAXLEN > pcNew->mKey.length); strcpy( pcNew->mKey.data, pKey ); - if (0xffffffff != iOutIndex) { + if (UINT_MAX != iOutIndex) { mProperties[iOutIndex] = pcNew; return AI_SUCCESS; } diff --git a/code/PretransformVertices.cpp b/code/PretransformVertices.cpp index 9a6a25e0c..829621e53 100644 --- a/code/PretransformVertices.cpp +++ b/code/PretransformVertices.cpp @@ -353,7 +353,7 @@ void PretransformVertices::BuildWCSMeshes(std::vector& out, aiMesh** in unsigned int numIn, aiNode* node) { // NOTE: - // aiMesh::mNumBones store original source mesh, or 0xffffffff if not a copy + // aiMesh::mNumBones store original source mesh, or UINT_MAX if not a copy // aiMesh::mBones store reference to abs. transform we multiplied with // process meshes @@ -364,7 +364,7 @@ void PretransformVertices::BuildWCSMeshes(std::vector& out, aiMesh** in if (!mesh->mBones || *reinterpret_cast(mesh->mBones) == node->mTransformation) { // yes, we can. mesh->mBones = reinterpret_cast (&node->mTransformation); - mesh->mNumBones = 0xffffffff; + mesh->mNumBones = UINT_MAX; } else { diff --git a/code/Q3DLoader.cpp b/code/Q3DLoader.cpp index a573396a6..15257c019 100644 --- a/code/Q3DLoader.cpp +++ b/code/Q3DLoader.cpp @@ -225,7 +225,7 @@ void Q3DImporter::InternReadFile( const std::string& pFile, if (!i && !a) mesh.prevUVIdx = vec.uvindices[a]; else if (vec.uvindices[a] != mesh.prevUVIdx) - mesh.prevUVIdx = 0xffffffff; + mesh.prevUVIdx = UINT_MAX; } } } diff --git a/code/Q3DLoader.h b/code/Q3DLoader.h index 897b2b573..3c2b9ac03 100644 --- a/code/Q3DLoader.h +++ b/code/Q3DLoader.h @@ -94,7 +94,7 @@ private: Material() : diffuse (0.6f,0.6f,0.6f) , transparency (0.f) - , texIdx (0xffffffff) + , texIdx (UINT_MAX) {} aiString name; diff --git a/code/SMDLoader.cpp b/code/SMDLoader.cpp index d2f7c607b..5c6622176 100644 --- a/code/SMDLoader.cpp +++ b/code/SMDLoader.cpp @@ -86,16 +86,15 @@ void SMDImporter::SetupProperties(const Importer* pImp) // The // AI_CONFIG_IMPORT_SMD_KEYFRAME option overrides the // AI_CONFIG_IMPORT_GLOBAL_KEYFRAME option. - configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_SMD_KEYFRAME,0xffffffff); - if(0xffffffff == configFrameID) { + configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_SMD_KEYFRAME,-1); + if(static_cast(-1) == configFrameID) { configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_GLOBAL_KEYFRAME,0); } } // ------------------------------------------------------------------------------------------------ // Imports the given file into the given scene structure. -void SMDImporter::InternReadFile( - const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) +void SMDImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) { boost::scoped_ptr file( pIOHandler->Open( pFile, "rb")); @@ -254,7 +253,7 @@ void SMDImporter::CreateOutputMeshes() iFace = asTriangles.begin(); iFace != asTriangles.end();++iFace,++iNum) { - if (0xffffffff == (*iFace).iTexture)aaiFaces[(*iFace).iTexture].push_back( 0 ); + if (UINT_MAX == (*iFace).iTexture)aaiFaces[(*iFace).iTexture].push_back( 0 ); else if ((*iFace).iTexture >= aszTextures.size()) { DefaultLogger::get()->error("[SMD/VTA] Material index overflow in face"); @@ -354,7 +353,7 @@ void SMDImporter::CreateOutputMeshes() // that the parent of a vertex is 0xffffffff (if the corresponding // entry in the file was unreadable) // ****************************************************************** - if (fSum < 0.975f && face.avVertices[iVert].iParentNode != 0xffffffff) + if (fSum < 0.975f && face.avVertices[iVert].iParentNode != UINT_MAX) { if (face.avVertices[iVert].iParentNode >= asBones.size()) { diff --git a/code/SMDLoader.h b/code/SMDLoader.h index 0eaa6deac..fe0e436ca 100644 --- a/code/SMDLoader.h +++ b/code/SMDLoader.h @@ -69,7 +69,7 @@ namespace SMD { */ struct Vertex { - Vertex() : iParentNode(0xffffffff) + Vertex() : iParentNode(UINT_MAX) {} //! Vertex position, normal and texture coordinate @@ -106,7 +106,7 @@ struct Face struct Bone { //! Default constructor - Bone() : iParent(0xffffffff), bIsUsed(false) + Bone() : iParent(UINT_MAX), bIsUsed(false) { } diff --git a/code/SceneCombiner.cpp b/code/SceneCombiner.cpp index e929b953d..b6baada8e 100644 --- a/code/SceneCombiner.cpp +++ b/code/SceneCombiner.cpp @@ -243,17 +243,17 @@ void SceneCombiner::MergeScenes(aiScene** _dest, aiScene* master, ai_assert(NULL != _dest); // if _dest points to NULL allocate a new scene. Otherwise clear the old and reuse it - if (srcList.empty()) - { - if (*_dest) - { + if (srcList.empty()) { + if (*_dest) { (*_dest)->~aiScene(); SceneCombiner::CopySceneFlat(_dest,master); } else *_dest = master; return; } - if (*_dest)(*_dest)->~aiScene(); + if (*_dest) { + (*_dest)->~aiScene(); + } else *_dest = new aiScene(); aiScene* dest = *_dest; @@ -265,20 +265,22 @@ void SceneCombiner::MergeScenes(aiScene** _dest, aiScene* master, } // this helper array specifies which scenes are duplicates of others - std::vector duplicates(src.size(),0xffffffff); + std::vector duplicates(src.size(),UINT_MAX); // this helper array is used as lookup table several times std::vector offset(src.size()); // Find duplicate scenes - for (unsigned int i = 0; i < src.size();++i) - { - if (duplicates[i] != i && duplicates[i] != 0xffffffff)continue; + for (unsigned int i = 0; i < src.size();++i) { + if (duplicates[i] != i && duplicates[i] != UINT_MAX) { + continue; + } + duplicates[i] = i; - for ( unsigned int a = i+1; a < src.size(); ++a) - { - if (src[i].scene == src[a].scene) + for ( unsigned int a = i+1; a < src.size(); ++a) { + if (src[i].scene == src[a].scene) { duplicates[a] = i; + } } } diff --git a/code/SceneCombiner.h b/code/SceneCombiner.h index c5bd7ffc2..9dee65603 100644 --- a/code/SceneCombiner.h +++ b/code/SceneCombiner.h @@ -76,7 +76,7 @@ struct NodeAttachmentInfo : node (NULL) , attachToNode (NULL) , resolved (false) - , src_idx (0xffffffff) + , src_idx (SIZE_MAX) {} NodeAttachmentInfo(aiNode* _scene, aiNode* _attachToNode,size_t idx) diff --git a/code/ScenePreprocessor.cpp b/code/ScenePreprocessor.cpp index c73c6de36..cb52abbb3 100644 --- a/code/ScenePreprocessor.cpp +++ b/code/ScenePreprocessor.cpp @@ -70,11 +70,11 @@ void ScenePreprocessor::ProcessScene () // Check whether there are meshes with at least one set of uv coordinates ... add a dummy texture for them // meshes without texture coordinates receive a boring gray default material. - unsigned int mat0 = 0xffffffff, mat1 = 0xffffffff; + unsigned int mat0 = UINT_MAX, mat1 = UINT_MAX; for (unsigned int i = 0; i < scene->mNumMeshes;++i) { if (scene->mMeshes[i]->mTextureCoords[0]) { - if (mat0 == 0xffffffff) { + if (mat0 == UINT_MAX) { scene->mMaterials[scene->mNumMaterials] = helper = new MaterialHelper(); name.Set("$texture.png"); @@ -88,9 +88,8 @@ void ScenePreprocessor::ProcessScene () } scene->mMeshes[i]->mMaterialIndex = mat0; } - else - { - if (mat1 == 0xffffffff) { + else { + if (mat1 == UINT_MAX) { scene->mMaterials[scene->mNumMaterials] = helper = new MaterialHelper(); aiColor3D clr(0.6f,0.6f,0.6f); diff --git a/code/SmoothingGroups.h b/code/SmoothingGroups.h index f6c4b9cdc..42fe25951 100644 --- a/code/SmoothingGroups.h +++ b/code/SmoothingGroups.h @@ -61,8 +61,8 @@ struct FaceWithSmoothingGroup //! Indices. .3ds is using uint16. However, after - //! an unique vrtex set has been generated it might - //! be an index becomes > 2^16 + //! an unique vrtex set has been generated, + //! individual index values might exceed 2^16 uint32_t mIndices[3]; //! specifies to which smoothing group the face belongs to diff --git a/code/SortByPTypeProcess.cpp b/code/SortByPTypeProcess.cpp index 66fb1eb86..3777a0734 100644 --- a/code/SortByPTypeProcess.cpp +++ b/code/SortByPTypeProcess.cpp @@ -92,7 +92,7 @@ void UpdateNodes(const std::vector& replaceMeshIndex, aiNode* node unsigned int add = node->mMeshes[m]<<2; for (unsigned int i = 0; i < 4;++i) { - if (0xffffffff != replaceMeshIndex[add+i])++newSize; + if (UINT_MAX != replaceMeshIndex[add+i])++newSize; } } if (!newSize) @@ -112,7 +112,7 @@ void UpdateNodes(const std::vector& replaceMeshIndex, aiNode* node unsigned int add = node->mMeshes[m]<<2; for (unsigned int i = 0; i < 4;++i) { - if (0xffffffff != replaceMeshIndex[add+i]) + if (UINT_MAX != replaceMeshIndex[add+i]) *newMeshes++ = replaceMeshIndex[add+i]; } } @@ -147,7 +147,7 @@ void SortByPTypeProcess::Execute( aiScene* pScene) bool bAnyChanges = false; - std::vector replaceMeshIndex(pScene->mNumMeshes*4,0xffffffff); + std::vector replaceMeshIndex(pScene->mNumMeshes*4,UINT_MAX); std::vector::iterator meshIdx = replaceMeshIndex.begin(); for (unsigned int i = 0; i < pScene->mNumMeshes;++i) { diff --git a/code/SpatialSort.cpp b/code/SpatialSort.cpp index e5e149945..b8e6fbb84 100644 --- a/code/SpatialSort.cpp +++ b/code/SpatialSort.cpp @@ -310,7 +310,7 @@ void SpatialSort::FindIdenticalPositions( const aiVector3D& pPosition, // ------------------------------------------------------------------------------------------------ unsigned int SpatialSort::GenerateMappingTable(std::vector& fill,float pRadius) const { - fill.resize(mPositions.size(),0xffffffff); + fill.resize(mPositions.size(),UINT_MAX); float dist, maxDist; unsigned int t=0; diff --git a/code/StandardShapes.cpp b/code/StandardShapes.cpp index fd2a274d3..858b360b7 100644 --- a/code/StandardShapes.cpp +++ b/code/StandardShapes.cpp @@ -401,7 +401,7 @@ void StandardShapes::MakeCone(float height,float radius1, std::swap(radius2,radius1); halfHeight = -halfHeight; } - else old = 0xffffffff; + else old = SIZE_MAX; // Use a large epsilon to check whether the cone is pointy if (radius1 < (radius2-radius1)*10e-3f)radius1 = 0.f; @@ -460,10 +460,10 @@ void StandardShapes::MakeCone(float height,float radius1, } // Need to flip face order? - if (0xffffffff != old ) - { - for (size_t s = old; s < positions.size();s += 3) + if ( SIZE_MAX != old ) { + for (size_t s = old; s < positions.size();s += 3) { std::swap(positions[s],positions[s+1]); + } } } diff --git a/code/StreamReader.h b/code/StreamReader.h index ec5b87ffc..76f92bc6d 100644 --- a/code/StreamReader.h +++ b/code/StreamReader.h @@ -248,11 +248,11 @@ public: /** Setup a temporary read limit * * @param limit Maximum number of bytes to be read from - * the beginning of the file. Passing 0xffffffff + * the beginning of the file. Specifying UINT_MAX * resets the limit to the original end of the stream. */ void SetReadLimit(unsigned int _limit) { - if (0xffffffff == _limit) { + if (UINT_MAX == _limit) { limit = end; return; } diff --git a/code/UnrealLoader.cpp b/code/UnrealLoader.cpp index 9ddf32712..b53c6beb5 100644 --- a/code/UnrealLoader.cpp +++ b/code/UnrealLoader.cpp @@ -92,8 +92,8 @@ void UnrealImporter::SetupProperties(const Importer* pImp) // The // AI_CONFIG_IMPORT_UNREAL_KEYFRAME option overrides the // AI_CONFIG_IMPORT_GLOBAL_KEYFRAME option. - configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_UNREAL_KEYFRAME,0xffffffff); - if(0xffffffff == configFrameID) { + configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_UNREAL_KEYFRAME,-1); + if(static_cast(-1) == configFrameID) { configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_GLOBAL_KEYFRAME,0); } diff --git a/code/fast_atof.h b/code/fast_atof.h index 1b64ec97a..90b67725d 100644 --- a/code/fast_atof.h +++ b/code/fast_atof.h @@ -111,11 +111,11 @@ inline unsigned int strtoul16( const char* in, const char** out=0) // ------------------------------------------------------------------------------------ // Convert just one hex digit -// Return value is 0xffffffff if the input is not hex +// Return value is UINT_MAX if the input character is not a hex digit. // ------------------------------------------------------------------------------------ inline unsigned int HexDigitToDecimal(char in) { - unsigned int out = 0xffffffff; + unsigned int out = UINT_MAX; if (in >= '0' && in <= '9') out = in - '0'; @@ -125,13 +125,12 @@ inline unsigned int HexDigitToDecimal(char in) else if (in >= 'A' && in <= 'F') out = 10u + in - 'A'; - // return value is 0xffffffff if the input is not a hex digit + // return value is UINT_MAX if the input is not a hex digit return out; } // ------------------------------------------------------------------------------------ -// Convert a hex-encoded octet (2 characters processed) -// Return value is 0xffffffff if the input is not hex +// Convert a hex-encoded octet (2 characters, i.e. df or 1a). // ------------------------------------------------------------------------------------ inline uint8_t HexOctetToDecimal(const char* in) {