pull/907/head
Kim Kulling 2016-06-04 19:04:06 +02:00
commit 814d2e7821
21 changed files with 148 additions and 178 deletions

View File

@ -186,15 +186,14 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile,
// internal verbose representation. Finally compute normal
// vectors from the smoothing groups we read from the
// file.
for (std::vector<D3DS::Mesh>::iterator i = mScene->mMeshes.begin(),
end = mScene->mMeshes.end(); i != end;++i) {
if ((*i).mFaces.size() > 0 && (*i).mPositions.size() == 0) {
for (auto &mesh : mScene->mMeshes) {
if (mesh.mFaces.size() > 0 && mesh.mPositions.size() == 0) {
delete mScene;
throw DeadlyImportError("3DS file contains faces but no vertices: " + pFile);
}
CheckIndices(*i);
MakeUnique (*i);
ComputeNormalsWithSmoothingsGroups<D3DS::Face>(*i);
CheckIndices(mesh);
MakeUnique (mesh);
ComputeNormalsWithSmoothingsGroups<D3DS::Face>(mesh);
}
// Replace all occurrences of the default material with a

View File

@ -225,17 +225,13 @@ void ASEImporter::InternReadFile( const std::string& pFile,
+ mParser->m_vCameras.size() + mParser->m_vDummies.size());
// Lights
for (std::vector<ASE::Light>::iterator it = mParser->m_vLights.begin(),
end = mParser->m_vLights.end();it != end; ++it)nodes.push_back(&(*it));
for (auto &light : mParser->m_vLights)nodes.push_back(&light);
// Cameras
for (std::vector<ASE::Camera>::iterator it = mParser->m_vCameras.begin(),
end = mParser->m_vCameras.end();it != end; ++it)nodes.push_back(&(*it));
for (auto &camera : mParser->m_vCameras)nodes.push_back(&camera);
// Meshes
for (std::vector<ASE::Mesh>::iterator it = mParser->m_vMeshes.begin(),
end = mParser->m_vMeshes.end();it != end; ++it)nodes.push_back(&(*it));
for (auto &mesh : mParser->m_vMeshes)nodes.push_back(&mesh);
// Dummies
for (std::vector<ASE::Dummy>::iterator it = mParser->m_vDummies.begin(),
end = mParser->m_vDummies.end();it != end; ++it)nodes.push_back(&(*it));
for (auto &dummy : mParser->m_vDummies)nodes.push_back(&dummy);
// build the final node graph
BuildNodes(nodes);
@ -657,8 +653,8 @@ void ASEImporter::BuildNodes(std::vector<BaseNode*>& nodes) {
ch->mParent = root;
// Change the transformation matrix of all nodes
for (std::vector<BaseNode*>::iterator it = nodes.begin(), end = nodes.end();it != end; ++it) {
aiMatrix4x4& m = (*it)->mTransform;
for (BaseNode *node : nodes) {
aiMatrix4x4& m = node->mTransform;
m.Transpose(); // row-order vs column-order
}

View File

@ -276,21 +276,20 @@ void ColladaLoader::ResolveNodeInstances( const ColladaParser& pParser, const Co
resolved.reserve(pNode->mNodeInstances.size());
// ... and iterate through all nodes to be instanced as children of pNode
for (std::vector<Collada::NodeInstance>::const_iterator it = pNode->mNodeInstances.begin(),
end = pNode->mNodeInstances.end(); it != end; ++it)
for (const auto &nodeInst: pNode->mNodeInstances)
{
// find the corresponding node in the library
const ColladaParser::NodeLibrary::const_iterator itt = pParser.mNodeLibrary.find((*it).mNode);
const ColladaParser::NodeLibrary::const_iterator itt = pParser.mNodeLibrary.find(nodeInst.mNode);
const Collada::Node* nd = itt == pParser.mNodeLibrary.end() ? NULL : (*itt).second;
// FIX for http://sourceforge.net/tracker/?func=detail&aid=3054873&group_id=226462&atid=1067632
// need to check for both name and ID to catch all. To avoid breaking valid files,
// the workaround is only enabled when the first attempt to resolve the node has failed.
if (!nd) {
nd = FindNode(pParser.mRootNode,(*it).mNode);
nd = FindNode(pParser.mRootNode, nodeInst.mNode);
}
if (!nd)
DefaultLogger::get()->error("Collada: Unable to resolve reference to instanced node " + (*it).mNode);
DefaultLogger::get()->error("Collada: Unable to resolve reference to instanced node " + nodeInst.mNode);
else {
// attach this node to the list of children
@ -1320,11 +1319,10 @@ void ColladaLoader::AddTexture ( aiMaterial& mat, const ColladaParser& pParser,
// Fills materials from the collada material definitions
void ColladaLoader::FillMaterials( const ColladaParser& pParser, aiScene* /*pScene*/)
{
for (std::vector<std::pair<Collada::Effect*, aiMaterial*> >::iterator it = newMats.begin(),
end = newMats.end(); it != end; ++it)
for (auto &elem : newMats)
{
aiMaterial& mat = (aiMaterial&)*it->second;
Collada::Effect& effect = *it->first;
aiMaterial& mat = (aiMaterial&)*elem.second;
Collada::Effect& effect = *elem.first;
// resolve shading mode
int shadeMode;

View File

@ -324,8 +324,8 @@ D3MFZipArchive::D3MFZipArchive(IOSystem* pIOHandler, const std::string& rFile)
// ------------------------------------------------------------------------------------------------
// Destructor.
D3MFZipArchive::~D3MFZipArchive() {
for( std::map<std::string, ZipFile*>::iterator it(m_ArchiveMap.begin()), end(m_ArchiveMap.end()); it != end; ++it ) {
delete it->second;
for(auto &file : m_ArchiveMap) {
delete file.second;
}
m_ArchiveMap.clear();
@ -398,8 +398,8 @@ void D3MFZipArchive::Close(IOStream *pFile) {
void D3MFZipArchive::getFileList(std::vector<std::string> &rFileList) {
rFileList.clear();
for(std::map<std::string, ZipFile*>::iterator it(m_ArchiveMap.begin()), end(m_ArchiveMap.end()); it != end; ++it) {
rFileList.push_back(it->first);
for(const auto &file : m_ArchiveMap) {
rFileList.push_back(file.first);
}
}

View File

@ -1062,8 +1062,8 @@ void Converter::GenerateTransformationNodeChain( const Model& model,
nd->mName.Set( name );
for ( size_t i = 0; i < TransformationComp_MAXIMUM; ++i ) {
nd->mTransformation = nd->mTransformation * chain[ i ];
for (const auto &transform : chain) {
nd->mTransformation = nd->mTransformation * transform;
}
}

View File

@ -269,8 +269,8 @@ Document::Document(const Parser& parser, const ImportSettings& settings)
, parser(parser)
{
// Cannot use array default initialization syntax because vc8 fails on it
for (unsigned int i = 0; i < sizeof(creationTimeStamp) / sizeof(creationTimeStamp[0]); ++i) {
creationTimeStamp[i] = 0;
for (auto &timeStamp : creationTimeStamp) {
timeStamp = 0;
}
ReadHeader();

View File

@ -1372,8 +1372,7 @@ void IRRImporter::InternReadFile( const std::string& pFile,
/* Now iterate through all cameras and compute their final (horizontal) FOV
*/
for (std::vector<aiCamera*>::iterator it = cameras.begin(), end = cameras.end();it != end; ++it) {
aiCamera* cam = *it;
for (aiCamera *cam : cameras) {
// screen aspect could be missing
if (cam->mAspect) {

View File

@ -246,8 +246,7 @@ void LWOImporter::InternReadFile( const std::string& pFile,
apcMeshes.reserve(mLayers->size()*std::min(((unsigned int)mSurfaces->size()/2u), 1u));
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;
for (LWO::Layer &layer : *mLayers) {
if (layer.skip)
continue;
@ -909,12 +908,12 @@ void LWOImporter::LoadLWO2PolygonTags(unsigned int length)
template <class T>
VMapEntry* FindEntry(std::vector< T >& list,const std::string& name, bool perPoly)
{
for (typename std::vector< T >::iterator it = list.begin(), end = list.end();it != end; ++it) {
if ((*it).name == name) {
for (auto & elem : list) {
if (elem.name == name) {
if (!perPoly) {
DefaultLogger::get()->warn("LWO2: Found two VMAP sections with equal names");
}
return &(*it);
return &elem;
}
}
list.push_back( T() );
@ -941,8 +940,8 @@ inline void CreateNewEntry(T& chan, unsigned int srcIdx)
template <class T>
inline void CreateNewEntry(std::vector< T >& list, unsigned int srcIdx)
{
for (typename std::vector< T >::iterator it = list.begin(), end = list.end();it != end;++it) {
CreateNewEntry( *it, srcIdx );
for (auto &elem : list) {
CreateNewEntry( elem, srcIdx );
}
}

View File

@ -90,8 +90,8 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex
aiString s;
bool ret = false;
for (TextureList::const_iterator it = in.begin(), end = in.end();it != end;++it) {
if (!(*it).enabled || !(*it).bCanUse)
for (const auto &texture : in) {
if (!texture.enabled || !texture.bCanUse)
continue;
ret = true;
@ -100,7 +100,7 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex
// channels if they're not there.
aiTextureMapping mapping;
switch ((*it).mapMode)
switch (texture.mapMode)
{
case LWO::Texture::Planar:
mapping = aiTextureMapping_PLANE;
@ -120,13 +120,13 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex
break;
case LWO::Texture::UV:
{
if( UINT_MAX == (*it).mRealUVIndex ) {
if( UINT_MAX == texture.mRealUVIndex ) {
// We have no UV index for this texture, so we can't display it
continue;
}
// add the UV source index
temp = (*it).mRealUVIndex;
temp = texture.mRealUVIndex;
pcMat->AddProperty<int>((int*)&temp,1,AI_MATKEY_UVWSRC(type,cur));
mapping = aiTextureMapping_UV;
@ -139,7 +139,7 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex
if (mapping != aiTextureMapping_UV) {
// Setup the main axis
aiVector3D v;
switch ((*it).majorAxis) {
switch (texture.majorAxis) {
case Texture::AXIS_X:
v = aiVector3D(1.f,0.f,0.f);
break;
@ -156,8 +156,8 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex
// Setup UV scalings for cylindric and spherical projections
if (mapping == aiTextureMapping_CYLINDER || mapping == aiTextureMapping_SPHERE) {
aiUVTransform trafo;
trafo.mScaling.x = (*it).wrapAmountW;
trafo.mScaling.y = (*it).wrapAmountH;
trafo.mScaling.x = texture.wrapAmountW;
trafo.mScaling.y = texture.wrapAmountH;
static_assert(sizeof(aiUVTransform)/sizeof(float) == 5, "sizeof(aiUVTransform)/sizeof(float) == 5");
pcMat->AddProperty(&trafo,1,AI_MATKEY_UVTRANSFORM(type,cur));
@ -171,7 +171,7 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex
// find the corresponding clip (take the last one if multiple
// share the same index)
ClipList::iterator end = mClips.end(), candidate = end;
temp = (*it).mClipIdx;
temp = texture.mClipIdx;
for (ClipList::iterator clip = mClips.begin(); clip != end; ++clip) {
if ((*clip).idx == temp) {
candidate = clip;
@ -208,7 +208,7 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex
}
else
{
std::string ss = (*it).mFileName;
std::string ss = texture.mFileName;
if (!ss.length()) {
DefaultLogger::get()->error("LWOB: Empty file name");
continue;
@ -219,10 +219,10 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex
pcMat->AddProperty(&s,AI_MATKEY_TEXTURE(type,cur));
// add the blend factor
pcMat->AddProperty<float>(&(*it).mStrength,1,AI_MATKEY_TEXBLEND(type,cur));
pcMat->AddProperty<float>(&texture.mStrength,1,AI_MATKEY_TEXBLEND(type,cur));
// add the blend operation
switch ((*it).blendType)
switch (texture.blendType)
{
case LWO::Texture::Normal:
case LWO::Texture::Multiply:
@ -254,11 +254,11 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex
pcMat->AddProperty<int>((int*)&mapping,1,AI_MATKEY_MAPPING(type,cur));
// add the u-wrapping
temp = (unsigned int)GetMapMode((*it).wrapModeWidth);
temp = (unsigned int)GetMapMode(texture.wrapModeWidth);
pcMat->AddProperty<int>((int*)&temp,1,AI_MATKEY_MAPPINGMODE_U(type,cur));
// add the v-wrapping
temp = (unsigned int)GetMapMode((*it).wrapModeHeight);
temp = (unsigned int)GetMapMode(texture.wrapModeHeight);
pcMat->AddProperty<int>((int*)&temp,1,AI_MATKEY_MAPPINGMODE_V(type,cur));
++cur;
@ -343,16 +343,14 @@ void LWOImporter::ConvertMaterial(const LWO::Surface& surf,aiMaterial* pcMat)
// Now we need to know which shader to use .. iterate through the shader list of
// the surface and search for a name which we know ...
for (ShaderList::const_iterator it = surf.mShaders.begin(), end = surf.mShaders.end();it != end;++it) {
//if (!(*it).enabled)continue;
if ((*it).functionName == "LW_SuperCelShader" || (*it).functionName == "AH_CelShader") {
for (const auto &shader : surf.mShaders) {
if (shader.functionName == "LW_SuperCelShader" || shader.functionName == "AH_CelShader") {
DefaultLogger::get()->info("LWO2: Mapping LW_SuperCelShader/AH_CelShader to aiShadingMode_Toon");
m = aiShadingMode_Toon;
break;
}
else if ((*it).functionName == "LW_RealFresnel" || (*it).functionName == "LW_FastFresnel") {
else if (shader.functionName == "LW_RealFresnel" || shader.functionName == "LW_FastFresnel") {
DefaultLogger::get()->info("LWO2: Mapping LW_RealFresnel/LW_FastFresnel to aiShadingMode_Fresnel");
m = aiShadingMode_Fresnel;
@ -360,7 +358,7 @@ void LWOImporter::ConvertMaterial(const LWO::Surface& surf,aiMaterial* pcMat)
}
else
{
DefaultLogger::get()->warn("LWO2: Unknown surface shader: " + (*it).functionName);
DefaultLogger::get()->warn("LWO2: Unknown surface shader: " + shader.functionName);
}
}
if (surf.mMaximumSmoothAngle <= 0.0f)
@ -381,20 +379,20 @@ char LWOImporter::FindUVChannels(LWO::TextureList& list,
LWO::Layer& /*layer*/,LWO::UVChannel& uv, unsigned int next)
{
char ret = 0;
for (TextureList::iterator it = list.begin(), end = list.end();it != end;++it) {
for (auto &texture : list) {
// Ignore textures with non-UV mappings for the moment.
if (!(*it).enabled || !(*it).bCanUse || (*it).mapMode != LWO::Texture::UV) {
if (!texture.enabled || !texture.bCanUse || texture.mapMode != LWO::Texture::UV) {
continue;
}
if ((*it).mUVChannelIndex == uv.name) {
if (texture.mUVChannelIndex == uv.name) {
ret = 1;
// got it.
if ((*it).mRealUVIndex == UINT_MAX || (*it).mRealUVIndex == next)
if (texture.mRealUVIndex == UINT_MAX || texture.mRealUVIndex == next)
{
(*it).mRealUVIndex = next;
texture.mRealUVIndex = next;
}
else {
// channel mismatch. need to duplicate the material.

View File

@ -193,13 +193,13 @@ bool MD5Parser::ParseSection(Section& out)
// skip all spaces ... handle EOL correctly
#define AI_MD5_SKIP_SPACES() if(!SkipSpaces(&sz)) \
MD5Parser::ReportWarning("Unexpected end of line",(*eit).iLineNumber);
MD5Parser::ReportWarning("Unexpected end of line",elem.iLineNumber);
// read a triple float in brackets: (1.0 1.0 1.0)
#define AI_MD5_READ_TRIPLE(vec) \
AI_MD5_SKIP_SPACES(); \
if ('(' != *sz++) \
MD5Parser::ReportWarning("Unexpected token: ( was expected",(*eit).iLineNumber); \
MD5Parser::ReportWarning("Unexpected token: ( was expected",elem.iLineNumber); \
AI_MD5_SKIP_SPACES(); \
sz = fast_atoreal_move<float>(sz,(float&)vec.x); \
AI_MD5_SKIP_SPACES(); \
@ -208,7 +208,7 @@ bool MD5Parser::ParseSection(Section& out)
sz = fast_atoreal_move<float>(sz,(float&)vec.z); \
AI_MD5_SKIP_SPACES(); \
if (')' != *sz++) \
MD5Parser::ReportWarning("Unexpected token: ) was expected",(*eit).iLineNumber);
MD5Parser::ReportWarning("Unexpected token: ) was expected",elem.iLineNumber);
// parse a string, enclosed in quotation marks or not
#define AI_MD5_PARSE_STRING(out) \
@ -220,7 +220,7 @@ bool MD5Parser::ParseSection(Section& out)
szStart++; \
if ('\"' != *(szEnd-=1)) { \
MD5Parser::ReportWarning("Expected closing quotation marks in string", \
(*eit).iLineNumber); \
elem.iLineNumber); \
continue; \
} \
} \
@ -244,11 +244,11 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections)
}
else if ((*iter).mName == "joints") {
// "origin" -1 ( -0.000000 0.016430 -0.006044 ) ( 0.707107 0.000000 0.707107 )
for (ElementList::const_iterator eit = (*iter).mElements.begin(), eitEnd = (*iter).mElements.end();eit != eitEnd; ++eit){
for (const auto & elem : (*iter).mElements){
mJoints.push_back(BoneDesc());
BoneDesc& desc = mJoints.back();
const char* sz = (*eit).szStart;
const char* sz = elem.szStart;
AI_MD5_PARSE_STRING(desc.mName);
AI_MD5_SKIP_SPACES();
@ -263,8 +263,8 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections)
mMeshes.push_back(MeshDesc());
MeshDesc& desc = mMeshes.back();
for (ElementList::const_iterator eit = (*iter).mElements.begin(), eitEnd = (*iter).mElements.end();eit != eitEnd; ++eit){
const char* sz = (*eit).szStart;
for (const auto & elem : (*iter).mElements){
const char* sz = elem.szStart;
// shader attribute
if (TokenMatch(sz,"shader",6)) {
@ -297,14 +297,14 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections)
VertexDesc& vert = desc.mVertices[idx];
if ('(' != *sz++)
MD5Parser::ReportWarning("Unexpected token: ( was expected",(*eit).iLineNumber);
MD5Parser::ReportWarning("Unexpected token: ( was expected",elem.iLineNumber);
AI_MD5_SKIP_SPACES();
sz = fast_atoreal_move<float>(sz,(float&)vert.mUV.x);
AI_MD5_SKIP_SPACES();
sz = fast_atoreal_move<float>(sz,(float&)vert.mUV.y);
AI_MD5_SKIP_SPACES();
if (')' != *sz++)
MD5Parser::ReportWarning("Unexpected token: ) was expected",(*eit).iLineNumber);
MD5Parser::ReportWarning("Unexpected token: ) was expected",elem.iLineNumber);
AI_MD5_SKIP_SPACES();
vert.mFirstWeight = ::strtoul10(sz,&sz);
AI_MD5_SKIP_SPACES();
@ -357,11 +357,11 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections)
for (SectionList::const_iterator iter = mSections.begin(), iterEnd = mSections.end();iter != iterEnd;++iter) {
if ((*iter).mName == "hierarchy") {
// "sheath" 0 63 6
for (ElementList::const_iterator eit = (*iter).mElements.begin(), eitEnd = (*iter).mElements.end();eit != eitEnd; ++eit) {
for (const auto & elem : (*iter).mElements) {
mAnimatedBones.push_back ( AnimBoneDesc () );
AnimBoneDesc& desc = mAnimatedBones.back();
const char* sz = (*eit).szStart;
const char* sz = elem.szStart;
AI_MD5_PARSE_STRING(desc.mName);
AI_MD5_SKIP_SPACES();
@ -371,7 +371,7 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections)
// flags (highest is 2^6-1)
AI_MD5_SKIP_SPACES();
if(63 < (desc.iFlags = ::strtoul10(sz,&sz))){
MD5Parser::ReportWarning("Invalid flag combination in hierarchy section",(*eit).iLineNumber);
MD5Parser::ReportWarning("Invalid flag combination in hierarchy section",elem.iLineNumber);
}
AI_MD5_SKIP_SPACES();
@ -381,8 +381,8 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections)
}
else if((*iter).mName == "baseframe") {
// ( -0.000000 0.016430 -0.006044 ) ( 0.707107 0.000242 0.707107 )
for (ElementList::const_iterator eit = (*iter).mElements.begin(), eitEnd = (*iter).mElements.end(); eit != eitEnd; ++eit) {
const char* sz = (*eit).szStart;
for (const auto & elem : (*iter).mElements) {
const char* sz = elem.szStart;
mBaseFrames.push_back ( BaseFrameDesc () );
BaseFrameDesc& desc = mBaseFrames.back();
@ -407,8 +407,8 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections)
}
// now read all elements (continuous list of floats)
for (ElementList::const_iterator eit = (*iter).mElements.begin(), eitEnd = (*iter).mElements.end(); eit != eitEnd; ++eit){
const char* sz = (*eit).szStart;
for (const auto & elem : (*iter).mElements){
const char* sz = elem.szStart;
while (SkipSpacesAndLineEnd(&sz)) {
float f;sz = fast_atoreal_move<float>(sz,f);
desc.mValues.push_back(f);
@ -455,13 +455,13 @@ MD5CameraParser::MD5CameraParser(SectionList& mSections)
cuts.reserve(strtoul10((*iter).mGlobalValue.c_str()));
}
else if ((*iter).mName == "cuts") {
for (ElementList::const_iterator eit = (*iter).mElements.begin(), eitEnd = (*iter).mElements.end(); eit != eitEnd; ++eit){
cuts.push_back(strtoul10((*eit).szStart)+1);
for (const auto & elem : (*iter).mElements){
cuts.push_back(strtoul10(elem.szStart)+1);
}
}
else if ((*iter).mName == "camera") {
for (ElementList::const_iterator eit = (*iter).mElements.begin(), eitEnd = (*iter).mElements.end(); eit != eitEnd; ++eit){
const char* sz = (*eit).szStart;
for (const auto & elem : (*iter).mElements){
const char* sz = elem.szStart;
frames.push_back(CameraAnimFrameDesc());
CameraAnimFrameDesc& cur = frames.back();

View File

@ -673,12 +673,11 @@ void NFFImporter::InternReadFile( const std::string& pFile,
if ('t' == line[0])
{
currentMeshWithUVCoords = NULL;
for (std::vector<MeshInfo>::iterator it = meshesWithUVCoords.begin(), end = meshesWithUVCoords.end();
it != end;++it)
for (auto &mesh : meshesWithUVCoords)
{
if ((*it).shader == s)
if (mesh.shader == s)
{
currentMeshWithUVCoords = &(*it);
currentMeshWithUVCoords = &mesh;
break;
}
}
@ -695,12 +694,11 @@ void NFFImporter::InternReadFile( const std::string& pFile,
else if ('p' == line[1])
{
currentMeshWithNormals = NULL;
for (std::vector<MeshInfo>::iterator it = meshesWithNormals.begin(), end = meshesWithNormals.end();
it != end;++it)
for (auto &mesh : meshesWithNormals)
{
if ((*it).shader == s)
if (mesh.shader == s)
{
currentMeshWithNormals = &(*it);
currentMeshWithNormals = &mesh;
break;
}
}
@ -717,12 +715,11 @@ void NFFImporter::InternReadFile( const std::string& pFile,
else
{
currentMesh = NULL;
for (std::vector<MeshInfo>::iterator it = meshes.begin(), end = meshes.end();
it != end;++it)
for (auto &mesh : meshes)
{
if ((*it).shader == s)
if (mesh.shader == s)
{
currentMesh = &(*it);
currentMesh = &mesh;
break;
}
}

View File

@ -501,10 +501,8 @@ void OgreBinarySerializer::NormalizeBoneWeights(VertexData *vertexData) const
Some exporters wont care if the sum of all bone weights
for a single vertex equals 1 or not, so validate here. */
const float epsilon = 0.05f;
for(std::set<uint32_t>::const_iterator iter=influencedVertices.begin(), end=influencedVertices.end(); iter != end; ++iter)
for (const uint32_t vertexIndex : influencedVertices)
{
const uint32_t vertexIndex = (*iter);
float sum = 0.0f;
for (VertexBoneAssignmentList::const_iterator baIter=vertexData->boneAssignments.begin(), baEnd=vertexData->boneAssignments.end(); baIter != baEnd; ++baIter)
{
@ -513,10 +511,10 @@ void OgreBinarySerializer::NormalizeBoneWeights(VertexData *vertexData) const
}
if ((sum < (1.0f - epsilon)) || (sum > (1.0f + epsilon)))
{
for (VertexBoneAssignmentList::iterator baIter=vertexData->boneAssignments.begin(), baEnd=vertexData->boneAssignments.end(); baIter != baEnd; ++baIter)
for (auto &boneAssign : vertexData->boneAssignments)
{
if (baIter->vertexIndex == vertexIndex)
baIter->weight /= sum;
if (boneAssign.vertexIndex == vertexIndex)
boneAssign.weight /= sum;
}
}
}

View File

@ -258,12 +258,11 @@ void IVertexData::AddVertexMapping(uint32_t oldIndex, uint32_t newIndex)
void IVertexData::BoneAssignmentsForVertex(uint32_t currentIndex, uint32_t newIndex, VertexBoneAssignmentList &dest) const
{
for (VertexBoneAssignmentList::const_iterator iter=boneAssignments.begin(), end=boneAssignments.end();
iter!=end; ++iter)
for (const auto &boneAssign : boneAssignments)
{
if (iter->vertexIndex == currentIndex)
if (boneAssign.vertexIndex == currentIndex)
{
VertexBoneAssignment a = (*iter);
VertexBoneAssignment a = boneAssign;
a.vertexIndex = newIndex;
dest.push_back(a);
}
@ -289,10 +288,9 @@ AssimpVertexBoneWeightList IVertexData::AssimpBoneWeights(size_t vertices)
std::set<uint16_t> IVertexData::ReferencedBonesByWeights() const
{
std::set<uint16_t> referenced;
for (VertexBoneAssignmentList::const_iterator iter=boneAssignments.begin(), end=boneAssignments.end();
iter!=end; ++iter)
for (const auto &boneAssign : boneAssignments)
{
referenced.insert(iter->boneIndex);
referenced.insert(boneAssign.boneIndex);
}
return referenced;
}
@ -318,10 +316,10 @@ void VertexData::Reset()
uint32_t VertexData::VertexSize(uint16_t source) const
{
uint32_t size = 0;
for(VertexElementList::const_iterator iter=vertexElements.begin(), end=vertexElements.end(); iter != end; ++iter)
for(const auto &element : vertexElements)
{
if (iter->source == source)
size += iter->Size();
if (element.source == source)
size += element.Size();
}
return size;
}
@ -335,9 +333,8 @@ MemoryStream *VertexData::VertexBuffer(uint16_t source)
VertexElement *VertexData::GetVertexElement(VertexElement::Semantic semantic, uint16_t index)
{
for(VertexElementList::iterator iter=vertexElements.begin(), end=vertexElements.end(); iter != end; ++iter)
for(auto & element : vertexElements)
{
VertexElement &element = (*iter);
if (element.semantic == semantic && element.index == index)
return &element;
}
@ -427,16 +424,16 @@ void Mesh::Reset()
OGRE_SAFE_DELETE(skeleton)
OGRE_SAFE_DELETE(sharedVertexData)
for(size_t i=0, len=subMeshes.size(); i<len; ++i) {
OGRE_SAFE_DELETE(subMeshes[i])
for(auto &mesh : subMeshes) {
OGRE_SAFE_DELETE(mesh)
}
subMeshes.clear();
for(size_t i=0, len=animations.size(); i<len; ++i) {
OGRE_SAFE_DELETE(animations[i])
for(auto &anim : animations) {
OGRE_SAFE_DELETE(anim)
}
animations.clear();
for(size_t i=0, len=poses.size(); i<len; ++i) {
OGRE_SAFE_DELETE(poses[i])
for(auto &pose : poses) {
OGRE_SAFE_DELETE(pose)
}
poses.clear();
}
@ -739,8 +736,8 @@ void MeshXml::Reset()
OGRE_SAFE_DELETE(skeleton)
OGRE_SAFE_DELETE(sharedVertexData)
for(size_t i=0, len=subMeshes.size(); i<len; ++i) {
OGRE_SAFE_DELETE(subMeshes[i])
for(auto &mesh : subMeshes) {
OGRE_SAFE_DELETE(mesh)
}
subMeshes.clear();
}
@ -988,12 +985,12 @@ Skeleton::~Skeleton()
void Skeleton::Reset()
{
for(size_t i=0, len=bones.size(); i<len; ++i) {
OGRE_SAFE_DELETE(bones[i])
for(auto &bone : bones) {
OGRE_SAFE_DELETE(bone)
}
bones.clear();
for(size_t i=0, len=animations.size(); i<len; ++i) {
OGRE_SAFE_DELETE(animations[i])
for(auto &anim : animations) {
OGRE_SAFE_DELETE(anim)
}
animations.clear();
}
@ -1082,11 +1079,11 @@ void Bone::CalculateWorldMatrixAndDefaultPose(Skeleton *skeleton)
defaultPose = aiMatrix4x4(scale, rotation, position);
// Recursively for all children now that the parent matrix has been calculated.
for (size_t i=0, len=children.size(); i<len; ++i)
for (auto boneId : children)
{
Bone *child = skeleton->BoneById(children[i]);
Bone *child = skeleton->BoneById(boneId);
if (!child) {
throw DeadlyImportError(Formatter::format() << "CalculateWorldMatrixAndDefaultPose: Failed to find child bone " << children[i] << " for parent " << id << " " << name);
throw DeadlyImportError(Formatter::format() << "CalculateWorldMatrixAndDefaultPose: Failed to find child bone " << boneId << " for parent " << id << " " << name);
}
child->CalculateWorldMatrixAndDefaultPose(skeleton);
}

View File

@ -453,7 +453,7 @@ void OgreXmlSerializer::ReadGeometryVertexBuffer(VertexDataXml *dest)
}
else if (uvs > 0 && m_currentNodeName == nnTexCoord)
{
for(size_t i=0, len=dest->uvs.size(); i<len; ++i)
for(auto &uvs : dest->uvs)
{
if (m_currentNodeName != nnTexCoord) {
throw DeadlyImportError("Vertex buffer declared more UVs than can be found in a vertex");
@ -462,7 +462,7 @@ void OgreXmlSerializer::ReadGeometryVertexBuffer(VertexDataXml *dest)
aiVector3D uv;
uv.x = ReadAttribute<float>("u");
uv.y = (ReadAttribute<float>("v") * -1) + 1; // Flip UV from Ogre to Assimp form
dest->uvs[i].push_back(uv);
uvs.push_back(uv);
NextNode();
}
@ -657,10 +657,8 @@ void OgreXmlSerializer::ReadBoneAssignments(VertexDataXml *dest)
Some exporters wont care if the sum of all bone weights
for a single vertex equals 1 or not, so validate here. */
const float epsilon = 0.05f;
for(std::set<uint32_t>::const_iterator iter=influencedVertices.begin(), end=influencedVertices.end(); iter != end; ++iter)
for (const uint32_t vertexIndex : influencedVertices)
{
const uint32_t vertexIndex = (*iter);
float sum = 0.0f;
for (VertexBoneAssignmentList::const_iterator baIter=dest->boneAssignments.begin(), baEnd=dest->boneAssignments.end(); baIter != baEnd; ++baIter)
{
@ -669,10 +667,10 @@ void OgreXmlSerializer::ReadBoneAssignments(VertexDataXml *dest)
}
if ((sum < (1.0f - epsilon)) || (sum > (1.0f + epsilon)))
{
for (VertexBoneAssignmentList::iterator baIter=dest->boneAssignments.begin(), baEnd=dest->boneAssignments.end(); baIter != baEnd; ++baIter)
for (auto &boneAssign : dest->boneAssignments)
{
if (baIter->vertexIndex == vertexIndex)
baIter->weight /= sum;
if (boneAssign.vertexIndex == vertexIndex)
boneAssign.weight /= sum;
}
}
}

View File

@ -236,8 +236,8 @@ OpenGEXImporter::VertexContainer::~VertexContainer() {
delete[] m_vertices;
delete[] m_normals;
for( size_t i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; i++ ) {
delete [] m_textureCoords[ i ];
for(auto &texcoords : m_textureCoords) {
delete [] texcoords;
}
}

View File

@ -131,11 +131,11 @@ static void normalizePathName( const std::string &rPath, std::string &rNormalize
static const unsigned int numDelimiters = 2;
const char delimiters[ numDelimiters ] = { '/', '\\' };
rNormalizedPath = rPath;
for ( unsigned int i=0; i<numDelimiters; i++ )
for (const char delimiter : delimiters)
{
for ( size_t j=0; j<rNormalizedPath.size(); j++ )
{
if ( rNormalizedPath[j] == delimiters[ i ] )
if ( rNormalizedPath[j] == delimiter )
{
rNormalizedPath[ j ] = sep[ 0 ];
}

View File

@ -195,8 +195,8 @@ Q3BSPZipArchive::Q3BSPZipArchive(IOSystem* pIOHandler, const std::string& rFile)
// ------------------------------------------------------------------------------------------------
// Destructor.
Q3BSPZipArchive::~Q3BSPZipArchive() {
for( std::map<std::string, ZipFile*>::iterator it(m_ArchiveMap.begin()), end(m_ArchiveMap.end()); it != end; ++it ) {
delete it->second;
for(auto &file : m_ArchiveMap) {
delete file.second;
}
m_ArchiveMap.clear();
@ -269,8 +269,8 @@ void Q3BSPZipArchive::Close(IOStream *pFile) {
void Q3BSPZipArchive::getFileList(std::vector<std::string> &rFileList) {
rFileList.clear();
for(std::map<std::string, ZipFile*>::iterator it(m_ArchiveMap.begin()), end(m_ArchiveMap.end()); it != end; ++it) {
rFileList.push_back(it->first);
for(auto &file : m_ArchiveMap) {
rFileList.push_back(file.first);
}
}

View File

@ -183,12 +183,11 @@ void RAWImporter::InternReadFile( const std::string& pFile,
}
// search in the list of meshes whether we have one with this texture
for (std::vector< MeshInformation >::iterator it = (*curGroup).meshes.begin(),
end = (*curGroup).meshes.end(); it != end; ++it)
for (auto &mesh : (*curGroup).meshes)
{
if (length == (*it).name.length() && (length ? !::strcmp(sz,(*it).name.c_str()) : true))
if (length == mesh.name.length() && (length ? !::strcmp(sz, mesh.name.c_str()) : true))
{
output = &(*it);
output = &mesh;
break;
}
}
@ -223,13 +222,12 @@ void RAWImporter::InternReadFile( const std::string& pFile,
// count the number of valid groups
// (meshes can't be empty)
for (std::vector< GroupInformation >::iterator it = outGroups.begin(), end = outGroups.end();
it != end;++it)
for (auto & outGroup : outGroups)
{
if (!(*it).meshes.empty())
if (!outGroup.meshes.empty())
{
++pScene->mRootNode->mNumChildren;
pScene->mNumMeshes += (unsigned int)(*it).meshes.size();
pScene->mNumMeshes += (unsigned int) outGroup.meshes.size();
}
}
@ -251,10 +249,9 @@ void RAWImporter::InternReadFile( const std::string& pFile,
aiMaterial** mats = pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials];
unsigned int meshIdx = 0;
for (std::vector< GroupInformation >::iterator it = outGroups.begin(), end = outGroups.end();
it != end;++it)
for (auto & outGroup : outGroups)
{
if ((*it).meshes.empty())continue;
if (outGroup.meshes.empty())continue;
aiNode* node;
if (pScene->mRootNode->mNumChildren)
@ -263,13 +260,13 @@ void RAWImporter::InternReadFile( const std::string& pFile,
node->mParent = pScene->mRootNode;
}
else node = *cc;++cc;
node->mName.Set((*it).name);
node->mName.Set(outGroup.name);
// add all meshes
node->mNumMeshes = (unsigned int)(*it).meshes.size();
node->mNumMeshes = (unsigned int) outGroup.meshes.size();
unsigned int* pi = node->mMeshes = new unsigned int[ node->mNumMeshes ];
for (std::vector< MeshInformation >::iterator it2 = (*it).meshes.begin(),
end2 = (*it).meshes.end(); it2 != end2; ++it2)
for (std::vector< MeshInformation >::iterator it2 = outGroup.meshes.begin(),
end2 = outGroup.meshes.end(); it2 != end2; ++it2)
{
ai_assert(!(*it2).vertices.empty());

View File

@ -459,11 +459,9 @@ void SplitLargeMeshesProcess_Vertex::SplitMesh(
if (iBase)
{
// we can't use memset here we unsigned int needn' be 32 bits
for (std::vector<unsigned int>::iterator
iter = avWasCopied.begin(),end = avWasCopied.end();
iter != end;++iter)
for (auto &elem : avWasCopied)
{
(*iter) = 0xffffffff;
elem = 0xffffffff;
}
}

View File

@ -171,9 +171,7 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
// collect triangles
std::vector<Unreal::Triangle> triangles(numTris);
for (std::vector<Unreal::Triangle>::iterator it = triangles.begin(), end = triangles.end();it != end; ++it) {
Unreal::Triangle& tri = *it;
for (auto & tri : triangles) {
for (unsigned int i = 0; i < 3;++i) {
tri.mVertex[i] = d_reader.GetI2();
@ -222,9 +220,9 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
// collect vertices
std::vector<aiVector3D> vertices(numVert);
for (std::vector<aiVector3D>::iterator it = vertices.begin(), end = vertices.end(); it != end; ++it) {
for (auto &vertex : vertices) {
int32_t val = a_reader.GetI4();
Unreal::DecompressVertex(*it,val);
Unreal::DecompressVertex(vertex ,val);
}
// list of textures.
@ -330,8 +328,7 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
materials.reserve(textures.size()*2+5);
// find out how many output meshes and materials we'll have and build material indices
for (std::vector<Unreal::Triangle>::iterator it = triangles.begin(), end = triangles.end();it != end; ++it) {
Unreal::Triangle& tri = *it;
for (Unreal::Triangle &tri : triangles) {
Unreal::TempMat mat(tri);
std::vector<Unreal::TempMat>::iterator nt = std::find(materials.begin(),materials.end(),mat);
if (nt == materials.end()) {
@ -418,8 +415,7 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
}
// fill them.
for (std::vector<Unreal::Triangle>::iterator it = triangles.begin(), end = triangles.end();it != end; ++it) {
Unreal::Triangle& tri = *it;
for (const Unreal::Triangle &tri : triangles) {
Unreal::TempMat mat(tri);
std::vector<Unreal::TempMat>::iterator nt = std::find(materials.begin(),materials.end(),mat);

View File

@ -6,7 +6,7 @@ setup(name='pyassimp',
version='0.1',
license='ISC',
description='Python bindings for the Open Asset Import Library (ASSIMP)',
url='http://assimp.sourceforge.net/',
url='https://github.com/assimp/assimp',
packages=['pyassimp'],
data_files=[('share/pyassimp', ['README.md']),
('share/examples/pyassimp', ['scripts/' + f for f in os.listdir('scripts/')])]