diff options
Diffstat (limited to 'source/blender/io')
23 files changed, 63 insertions, 90 deletions
diff --git a/source/blender/io/alembic/exporter/abc_subdiv_disabler.cc b/source/blender/io/alembic/exporter/abc_subdiv_disabler.cc index 334a26df784..8073e157c13 100644 --- a/source/blender/io/alembic/exporter/abc_subdiv_disabler.cc +++ b/source/blender/io/alembic/exporter/abc_subdiv_disabler.cc @@ -18,7 +18,7 @@ */ #include "abc_subdiv_disabler.h" -#include <stdio.h> +#include <cstdio> #include "BLI_listbase.h" 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/alembic/tests/abc_export_test.cc b/source/blender/io/alembic/tests/abc_export_test.cc index e1a9bd34f6b..e20fe2ff492 100644 --- a/source/blender/io/alembic/tests/abc_export_test.cc +++ b/source/blender/io/alembic/tests/abc_export_test.cc @@ -23,7 +23,7 @@ class AlembicExportTest : public testing::Test { Depsgraph *depsgraph; Main *bmain; - virtual void SetUp() + void SetUp() override { abc_archive = nullptr; @@ -41,7 +41,7 @@ class AlembicExportTest : public testing::Test { depsgraph = DEG_graph_new(bmain, &scene, view_layer, DAG_EVAL_RENDER); } - virtual void TearDown() + void TearDown() override { BKE_main_free(bmain); DEG_graph_free(depsgraph); diff --git a/source/blender/io/collada/AnimationImporter.cpp b/source/blender/io/collada/AnimationImporter.cpp index 2e7977d89bb..77ccdeae28d 100644 --- a/source/blender/io/collada/AnimationImporter.cpp +++ b/source/blender/io/collada/AnimationImporter.cpp @@ -18,7 +18,7 @@ * \ingroup collada */ -#include <stddef.h> +#include <cstddef> /* COLLADABU_ASSERT, may be able to remove later */ #include "COLLADABUPlatform.h" @@ -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/BCAnimationCurve.cpp b/source/blender/io/collada/BCAnimationCurve.cpp index 33eaf3376cd..5065accf554 100644 --- a/source/blender/io/collada/BCAnimationCurve.cpp +++ b/source/blender/io/collada/BCAnimationCurve.cpp @@ -173,8 +173,14 @@ std::string BCAnimationCurve::get_animation_name(Object *ob) const name = ""; } else { - const char *boneName = BLI_str_quoted_substrN(fcurve->rna_path, "pose.bones["); - name = (boneName) ? id_name(ob) + "_" + std::string(boneName) : ""; + char *boneName = BLI_str_quoted_substrN(fcurve->rna_path, "pose.bones["); + if (boneName) { + name = id_name(ob) + "_" + std::string(boneName); + MEM_freeN(boneName); + } + else { + name = ""; + } } } break; diff --git a/source/blender/io/collada/BCAnimationSampler.cpp b/source/blender/io/collada/BCAnimationSampler.cpp index abc770ceef5..a6ee0b8bee6 100644 --- a/source/blender/io/collada/BCAnimationSampler.cpp +++ b/source/blender/io/collada/BCAnimationSampler.cpp @@ -448,6 +448,7 @@ void BCAnimationSampler::initialize_curves(BCAnimationCurveMap &curves, Object * char *boneName = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones["); if (boneName) { object_type = BC_ANIMATION_TYPE_BONE; + MEM_freeN(boneName); } } diff --git a/source/blender/io/collada/BCMath.cpp b/source/blender/io/collada/BCMath.cpp index 8a3fbf3c92c..0521fda5fb1 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 (double &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/DocumentExporter.cpp b/source/blender/io/collada/DocumentExporter.cpp index 241afbd4034..46dfdda4ede 100644 --- a/source/blender/io/collada/DocumentExporter.cpp +++ b/source/blender/io/collada/DocumentExporter.cpp @@ -19,9 +19,9 @@ */ #include <algorithm> /* std::find */ -#include <math.h> -#include <stdio.h> -#include <stdlib.h> +#include <cmath> +#include <cstdio> +#include <cstdlib> #include <vector> #include "COLLADASWAsset.h" @@ -121,7 +121,7 @@ extern "C" char build_hash[]; #include "MaterialExporter.h" #include "SceneExporter.h" -#include <errno.h> +#include <cerrno> char *bc_CustomData_get_layer_name(const struct CustomData *data, int type, int n) { 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/ErrorHandler.cpp b/source/blender/io/collada/ErrorHandler.cpp index 7467d519f28..844065e3ba3 100644 --- a/source/blender/io/collada/ErrorHandler.cpp +++ b/source/blender/io/collada/ErrorHandler.cpp @@ -26,7 +26,7 @@ #include "GeneratedSaxParserParserError.h" -#include <string.h> +#include <cstring> #include "BLI_utildefines.h" diff --git a/source/blender/io/collada/ExtraHandler.cpp b/source/blender/io/collada/ExtraHandler.cpp index 8aefb321dd6..11cb75fb5e9 100644 --- a/source/blender/io/collada/ExtraHandler.cpp +++ b/source/blender/io/collada/ExtraHandler.cpp @@ -19,7 +19,7 @@ */ #include "BLI_string.h" -#include <stddef.h> +#include <cstddef> #include "ExtraHandler.h" diff --git a/source/blender/io/collada/ExtraTags.cpp b/source/blender/io/collada/ExtraTags.cpp index d8fbf96db51..8c63a21f88a 100644 --- a/source/blender/io/collada/ExtraTags.cpp +++ b/source/blender/io/collada/ExtraTags.cpp @@ -19,8 +19,8 @@ */ #include "BLI_string.h" -#include <stddef.h> -#include <stdlib.h> +#include <cstddef> +#include <cstdlib> #include <iostream> 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/SkinInfo.cpp b/source/blender/io/collada/SkinInfo.cpp index 19a4a4f61c2..8f6f1e467d9 100644 --- a/source/blender/io/collada/SkinInfo.cpp +++ b/source/blender/io/collada/SkinInfo.cpp @@ -21,7 +21,7 @@ #include <algorithm> #if !defined(WIN32) -# include <stdint.h> +# include <cstdint> #endif /* COLLADABU_ASSERT, may be able to remove later */ diff --git a/source/blender/io/collada/collada_internal.cpp b/source/blender/io/collada/collada_internal.cpp index 096f6a678ac..787af933e8f 100644 --- a/source/blender/io/collada/collada_internal.cpp +++ b/source/blender/io/collada/collada_internal.cpp @@ -205,7 +205,7 @@ const unsigned char translate_name_map[256] = { 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, }; -typedef std::map<std::string, std::vector<std::string>> map_string_list; +using map_string_list = std::map<std::string, std::vector<std::string>>; map_string_list global_id_map; void clear_global_id_map() @@ -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..ad1cc1035fb 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; @@ -1180,17 +1176,6 @@ static std::string bc_get_uvlayer_name(Mesh *me, int layer) return ""; } -std::string bc_find_bonename_in_path(std::string path, std::string probe) -{ - std::string result; - char *boneName = BLI_str_quoted_substrN(path.c_str(), probe.c_str()); - if (boneName) { - result = std::string(boneName); - MEM_freeN(boneName); - } - return result; -} - static bNodeTree *prepare_material_nodetree(Material *ma) { if (ma->nodetree == nullptr) { diff --git a/source/blender/io/collada/collada_utils.h b/source/blender/io/collada/collada_utils.h index fa65d398954..d0a5d37d6d2 100644 --- a/source/blender/io/collada/collada_utils.h +++ b/source/blender/io/collada/collada_utils.h @@ -146,8 +146,6 @@ extern void bc_bubble_sort_by_Object_name(LinkNode *export_set); extern bool bc_is_root_bone(Bone *aBone, bool deform_bones_only); extern int bc_get_active_UVLayer(Object *ob); -std::string bc_find_bonename_in_path(std::string path, std::string probe); - inline std::string bc_string_after(const std::string &s, const std::string probe) { size_t i = s.rfind(probe); diff --git a/source/blender/io/common/intern/abstract_hierarchy_iterator.cc b/source/blender/io/common/intern/abstract_hierarchy_iterator.cc index fc47b024be1..eaa4d2fdde7 100644 --- a/source/blender/io/common/intern/abstract_hierarchy_iterator.cc +++ b/source/blender/io/common/intern/abstract_hierarchy_iterator.cc @@ -19,10 +19,10 @@ #include "IO_abstract_hierarchy_iterator.h" #include "dupli_parent_finder.hh" +#include <climits> +#include <cstdio> #include <iostream> -#include <limits.h> #include <sstream> -#include <stdio.h> #include <string> #include "BKE_anim_data.h" diff --git a/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc b/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc index ad0d6820e2b..8acdba416d3 100644 --- a/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc +++ b/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc @@ -73,7 +73,7 @@ class TestingHierarchyIterator : public AbstractHierarchyIterator { explicit TestingHierarchyIterator(Depsgraph *depsgraph) : AbstractHierarchyIterator(depsgraph) { } - virtual ~TestingHierarchyIterator() + ~TestingHierarchyIterator() override { release_writers(); } @@ -106,13 +106,13 @@ class AbstractHierarchyIteratorTest : public BlendfileLoadingBaseTest { protected: TestingHierarchyIterator *iterator; - virtual void SetUp() + void SetUp() override { BlendfileLoadingBaseTest::SetUp(); iterator = nullptr; } - virtual void TearDown() + void TearDown() override { iterator_free(); BlendfileLoadingBaseTest::TearDown(); diff --git a/source/blender/io/common/intern/object_identifier.cc b/source/blender/io/common/intern/object_identifier.cc index a2d2d998bec..5d0b89b0630 100644 --- a/source/blender/io/common/intern/object_identifier.cc +++ b/source/blender/io/common/intern/object_identifier.cc @@ -21,7 +21,7 @@ #include "BKE_duplilist.h" extern "C" { -#include <limits.h> /* For INT_MAX. */ +#include <climits> /* For INT_MAX. */ } #include <cstring> #include <sstream> |