From f1e8ec942d434ba8c72028031e7a539ec628df62 Mon Sep 17 00:00:00 2001 From: "K. S. Ernest (iFire) Lee" Date: Tue, 16 Mar 2021 12:18:32 -0700 Subject: [PATCH] Expand bone name possibilities. (cherry picked from commit c203fbfa8c4b4fe27cd29b03fa1d3ad068c9bef1) --- editor/import/editor_scene_importer_gltf.cpp | 25 ++++---------------- editor/import/editor_scene_importer_gltf.h | 2 +- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index 50bf635a2f92..3aa48a638828 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -35,7 +35,6 @@ #include "core/math/math_defs.h" #include "core/os/file_access.h" #include "core/os/os.h" -#include "modules/regex/regex.h" #include "scene/3d/bone_attachment.h" #include "scene/3d/camera.h" #include "scene/3d/mesh_instance.h" @@ -213,25 +212,11 @@ String EditorSceneImporterGLTF::_gen_unique_animation_name(GLTFState &state, con return name; } -String EditorSceneImporterGLTF::_sanitize_bone_name(const String &name) { - String p_name = name.camelcase_to_underscore(true); - - RegEx pattern_nocolon(":"); - p_name = pattern_nocolon.sub(p_name, "_", true); - - RegEx pattern_noslash("/"); - p_name = pattern_noslash.sub(p_name, "_", true); - - RegEx pattern_nospace(" +"); - p_name = pattern_nospace.sub(p_name, "_", true); - - RegEx pattern_multiple("_+"); - p_name = pattern_multiple.sub(p_name, "_", true); - - RegEx pattern_padded("0+(\\d+)"); - p_name = pattern_padded.sub(p_name, "$1", true); - - return p_name; +String EditorSceneImporterGLTF::_sanitize_bone_name(const String &p_name) { + String name = p_name; + name = name.replace(":", "_"); + name = name.replace("/", "_"); + return name; } String EditorSceneImporterGLTF::_gen_unique_bone_name(GLTFState &state, const GLTFSkeletonIndex skel_i, const String &p_name) { diff --git a/editor/import/editor_scene_importer_gltf.h b/editor/import/editor_scene_importer_gltf.h index 96e041aea8f4..d02a1f32bac8 100644 --- a/editor/import/editor_scene_importer_gltf.h +++ b/editor/import/editor_scene_importer_gltf.h @@ -364,7 +364,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { String _sanitize_animation_name(const String &p_name); String _gen_unique_animation_name(GLTFState &state, const String &p_name); - String _sanitize_bone_name(const String &name); + String _sanitize_bone_name(const String &p_name); String _gen_unique_bone_name(GLTFState &state, const GLTFSkeletonIndex skel_i, const String &p_name); Ref _get_texture(GLTFState &state, const GLTFTextureIndex p_texture);