summaryrefslogtreecommitdiff
path: root/editor/import
diff options
context:
space:
mode:
authorLightning_A <aaronjrecord@gmail.com>2021-08-09 14:13:42 -0600
committerLightning_A <aaronjrecord@gmail.com>2021-09-30 15:09:12 -0600
commitc63b18507d21b8a213c073bced9057b571cdcd7a (patch)
tree96b8f7532ae5d923b75bfbac8d6763015b6646bb /editor/import
parente4dfa69bcf58e4d50acdde32c590364e43fce3ab (diff)
Use range iterators for `Map`
Diffstat (limited to 'editor/import')
-rw-r--r--editor/import/collada.cpp20
-rw-r--r--editor/import/editor_import_collada.cpp20
-rw-r--r--editor/import/editor_importer_bake_reset.cpp8
-rw-r--r--editor/import/resource_importer_texture.cpp16
-rw-r--r--editor/import/scene_import_settings.cpp58
-rw-r--r--editor/import/scene_importer_mesh.cpp4
6 files changed, 63 insertions, 63 deletions
diff --git a/editor/import/collada.cpp b/editor/import/collada.cpp
index b6d0927ce6..4cd9066350 100644
--- a/editor/import/collada.cpp
+++ b/editor/import/collada.cpp
@@ -2095,19 +2095,19 @@ void Collada::_merge_skeletons(VisualScene *p_vscene, Node *p_node) {
}
void Collada::_merge_skeletons2(VisualScene *p_vscene) {
- for (Map<String, SkinControllerData>::Element *E = state.skin_controller_data_map.front(); E; E = E->next()) {
- SkinControllerData &cd = E->get();
+ for (KeyValue<String, SkinControllerData> &E : state.skin_controller_data_map) {
+ SkinControllerData &cd = E.value;
NodeSkeleton *skeleton = nullptr;
- for (Map<String, Transform3D>::Element *F = cd.bone_rest_map.front(); F; F = F->next()) {
+ for (const KeyValue<String, Transform3D> &F : cd.bone_rest_map) {
String name;
- if (!state.sid_to_node_map.has(F->key())) {
+ if (!state.sid_to_node_map.has(F.key)) {
continue;
}
- name = state.sid_to_node_map[F->key()];
+ name = state.sid_to_node_map[F.key];
ERR_CONTINUE(!state.scene_map.has(name));
@@ -2248,9 +2248,9 @@ bool Collada::_move_geometry_to_skeletons(VisualScene *p_vscene, Node *p_node, L
p_node->default_transform = skel_inv * (skin.bind_shape /* p_node->get_global_transform()*/); // i honestly have no idea what to do with a previous model xform.. most exporters ignore it
//make rests relative to the skeleton (they seem to be always relative to world)
- for (Map<String, Transform3D>::Element *E = skin.bone_rest_map.front(); E; E = E->next()) {
- E->get() = skel_inv * E->get(); //make the bone rest local to the skeleton
- state.bone_rest_map[E->key()] = E->get(); // make it remember where the bone is globally, now that it's relative
+ for (KeyValue<String, Transform3D> &E : skin.bone_rest_map) {
+ E.value = skel_inv * E.value; //make the bone rest local to the skeleton
+ state.bone_rest_map[E.key] = E.value; // make it remember where the bone is globally, now that it's relative
}
//but most exporters seem to work only if i do this..
@@ -2302,8 +2302,8 @@ void Collada::_find_morph_nodes(VisualScene *p_vscene, Node *p_node) {
}
void Collada::_optimize() {
- for (Map<String, VisualScene>::Element *E = state.visual_scene_map.front(); E; E = E->next()) {
- VisualScene &vs = E->get();
+ for (KeyValue<String, VisualScene> &E : state.visual_scene_map) {
+ VisualScene &vs = E.value;
for (int i = 0; i < vs.root_nodes.size(); i++) {
_create_skeletons(&vs.root_nodes.write[i]);
}
diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp
index 7ab80ac3b4..3de7426302 100644
--- a/editor/import/editor_import_collada.cpp
+++ b/editor/import/editor_import_collada.cpp
@@ -1314,8 +1314,8 @@ Error ColladaImport::load(const String &p_path, int p_flags, bool p_force_make_t
}
void ColladaImport::_fix_param_animation_tracks() {
- for (Map<String, Collada::Node *>::Element *E = collada.state.scene_map.front(); E; E = E->next()) {
- Collada::Node *n = E->get();
+ for (KeyValue<String, Collada::Node *> &E : collada.state.scene_map) {
+ Collada::Node *n = E.value;
switch (n->type) {
case Collada::Node::TYPE_NODE: {
// ? do nothing
@@ -1363,7 +1363,7 @@ void ColladaImport::_fix_param_animation_tracks() {
for (int rti = 0; rti < rt.size(); rti++) {
Collada::AnimationTrack *at = &collada.state.animation_tracks.write[rt[rti]];
- at->target = E->key();
+ at->target = E.key;
at->param = "morph/" + collada.state.mesh_name_map[mesh_name];
at->property = true;
//at->param
@@ -1431,11 +1431,11 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
animation->set_name(collada.state.animation_clips[p_clip].name);
}
- for (Map<String, NodeMap>::Element *E = node_map.front(); E; E = E->next()) {
- if (E->get().bone < 0) {
+ for (const KeyValue<String, NodeMap> &E : node_map) {
+ if (E.value.bone < 0) {
continue;
}
- bones_with_animation[E->key()] = false;
+ bones_with_animation[E.key] = false;
}
//store and validate tracks
@@ -1626,19 +1626,19 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
if (p_make_tracks_in_all_bones) {
//some bones may lack animation, but since we don't store pose as a property, we must add keyframes!
- for (Map<String, bool>::Element *E = bones_with_animation.front(); E; E = E->next()) {
- if (E->get()) {
+ for (const KeyValue<String, bool> &E : bones_with_animation) {
+ if (E.value) {
continue;
}
- NodeMap &nm = node_map[E->key()];
+ NodeMap &nm = node_map[E.key];
String path = scene->get_path_to(nm.node);
ERR_CONTINUE(nm.bone < 0);
Skeleton3D *sk = static_cast<Skeleton3D *>(nm.node);
String name = sk->get_bone_name(nm.bone);
path = path + ":" + name;
- Collada::Node *cn = collada.state.scene_map[E->key()];
+ Collada::Node *cn = collada.state.scene_map[E.key];
if (cn->ignore_anim) {
WARN_PRINT("Collada: Ignoring animation on node: " + path);
continue;
diff --git a/editor/import/editor_importer_bake_reset.cpp b/editor/import/editor_importer_bake_reset.cpp
index 00dce6850e..fb5de941ae 100644
--- a/editor/import/editor_importer_bake_reset.cpp
+++ b/editor/import/editor_importer_bake_reset.cpp
@@ -122,14 +122,14 @@ void BakeReset::_align_animations(AnimationPlayer *p_ap, const Map<StringName, B
for (List<StringName>::Element *anim_i = anim_names.front(); anim_i; anim_i = anim_i->next()) {
Ref<Animation> a = p_ap->get_animation(anim_i->get());
ERR_CONTINUE(a.is_null());
- for (Map<StringName, BakeResetRestBone>::Element *rest_bone_i = r_rest_bones.front(); rest_bone_i; rest_bone_i = rest_bone_i->next()) {
- int track = a->find_track(NodePath(rest_bone_i->key()));
+ for (const KeyValue<StringName, BakeResetRestBone> &rest_bone_i : r_rest_bones) {
+ int track = a->find_track(NodePath(rest_bone_i.key));
if (track == -1) {
continue;
}
int new_track = a->add_track(Animation::TYPE_TRANSFORM3D);
- NodePath new_path = NodePath(rest_bone_i->key());
- BakeResetRestBone rest_bone = rest_bone_i->get();
+ NodePath new_path = NodePath(rest_bone_i.key);
+ const BakeResetRestBone rest_bone = rest_bone_i.value;
a->track_set_path(new_track, new_path);
for (int key_i = 0; key_i < a->track_get_key_count(track); key_i++) {
Vector3 loc;
diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp
index 61745cb6ee..96a53b3257 100644
--- a/editor/import/resource_importer_texture.cpp
+++ b/editor/import/resource_importer_texture.cpp
@@ -86,28 +86,28 @@ void ResourceImporterTexture::update_imports() {
return;
}
- for (Map<StringName, MakeInfo>::Element *E = make_flags.front(); E; E = E->next()) {
+ for (const KeyValue<StringName, MakeInfo> &E : make_flags) {
Ref<ConfigFile> cf;
cf.instantiate();
- String src_path = String(E->key()) + ".import";
+ String src_path = String(E.key) + ".import";
Error err = cf->load(src_path);
ERR_CONTINUE(err != OK);
bool changed = false;
- if (E->get().flags & MAKE_NORMAL_FLAG && int(cf->get_value("params", "compress/normal_map")) == 0) {
+ if (E.value.flags & MAKE_NORMAL_FLAG && int(cf->get_value("params", "compress/normal_map")) == 0) {
cf->set_value("params", "compress/normal_map", 1);
changed = true;
}
- if (E->get().flags & MAKE_ROUGHNESS_FLAG && int(cf->get_value("params", "roughness/mode")) == 0) {
- cf->set_value("params", "roughness/mode", E->get().channel_for_roughness + 2);
- cf->set_value("params", "roughness/src_normal", E->get().normal_path_for_roughness);
+ if (E.value.flags & MAKE_ROUGHNESS_FLAG && int(cf->get_value("params", "roughness/mode")) == 0) {
+ cf->set_value("params", "roughness/mode", E.value.channel_for_roughness + 2);
+ cf->set_value("params", "roughness/src_normal", E.value.normal_path_for_roughness);
changed = true;
}
- if (E->get().flags & MAKE_3D_FLAG && bool(cf->get_value("params", "detect_3d/compress_to"))) {
+ if (E.value.flags & MAKE_3D_FLAG && bool(cf->get_value("params", "detect_3d/compress_to"))) {
int compress_to = cf->get_value("params", "detect_3d/compress_to");
cf->set_value("params", "detect_3d/compress_to", 0);
if (compress_to == 1) {
@@ -121,7 +121,7 @@ void ResourceImporterTexture::update_imports() {
if (changed) {
cf->save(src_path);
- to_reimport.push_back(E->key());
+ to_reimport.push_back(E.key);
}
}
diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp
index f99ab9888a..7ab5308a47 100644
--- a/editor/import/scene_import_settings.cpp
+++ b/editor/import/scene_import_settings.cpp
@@ -771,52 +771,52 @@ void SceneImportSettings::_re_import() {
Dictionary subresources;
- for (Map<String, NodeData>::Element *E = node_map.front(); E; E = E->next()) {
- if (E->get().settings.size()) {
+ for (KeyValue<String, NodeData> &E : node_map) {
+ if (E.value.settings.size()) {
Dictionary d;
- for (Map<StringName, Variant>::Element *F = E->get().settings.front(); F; F = F->next()) {
- d[String(F->key())] = F->get();
+ for (const KeyValue<StringName, Variant> &F : E.value.settings) {
+ d[String(F.key)] = F.value;
}
- nodes[E->key()] = d;
+ nodes[E.key] = d;
}
}
if (nodes.size()) {
subresources["nodes"] = nodes;
}
- for (Map<String, MaterialData>::Element *E = material_map.front(); E; E = E->next()) {
- if (E->get().settings.size()) {
+ for (KeyValue<String, MaterialData> &E : material_map) {
+ if (E.value.settings.size()) {
Dictionary d;
- for (Map<StringName, Variant>::Element *F = E->get().settings.front(); F; F = F->next()) {
- d[String(F->key())] = F->get();
+ for (const KeyValue<StringName, Variant> &F : E.value.settings) {
+ d[String(F.key)] = F.value;
}
- materials[E->key()] = d;
+ materials[E.key] = d;
}
}
if (materials.size()) {
subresources["materials"] = materials;
}
- for (Map<String, MeshData>::Element *E = mesh_map.front(); E; E = E->next()) {
- if (E->get().settings.size()) {
+ for (KeyValue<String, MeshData> &E : mesh_map) {
+ if (E.value.settings.size()) {
Dictionary d;
- for (Map<StringName, Variant>::Element *F = E->get().settings.front(); F; F = F->next()) {
- d[String(F->key())] = F->get();
+ for (const KeyValue<StringName, Variant> &F : E.value.settings) {
+ d[String(F.key)] = F.value;
}
- meshes[E->key()] = d;
+ meshes[E.key] = d;
}
}
if (meshes.size()) {
subresources["meshes"] = meshes;
}
- for (Map<String, AnimationData>::Element *E = animation_map.front(); E; E = E->next()) {
- if (E->get().settings.size()) {
+ for (KeyValue<String, AnimationData> &E : animation_map) {
+ if (E.value.settings.size()) {
Dictionary d;
- for (Map<StringName, Variant>::Element *F = E->get().settings.front(); F; F = F->next()) {
- d[String(F->key())] = F->get();
+ for (const KeyValue<StringName, Variant> &F : E.value.settings) {
+ d[String(F.key)] = F.value;
}
- animations[E->key()] = d;
+ animations[E.key] = d;
}
}
if (animations.size()) {
@@ -889,8 +889,8 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) {
switch (current_action) {
case ACTION_EXTRACT_MATERIALS: {
- for (Map<String, MaterialData>::Element *E = material_map.front(); E; E = E->next()) {
- MaterialData &md = material_map[E->key()];
+ for (const KeyValue<String, MaterialData> &E : material_map) {
+ MaterialData &md = material_map[E.key];
TreeItem *item = external_path_tree->create_item(root);
@@ -905,7 +905,7 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) {
item->set_text(2, "Already External");
item->set_tooltip(2, TTR("This material already references an external file, no action will be taken.\nDisable the external property for it to be extracted again."));
} else {
- item->set_metadata(0, E->key());
+ item->set_metadata(0, E.key);
item->set_editable(0, true);
item->set_checked(0, true);
String path = p_path.plus_file(name);
@@ -942,8 +942,8 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) {
external_paths->get_ok_button()->set_text(TTR("Extract"));
} break;
case ACTION_CHOOSE_MESH_SAVE_PATHS: {
- for (Map<String, MeshData>::Element *E = mesh_map.front(); E; E = E->next()) {
- MeshData &md = mesh_map[E->key()];
+ for (const KeyValue<String, MeshData> &E : mesh_map) {
+ MeshData &md = mesh_map[E.key];
TreeItem *item = external_path_tree->create_item(root);
@@ -958,7 +958,7 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) {
item->set_text(2, "Already Saving");
item->set_tooltip(2, TTR("This mesh already saves to an external resource, no action will be taken."));
} else {
- item->set_metadata(0, E->key());
+ item->set_metadata(0, E.key);
item->set_editable(0, true);
item->set_checked(0, true);
String path = p_path.plus_file(name);
@@ -995,8 +995,8 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) {
external_paths->get_ok_button()->set_text(TTR("Set Paths"));
} break;
case ACTION_CHOOSE_ANIMATION_SAVE_PATHS: {
- for (Map<String, AnimationData>::Element *E = animation_map.front(); E; E = E->next()) {
- AnimationData &ad = animation_map[E->key()];
+ for (const KeyValue<String, AnimationData> &E : animation_map) {
+ AnimationData &ad = animation_map[E.key];
TreeItem *item = external_path_tree->create_item(root);
@@ -1010,7 +1010,7 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) {
item->set_text(2, "Already Saving");
item->set_tooltip(2, TTR("This animation already saves to an external resource, no action will be taken."));
} else {
- item->set_metadata(0, E->key());
+ item->set_metadata(0, E.key);
item->set_editable(0, true);
item->set_checked(0, true);
String path = p_path.plus_file(name);
diff --git a/editor/import/scene_importer_mesh.cpp b/editor/import/scene_importer_mesh.cpp
index f83a7d046a..370394b475 100644
--- a/editor/import/scene_importer_mesh.cpp
+++ b/editor/import/scene_importer_mesh.cpp
@@ -966,8 +966,8 @@ Ref<NavigationMesh> EditorSceneImporterMesh::create_navigation_mesh() {
Vector<Vector3> vertices;
vertices.resize(unique_vertices.size());
- for (Map<Vector3, int>::Element *E = unique_vertices.front(); E; E = E->next()) {
- vertices.write[E->get()] = E->key();
+ for (const KeyValue<Vector3, int> &E : unique_vertices) {
+ vertices.write[E.value] = E.key;
}
Ref<NavigationMesh> nm;