diff options
21 files changed, 105 insertions, 135 deletions
diff --git a/source/blender/blenlib/tests/BLI_linklist_lockfree_test.cc b/source/blender/blenlib/tests/BLI_linklist_lockfree_test.cc index f2ae121e8ae..e9810aed179 100644 --- a/source/blender/blenlib/tests/BLI_linklist_lockfree_test.cc +++ b/source/blender/blenlib/tests/BLI_linklist_lockfree_test.cc @@ -37,8 +37,8 @@ TEST(LockfreeLinkList, InsertMultiple) LockfreeLinkNode nodes[num_nodes]; BLI_linklist_lockfree_init(&list); /* Insert all the nodes. */ - for (int i = 0; i < num_nodes; ++i) { - BLI_linklist_lockfree_insert(&list, &nodes[i]); + for (LockfreeLinkNode &node : nodes) { + BLI_linklist_lockfree_insert(&list, &node); } /* Check head and tail. */ EXPECT_EQ(list.head, &list.dummy_node); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index d71cdea1974..5af70305e13 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -1247,8 +1247,7 @@ void DepsgraphNodeBuilder::build_particle_settings(ParticleSettings *particle_se &particle_settings->id, NodeType::PARTICLE_SETTINGS, OperationCode::PARTICLE_SETTINGS_EVAL); op_node->set_as_exit(); /* Texture slots. */ - for (int mtex_index = 0; mtex_index < MAX_MTEX; mtex_index++) { - MTex *mtex = particle_settings->mtex[mtex_index]; + for (MTex *mtex : particle_settings->mtex) { if (mtex == nullptr || mtex->tex == nullptr) { continue; } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 3f6aa778b59..11d34782569 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -1907,8 +1907,7 @@ void DepsgraphRelationBuilder::build_particle_settings(ParticleSettings *part) particle_settings_init_key, particle_settings_eval_key, "Particle Settings Init Order"); add_relation(particle_settings_reset_key, particle_settings_eval_key, "Particle Settings Reset"); /* Texture slots. */ - for (int mtex_index = 0; mtex_index < MAX_MTEX; mtex_index++) { - MTex *mtex = part->mtex[mtex_index]; + for (MTex *mtex : part->mtex) { if (mtex == nullptr || mtex->tex == nullptr) { continue; } diff --git a/source/blender/depsgraph/intern/depsgraph_query.cc b/source/blender/depsgraph/intern/depsgraph_query.cc index 1a334d8a451..57de62e1880 100644 --- a/source/blender/depsgraph/intern/depsgraph_query.cc +++ b/source/blender/depsgraph/intern/depsgraph_query.cc @@ -90,8 +90,8 @@ bool DEG_id_type_any_updated(const Depsgraph *graph) const deg::Depsgraph *deg_graph = reinterpret_cast<const deg::Depsgraph *>(graph); /* Loop over all ID types. */ - for (int id_type_index = 0; id_type_index < MAX_LIBARRAY; id_type_index++) { - if (deg_graph->id_type_updated[id_type_index]) { + for (char id_type_index : deg_graph->id_type_updated) { + if (id_type_index) { return true; } } diff --git a/source/blender/gpu/intern/gpu_batch.cc b/source/blender/gpu/intern/gpu_batch.cc index cdb158572b7..08b2e3c0f00 100644 --- a/source/blender/gpu/intern/gpu_batch.cc +++ b/source/blender/gpu/intern/gpu_batch.cc @@ -81,8 +81,8 @@ void GPU_batch_init_ex(GPUBatch *batch, for (int v = 1; v < GPU_BATCH_VBO_MAX_LEN; v++) { batch->verts[v] = nullptr; } - for (int v = 0; v < GPU_BATCH_INST_VBO_MAX_LEN; v++) { - batch->inst[v] = nullptr; + for (auto & v : batch->inst) { + v = nullptr; } batch->elem = elem; batch->prim_type = prim_type; diff --git a/source/blender/gpu/intern/gpu_framebuffer.cc b/source/blender/gpu/intern/gpu_framebuffer.cc index f11f1cea753..d5d7994a154 100644 --- a/source/blender/gpu/intern/gpu_framebuffer.cc +++ b/source/blender/gpu/intern/gpu_framebuffer.cc @@ -57,18 +57,18 @@ FrameBuffer::FrameBuffer(const char *name) dirty_attachments_ = true; dirty_state_ = true; - for (int i = 0; i < ARRAY_SIZE(attachments_); i++) { - attachments_[i].tex = nullptr; - attachments_[i].mip = -1; - attachments_[i].layer = -1; + for (GPUAttachment &attachment : attachments_) { + attachment.tex = nullptr; + attachment.mip = -1; + attachment.layer = -1; } } FrameBuffer::~FrameBuffer() { - for (int i = 0; i < ARRAY_SIZE(attachments_); i++) { - if (attachments_[i].tex != nullptr) { - reinterpret_cast<Texture *>(attachments_[i].tex)->detach_from(this); + for (GPUAttachment &attachment : attachments_) { + if (attachment.tex != nullptr) { + reinterpret_cast<Texture *>(attachment.tex)->detach_from(this); } } } @@ -148,8 +148,8 @@ void FrameBuffer::recursive_downsample(int max_lvl, for (int mip_lvl = 1; mip_lvl <= max_lvl; mip_lvl++) { /* Replace attached mip-level for each attachment. */ - for (int att = 0; att < ARRAY_SIZE(attachments_); att++) { - Texture *tex = reinterpret_cast<Texture *>(attachments_[att].tex); + for (GPUAttachment &attachment : attachments_) { + Texture *tex = reinterpret_cast<Texture *>(attachment.tex); if (tex != nullptr) { /* Some Intel HDXXX have issue with rendering to a mipmap that is below * the texture GL_TEXTURE_MAX_LEVEL. So even if it not correct, in this case @@ -158,7 +158,7 @@ void FrameBuffer::recursive_downsample(int max_lvl, /* Restrict fetches only to previous level. */ tex->mip_range_set(mip_lvl - 1, mip_max); /* Bind next level. */ - attachments_[att].mip = mip_lvl; + attachment.mip = mip_lvl; } } /* Update the internal attachments and viewport size. */ @@ -168,12 +168,12 @@ void FrameBuffer::recursive_downsample(int max_lvl, callback(userData, mip_lvl); } - for (int att = 0; att < ARRAY_SIZE(attachments_); att++) { - if (attachments_[att].tex != nullptr) { + for (GPUAttachment &attachment : attachments_) { + if (attachment.tex != nullptr) { /* Reset mipmap level range. */ - reinterpret_cast<Texture *>(attachments_[att].tex)->mip_range_set(0, max_lvl); + reinterpret_cast<Texture *>(attachment.tex)->mip_range_set(0, max_lvl); /* Reset base level. NOTE: might not be the one bound at the start of this function. */ - attachments_[att].mip = 0; + attachment.mip = 0; } } dirty_attachments_ = true; @@ -525,18 +525,18 @@ static GPUFrameBuffer *gpu_offscreen_fb_get(GPUOffScreen *ofs) Context *ctx = Context::get(); BLI_assert(ctx); - for (int i = 0; i < MAX_CTX_FB_LEN; i++) { - if (ofs->framebuffers[i].fb == nullptr) { - ofs->framebuffers[i].ctx = ctx; - GPU_framebuffer_ensure_config(&ofs->framebuffers[i].fb, + for (auto &framebuffer : ofs->framebuffers) { + if (framebuffer.fb == nullptr) { + framebuffer.ctx = ctx; + GPU_framebuffer_ensure_config(&framebuffer.fb, { GPU_ATTACHMENT_TEXTURE(ofs->depth), GPU_ATTACHMENT_TEXTURE(ofs->color), }); } - if (ofs->framebuffers[i].ctx == ctx) { - return ofs->framebuffers[i].fb; + if (framebuffer.ctx == ctx) { + return framebuffer.fb; } } @@ -550,9 +550,9 @@ static GPUFrameBuffer *gpu_offscreen_fb_get(GPUOffScreen *ofs) "Warning: GPUOffscreen used in more than 3 GPUContext. " "This may create performance drop.\n"); - for (int i = 0; i < MAX_CTX_FB_LEN; i++) { - GPU_framebuffer_free(ofs->framebuffers[i].fb); - ofs->framebuffers[i].fb = nullptr; + for (auto &framebuffer : ofs->framebuffers) { + GPU_framebuffer_free(framebuffer.fb); + framebuffer.fb = nullptr; } return gpu_offscreen_fb_get(ofs); @@ -595,9 +595,9 @@ GPUOffScreen *GPU_offscreen_create( void GPU_offscreen_free(GPUOffScreen *ofs) { - for (int i = 0; i < MAX_CTX_FB_LEN; i++) { - if (ofs->framebuffers[i].fb) { - GPU_framebuffer_free(ofs->framebuffers[i].fb); + for (auto &framebuffer : ofs->framebuffers) { + if (framebuffer.fb) { + GPU_framebuffer_free(framebuffer.fb); } } if (ofs->color) { diff --git a/source/blender/gpu/intern/gpu_shader.cc b/source/blender/gpu/intern/gpu_shader.cc index 827ea06686f..d47ad5e0100 100644 --- a/source/blender/gpu/intern/gpu_shader.cc +++ b/source/blender/gpu/intern/gpu_shader.cc @@ -470,9 +470,9 @@ struct GPUShader *GPU_shader_create_from_arrays_impl( GPUShader *sh = GPU_shader_create( str_dst[0].str, str_dst[1].str, str_dst[2].str, nullptr, str_dst[3].str, name); - for (int i = 0; i < ARRAY_SIZE(str_dst); i++) { - if (str_dst[i].is_alloc) { - MEM_freeN((void *)str_dst[i].str); + for (auto &i : str_dst) { + if (i.is_alloc) { + MEM_freeN((void *)i.str); } } return sh; diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp index 7047b6f3727..c91da839d25 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.cpp +++ b/source/blender/ikplugin/intern/itasc_plugin.cpp @@ -194,8 +194,8 @@ struct IK_Scene { { /* delete scene first */ delete scene; - for (std::vector<IK_Target *>::iterator it = targets.begin(); it != targets.end(); ++it) { - delete (*it); + for (IK_Target *target : targets) { + delete target; } targets.clear(); delete[] channels; diff --git a/source/blender/imbuf/intern/dds/BlockDXT.cpp b/source/blender/imbuf/intern/dds/BlockDXT.cpp index 2d9c300a147..4e4fca864a0 100644 --- a/source/blender/imbuf/intern/dds/BlockDXT.cpp +++ b/source/blender/imbuf/intern/dds/BlockDXT.cpp @@ -608,8 +608,8 @@ void mem_read(Stream &mem, BlockDXT1 &block) void mem_read(Stream &mem, AlphaBlockDXT3 &block) { - for (unsigned int i = 0; i < 4; i++) { - mem_read(mem, block.row[i]); + for (unsigned short &alpha : block.row) { + mem_read(mem, alpha); } } diff --git a/source/blender/imbuf/intern/dds/ColorBlock.cpp b/source/blender/imbuf/intern/dds/ColorBlock.cpp index 7c8b7c1d345..00fa0111d1c 100644 --- a/source/blender/imbuf/intern/dds/ColorBlock.cpp +++ b/source/blender/imbuf/intern/dds/ColorBlock.cpp @@ -150,12 +150,12 @@ static inline uint8 component(Color32 c, uint i) void ColorBlock::swizzle(uint x, uint y, uint z, uint w) { - for (int i = 0; i < 16; i++) { - Color32 c = m_color[i]; - m_color[i].r = component(c, x); - m_color[i].g = component(c, y); - m_color[i].b = component(c, z); - m_color[i].a = component(c, w); + for (Color32 &color : m_color) { + const Color32 c = color; + color.r = component(c, x); + color.g = component(c, y); + color.b = component(c, z); + color.a = component(c, w); } } @@ -243,8 +243,8 @@ Color32 ColorBlock::averageColor() const /** Return true if the block is not fully opaque. */ bool ColorBlock::hasAlpha() const { - for (uint i = 0; i < 16; i++) { - if (m_color[i].a != 255) { + for (const auto &i : m_color) { + if (i.a != 255) { return true; } } diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 087e001b0b3..12faa48c81c 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -733,8 +733,8 @@ static void imb_exr_get_views(MultiPartInputFile &file, StringVector &views) if (exr_has_multipart_file(file) == false) { if (exr_has_multiview(file)) { StringVector sv = multiView(file.header(0)); - for (StringVector::const_iterator i = sv.begin(); i != sv.end(); ++i) { - views.push_back(*i); + for (const std::string &view_name : sv) { + views.push_back(view_name); } } } @@ -991,21 +991,15 @@ int IMB_exr_begin_read(void *handle, const char *filename, int *width, int *heig std::vector<MultiViewChannelName> channels; GetChannelsInMultiPartFile(*data->ifile, channels); - for (size_t i = 0; i < channels.size(); i++) { - IMB_exr_add_channel(data, - nullptr, - channels[i].name.c_str(), - channels[i].view.c_str(), - 0, - 0, - nullptr, - false); + for (const MultiViewChannelName &channel : channels) { + IMB_exr_add_channel( + data, nullptr, channel.name.c_str(), channel.view.c_str(), 0, 0, nullptr, false); echan = (ExrChannel *)data->channels.last; - echan->m->name = channels[i].name; - echan->m->view = channels[i].view; - echan->m->part_number = channels[i].part_number; - echan->m->internal_name = channels[i].internal_name; + echan->m->name = channel.name; + echan->m->view = channel.view; + echan->m->part_number = channel.part_number; + echan->m->internal_name = channel.internal_name; } return 1; @@ -1311,9 +1305,8 @@ void IMB_exr_multilayer_convert(void *handle, } else { /* add views to RenderResult */ - for (StringVector::const_iterator i = data->multiView->begin(); i != data->multiView->end(); - ++i) { - addview(base, (*i).c_str()); + for (const std::string &view_name : *data->multiView) { + addview(base, view_name.c_str()); } } @@ -1554,15 +1547,15 @@ static ExrHandle *imb_exr_begin_read_mem(IStream &file_stream, imb_exr_get_views(*data->ifile, *data->multiView); - for (size_t i = 0; i < channels.size(); i++) { + for (const MultiViewChannelName &channel : channels) { IMB_exr_add_channel( - data, nullptr, channels[i].name.c_str(), channels[i].view.c_str(), 0, 0, nullptr, false); + data, nullptr, channel.name.c_str(), channel.view.c_str(), 0, 0, nullptr, false); echan = (ExrChannel *)data->channels.last; - echan->m->name = channels[i].name; - echan->m->view = channels[i].view; - echan->m->part_number = channels[i].part_number; - echan->m->internal_name = channels[i].internal_name; + echan->m->name = channel.name; + echan->m->view = channel.view; + echan->m->part_number = channel.part_number; + echan->m->internal_name = channel.internal_name; } /* now try to sort out how to assign memory to the channels */ @@ -1689,8 +1682,8 @@ static void exr_print_filecontents(MultiPartInputFile &file) const StringVector views = multiView(file.header(0)); printf("OpenEXR-load: MultiView file\n"); printf("OpenEXR-load: Default view: %s\n", defaultViewName(views).c_str()); - for (StringVector::const_iterator i = views.begin(); i != views.end(); ++i) { - printf("OpenEXR-load: Found view %s\n", (*i).c_str()); + for (const std::string &view : views) { + printf("OpenEXR-load: Found view %s\n", view.c_str()); } } else if (numparts > 1) { @@ -1835,10 +1828,10 @@ static void imb_exr_type_by_channels(ChannelList &channels, * with non-empty ones in the file. */ for (ChannelList::ConstIterator i = channels.begin(); i != channels.end(); i++) { - for (std::set<string>::iterator i = layerNames.begin(); i != layerNames.end(); i++) { + for (const std::string &layer_name : layerNames) { /* see if any layername differs from a viewname */ - if (imb_exr_get_multiView_id(views, *i) == -1) { - std::string layerName = *i; + if (imb_exr_get_multiView_id(views, layer_name) == -1) { + std::string layerName = layer_name; size_t pos = layerName.rfind('.'); if (pos == std::string::npos) { diff --git a/source/blender/io/alembic/intern/abc_reader_mesh.cc b/source/blender/io/alembic/intern/abc_reader_mesh.cc index 14c3d756d56..0b9636ffb70 100644 --- a/source/blender/io/alembic/intern/abc_reader_mesh.cc +++ b/source/blender/io/alembic/intern/abc_reader_mesh.cc @@ -724,9 +724,7 @@ void AbcMeshReader::assign_facesets_to_mpoly(const ISampleSelector &sample_sel, int current_mat = 0; - for (int i = 0; i < face_sets.size(); i++) { - const std::string &grp_name = face_sets[i]; - + for (const std::string &grp_name : face_sets) { if (r_mat_map.find(grp_name) == r_mat_map.end()) { r_mat_map[grp_name] = ++current_mat; } diff --git a/source/blender/io/collada/AnimationImporter.cpp b/source/blender/io/collada/AnimationImporter.cpp index 850b6a813ed..77ccdeae28d 100644 --- a/source/blender/io/collada/AnimationImporter.cpp +++ b/source/blender/io/collada/AnimationImporter.cpp @@ -272,9 +272,8 @@ void AnimationImporter::add_fcurves_to_object(Main *bmain, AnimationImporter::~AnimationImporter() { /* free unused FCurves */ - for (std::vector<FCurve *>::iterator it = unused_curves.begin(); it != unused_curves.end(); - it++) { - BKE_fcurve_free(*it); + for (FCurve *unused_curve : unused_curves) { + BKE_fcurve_free(unused_curve); } if (!unused_curves.empty()) { @@ -2035,8 +2034,8 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, COLLADABU::Math::Matrix4 matrix; int mi = 0, mj = 0; - for (std::vector<FCurve *>::iterator it = curves.begin(); it != curves.end(); it++) { - matrix.setElement(mi, mj, evaluate_fcurve(*it, fra)); + for (FCurve *curve : curves) { + matrix.setElement(mi, mj, evaluate_fcurve(curve, fra)); mj++; if (mj == 4) { mi++; diff --git a/source/blender/io/collada/BCMath.cpp b/source/blender/io/collada/BCMath.cpp index 8a3fbf3c92c..7d8e5825ac9 100644 --- a/source/blender/io/collada/BCMath.cpp +++ b/source/blender/io/collada/BCMath.cpp @@ -157,20 +157,20 @@ void BCMatrix::transpose(Matrix &mat) void BCMatrix::sanitize(Matrix &mat, int precision) { - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - double val = (double)mat[i][j]; + for (auto &row : mat) { + for (float &cell : row) { + double val = (double)cell; val = double_round(val, precision); - mat[i][j] = (float)val; + cell = (float)val; } } } void BCMatrix::sanitize(DMatrix &mat, int precision) { - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - mat[i][j] = double_round(mat[i][j], precision); + for (auto &row : mat) { + for (float &cell : row) { + cell = double_round(cell, precision); } } } diff --git a/source/blender/io/collada/BlenderContext.cpp b/source/blender/io/collada/BlenderContext.cpp index 8009f10aa03..ab420e79ba7 100644 --- a/source/blender/io/collada/BlenderContext.cpp +++ b/source/blender/io/collada/BlenderContext.cpp @@ -81,8 +81,8 @@ bool bc_is_in_Export_set(LinkNode *export_set, Object *ob, ViewLayer *view_layer std::vector<Object *> children; bc_get_children(children, ob, view_layer); - for (int i = 0; i < children.size(); i++) { - if (bc_is_in_Export_set(export_set, children[i], view_layer)) { + for (Object *child : children) { + if (bc_is_in_Export_set(export_set, child, view_layer)) { to_export = true; break; } diff --git a/source/blender/io/collada/ControllerExporter.cpp b/source/blender/io/collada/ControllerExporter.cpp index 52d4bbf122e..6f0d422dbe2 100644 --- a/source/blender/io/collada/ControllerExporter.cpp +++ b/source/blender/io/collada/ControllerExporter.cpp @@ -245,9 +245,9 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm) if (sumw > 0.0f) { float invsumw = 1.0f / sumw; vcounts.push_back(jw.size()); - for (std::map<int, float>::iterator m = jw.begin(); m != jw.end(); ++m) { - joints.push_back((*m).first); - weights.push_back(invsumw * (*m).second); + for (auto &index_and_weight : jw) { + joints.push_back(index_and_weight.first); + weights.push_back(invsumw * index_and_weight.second); } } else { @@ -596,8 +596,8 @@ std::string ControllerExporter::add_weights_source(Mesh *me, source.prepareToAppendValues(); - for (std::list<float>::const_iterator i = weights.begin(); i != weights.end(); ++i) { - source.appendValues(*i); + for (float weight : weights) { + source.appendValues(weight); } source.finish(); @@ -638,8 +638,8 @@ void ControllerExporter::add_vertex_weights_element(const std::string &weights_s /* write deformer index - weight index pairs */ int weight_index = 0; - for (std::list<int>::const_iterator i = joints.begin(); i != joints.end(); ++i) { - weightselem.appendValues(*i, weight_index++); + for (int joint_index : joints) { + weightselem.appendValues(joint_index, weight_index++); } weightselem.finish(); diff --git a/source/blender/io/collada/DocumentImporter.cpp b/source/blender/io/collada/DocumentImporter.cpp index b85a96d89de..10c1a90576c 100644 --- a/source/blender/io/collada/DocumentImporter.cpp +++ b/source/blender/io/collada/DocumentImporter.cpp @@ -241,10 +241,8 @@ void DocumentImporter::finish() armature_importer.fix_animation(); #endif - for (std::vector<const COLLADAFW::VisualScene *>::iterator vsit = vscenes.begin(); - vsit != vscenes.end(); - vsit++) { - const COLLADAFW::NodePointerArray &roots = (*vsit)->getRootNodes(); + for (const COLLADAFW::VisualScene *vscene : vscenes) { + const COLLADAFW::NodePointerArray &roots = vscene->getRootNodes(); for (unsigned int i = 0; i < roots.getCount(); i++) { translate_anim_recursive(roots[i], nullptr, nullptr); @@ -665,9 +663,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, goto finally; } - for (std::vector<Object *>::iterator it = objects_done->begin(); it != objects_done->end(); - ++it) { - ob = *it; + for (Object *ob : *objects_done) { std::string nodename = node->getName().empty() ? node->getOriginalId() : node->getName(); BKE_libblock_rename(bmain, &ob->id, (char *)nodename.c_str()); object_map.insert(std::pair<COLLADAFW::UniqueId, Object *>(node->getUniqueId(), ob)); @@ -681,10 +677,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, /* create_constraints(et,ob); */ } - for (std::vector<Object *>::iterator it = objects_done->begin(); it != objects_done->end(); - ++it) { - ob = *it; - + for (Object *ob : *objects_done) { if (read_transform) { anim_importer.read_node_transform(node, ob); /* overwrites location set earlier */ } diff --git a/source/blender/io/collada/MeshImporter.cpp b/source/blender/io/collada/MeshImporter.cpp index bb2aabb0598..2934ea1caa6 100644 --- a/source/blender/io/collada/MeshImporter.cpp +++ b/source/blender/io/collada/MeshImporter.cpp @@ -973,9 +973,7 @@ static void bc_remove_materials_from_object(Object *ob, Mesh *me) std::vector<Object *> MeshImporter::get_all_users_of(Mesh *reference_mesh) { std::vector<Object *> mesh_users; - for (std::vector<Object *>::iterator it = imported_objects.begin(); it != imported_objects.end(); - ++it) { - Object *ob = (*it); + for (Object *ob : imported_objects) { if (bc_is_marked(ob)) { bc_remove_mark(ob); Mesh *me = (Mesh *)ob->data; @@ -1007,9 +1005,7 @@ std::vector<Object *> MeshImporter::get_all_users_of(Mesh *reference_mesh) */ void MeshImporter::optimize_material_assignements() { - for (std::vector<Object *>::iterator it = imported_objects.begin(); it != imported_objects.end(); - ++it) { - Object *ob = (*it); + for (Object *ob : imported_objects) { Mesh *me = (Mesh *)ob->data; if (ID_REAL_USERS(&me->id) == 1) { bc_copy_materials_to_data(ob, me); @@ -1029,8 +1025,7 @@ void MeshImporter::optimize_material_assignements() } if (can_move) { bc_copy_materials_to_data(ref_ob, me); - for (int index = 0; index < mesh_users.size(); index++) { - Object *object = mesh_users[index]; + for (Object *object : mesh_users) { bc_remove_materials_from_object(object, me); bc_remove_mark(object); } diff --git a/source/blender/io/collada/SceneExporter.cpp b/source/blender/io/collada/SceneExporter.cpp index 01c270518e9..5bbd22b8275 100644 --- a/source/blender/io/collada/SceneExporter.cpp +++ b/source/blender/io/collada/SceneExporter.cpp @@ -86,8 +86,7 @@ void SceneExporter::writeNodeList(std::vector<Object *> &child_objects, Object * * I really prefer to enforce the export of hidden * elements in an object hierarchy. When the children of * the hidden elements are exported as well. */ - for (int i = 0; i < child_objects.size(); i++) { - Object *child = child_objects[i]; + for (auto *child : child_objects) { writeNode(child); if (bc_is_marked(child)) { bc_remove_mark(child); diff --git a/source/blender/io/collada/collada_internal.cpp b/source/blender/io/collada/collada_internal.cpp index 096f6a678ac..ed5cc62d05f 100644 --- a/source/blender/io/collada/collada_internal.cpp +++ b/source/blender/io/collada/collada_internal.cpp @@ -280,8 +280,7 @@ std::string encode_xml(std::string xml) std::map<char, std::string>::const_iterator it; std::string encoded_xml; - for (unsigned int i = 0; i < xml.size(); i++) { - char c = xml.at(i); + for (char c : xml) { it = escape.find(c); if (it == escape.end()) { diff --git a/source/blender/io/collada/collada_utils.cpp b/source/blender/io/collada/collada_utils.cpp index c57952afcc8..25c10c717e2 100644 --- a/source/blender/io/collada/collada_utils.cpp +++ b/source/blender/io/collada/collada_utils.cpp @@ -379,11 +379,9 @@ void bc_match_scale(std::vector<Object *> *objects_done, UnitConverter &bc_unit, bool scale_to_scene) { - for (std::vector<Object *>::iterator it = objects_done->begin(); it != objects_done->end(); - ++it) { - Object *ob = *it; + for (Object *ob : *objects_done) { if (ob->parent == nullptr) { - bc_match_scale(*it, bc_unit, scale_to_scene); + bc_match_scale(ob, bc_unit, scale_to_scene); } } } @@ -524,10 +522,8 @@ BoneExtensionManager::~BoneExtensionManager() std::map<std::string, BoneExtensionMap *>::iterator map_it; for (map_it = extended_bone_maps.begin(); map_it != extended_bone_maps.end(); ++map_it) { BoneExtensionMap *extended_bones = map_it->second; - for (BoneExtensionMap::iterator ext_it = extended_bones->begin(); - ext_it != extended_bones->end(); - ++ext_it) { - delete ext_it->second; + for (auto &extended_bone : *extended_bones) { + delete extended_bone.second; } extended_bones->clear(); delete extended_bones; |