diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-09-30 23:52:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-30 23:52:46 +0200 |
commit | 77721b35ba21f2e7e8bb42cf415fccb018517843 (patch) | |
tree | 96b8f7532ae5d923b75bfbac8d6763015b6646bb /modules/fbx | |
parent | 3e1b6304613855cad56938e8a58848f09363a298 (diff) | |
parent | c63b18507d21b8a213c073bced9057b571cdcd7a (diff) |
Merge pull request #51409 from LightningAA/use-map-iterators
Use range iterators for `Map` in most cases
Diffstat (limited to 'modules/fbx')
-rw-r--r-- | modules/fbx/data/fbx_skeleton.cpp | 6 | ||||
-rw-r--r-- | modules/fbx/editor_scene_importer_fbx.cpp | 34 | ||||
-rw-r--r-- | modules/fbx/tools/validation_tools.h | 6 |
3 files changed, 23 insertions, 23 deletions
diff --git a/modules/fbx/data/fbx_skeleton.cpp b/modules/fbx/data/fbx_skeleton.cpp index 1ac4922acf..3dc163964c 100644 --- a/modules/fbx/data/fbx_skeleton.cpp +++ b/modules/fbx/data/fbx_skeleton.cpp @@ -98,9 +98,9 @@ void FBXSkeleton::init_skeleton(const ImportState &state) { ERR_FAIL_COND_MSG(skeleton->get_bone_count() != bone_count, "Not all bones got added, is the file corrupted?"); - for (Map<int, Ref<FBXBone>>::Element *bone_element = bone_map.front(); bone_element; bone_element = bone_element->next()) { - const Ref<FBXBone> bone = bone_element->value(); - int bone_index = bone_element->key(); + for (const KeyValue<int, Ref<FBXBone>> &bone_element : bone_map) { + const Ref<FBXBone> bone = bone_element.value; + int bone_index = bone_element.key; print_verbose("working on bone: " + itos(bone_index) + " bone name:" + bone->bone_name); skeleton->set_bone_rest(bone->godot_bone_id, get_unscaled_transform(bone->node->pivot_transform->LocalTransform, state.scale)); diff --git a/modules/fbx/editor_scene_importer_fbx.cpp b/modules/fbx/editor_scene_importer_fbx.cpp index e3f36ef3e3..e0663ab49d 100644 --- a/modules/fbx/editor_scene_importer_fbx.cpp +++ b/modules/fbx/editor_scene_importer_fbx.cpp @@ -567,8 +567,8 @@ Node3D *EditorSceneImporterFBX::_generate_scene( // this means that the nodes from maya kLocators will be preserved as bones // in the same rig without having to match this across skeletons and merge by detection // we can just merge and undo any parent transforms - for (Map<uint64_t, Ref<FBXBone>>::Element *bone_element = state.fbx_bone_map.front(); bone_element; bone_element = bone_element->next()) { - Ref<FBXBone> bone = bone_element->value(); + for (KeyValue<uint64_t, Ref<FBXBone>> &bone_element : state.fbx_bone_map) { + Ref<FBXBone> bone = bone_element.value; Ref<FBXSkeleton> fbx_skeleton_inst; uint64_t armature_id = bone->armature_id; @@ -609,8 +609,8 @@ Node3D *EditorSceneImporterFBX::_generate_scene( } // setup skeleton instances if required :) - for (Map<uint64_t, Ref<FBXSkeleton>>::Element *skeleton_node = state.skeleton_map.front(); skeleton_node; skeleton_node = skeleton_node->next()) { - Ref<FBXSkeleton> &skeleton = skeleton_node->value(); + for (KeyValue<uint64_t, Ref<FBXSkeleton>> &skeleton_node : state.skeleton_map) { + Ref<FBXSkeleton> &skeleton = skeleton_node.value; skeleton->init_skeleton(state); ERR_CONTINUE_MSG(skeleton->fbx_node.is_null(), "invalid fbx target map, missing skeleton"); @@ -699,9 +699,9 @@ Node3D *EditorSceneImporterFBX::_generate_scene( } } - for (Map<uint64_t, Ref<FBXMeshData>>::Element *mesh_data = state.renderer_mesh_data.front(); mesh_data; mesh_data = mesh_data->next()) { - const uint64_t mesh_id = mesh_data->key(); - Ref<FBXMeshData> mesh = mesh_data->value(); + for (KeyValue<uint64_t, Ref<FBXMeshData>> &mesh_data : state.renderer_mesh_data) { + const uint64_t mesh_id = mesh_data.key; + Ref<FBXMeshData> mesh = mesh_data.value; const FBXDocParser::MeshGeometry *mesh_geometry = p_document->GetObject(mesh_id)->Get<FBXDocParser::MeshGeometry>(); @@ -765,9 +765,9 @@ Node3D *EditorSceneImporterFBX::_generate_scene( } // mesh data iteration for populating skeleton mapping - for (Map<uint64_t, Ref<FBXMeshData>>::Element *mesh_data = state.renderer_mesh_data.front(); mesh_data; mesh_data = mesh_data->next()) { - Ref<FBXMeshData> mesh = mesh_data->value(); - const uint64_t mesh_id = mesh_data->key(); + for (KeyValue<uint64_t, Ref<FBXMeshData>> &mesh_data : state.renderer_mesh_data) { + Ref<FBXMeshData> mesh = mesh_data.value; + const uint64_t mesh_id = mesh_data.key; EditorSceneImporterMeshNode3D *mesh_instance = mesh->godot_mesh_instance; const int mesh_weights = mesh->max_weight_count; Ref<FBXSkeleton> skeleton; @@ -1004,13 +1004,13 @@ Node3D *EditorSceneImporterFBX::_generate_scene( // target id, [ track name, [time index, vector] ] //std::map<uint64_t, std::map<StringName, FBXTrack > > AnimCurveNodes; - for (Map<uint64_t, Map<StringName, FBXTrack>>::Element *track = AnimCurveNodes.front(); track; track = track->next()) { + for (KeyValue<uint64_t, Map<StringName, FBXTrack>> &track : AnimCurveNodes) { // 5 tracks // current track index // track count is 5 // track count is 5. // next track id is 5. - const uint64_t target_id = track->key(); + const uint64_t target_id = track.key; int track_idx = animation->add_track(Animation::TYPE_TRANSFORM3D); // animation->track_set_path(track_idx, node_path); @@ -1072,7 +1072,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene( const FBXDocParser::Model *model = target_node->fbx_model; const FBXDocParser::PropertyTable *props = dynamic_cast<const FBXDocParser::PropertyTable *>(model); - Map<StringName, FBXTrack> &track_data = track->value(); + Map<StringName, FBXTrack> &track_data = track.value; FBXTrack &translation_keys = track_data[StringName("T")]; FBXTrack &rotation_keys = track_data[StringName("R")]; FBXTrack &scale_keys = track_data[StringName("S")]; @@ -1259,15 +1259,15 @@ Node3D *EditorSceneImporterFBX::_generate_scene( state.fbx_target_map.clear(); state.fbx_node_list.clear(); - for (Map<uint64_t, Ref<FBXBone>>::Element *element = state.fbx_bone_map.front(); element; element = element->next()) { - Ref<FBXBone> bone = element->value(); + for (KeyValue<uint64_t, Ref<FBXBone>> &element : state.fbx_bone_map) { + Ref<FBXBone> bone = element.value; bone->parent_bone.unref(); bone->node.unref(); bone->fbx_skeleton.unref(); } - for (Map<uint64_t, Ref<FBXSkeleton>>::Element *element = state.skeleton_map.front(); element; element = element->next()) { - Ref<FBXSkeleton> skel = element->value(); + for (KeyValue<uint64_t, Ref<FBXSkeleton>> &element : state.skeleton_map) { + Ref<FBXSkeleton> skel = element.value; skel->fbx_node.unref(); skel->skeleton_bones.clear(); } diff --git a/modules/fbx/tools/validation_tools.h b/modules/fbx/tools/validation_tools.h index 906a721045..12d644ee94 100644 --- a/modules/fbx/tools/validation_tools.h +++ b/modules/fbx/tools/validation_tools.h @@ -53,9 +53,9 @@ protected: String csv_header = "file_path, error message, extra data\n"; massive_log_file += csv_header; - for (Map<String, LocalVector<String>>::Element *element = validation_entries.front(); element; element = element->next()) { - for (unsigned int x = 0; x < element->value().size(); x++) { - const String &line_entry = element->key() + ", " + element->value()[x].c_escape() + "\n"; + for (const KeyValue<String, LocalVector<String>> &element : validation_entries) { + for (unsigned int x = 0; x < element.value.size(); x++) { + const String &line_entry = element.key + ", " + element.value[x].c_escape() + "\n"; massive_log_file += line_entry; } } |