summaryrefslogtreecommitdiff
path: root/editor/import
diff options
context:
space:
mode:
Diffstat (limited to 'editor/import')
-rw-r--r--editor/import/collada.cpp26
-rw-r--r--editor/import/collada.h72
-rw-r--r--editor/import/dynamic_font_import_settings.cpp86
-rw-r--r--editor/import/dynamic_font_import_settings.h13
-rw-r--r--editor/import/editor_import_collada.cpp52
-rw-r--r--editor/import/editor_import_collada.h2
-rw-r--r--editor/import/editor_import_plugin.cpp16
-rw-r--r--editor/import/editor_import_plugin.h4
-rw-r--r--editor/import/post_import_plugin_skeleton_renamer.cpp144
-rw-r--r--editor/import/post_import_plugin_skeleton_renamer.h46
-rw-r--r--editor/import/resource_importer_bitmask.cpp4
-rw-r--r--editor/import/resource_importer_bitmask.h4
-rw-r--r--editor/import/resource_importer_bmfont.cpp4
-rw-r--r--editor/import/resource_importer_bmfont.h4
-rw-r--r--editor/import/resource_importer_csv_translation.cpp4
-rw-r--r--editor/import/resource_importer_csv_translation.h4
-rw-r--r--editor/import/resource_importer_dynamic_font.cpp11
-rw-r--r--editor/import/resource_importer_dynamic_font.h4
-rw-r--r--editor/import/resource_importer_image.cpp4
-rw-r--r--editor/import/resource_importer_image.h4
-rw-r--r--editor/import/resource_importer_imagefont.cpp6
-rw-r--r--editor/import/resource_importer_imagefont.h4
-rw-r--r--editor/import/resource_importer_layered_texture.cpp4
-rw-r--r--editor/import/resource_importer_layered_texture.h6
-rw-r--r--editor/import/resource_importer_obj.cpp12
-rw-r--r--editor/import/resource_importer_obj.h6
-rw-r--r--editor/import/resource_importer_scene.cpp157
-rw-r--r--editor/import/resource_importer_scene.h32
-rw-r--r--editor/import/resource_importer_shader_file.cpp4
-rw-r--r--editor/import/resource_importer_shader_file.h4
-rw-r--r--editor/import/resource_importer_texture.cpp12
-rw-r--r--editor/import/resource_importer_texture.h6
-rw-r--r--editor/import/resource_importer_texture_atlas.cpp24
-rw-r--r--editor/import/resource_importer_texture_atlas.h6
-rw-r--r--editor/import/resource_importer_wav.cpp68
-rw-r--r--editor/import/resource_importer_wav.h4
-rw-r--r--editor/import/scene_import_settings.cpp32
-rw-r--r--editor/import/scene_import_settings.h27
38 files changed, 636 insertions, 286 deletions
diff --git a/editor/import/collada.cpp b/editor/import/collada.cpp
index e68c5e9a22..f4d19fe8b6 100644
--- a/editor/import/collada.cpp
+++ b/editor/import/collada.cpp
@@ -1645,12 +1645,12 @@ void Collada::_parse_animation(XMLParser &parser) {
return;
}
- Map<String, Vector<float>> float_sources;
- Map<String, Vector<String>> string_sources;
- Map<String, int> source_strides;
- Map<String, Map<String, String>> samplers;
- Map<String, Vector<String>> source_param_names;
- Map<String, Vector<String>> source_param_types;
+ HashMap<String, Vector<float>> float_sources;
+ HashMap<String, Vector<String>> string_sources;
+ HashMap<String, int> source_strides;
+ HashMap<String, HashMap<String, String>> samplers;
+ HashMap<String, Vector<String>> source_param_names;
+ HashMap<String, Vector<String>> source_param_types;
String id = "";
if (parser.has_attribute("id")) {
@@ -1685,7 +1685,7 @@ void Collada::_parse_animation(XMLParser &parser) {
}
} else if (name == "sampler") {
current_sampler = parser.get_attribute_value("id");
- samplers[current_sampler] = Map<String, String>();
+ samplers[current_sampler] = HashMap<String, String>();
} else if (name == "param") {
if (parser.has_attribute("name")) {
source_param_names[current_source].push_back(parser.get_attribute_value("name"));
@@ -1718,7 +1718,7 @@ void Collada::_parse_animation(XMLParser &parser) {
String source = _uri_to_id(channel_sources[i]);
String target = channel_targets[i];
ERR_CONTINUE(!samplers.has(source));
- Map<String, String> &sampler = samplers[source];
+ HashMap<String, String> &sampler = samplers[source];
ERR_CONTINUE(!sampler.has("INPUT")); //no input semantic? wtf?
String input_id = _uri_to_id(sampler["INPUT"]);
@@ -2029,7 +2029,7 @@ void Collada::_merge_skeletons(VisualScene *p_vscene, Node *p_node) {
NodeGeometry *gnode = static_cast<NodeGeometry *>(p_node);
if (gnode->controller) {
// recount skeletons used
- Set<NodeSkeleton *> skeletons;
+ HashSet<NodeSkeleton *> skeletons;
for (int i = 0; i < gnode->skeletons.size(); i++) {
String nodeid = gnode->skeletons[i];
@@ -2049,11 +2049,11 @@ void Collada::_merge_skeletons(VisualScene *p_vscene, Node *p_node) {
if (skeletons.size() > 1) {
//do the merger!!
- Set<NodeSkeleton *>::Element *E = skeletons.front();
- NodeSkeleton *base = E->get();
+ HashSet<NodeSkeleton *>::Iterator E = skeletons.begin();
+ NodeSkeleton *base = *E;
- for (E = E->next(); E; E = E->next()) {
- NodeSkeleton *merged = E->get();
+ for (++E; E; ++E) {
+ NodeSkeleton *merged = *E;
_remove_node(p_vscene, merged);
for (int i = 0; i < merged->children.size(); i++) {
_joint_set_owner(merged->children[i], base);
diff --git a/editor/import/collada.h b/editor/import/collada.h
index df2b789081..f1d9c5593f 100644
--- a/editor/import/collada.h
+++ b/editor/import/collada.h
@@ -33,7 +33,7 @@
#include "core/config/project_settings.h"
#include "core/io/xml_parser.h"
-#include "core/templates/map.h"
+#include "core/templates/rb_map.h"
#include "scene/resources/material.h"
class Collada {
@@ -54,7 +54,7 @@ public:
struct Effect {
String name;
- Map<String, Variant> params;
+ HashMap<String, Variant> params;
struct Channel {
int uv_idx = 0;
@@ -131,13 +131,13 @@ public:
int stride = 0;
};
- Map<String, Source> sources;
+ HashMap<String, Source> sources;
struct Vertices {
- Map<String, String> sources;
+ HashMap<String, String> sources;
};
- Map<String, Vertices> vertices;
+ HashMap<String, Vertices> vertices;
struct Primitives {
struct SourceRef {
@@ -146,7 +146,7 @@ public:
};
String material;
- Map<String, SourceRef> sources;
+ HashMap<String, SourceRef> sources;
Vector<float> polygons;
Vector<float> indices;
int count = 0;
@@ -171,9 +171,9 @@ public:
int stride = 0;
};
- Map<String, Source> sources;
+ HashMap<String, Source> sources;
- Map<String, String> control_vertices;
+ HashMap<String, String> control_vertices;
CurveData() {}
};
@@ -191,10 +191,10 @@ public:
Source() {}
};
- Map<String, Source> sources;
+ HashMap<String, Source> sources;
struct Joints {
- Map<String, String> sources;
+ HashMap<String, String> sources;
} joints;
struct Weights {
@@ -204,13 +204,13 @@ public:
};
String material;
- Map<String, SourceRef> sources;
+ HashMap<String, SourceRef> sources;
Vector<float> sets;
Vector<float> indices;
int count = 0;
} weights;
- Map<String, Transform3D> bone_rest_map;
+ HashMap<String, Transform3D> bone_rest_map;
SkinControllerData() {}
};
@@ -226,9 +226,9 @@ public:
Source() {}
};
- Map<String, Source> sources;
+ HashMap<String, Source> sources;
- Map<String, String> targets;
+ HashMap<String, String> targets;
MorphControllerData() {}
};
@@ -382,7 +382,7 @@ public:
String target;
};
- Map<String, Material> material_map;
+ HashMap<String, Material> material_map;
Vector<String> skeletons;
NodeGeometry() { type = TYPE_GEOMETRY; }
@@ -476,28 +476,28 @@ public:
}
} version;
- Map<String, CameraData> camera_data_map;
- Map<String, MeshData> mesh_data_map;
- Map<String, LightData> light_data_map;
- Map<String, CurveData> curve_data_map;
+ HashMap<String, CameraData> camera_data_map;
+ HashMap<String, MeshData> mesh_data_map;
+ HashMap<String, LightData> light_data_map;
+ HashMap<String, CurveData> curve_data_map;
- Map<String, String> mesh_name_map;
- Map<String, String> morph_name_map;
- Map<String, String> morph_ownership_map;
- Map<String, SkinControllerData> skin_controller_data_map;
- Map<String, MorphControllerData> morph_controller_data_map;
+ HashMap<String, String> mesh_name_map;
+ HashMap<String, String> morph_name_map;
+ HashMap<String, String> morph_ownership_map;
+ HashMap<String, SkinControllerData> skin_controller_data_map;
+ HashMap<String, MorphControllerData> morph_controller_data_map;
- Map<String, Image> image_map;
- Map<String, Material> material_map;
- Map<String, Effect> effect_map;
+ HashMap<String, Image> image_map;
+ HashMap<String, Material> material_map;
+ HashMap<String, Effect> effect_map;
- Map<String, VisualScene> visual_scene_map;
- Map<String, Node *> scene_map;
- Set<String> idref_joints;
- Map<String, String> sid_to_node_map;
- //Map<String,NodeJoint*> bone_map;
+ HashMap<String, VisualScene> visual_scene_map;
+ HashMap<String, Node *> scene_map;
+ HashSet<String> idref_joints;
+ HashMap<String, String> sid_to_node_map;
+ //RBMap<String,NodeJoint*> bone_map;
- Map<String, Transform3D> bone_rest_map;
+ HashMap<String, Transform3D> bone_rest_map;
String local_path;
String root_visual_scene;
@@ -505,8 +505,8 @@ public:
Vector<AnimationClip> animation_clips;
Vector<AnimationTrack> animation_tracks;
- Map<String, Vector<int>> referenced_tracks;
- Map<String, Vector<int>> by_id_tracks;
+ HashMap<String, Vector<int>> referenced_tracks;
+ HashMap<String, Vector<int>> by_id_tracks;
float animation_length = 0;
@@ -524,7 +524,7 @@ public:
int get_uv_channel(String p_name);
private: // private stuff
- Map<String, int> channel_map;
+ HashMap<String, int> channel_map;
void _parse_asset(XMLParser &parser);
void _parse_image(XMLParser &parser);
diff --git a/editor/import/dynamic_font_import_settings.cpp b/editor/import/dynamic_font_import_settings.cpp
index 451cb245dd..f7fe334828 100644
--- a/editor/import/dynamic_font_import_settings.cpp
+++ b/editor/import/dynamic_font_import_settings.cpp
@@ -45,8 +45,8 @@ class DynamicFontImportSettingsData : public RefCounted {
GDCLASS(DynamicFontImportSettingsData, RefCounted)
friend class DynamicFontImportSettings;
- Map<StringName, Variant> settings;
- Map<StringName, Variant> defaults;
+ HashMap<StringName, Variant> settings;
+ HashMap<StringName, Variant> defaults;
List<ResourceImporter::ImportOption> options;
DynamicFontImportSettings *owner = nullptr;
@@ -454,7 +454,11 @@ void DynamicFontImportSettings::_add_glyph_range_item(int32_t p_start, int32_t p
void DynamicFontImportSettings::_main_prop_changed(const String &p_edited_property) {
// Update font preview.
- if (p_edited_property == "antialiased") {
+ if (p_edited_property == "face_index") {
+ if (font_preview->get_data_count() > 0) {
+ font_preview->get_data(0)->set_face_index(import_settings_data->get("face_index"));
+ }
+ } else if (p_edited_property == "antialiased") {
if (font_preview->get_data_count() > 0) {
font_preview->get_data(0)->set_antialiased(import_settings_data->get("antialiased"));
}
@@ -547,7 +551,11 @@ void DynamicFontImportSettings::_variation_selected() {
}
}
-void DynamicFontImportSettings::_variation_remove(Object *p_item, int p_column, int p_id) {
+void DynamicFontImportSettings::_variation_remove(Object *p_item, int p_column, int p_id, MouseButton p_button) {
+ if (p_button != MouseButton::LEFT) {
+ return;
+ }
+
TreeItem *vars_item = (TreeItem *)p_item;
ERR_FAIL_NULL(vars_item);
@@ -581,10 +589,10 @@ void DynamicFontImportSettings::_variations_validate() {
for (TreeItem *vars_item_b = vars_list_root->get_first_child(); vars_item_b; vars_item_b = vars_item_b->get_next()) {
if (vars_item_b != vars_item_a) {
bool match = true;
- for (Map<StringName, Variant>::Element *E = import_variation_data_a->settings.front(); E; E = E->next()) {
+ for (const KeyValue<StringName, Variant> &E : import_variation_data_a->settings) {
Ref<DynamicFontImportSettingsData> import_variation_data_b = vars_item_b->get_metadata(0);
ERR_FAIL_NULL(import_variation_data_b);
- match = match && (import_variation_data_b->settings[E->key()] == E->get());
+ match = match && (import_variation_data_b->settings[E.key] == E.value);
}
if (match) {
warn = TTR("Warning: Multiple configurations have identical settings. Duplicates will be ignored.");
@@ -621,7 +629,7 @@ void DynamicFontImportSettings::_change_text_opts() {
void DynamicFontImportSettings::_glyph_clear() {
selected_glyphs.clear();
- label_glyphs->set_text(TTR("Preloaded glyphs: ") + itos(selected_glyphs.size()));
+ label_glyphs->set_text(TTR("Preloaded glyphs:") + " " + itos(selected_glyphs.size()));
_range_selected();
}
@@ -650,7 +658,7 @@ void DynamicFontImportSettings::_glyph_text_selected() {
}
}
TS->free_rid(text_rid);
- label_glyphs->set_text(TTR("Preloaded glyphs: ") + itos(selected_glyphs.size()));
+ label_glyphs->set_text(TTR("Preloaded glyphs:") + " " + itos(selected_glyphs.size()));
}
_range_selected();
}
@@ -677,7 +685,7 @@ void DynamicFontImportSettings::_glyph_selected() {
item->clear_custom_bg_color(glyph_table->get_selected_column());
}
}
- label_glyphs->set_text(TTR("Preloaded glyphs: ") + itos(selected_glyphs.size()));
+ label_glyphs->set_text(TTR("Preloaded glyphs:") + " " + itos(selected_glyphs.size()));
item = glyph_tree->get_selected();
ERR_FAIL_NULL(item);
@@ -765,7 +773,7 @@ void DynamicFontImportSettings::_edit_range(int32_t p_start, int32_t p_end) {
col = 0;
}
}
- label_glyphs->set_text(TTR("Preloaded glyphs: ") + itos(selected_glyphs.size()));
+ label_glyphs->set_text(TTR("Preloaded glyphs:") + " " + itos(selected_glyphs.size()));
}
bool DynamicFontImportSettings::_char_update(int32_t p_char) {
@@ -832,7 +840,11 @@ void DynamicFontImportSettings::_lang_add_item(const String &p_locale) {
lang_item->set_button_color(2, 0, Color(1, 1, 1, 0.75));
}
-void DynamicFontImportSettings::_lang_remove(Object *p_item, int p_column, int p_id) {
+void DynamicFontImportSettings::_lang_remove(Object *p_item, int p_column, int p_id, MouseButton p_button) {
+ if (p_button != MouseButton::LEFT) {
+ return;
+ }
+
TreeItem *lang_item = (TreeItem *)p_item;
ERR_FAIL_NULL(lang_item);
@@ -864,7 +876,11 @@ void DynamicFontImportSettings::_ot_add_item(int p_option) {
ot_item->set_button_color(2, 0, Color(1, 1, 1, 0.75));
}
-void DynamicFontImportSettings::_ot_remove(Object *p_item, int p_column, int p_id) {
+void DynamicFontImportSettings::_ot_remove(Object *p_item, int p_column, int p_id, MouseButton p_button) {
+ if (p_button != MouseButton::LEFT) {
+ return;
+ }
+
TreeItem *ot_item = (TreeItem *)p_item;
ERR_FAIL_NULL(ot_item);
@@ -891,7 +907,11 @@ void DynamicFontImportSettings::_script_add_item(int p_option) {
script_item->set_button_color(2, 0, Color(1, 1, 1, 0.75));
}
-void DynamicFontImportSettings::_script_remove(Object *p_item, int p_column, int p_id) {
+void DynamicFontImportSettings::_script_remove(Object *p_item, int p_column, int p_id, MouseButton p_button) {
+ if (p_button != MouseButton::LEFT) {
+ return;
+ }
+
TreeItem *script_item = (TreeItem *)p_item;
ERR_FAIL_NULL(script_item);
@@ -927,8 +947,9 @@ void DynamicFontImportSettings::_notification(int p_what) {
}
void DynamicFontImportSettings::_re_import() {
- Map<StringName, Variant> main_settings;
+ HashMap<StringName, Variant> main_settings;
+ main_settings["face_index"] = import_settings_data->get("face_index");
main_settings["antialiased"] = import_settings_data->get("antialiased");
main_settings["generate_mipmaps"] = import_settings_data->get("generate_mipmaps");
main_settings["multichannel_signed_distance_field"] = import_settings_data->get("multichannel_signed_distance_field");
@@ -950,11 +971,11 @@ void DynamicFontImportSettings::_re_import() {
String name = vars_item->get_text(0);
variation += ("name=" + name);
- for (Map<StringName, Variant>::Element *E = import_variation_data->settings.front(); E; E = E->next()) {
+ for (const KeyValue<StringName, Variant> &E : import_variation_data->settings) {
if (!variation.is_empty()) {
variation += ",";
}
- variation += (String(E->key()) + "=" + String(E->get()));
+ variation += (String(E.key) + "=" + String(E.value));
}
variations.push_back(variation);
}
@@ -991,7 +1012,7 @@ void DynamicFontImportSettings::_re_import() {
if (!selected_chars.is_empty()) {
Vector<String> ranges;
char32_t start = selected_chars.front()->get();
- for (Set<char32_t>::Element *E = selected_chars.front()->next(); E; E = E->next()) {
+ for (RBSet<char32_t>::Element *E = selected_chars.front()->next(); E; E = E->next()) {
if (E->prev() && ((E->prev()->get() + 1) != E->get())) {
ranges.push_back(String("0x") + String::num_int64(start, 16) + String("-0x") + String::num_int64(E->prev()->get(), 16));
start = E->get();
@@ -1004,7 +1025,7 @@ void DynamicFontImportSettings::_re_import() {
if (!selected_glyphs.is_empty()) {
Vector<String> ranges;
int32_t start = selected_glyphs.front()->get();
- for (Set<int32_t>::Element *E = selected_glyphs.front()->next(); E; E = E->next()) {
+ for (RBSet<int32_t>::Element *E = selected_glyphs.front()->next(); E; E = E->next()) {
if (E->prev() && ((E->prev()->get() + 1) != E->get())) {
ranges.push_back(String("0x") + String::num_int64(start, 16) + String("-0x") + String::num_int64(E->prev()->get(), 16));
start = E->get();
@@ -1024,8 +1045,8 @@ void DynamicFontImportSettings::_re_import() {
if (OS::get_singleton()->is_stdout_verbose()) {
print_line("Import settings:");
- for (Map<StringName, Variant>::Element *E = main_settings.front(); E; E = E->next()) {
- print_line(String(" ") + String(E->key()).utf8().get_data() + " == " + String(E->get()).utf8().get_data());
+ for (const KeyValue<StringName, Variant> &E : main_settings) {
+ print_line(String(" ") + String(E.key).utf8().get_data() + " == " + String(E.value).utf8().get_data());
}
}
@@ -1276,13 +1297,14 @@ void DynamicFontImportSettings::open_settings(const String &p_path) {
}
}
}
- label_glyphs->set_text(TTR("Preloaded glyphs: ") + itos(selected_glyphs.size()));
+ label_glyphs->set_text(TTR("Preloaded glyphs:") + " " + itos(selected_glyphs.size()));
import_settings_data->options = options_general;
inspector_general->edit(import_settings_data.ptr());
import_settings_data->notify_property_list_changed();
if (font_preview->get_data_count() > 0) {
+ font_preview->get_data(0)->set_face_index(import_settings_data->get("face_index"));
font_preview->get_data(0)->set_antialiased(import_settings_data->get("antialiased"));
font_preview->get_data(0)->set_multichannel_signed_distance_field(import_settings_data->get("multichannel_signed_distance_field"));
font_preview->get_data(0)->set_msdf_pixel_range(import_settings_data->get("msdf_pixel_range"));
@@ -1344,6 +1366,7 @@ DynamicFontImportSettings *DynamicFontImportSettings::get_singleton() {
DynamicFontImportSettings::DynamicFontImportSettings() {
singleton = this;
+ options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "face_index"), 0));
options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "antialiased"), true));
options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "generate_mipmaps"), false));
options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "multichannel_signed_distance_field", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), true));
@@ -1402,6 +1425,7 @@ DynamicFontImportSettings::DynamicFontImportSettings() {
main_pages->set_tab_alignment(TabBar::ALIGNMENT_CENTER);
main_pages->set_v_size_flags(Control::SIZE_EXPAND_FILL);
main_pages->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ main_pages->set_theme_type_variation("TabContainerOdd");
root_vb->add_child(main_pages);
label_warn = memnew(Label);
@@ -1431,7 +1455,7 @@ DynamicFontImportSettings::DynamicFontImportSettings() {
font_preview_label->add_theme_font_size_override("font_size", 200 * EDSCALE);
font_preview_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
font_preview_label->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER);
- font_preview_label->set_autowrap_mode(Label::AUTOWRAP_ARBITRARY);
+ font_preview_label->set_autowrap_mode(TextServer::AUTOWRAP_ARBITRARY);
font_preview_label->set_clip_text(true);
font_preview_label->set_v_size_flags(Control::SIZE_EXPAND_FILL);
font_preview_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
@@ -1451,7 +1475,7 @@ DynamicFontImportSettings::DynamicFontImportSettings() {
page2_description = memnew(Label);
page2_description->set_text(TTR("Add font size, variation coordinates, and extra spacing combinations to pre-render:"));
page2_description->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- page2_description->set_autowrap_mode(Label::AUTOWRAP_WORD_SMART);
+ page2_description->set_autowrap_mode(TextServer::AUTOWRAP_WORD_SMART);
page2_vb->add_child(page2_description);
HSplitContainer *page2_hb = memnew(HSplitContainer);
@@ -1487,7 +1511,7 @@ DynamicFontImportSettings::DynamicFontImportSettings() {
vars_list->set_column_expand(1, false);
vars_list->set_column_custom_minimum_width(1, 50 * EDSCALE);
vars_list->connect("item_selected", callable_mp(this, &DynamicFontImportSettings::_variation_selected));
- vars_list->connect("button_pressed", callable_mp(this, &DynamicFontImportSettings::_variation_remove));
+ vars_list->connect("button_clicked", callable_mp(this, &DynamicFontImportSettings::_variation_remove));
vars_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
inspector_vars = memnew(EditorInspector);
@@ -1503,7 +1527,7 @@ DynamicFontImportSettings::DynamicFontImportSettings() {
page3_description = memnew(Label);
page3_description->set_text(TTR("Enter a text to shape and add all required glyphs to pre-render list:"));
page3_description->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- page3_description->set_autowrap_mode(Label::AUTOWRAP_WORD_SMART);
+ page3_description->set_autowrap_mode(TextServer::AUTOWRAP_WORD_SMART);
page3_vb->add_child(page3_description);
HBoxContainer *ot_hb = memnew(HBoxContainer);
@@ -1539,7 +1563,7 @@ DynamicFontImportSettings::DynamicFontImportSettings() {
label_glyphs = memnew(Label);
text_hb->add_child(label_glyphs);
- label_glyphs->set_text(TTR("Preloaded glyphs: ") + itos(0));
+ label_glyphs->set_text(TTR("Preloaded glyphs:") + " " + itos(0));
label_glyphs->set_custom_minimum_size(Size2(50 * EDSCALE, 0));
Button *btn_fill = memnew(Button);
@@ -1560,7 +1584,7 @@ DynamicFontImportSettings::DynamicFontImportSettings() {
page4_description = memnew(Label);
page4_description->set_text(TTR("Add or remove additional glyphs from the character map to pre-render list:\nNote: Some stylistic alternatives and glyph variants do not have one-to-one correspondence to character, and not shown in this map, use \"Glyphs from the text\" to add these."));
page4_description->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- page4_description->set_autowrap_mode(Label::AUTOWRAP_WORD_SMART);
+ page4_description->set_autowrap_mode(TextServer::AUTOWRAP_WORD_SMART);
page4_vb->add_child(page4_description);
HSplitContainer *glyphs_split = memnew(HSplitContainer);
@@ -1611,7 +1635,7 @@ DynamicFontImportSettings::DynamicFontImportSettings() {
page5_description = memnew(Label);
page5_description->set_text(TTR("Add or remove language and script support overrides, to control fallback font selection order:"));
page5_description->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- page5_description->set_autowrap_mode(Label::AUTOWRAP_WORD_SMART);
+ page5_description->set_autowrap_mode(TextServer::AUTOWRAP_WORD_SMART);
page5_vb->add_child(page5_description);
HBoxContainer *hb_lang = memnew(HBoxContainer);
@@ -1639,7 +1663,7 @@ DynamicFontImportSettings::DynamicFontImportSettings() {
lang_list->set_column_custom_minimum_width(1, 80 * EDSCALE);
lang_list->set_column_expand(2, false);
lang_list->set_column_custom_minimum_width(2, 50 * EDSCALE);
- lang_list->connect("button_pressed", callable_mp(this, &DynamicFontImportSettings::_lang_remove));
+ lang_list->connect("button_clicked", callable_mp(this, &DynamicFontImportSettings::_lang_remove));
lang_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
HBoxContainer *hb_script = memnew(HBoxContainer);
@@ -1667,7 +1691,7 @@ DynamicFontImportSettings::DynamicFontImportSettings() {
script_list->set_column_custom_minimum_width(1, 80 * EDSCALE);
script_list->set_column_expand(2, false);
script_list->set_column_custom_minimum_width(2, 50 * EDSCALE);
- script_list->connect("button_pressed", callable_mp(this, &DynamicFontImportSettings::_script_remove));
+ script_list->connect("button_clicked", callable_mp(this, &DynamicFontImportSettings::_script_remove));
script_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
HBoxContainer *hb_ot = memnew(HBoxContainer);
@@ -1695,7 +1719,7 @@ DynamicFontImportSettings::DynamicFontImportSettings() {
ot_list->set_column_custom_minimum_width(1, 80 * EDSCALE);
ot_list->set_column_expand(2, false);
ot_list->set_column_custom_minimum_width(2, 50 * EDSCALE);
- ot_list->connect("button_pressed", callable_mp(this, &DynamicFontImportSettings::_ot_remove));
+ ot_list->connect("button_clicked", callable_mp(this, &DynamicFontImportSettings::_ot_remove));
ot_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
// Common
diff --git a/editor/import/dynamic_font_import_settings.h b/editor/import/dynamic_font_import_settings.h
index c1e868403f..ba75c98057 100644
--- a/editor/import/dynamic_font_import_settings.h
+++ b/editor/import/dynamic_font_import_settings.h
@@ -33,6 +33,7 @@
#include "editor/import/resource_importer_dynamic_font.h"
+#include "core/templates/rb_set.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/item_list.h"
#include "scene/gui/option_button.h"
@@ -90,7 +91,7 @@ class DynamicFontImportSettings : public ConfirmationDialog {
void _variation_add();
void _variation_selected();
- void _variation_remove(Object *p_item, int p_column, int p_id);
+ void _variation_remove(Object *p_item, int p_column, int p_id, MouseButton p_button);
void _variation_changed(const String &p_edited_property);
void _variations_validate();
@@ -144,15 +145,15 @@ class DynamicFontImportSettings : public ConfirmationDialog {
void _lang_add();
void _lang_add_item(const String &p_locale);
- void _lang_remove(Object *p_item, int p_column, int p_id);
+ void _lang_remove(Object *p_item, int p_column, int p_id, MouseButton p_button);
void _script_add();
void _script_add_item(int p_option);
- void _script_remove(Object *p_item, int p_column, int p_id);
+ void _script_remove(Object *p_item, int p_column, int p_id, MouseButton p_button);
void _ot_add();
void _ot_add_item(int p_option);
- void _ot_remove(Object *p_item, int p_column, int p_id);
+ void _ot_remove(Object *p_item, int p_column, int p_id, MouseButton p_button);
// Common
@@ -161,8 +162,8 @@ class DynamicFontImportSettings : public ConfirmationDialog {
Ref<Font> font_preview;
Ref<Font> font_main;
- Set<char32_t> selected_chars;
- Set<int32_t> selected_glyphs;
+ RBSet<char32_t> selected_chars;
+ RBSet<int32_t> selected_glyphs;
void _re_import();
diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp
index 013dcb5deb..8d44329022 100644
--- a/editor/import/editor_import_collada.cpp
+++ b/editor/import/editor_import_collada.cpp
@@ -67,34 +67,34 @@ struct ColladaImport {
bool use_mesh_builtin_materials = false;
float bake_fps = 15;
- Map<String, NodeMap> node_map; //map from collada node to engine node
- Map<String, String> node_name_map; //map from collada node to engine node
- Map<String, Ref<ImporterMesh>> mesh_cache;
- Map<String, Ref<Curve3D>> curve_cache;
- Map<String, Ref<Material>> material_cache;
- Map<Collada::Node *, Skeleton3D *> skeleton_map;
+ HashMap<String, NodeMap> node_map; //map from collada node to engine node
+ HashMap<String, String> node_name_map; //map from collada node to engine node
+ HashMap<String, Ref<ImporterMesh>> mesh_cache;
+ HashMap<String, Ref<Curve3D>> curve_cache;
+ HashMap<String, Ref<Material>> material_cache;
+ HashMap<Collada::Node *, Skeleton3D *> skeleton_map;
- Map<Skeleton3D *, Map<String, int>> skeleton_bone_map;
+ HashMap<Skeleton3D *, HashMap<String, int>> skeleton_bone_map;
- Set<String> valid_animated_nodes;
+ HashSet<String> valid_animated_nodes;
Vector<int> valid_animated_properties;
- Map<String, bool> bones_with_animation;
+ HashMap<String, bool> bones_with_animation;
- Set<String> mesh_unique_names;
- Set<String> material_unique_names;
+ HashSet<String> mesh_unique_names;
+ HashSet<String> material_unique_names;
Error _populate_skeleton(Skeleton3D *p_skeleton, Collada::Node *p_node, int &r_bone, int p_parent);
Error _create_scene_skeletons(Collada::Node *p_node);
Error _create_scene(Collada::Node *p_node, Node3D *p_parent);
Error _create_resources(Collada::Node *p_node, bool p_use_compression);
Error _create_material(const String &p_target);
- Error _create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p_mesh, const Map<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform3D &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<ImporterMesh>> p_morph_meshes = Vector<Ref<ImporterMesh>>(), bool p_use_compression = false, bool p_use_mesh_material = false);
+ Error _create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p_mesh, const HashMap<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform3D &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<ImporterMesh>> p_morph_meshes = Vector<Ref<ImporterMesh>>(), bool p_use_compression = false, bool p_use_mesh_material = false);
Error load(const String &p_path, int p_flags, bool p_force_make_tangents = false, bool p_use_compression = false);
void _fix_param_animation_tracks();
void create_animation(int p_clip, bool p_import_value_tracks);
void create_animations(bool p_import_value_tracks);
- Set<String> tracks_in_clips;
+ HashSet<String> tracks_in_clips;
Vector<String> missing_textures;
void _pre_process_lights(Collada::Node *p_node);
@@ -467,7 +467,7 @@ Error ColladaImport::_create_material(const String &p_target) {
return OK;
}
-Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p_mesh, const Map<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform3D &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<ImporterMesh>> p_morph_meshes, bool p_use_compression, bool p_use_mesh_material) {
+Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p_mesh, const HashMap<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform3D &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<ImporterMesh>> p_morph_meshes, bool p_use_compression, bool p_use_mesh_material) {
bool local_xform_mirror = p_local_xform.basis.determinant() < 0;
if (p_morph_data) {
@@ -637,7 +637,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p
/* ADD WEIGHTS IF EXIST */
/************************/
- Map<int, Vector<Collada::Vertex::Weight>> pre_weights;
+ HashMap<int, Vector<Collada::Vertex::Weight>> pre_weights;
bool has_weights = false;
@@ -727,7 +727,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p
has_weights = true;
}
- Set<Collada::Vertex> vertex_set; //vertex set will be the vertices
+ RBSet<Collada::Vertex> vertex_set; //vertex set will be the vertices
List<int> indices_list; //indices will be the indices
/**************************/
@@ -875,8 +875,8 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p
Vector<Collada::Vertex> vertex_array; //there we go, vertex array
vertex_array.resize(vertex_set.size());
- for (Set<Collada::Vertex>::Element *F = vertex_set.front(); F; F = F->next()) {
- vertex_array.write[F->get().idx] = F->get();
+ for (const Collada::Vertex &F : vertex_set) {
+ vertex_array.write[F.idx] = F;
}
if (has_weights) {
@@ -1127,7 +1127,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
Skeleton3D *sk = Object::cast_to<Skeleton3D>(nmsk.node);
ERR_FAIL_COND_V(!sk, ERR_INVALID_DATA);
ERR_FAIL_COND_V(!skeleton_bone_map.has(sk), ERR_INVALID_DATA);
- Map<String, int> &bone_remap_map = skeleton_bone_map[sk];
+ HashMap<String, int> &bone_remap_map = skeleton_bone_map[sk];
meshid = skin->base;
@@ -1452,7 +1452,7 @@ void ColladaImport::create_animation(int p_clip, bool p_import_value_tracks) {
//main anim
}
- Set<int> track_filter;
+ HashSet<int> track_filter;
if (p_clip == -1) {
for (int i = 0; i < collada.state.animation_clips.size(); i++) {
@@ -1507,14 +1507,14 @@ void ColladaImport::create_animation(int p_clip, bool p_import_value_tracks) {
bool tracks_found = false;
- for (Set<String>::Element *E = valid_animated_nodes.front(); E; E = E->next()) {
+ for (const String &E : valid_animated_nodes) {
// take snapshots
- if (!collada.state.scene_map.has(E->get())) {
+ if (!collada.state.scene_map.has(E)) {
continue;
}
- NodeMap &nm = node_map[E->get()];
+ NodeMap &nm = node_map[E];
String path = scene->get_path_to(nm.node);
if (nm.bone >= 0) {
@@ -1525,7 +1525,7 @@ void ColladaImport::create_animation(int p_clip, bool p_import_value_tracks) {
bool found_anim = false;
- Collada::Node *cn = collada.state.scene_map[E->get()];
+ Collada::Node *cn = collada.state.scene_map[E];
if (cn->ignore_anim) {
continue;
}
@@ -1665,7 +1665,7 @@ void ColladaImport::create_animation(int p_clip, bool p_import_value_tracks) {
if (nm.bone >= 0) {
if (found_anim) {
- bones_with_animation[E->get()] = true;
+ bones_with_animation[E] = true;
}
}
@@ -1754,7 +1754,7 @@ void EditorSceneFormatImporterCollada::get_extensions(List<String> *r_extensions
r_extensions->push_back("dae");
}
-Node *EditorSceneFormatImporterCollada::import_scene(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
+Node *EditorSceneFormatImporterCollada::import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
if (r_err) {
*r_err = OK;
}
diff --git a/editor/import/editor_import_collada.h b/editor/import/editor_import_collada.h
index be3f74d821..e45db47440 100644
--- a/editor/import/editor_import_collada.h
+++ b/editor/import/editor_import_collada.h
@@ -39,7 +39,7 @@ class EditorSceneFormatImporterCollada : public EditorSceneFormatImporter {
public:
virtual uint32_t get_import_flags() const override;
virtual void get_extensions(List<String> *r_extensions) const override;
- virtual Node *import_scene(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps = nullptr, Error *r_err = nullptr) override;
+ virtual Node *import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps = nullptr, Error *r_err = nullptr) override;
EditorSceneFormatImporterCollada();
};
diff --git a/editor/import/editor_import_plugin.cpp b/editor/import/editor_import_plugin.cpp
index f7d373ef60..e822b4963a 100644
--- a/editor/import/editor_import_plugin.cpp
+++ b/editor/import/editor_import_plugin.cpp
@@ -147,12 +147,12 @@ void EditorImportPlugin::get_import_options(const String &p_path, List<ResourceI
ERR_FAIL_MSG("Unimplemented _get_import_options in add-on.");
}
-bool EditorImportPlugin::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
+bool EditorImportPlugin::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
Dictionary d;
- Map<StringName, Variant>::Element *E = p_options.front();
+ HashMap<StringName, Variant>::ConstIterator E = p_options.begin();
while (E) {
- d[E->key()] = E->get();
- E = E->next();
+ d[E->key] = E->value;
+ ++E;
}
bool visible;
if (GDVIRTUAL_CALL(_get_option_visibility, p_path, p_option, d, visible)) {
@@ -162,14 +162,14 @@ bool EditorImportPlugin::get_option_visibility(const String &p_path, const Strin
ERR_FAIL_V_MSG(false, "Unimplemented _get_option_visibility in add-on.");
}
-Error EditorImportPlugin::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
+Error EditorImportPlugin::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
Dictionary options;
Array platform_variants, gen_files;
- Map<StringName, Variant>::Element *E = p_options.front();
+ HashMap<StringName, Variant>::ConstIterator E = p_options.begin();
while (E) {
- options[E->key()] = E->get();
- E = E->next();
+ options[E->key] = E->value;
+ ++E;
}
int err;
diff --git a/editor/import/editor_import_plugin.h b/editor/import/editor_import_plugin.h
index 6cff8fb917..44fbd41962 100644
--- a/editor/import/editor_import_plugin.h
+++ b/editor/import/editor_import_plugin.h
@@ -64,8 +64,8 @@ public:
virtual float get_priority() const override;
virtual int get_import_order() const override;
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset) const override;
- virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
- virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata = nullptr) override;
+ virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override;
+ virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata = nullptr) override;
};
#endif //EDITOR_IMPORT_PLUGIN_H
diff --git a/editor/import/post_import_plugin_skeleton_renamer.cpp b/editor/import/post_import_plugin_skeleton_renamer.cpp
new file mode 100644
index 0000000000..b0c4bc8c30
--- /dev/null
+++ b/editor/import/post_import_plugin_skeleton_renamer.cpp
@@ -0,0 +1,144 @@
+/*************************************************************************/
+/* post_import_plugin_skeleton_renamer.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "post_import_plugin_skeleton_renamer.h"
+
+#include "editor/import/scene_import_settings.h"
+#include "scene/3d/importer_mesh_instance_3d.h"
+#include "scene/3d/skeleton_3d.h"
+#include "scene/animation/animation_player.h"
+#include "scene/resources/bone_map.h"
+
+void PostImportPluginSkeletonRenamer::get_internal_import_options(InternalImportCategory p_category, List<ResourceImporter::ImportOption> *r_options) {
+ if (p_category == INTERNAL_IMPORT_CATEGORY_SKELETON_3D_NODE) {
+ r_options->push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "retarget/bone_renamer/rename_bones"), true));
+ }
+}
+
+void PostImportPluginSkeletonRenamer::internal_process(InternalImportCategory p_category, Node *p_base_scene, Node *p_node, Ref<Resource> p_resource, const Dictionary &p_options) {
+ if (p_category == INTERNAL_IMPORT_CATEGORY_SKELETON_3D_NODE) {
+ // Prepare objects.
+ Object *map = p_options["retarget/bone_map"].get_validated_object();
+ if (!map || !bool(p_options["retarget/bone_renamer/rename_bones"])) {
+ return;
+ }
+ BoneMap *bone_map = Object::cast_to<BoneMap>(map);
+ Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(p_node);
+
+ // Rename bones in Skeleton3D.
+ {
+ int len = skeleton->get_bone_count();
+ for (int i = 0; i < len; i++) {
+ StringName bn = bone_map->find_profile_bone_name(skeleton->get_bone_name(i));
+ if (bn) {
+ skeleton->set_bone_name(i, bn);
+ }
+ }
+ }
+
+ // Rename bones in Skin.
+ {
+ TypedArray<Node> nodes = p_base_scene->find_children("*", "ImporterMeshInstance3D");
+ while (nodes.size()) {
+ ImporterMeshInstance3D *mi = Object::cast_to<ImporterMeshInstance3D>(nodes.pop_back());
+ Ref<Skin> skin = mi->get_skin();
+ if (skin.is_valid()) {
+ Node *node = mi->get_node(mi->get_skeleton_path());
+ if (node) {
+ Skeleton3D *mesh_skeleton = Object::cast_to<Skeleton3D>(node);
+ if (mesh_skeleton && node == skeleton) {
+ int len = skin->get_bind_count();
+ for (int i = 0; i < len; i++) {
+ StringName bn = bone_map->find_profile_bone_name(skin->get_bind_name(i));
+ if (bn) {
+ skin->set_bind_name(i, bn);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // Rename bones in AnimationPlayer.
+ {
+ TypedArray<Node> nodes = p_base_scene->find_children("*", "AnimationPlayer");
+ while (nodes.size()) {
+ AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(nodes.pop_back());
+ List<StringName> anims;
+ ap->get_animation_list(&anims);
+ for (const StringName &name : anims) {
+ Ref<Animation> anim = ap->get_animation(name);
+ int len = anim->get_track_count();
+ for (int i = 0; i < len; i++) {
+ if (anim->track_get_path(i).get_subname_count() != 1 || !(anim->track_get_type(i) == Animation::TYPE_POSITION_3D || anim->track_get_type(i) == Animation::TYPE_ROTATION_3D || anim->track_get_type(i) == Animation::TYPE_SCALE_3D)) {
+ continue;
+ }
+ String track_path = String(anim->track_get_path(i).get_concatenated_names());
+ Node *node = (ap->get_node(ap->get_root()))->get_node(NodePath(track_path));
+ if (node) {
+ Skeleton3D *track_skeleton = Object::cast_to<Skeleton3D>(node);
+ if (track_skeleton && track_skeleton == skeleton) {
+ StringName bn = bone_map->find_profile_bone_name(anim->track_get_path(i).get_subname(0));
+ if (bn) {
+ anim->track_set_path(i, track_path + ":" + bn);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // Rename bones in all Nodes by calling method.
+ {
+ Vector<Variant> vargs;
+ vargs.push_back(p_base_scene);
+ vargs.push_back(skeleton);
+ vargs.push_back(bone_map);
+ const Variant **argptrs = (const Variant **)alloca(sizeof(const Variant **) * vargs.size());
+ const Variant *args = vargs.ptr();
+ uint32_t argcount = vargs.size();
+ for (uint32_t i = 0; i < argcount; i++) {
+ argptrs[i] = &args[i];
+ }
+
+ TypedArray<Node> nodes = p_base_scene->find_children("*");
+ while (nodes.size()) {
+ Node *nd = Object::cast_to<Node>(nodes.pop_back());
+ Callable::CallError ce;
+ nd->callp("_notify_skeleton_bones_renamed", argptrs, argcount, ce);
+ }
+ }
+ }
+}
+
+PostImportPluginSkeletonRenamer::PostImportPluginSkeletonRenamer() {
+}
diff --git a/editor/import/post_import_plugin_skeleton_renamer.h b/editor/import/post_import_plugin_skeleton_renamer.h
new file mode 100644
index 0000000000..73cbabd1c5
--- /dev/null
+++ b/editor/import/post_import_plugin_skeleton_renamer.h
@@ -0,0 +1,46 @@
+/*************************************************************************/
+/* post_import_plugin_skeleton_renamer.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef POST_IMPORT_PLUGIN_SKELETON_RENAMER_H
+#define POST_IMPORT_PLUGIN_SKELETON_RENAMER_H
+
+#include "resource_importer_scene.h"
+
+class PostImportPluginSkeletonRenamer : public EditorScenePostImportPlugin {
+ GDCLASS(PostImportPluginSkeletonRenamer, EditorScenePostImportPlugin);
+
+public:
+ virtual void get_internal_import_options(InternalImportCategory p_category, List<ResourceImporter::ImportOption> *r_options) override;
+ virtual void internal_process(InternalImportCategory p_category, Node *p_base_scene, Node *p_node, Ref<Resource> p_resource, const Dictionary &p_options) override;
+
+ PostImportPluginSkeletonRenamer();
+};
+
+#endif // POST_IMPORT_PLUGIN_SKELETON_RENAMER_H
diff --git a/editor/import/resource_importer_bitmask.cpp b/editor/import/resource_importer_bitmask.cpp
index 46d15e8989..966719dc48 100644
--- a/editor/import/resource_importer_bitmask.cpp
+++ b/editor/import/resource_importer_bitmask.cpp
@@ -55,7 +55,7 @@ String ResourceImporterBitMap::get_resource_type() const {
return "BitMap";
}
-bool ResourceImporterBitMap::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
+bool ResourceImporterBitMap::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
return true;
}
@@ -72,7 +72,7 @@ void ResourceImporterBitMap::get_import_options(const String &p_path, List<Impor
r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "threshold", PROPERTY_HINT_RANGE, "0,1,0.01"), 0.5));
}
-Error ResourceImporterBitMap::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
+Error ResourceImporterBitMap::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
int create_from = p_options["create_from"];
float threshold = p_options["threshold"];
Ref<Image> image;
diff --git a/editor/import/resource_importer_bitmask.h b/editor/import/resource_importer_bitmask.h
index 6dd6843171..8682ab80a3 100644
--- a/editor/import/resource_importer_bitmask.h
+++ b/editor/import/resource_importer_bitmask.h
@@ -47,8 +47,8 @@ public:
virtual String get_preset_name(int p_idx) const override;
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
- virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
- virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
+ virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override;
+ virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
ResourceImporterBitMap();
~ResourceImporterBitMap();
diff --git a/editor/import/resource_importer_bmfont.cpp b/editor/import/resource_importer_bmfont.cpp
index 8a655fbc0c..8a40b113b9 100644
--- a/editor/import/resource_importer_bmfont.cpp
+++ b/editor/import/resource_importer_bmfont.cpp
@@ -55,7 +55,7 @@ String ResourceImporterBMFont::get_resource_type() const {
return "FontData";
}
-bool ResourceImporterBMFont::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
+bool ResourceImporterBMFont::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
return true;
}
@@ -63,7 +63,7 @@ void ResourceImporterBMFont::get_import_options(const String &p_path, List<Impor
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "compress"), true));
}
-Error ResourceImporterBMFont::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
+Error ResourceImporterBMFont::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
print_verbose("Importing BMFont font from: " + p_source_file);
Ref<FontData> font;
diff --git a/editor/import/resource_importer_bmfont.h b/editor/import/resource_importer_bmfont.h
index e5a96e2c40..0711302bd5 100644
--- a/editor/import/resource_importer_bmfont.h
+++ b/editor/import/resource_importer_bmfont.h
@@ -46,9 +46,9 @@ public:
virtual String get_resource_type() const override;
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
- virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
+ virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override;
- virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
+ virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
ResourceImporterBMFont();
};
diff --git a/editor/import/resource_importer_csv_translation.cpp b/editor/import/resource_importer_csv_translation.cpp
index ee6500a643..0b3622e3c0 100644
--- a/editor/import/resource_importer_csv_translation.cpp
+++ b/editor/import/resource_importer_csv_translation.cpp
@@ -55,7 +55,7 @@ String ResourceImporterCSVTranslation::get_resource_type() const {
return "Translation";
}
-bool ResourceImporterCSVTranslation::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
+bool ResourceImporterCSVTranslation::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
return true;
}
@@ -72,7 +72,7 @@ void ResourceImporterCSVTranslation::get_import_options(const String &p_path, Li
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "delimiter", PROPERTY_HINT_ENUM, "Comma,Semicolon,Tab"), 0));
}
-Error ResourceImporterCSVTranslation::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
+Error ResourceImporterCSVTranslation::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
bool compress = p_options["compress"];
String delimiter;
diff --git a/editor/import/resource_importer_csv_translation.h b/editor/import/resource_importer_csv_translation.h
index 8f6cf94984..306aafa843 100644
--- a/editor/import/resource_importer_csv_translation.h
+++ b/editor/import/resource_importer_csv_translation.h
@@ -47,9 +47,9 @@ public:
virtual String get_preset_name(int p_idx) const override;
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
- virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
+ virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override;
- virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
+ virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
ResourceImporterCSVTranslation();
};
diff --git a/editor/import/resource_importer_dynamic_font.cpp b/editor/import/resource_importer_dynamic_font.cpp
index 2dc24c9d44..a92b0fe280 100644
--- a/editor/import/resource_importer_dynamic_font.cpp
+++ b/editor/import/resource_importer_dynamic_font.cpp
@@ -50,7 +50,9 @@ void ResourceImporterDynamicFont::get_recognized_extensions(List<String> *p_exte
if (p_extensions) {
#ifdef MODULE_FREETYPE_ENABLED
p_extensions->push_back("ttf");
+ p_extensions->push_back("ttc");
p_extensions->push_back("otf");
+ p_extensions->push_back("otc");
p_extensions->push_back("woff");
p_extensions->push_back("woff2");
p_extensions->push_back("pfb");
@@ -67,7 +69,7 @@ String ResourceImporterDynamicFont::get_resource_type() const {
return "FontData";
}
-bool ResourceImporterDynamicFont::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
+bool ResourceImporterDynamicFont::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
if (p_option == "msdf_pixel_range" && !bool(p_options["multichannel_signed_distance_field"])) {
return false;
}
@@ -101,6 +103,8 @@ String ResourceImporterDynamicFont::get_preset_name(int p_idx) const {
void ResourceImporterDynamicFont::get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset) const {
bool msdf = p_preset == PRESET_MSDF;
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "face_index"), 0));
+
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "antialiased"), true));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "generate_mipmaps"), false));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "multichannel_signed_distance_field", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), (msdf) ? true : false));
@@ -176,9 +180,11 @@ void ResourceImporterDynamicFont::show_advanced_options(const String &p_path) {
DynamicFontImportSettings::get_singleton()->open_settings(p_path);
}
-Error ResourceImporterDynamicFont::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
+Error ResourceImporterDynamicFont::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
print_verbose("Importing dynamic font from: " + p_source_file);
+ int face_index = p_options["face_index"];
+
bool antialiased = p_options["antialiased"];
bool generate_mipmaps = p_options["generate_mipmaps"];
bool msdf = p_options["multichannel_signed_distance_field"];
@@ -200,6 +206,7 @@ Error ResourceImporterDynamicFont::import(const String &p_source_file, const Str
Ref<FontData> font;
font.instantiate();
font->set_data(data);
+ font->set_face_index(face_index);
font->set_antialiased(antialiased);
font->set_generate_mipmaps(generate_mipmaps);
font->set_multichannel_signed_distance_field(msdf);
diff --git a/editor/import/resource_importer_dynamic_font.h b/editor/import/resource_importer_dynamic_font.h
index 2761b418e1..c0b6c094b0 100644
--- a/editor/import/resource_importer_dynamic_font.h
+++ b/editor/import/resource_importer_dynamic_font.h
@@ -56,12 +56,12 @@ public:
virtual String get_preset_name(int p_idx) const override;
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
- virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
+ virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override;
bool has_advanced_options() const override;
void show_advanced_options(const String &p_path) override;
- virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
+ virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
ResourceImporterDynamicFont();
};
diff --git a/editor/import/resource_importer_image.cpp b/editor/import/resource_importer_image.cpp
index 8514df76bb..fa7c4cd24f 100644
--- a/editor/import/resource_importer_image.cpp
+++ b/editor/import/resource_importer_image.cpp
@@ -55,7 +55,7 @@ String ResourceImporterImage::get_resource_type() const {
return "Image";
}
-bool ResourceImporterImage::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
+bool ResourceImporterImage::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
return true;
}
@@ -70,7 +70,7 @@ String ResourceImporterImage::get_preset_name(int p_idx) const {
void ResourceImporterImage::get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset) const {
}
-Error ResourceImporterImage::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
+Error ResourceImporterImage::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
Ref<FileAccess> f = FileAccess::open(p_source_file, FileAccess::READ);
ERR_FAIL_COND_V_MSG(f.is_null(), ERR_CANT_OPEN, "Cannot open file from path '" + p_source_file + "'.");
diff --git a/editor/import/resource_importer_image.h b/editor/import/resource_importer_image.h
index 81aedc91e8..a1a345287e 100644
--- a/editor/import/resource_importer_image.h
+++ b/editor/import/resource_importer_image.h
@@ -48,9 +48,9 @@ public:
virtual String get_preset_name(int p_idx) const override;
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
- virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
+ virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override;
- virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
+ virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
ResourceImporterImage();
};
diff --git a/editor/import/resource_importer_imagefont.cpp b/editor/import/resource_importer_imagefont.cpp
index 2b67a171cc..30c349d0f2 100644
--- a/editor/import/resource_importer_imagefont.cpp
+++ b/editor/import/resource_importer_imagefont.cpp
@@ -55,7 +55,7 @@ String ResourceImporterImageFont::get_resource_type() const {
return "FontData";
}
-bool ResourceImporterImageFont::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
+bool ResourceImporterImageFont::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
return true;
}
@@ -85,7 +85,7 @@ bool ResourceImporterImageFont::_decode_range(const String &p_token, int32_t &r_
}
}
-Error ResourceImporterImageFont::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
+Error ResourceImporterImageFont::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
print_verbose("Importing image font from: " + p_source_file);
int columns = p_options["columns"];
@@ -107,7 +107,7 @@ Error ResourceImporterImageFont::import(const String &p_source_file, const Strin
Ref<Image> img;
img.instantiate();
Error err = ImageLoader::load_image(p_source_file, img);
- ERR_FAIL_COND_V_MSG(err != OK, ERR_FILE_CANT_READ, TTR("Can't load font texture: ") + "\"" + p_source_file + "\".");
+ ERR_FAIL_COND_V_MSG(err != OK, ERR_FILE_CANT_READ, TTR("Can't load font texture:") + " \"" + p_source_file + "\".");
font->set_texture_image(0, Vector2i(base_size, 0), 0, img);
int count = columns * rows;
diff --git a/editor/import/resource_importer_imagefont.h b/editor/import/resource_importer_imagefont.h
index c1116d5a83..f46bc8c19b 100644
--- a/editor/import/resource_importer_imagefont.h
+++ b/editor/import/resource_importer_imagefont.h
@@ -48,9 +48,9 @@ public:
virtual String get_resource_type() const override;
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
- virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
+ virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override;
- virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
+ virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
ResourceImporterImageFont();
};
diff --git a/editor/import/resource_importer_layered_texture.cpp b/editor/import/resource_importer_layered_texture.cpp
index 7c0c99cd29..bacd09592e 100644
--- a/editor/import/resource_importer_layered_texture.cpp
+++ b/editor/import/resource_importer_layered_texture.cpp
@@ -119,7 +119,7 @@ String ResourceImporterLayeredTexture::get_resource_type() const {
ERR_FAIL_V(String());
}
-bool ResourceImporterLayeredTexture::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
+bool ResourceImporterLayeredTexture::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
if (p_option == "compress/lossy_quality" && p_options.has("compress/mode")) {
return int(p_options["compress/mode"]) == COMPRESS_LOSSY;
}
@@ -282,7 +282,7 @@ void ResourceImporterLayeredTexture::_save_tex(Vector<Ref<Image>> p_images, cons
}
}
-Error ResourceImporterLayeredTexture::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
+Error ResourceImporterLayeredTexture::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
int compress_mode = p_options["compress/mode"];
float lossy = p_options["compress/lossy_quality"];
int hdr_compression = p_options["compress/hdr_compression"];
diff --git a/editor/import/resource_importer_layered_texture.h b/editor/import/resource_importer_layered_texture.h
index 5791914a9b..5a29010c3b 100644
--- a/editor/import/resource_importer_layered_texture.h
+++ b/editor/import/resource_importer_layered_texture.h
@@ -43,7 +43,7 @@ class LayeredTextureImport : public RefCounted {
public:
Image::CompressSource *csource = nullptr;
String save_path;
- Map<StringName, Variant> options;
+ HashMap<StringName, Variant> options;
List<String> *platform_variants = nullptr;
Ref<Image> image = nullptr;
Array formats_imported;
@@ -108,11 +108,11 @@ public:
virtual String get_preset_name(int p_idx) const override;
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
- virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
+ virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override;
void _save_tex(Vector<Ref<Image>> p_images, const String &p_to_path, int p_compress_mode, float p_lossy, Image::CompressMode p_vram_compression, Image::CompressSource p_csource, Image::UsedChannels used_channels, bool p_mipmaps, bool p_force_po2);
- virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
+ virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
virtual bool are_import_settings_valid(const String &p_path) const override;
virtual String get_import_settings_string() const override;
diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp
index 88837d089a..6fbfecfdfa 100644
--- a/editor/import/resource_importer_obj.cpp
+++ b/editor/import/resource_importer_obj.cpp
@@ -43,7 +43,7 @@ uint32_t EditorOBJImporter::get_import_flags() const {
return IMPORT_SCENE;
}
-static Error _parse_material_library(const String &p_path, Map<String, Ref<StandardMaterial3D>> &material_map, List<String> *r_missing_deps) {
+static Error _parse_material_library(const String &p_path, HashMap<String, Ref<StandardMaterial3D>> &material_map, List<String> *r_missing_deps) {
Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::READ);
ERR_FAIL_COND_V_MSG(f.is_null(), ERR_CANT_OPEN, vformat("Couldn't open MTL file '%s', it may not exist or not be readable.", p_path));
@@ -219,7 +219,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_
Vector<Vector2> uvs;
String name;
- Map<String, Map<String, Ref<StandardMaterial3D>>> material_map;
+ HashMap<String, HashMap<String, Ref<StandardMaterial3D>>> material_map;
Ref<SurfaceTool> surf_tool = memnew(SurfaceTool);
surf_tool->begin(Mesh::PRIMITIVE_TRIANGLES);
@@ -402,7 +402,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_
current_material_library = l.replace("mtllib", "").strip_edges();
if (!material_map.has(current_material_library)) {
- Map<String, Ref<StandardMaterial3D>> lib;
+ HashMap<String, Ref<StandardMaterial3D>> lib;
String lib_path = current_material_library;
if (lib_path.is_relative_path()) {
lib_path = p_path.get_base_dir().plus_file(current_material_library);
@@ -422,7 +422,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_
return OK;
}
-Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
+Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
List<Ref<Mesh>> meshes;
Error err = _parse_obj(p_path, meshes, false, p_flags & IMPORT_GENERATE_TANGENT_ARRAYS, false, Vector3(1, 1, 1), Vector3(0, 0, 0), r_missing_deps);
@@ -505,11 +505,11 @@ void ResourceImporterOBJ::get_import_options(const String &p_path, List<ImportOp
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "optimize_mesh"), true));
}
-bool ResourceImporterOBJ::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
+bool ResourceImporterOBJ::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
return true;
}
-Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
+Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
List<Ref<Mesh>> meshes;
Error err = _parse_obj(p_source_file, meshes, true, p_options["generate_tangents"], p_options["optimize_mesh"], p_options["scale_mesh"], p_options["offset_mesh"], nullptr);
diff --git a/editor/import/resource_importer_obj.h b/editor/import/resource_importer_obj.h
index 1b5e8bbdc1..3da9f02adb 100644
--- a/editor/import/resource_importer_obj.h
+++ b/editor/import/resource_importer_obj.h
@@ -39,7 +39,7 @@ class EditorOBJImporter : public EditorSceneFormatImporter {
public:
virtual uint32_t get_import_flags() const override;
virtual void get_extensions(List<String> *r_extensions) const override;
- virtual Node *import_scene(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr) override;
+ virtual Node *import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr) override;
EditorOBJImporter();
};
@@ -59,9 +59,9 @@ public:
virtual String get_preset_name(int p_idx) const override;
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
- virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
+ virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override;
- virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
+ virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
// Threaded import can currently cause deadlocks, see GH-48265.
virtual bool can_import_threaded() const override { return false; }
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index 43b52177c6..a9c43e573f 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -74,7 +74,7 @@ void EditorSceneFormatImporter::get_extensions(List<String> *r_extensions) const
ERR_FAIL();
}
-Node *EditorSceneFormatImporter::import_scene(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
+Node *EditorSceneFormatImporter::import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
Dictionary options_dict;
for (const KeyValue<StringName, Variant> &elem : p_options) {
options_dict[elem.key] = elem.value;
@@ -91,7 +91,7 @@ void EditorSceneFormatImporter::get_import_options(const String &p_path, List<Re
GDVIRTUAL_CALL(_get_import_options, p_path);
}
-Variant EditorSceneFormatImporter::get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option, const Map<StringName, Variant> &p_options) {
+Variant EditorSceneFormatImporter::get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option, const HashMap<StringName, Variant> &p_options) {
Variant ret;
GDVIRTUAL_CALL(_get_option_visibility, p_path, p_for_animation, p_option, ret);
return ret;
@@ -166,14 +166,14 @@ void EditorScenePostImportPlugin::get_internal_import_options(InternalImportCate
GDVIRTUAL_CALL(_get_internal_import_options, p_category);
current_option_list = nullptr;
}
-Variant EditorScenePostImportPlugin::get_internal_option_visibility(InternalImportCategory p_category, bool p_for_animation, const String &p_option, const Map<StringName, Variant> &p_options) const {
+Variant EditorScenePostImportPlugin::get_internal_option_visibility(InternalImportCategory p_category, bool p_for_animation, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
current_options = &p_options;
Variant ret;
GDVIRTUAL_CALL(_get_internal_option_visibility, p_category, p_for_animation, p_option, ret);
current_options = nullptr;
return ret;
}
-Variant EditorScenePostImportPlugin::get_internal_option_update_view_required(InternalImportCategory p_category, const String &p_option, const Map<StringName, Variant> &p_options) const {
+Variant EditorScenePostImportPlugin::get_internal_option_update_view_required(InternalImportCategory p_category, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
current_options = &p_options;
Variant ret;
GDVIRTUAL_CALL(_get_internal_option_update_view_required, p_category, p_option, ret);
@@ -192,7 +192,7 @@ void EditorScenePostImportPlugin::get_import_options(const String &p_path, List<
GDVIRTUAL_CALL(_get_import_options, p_path);
current_option_list = nullptr;
}
-Variant EditorScenePostImportPlugin::get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option, const Map<StringName, Variant> &p_options) const {
+Variant EditorScenePostImportPlugin::get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
current_options = &p_options;
Variant ret;
GDVIRTUAL_CALL(_get_option_visibility, p_path, p_for_animation, p_option, ret);
@@ -200,12 +200,12 @@ Variant EditorScenePostImportPlugin::get_option_visibility(const String &p_path,
return ret;
}
-void EditorScenePostImportPlugin::pre_process(Node *p_scene, const Map<StringName, Variant> &p_options) {
+void EditorScenePostImportPlugin::pre_process(Node *p_scene, const HashMap<StringName, Variant> &p_options) {
current_options = &p_options;
GDVIRTUAL_CALL(_pre_process, p_scene);
current_options = nullptr;
}
-void EditorScenePostImportPlugin::post_process(Node *p_scene, const Map<StringName, Variant> &p_options) {
+void EditorScenePostImportPlugin::post_process(Node *p_scene, const HashMap<StringName, Variant> &p_options) {
current_options = &p_options;
GDVIRTUAL_CALL(_post_process, p_scene);
current_options = nullptr;
@@ -232,6 +232,7 @@ void EditorScenePostImportPlugin::_bind_methods() {
BIND_ENUM_CONSTANT(INTERNAL_IMPORT_CATEGORY_MATERIAL);
BIND_ENUM_CONSTANT(INTERNAL_IMPORT_CATEGORY_ANIMATION);
BIND_ENUM_CONSTANT(INTERNAL_IMPORT_CATEGORY_ANIMATION_NODE);
+ BIND_ENUM_CONSTANT(INTERNAL_IMPORT_CATEGORY_SKELETON_3D_NODE);
BIND_ENUM_CONSTANT(INTERNAL_IMPORT_CATEGORY_MAX);
}
@@ -263,7 +264,7 @@ int ResourceImporterScene::get_format_version() const {
return 1;
}
-bool ResourceImporterScene::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
+bool ResourceImporterScene::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
if (animation_importer) {
if (p_option == "animation/import") { // Option ignored, animation always imported.
return false;
@@ -367,7 +368,7 @@ static void _pre_gen_shape_list(Ref<ImporterMesh> &mesh, Vector<Ref<Shape3D>> &r
}
}
-Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> &r_collision_map, Pair<PackedVector3Array, PackedInt32Array> *r_occluder_arrays, List<Pair<NodePath, Node *>> &r_node_renames) {
+Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, HashMap<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> &r_collision_map, Pair<PackedVector3Array, PackedInt32Array> *r_occluder_arrays, List<Pair<NodePath, Node *>> &r_node_renames) {
// Children first.
for (int i = 0; i < p_node->get_child_count(); i++) {
Node *r = _pre_fix_node(p_node->get_child(i), p_root, r_collision_map, r_occluder_arrays, r_node_renames);
@@ -466,7 +467,7 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<I
static const char *loop_strings[loop_string_count] = { "loop_mode", "loop", "cycle" };
for (int i = 0; i < loop_string_count; i++) {
if (_teststr(animname, loop_strings[i])) {
- anim->set_loop_mode(Animation::LoopMode::LOOP_LINEAR);
+ anim->set_loop_mode(Animation::LOOP_LINEAR);
animname = _fixstr(animname, loop_strings[i]);
Ref<AnimationLibrary> library = ap->get_animation_library(ap->find_animation_library(anim));
@@ -658,6 +659,44 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<I
}
}
}
+ } else if (_teststr(name, "vehicle")) {
+ if (isroot) {
+ return p_node;
+ }
+
+ Node *owner = p_node->get_owner();
+ Node3D *s = Object::cast_to<Node3D>(p_node);
+ VehicleBody3D *bv = memnew(VehicleBody3D);
+ String n = _fixstr(p_node->get_name(), "vehicle");
+ bv->set_name(n);
+ p_node->replace_by(bv);
+ p_node->set_name(n);
+ bv->add_child(p_node);
+ bv->set_owner(owner);
+ p_node->set_owner(owner);
+ bv->set_transform(s->get_transform());
+ s->set_transform(Transform3D());
+
+ p_node = bv;
+ } else if (_teststr(name, "wheel")) {
+ if (isroot) {
+ return p_node;
+ }
+
+ Node *owner = p_node->get_owner();
+ Node3D *s = Object::cast_to<Node3D>(p_node);
+ VehicleWheel3D *bv = memnew(VehicleWheel3D);
+ String n = _fixstr(p_node->get_name(), "wheel");
+ bv->set_name(n);
+ p_node->replace_by(bv);
+ p_node->set_name(n);
+ bv->add_child(p_node);
+ bv->set_owner(owner);
+ p_node->set_owner(owner);
+ bv->set_transform(s->get_transform());
+ s->set_transform(Transform3D());
+
+ p_node = bv;
} else if (Object::cast_to<ImporterMeshInstance3D>(p_node)) {
//last attempt, maybe collision inside the mesh data
@@ -704,7 +743,7 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<I
return p_node;
}
-Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> &collision_map, Pair<PackedVector3Array, PackedInt32Array> &r_occluder_arrays, Set<Ref<ImporterMesh>> &r_scanned_meshes, const Dictionary &p_node_data, const Dictionary &p_material_data, const Dictionary &p_animation_data, float p_animation_fps) {
+Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, HashMap<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> &collision_map, Pair<PackedVector3Array, PackedInt32Array> &r_occluder_arrays, HashSet<Ref<ImporterMesh>> &r_scanned_meshes, const Dictionary &p_node_data, const Dictionary &p_material_data, const Dictionary &p_animation_data, float p_animation_fps) {
// children first
for (int i = 0; i < p_node->get_child_count(); i++) {
Node *r = _post_fix_node(p_node->get_child(i), p_root, collision_map, r_occluder_arrays, r_scanned_meshes, p_node_data, p_material_data, p_animation_data, p_animation_fps);
@@ -728,6 +767,27 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref<
}
{
+ //make sure this is unique
+ node_settings = node_settings.duplicate(true);
+ //fill node settings for this node with default values
+ List<ImportOption> iopts;
+ if (Object::cast_to<ImporterMeshInstance3D>(p_node)) {
+ get_internal_import_options(INTERNAL_IMPORT_CATEGORY_MESH_3D_NODE, &iopts);
+ } else if (Object::cast_to<AnimationPlayer>(p_node)) {
+ get_internal_import_options(INTERNAL_IMPORT_CATEGORY_ANIMATION_NODE, &iopts);
+ } else if (Object::cast_to<Skeleton3D>(p_node)) {
+ get_internal_import_options(INTERNAL_IMPORT_CATEGORY_SKELETON_3D_NODE, &iopts);
+ } else {
+ get_internal_import_options(INTERNAL_IMPORT_CATEGORY_NODE, &iopts);
+ }
+ for (const ImportOption &E : iopts) {
+ if (!node_settings.has(E.option.name)) {
+ node_settings[E.option.name] = E.default_value;
+ }
+ }
+ }
+
+ {
ObjectID node_id = p_node->get_instance_id();
for (int i = 0; i < post_importer_plugins.size(); i++) {
post_importer_plugins.write[i]->internal_process(EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_NODE, p_root, p_node, Ref<Resource>(), node_settings);
@@ -747,6 +807,16 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref<
}
}
+ if (Object::cast_to<Skeleton3D>(p_node)) {
+ ObjectID node_id = p_node->get_instance_id();
+ for (int i = 0; i < post_importer_plugins.size(); i++) {
+ post_importer_plugins.write[i]->internal_process(EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_SKELETON_3D_NODE, p_root, p_node, Ref<Resource>(), node_settings);
+ if (ObjectDB::get_instance(node_id) == nullptr) { //may have been erased, so do not continue
+ break;
+ }
+ }
+ }
+
if (Object::cast_to<ImporterMeshInstance3D>(p_node)) {
ImporterMeshInstance3D *mi = Object::cast_to<ImporterMeshInstance3D>(p_node);
@@ -761,6 +831,16 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref<
if (!mat_id.is_empty() && p_material_data.has(mat_id)) {
Dictionary matdata = p_material_data[mat_id];
+ {
+ //fill node settings for this node with default values
+ List<ImportOption> iopts;
+ get_internal_import_options(INTERNAL_IMPORT_CATEGORY_MATERIAL, &iopts);
+ for (const ImportOption &E : iopts) {
+ if (!matdata.has(E.option.name)) {
+ matdata[E.option.name] = E.default_value;
+ }
+ }
+ }
for (int j = 0; j < post_importer_plugins.size(); j++) {
post_importer_plugins.write[j]->internal_process(EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_MATERIAL, p_root, p_node, mat, matdata);
@@ -928,19 +1008,6 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref<
if (Object::cast_to<AnimationPlayer>(p_node)) {
AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(p_node);
- {
- //make sure this is unique
- node_settings = node_settings.duplicate(true);
- //fill node settings for this node with default values
- List<ImportOption> iopts;
- get_internal_import_options(INTERNAL_IMPORT_CATEGORY_ANIMATION_NODE, &iopts);
- for (const ImportOption &E : iopts) {
- if (!node_settings.has(E.option.name)) {
- node_settings[E.option.name] = E.default_value;
- }
- }
- }
-
for (int i = 0; i < post_importer_plugins.size(); i++) {
post_importer_plugins.write[i]->internal_process(EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_ANIMATION_NODE, p_root, p_node, Ref<Resource>(), node_settings);
}
@@ -1077,7 +1144,7 @@ Ref<Animation> ResourceImporterScene::_save_animation_to_file(Ref<Animation> ani
}
if (ResourceCache::has(p_save_to_path)) {
- Ref<Animation> old_anim = Ref<Resource>(ResourceCache::get(p_save_to_path));
+ Ref<Animation> old_anim = ResourceCache::get_ref(p_save_to_path);
if (old_anim.is_valid()) {
old_anim->copy_from(anim);
anim = old_anim;
@@ -1347,6 +1414,10 @@ void ResourceImporterScene::get_internal_import_options(InternalImportCategory p
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "slice_" + itos(i + 1) + "/save_to_file/keep_custom_tracks"), false));
}
} break;
+ case INTERNAL_IMPORT_CATEGORY_SKELETON_3D_NODE: {
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "import/skip_import", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::OBJECT, "retarget/bone_map", PROPERTY_HINT_RESOURCE_TYPE, "BoneMap", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), Variant()));
+ } break;
default: {
}
}
@@ -1356,7 +1427,7 @@ void ResourceImporterScene::get_internal_import_options(InternalImportCategory p
}
}
-bool ResourceImporterScene::get_internal_option_visibility(InternalImportCategory p_category, const String &p_option, const Map<StringName, Variant> &p_options) const {
+bool ResourceImporterScene::get_internal_option_visibility(InternalImportCategory p_category, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
if (p_options.has("import/skip_import") && p_option != "import/skip_import" && bool(p_options["import/skip_import"])) {
return false; //if skip import
}
@@ -1461,6 +1532,12 @@ bool ResourceImporterScene::get_internal_option_visibility(InternalImportCategor
}
}
} break;
+ case INTERNAL_IMPORT_CATEGORY_SKELETON_3D_NODE: {
+ const bool use_retarget = p_options["retarget/bone_map"].get_validated_object() != nullptr;
+ if (p_option != "retarget/bone_map" && p_option.begins_with("retarget/")) {
+ return use_retarget;
+ }
+ } break;
default: {
}
}
@@ -1475,7 +1552,7 @@ bool ResourceImporterScene::get_internal_option_visibility(InternalImportCategor
return true;
}
-bool ResourceImporterScene::get_internal_option_update_view_required(InternalImportCategory p_category, const String &p_option, const Map<StringName, Variant> &p_options) const {
+bool ResourceImporterScene::get_internal_option_update_view_required(InternalImportCategory p_category, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
switch (p_category) {
case INTERNAL_IMPORT_CATEGORY_NODE: {
} break;
@@ -1496,6 +1573,8 @@ bool ResourceImporterScene::get_internal_option_update_view_required(InternalImp
} break;
case INTERNAL_IMPORT_CATEGORY_ANIMATION_NODE: {
} break;
+ case INTERNAL_IMPORT_CATEGORY_SKELETON_3D_NODE: {
+ } break;
default: {
}
}
@@ -1584,6 +1663,16 @@ void ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_m
if (!mesh_id.is_empty() && p_mesh_data.has(mesh_id)) {
Dictionary mesh_settings = p_mesh_data[mesh_id];
+ {
+ //fill node settings for this node with default values
+ List<ImportOption> iopts;
+ get_internal_import_options(INTERNAL_IMPORT_CATEGORY_MESH, &iopts);
+ for (const ImportOption &E : iopts) {
+ if (!mesh_settings.has(E.option.name)) {
+ mesh_settings[E.option.name] = E.default_value;
+ }
+ }
+ }
if (mesh_settings.has("generate/shadow_meshes")) {
int shadow_meshes = mesh_settings["generate/shadow_meshes"];
@@ -1673,7 +1762,7 @@ void ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_m
}
if (!save_to_file.is_empty()) {
- Ref<Mesh> existing = Ref<Resource>(ResourceCache::get(save_to_file));
+ Ref<Mesh> existing = ResourceCache::get_ref(save_to_file);
if (existing.is_valid()) {
//if somehow an existing one is useful, create
existing->reset_state();
@@ -1909,19 +1998,19 @@ Node *ResourceImporterScene::pre_import(const String &p_source_file) {
ERR_FAIL_COND_V(!importer.is_valid(), nullptr);
Error err = OK;
- Node *scene = importer->import_scene(p_source_file, EditorSceneFormatImporter::IMPORT_ANIMATION | EditorSceneFormatImporter::IMPORT_GENERATE_TANGENT_ARRAYS, Map<StringName, Variant>(), 15, nullptr, &err);
+ Node *scene = importer->import_scene(p_source_file, EditorSceneFormatImporter::IMPORT_ANIMATION | EditorSceneFormatImporter::IMPORT_GENERATE_TANGENT_ARRAYS, HashMap<StringName, Variant>(), 15, nullptr, &err);
if (!scene || err != OK) {
return nullptr;
}
- Map<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> collision_map;
+ HashMap<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> collision_map;
List<Pair<NodePath, Node *>> node_renames;
_pre_fix_node(scene, scene, collision_map, nullptr, node_renames);
return scene;
}
-Error ResourceImporterScene::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
+Error ResourceImporterScene::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
const String &src_path = p_source_file;
Ref<EditorSceneFormatImporter> importer;
@@ -1994,8 +2083,8 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
animation_data = subresources["animations"];
}
- Set<Ref<ImporterMesh>> scanned_meshes;
- Map<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> collision_map;
+ HashSet<Ref<ImporterMesh>> scanned_meshes;
+ HashMap<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> collision_map;
Pair<PackedVector3Array, PackedInt32Array> occluder_arrays;
List<Pair<NodePath, Node *>> node_renames;
@@ -2223,7 +2312,7 @@ void EditorSceneFormatImporterESCN::get_extensions(List<String> *r_extensions) c
r_extensions->push_back("escn");
}
-Node *EditorSceneFormatImporterESCN::import_scene(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
+Node *EditorSceneFormatImporterESCN::import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
Error error;
Ref<PackedScene> ps = ResourceFormatLoaderText::singleton->load(p_path, p_path, &error);
ERR_FAIL_COND_V_MSG(!ps.is_valid(), nullptr, "Cannot load scene as text resource from path '" + p_path + "'.");
diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h
index ac72a8f39d..c143e86bd4 100644
--- a/editor/import/resource_importer_scene.h
+++ b/editor/import/resource_importer_scene.h
@@ -71,9 +71,9 @@ public:
virtual uint32_t get_import_flags() const;
virtual void get_extensions(List<String> *r_extensions) const;
- virtual Node *import_scene(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr);
+ virtual Node *import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr);
virtual void get_import_options(const String &p_path, List<ResourceImporter::ImportOption> *r_options);
- virtual Variant get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option, const Map<StringName, Variant> &p_options);
+ virtual Variant get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option, const HashMap<StringName, Variant> &p_options);
EditorSceneFormatImporter() {}
};
@@ -106,11 +106,12 @@ public:
INTERNAL_IMPORT_CATEGORY_MATERIAL,
INTERNAL_IMPORT_CATEGORY_ANIMATION,
INTERNAL_IMPORT_CATEGORY_ANIMATION_NODE,
+ INTERNAL_IMPORT_CATEGORY_SKELETON_3D_NODE,
INTERNAL_IMPORT_CATEGORY_MAX
};
private:
- mutable const Map<StringName, Variant> *current_options = nullptr;
+ mutable const HashMap<StringName, Variant> *current_options = nullptr;
mutable const Dictionary *current_options_dict = nullptr;
List<ResourceImporter::ImportOption> *current_option_list = nullptr;
InternalImportCategory current_category = INTERNAL_IMPORT_CATEGORY_MAX;
@@ -133,16 +134,16 @@ public:
void add_import_option_advanced(Variant::Type p_type, const String &p_name, Variant p_default_value, PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_string = String(), int p_usage_flags = PROPERTY_USAGE_DEFAULT);
virtual void get_internal_import_options(InternalImportCategory p_category, List<ResourceImporter::ImportOption> *r_options);
- virtual Variant get_internal_option_visibility(InternalImportCategory p_category, bool p_for_animation, const String &p_option, const Map<StringName, Variant> &p_options) const;
- virtual Variant get_internal_option_update_view_required(InternalImportCategory p_category, const String &p_option, const Map<StringName, Variant> &p_options) const;
+ virtual Variant get_internal_option_visibility(InternalImportCategory p_category, bool p_for_animation, const String &p_option, const HashMap<StringName, Variant> &p_options) const;
+ virtual Variant get_internal_option_update_view_required(InternalImportCategory p_category, const String &p_option, const HashMap<StringName, Variant> &p_options) const;
virtual void internal_process(InternalImportCategory p_category, Node *p_base_scene, Node *p_node, Ref<Resource> p_resource, const Dictionary &p_options);
virtual void get_import_options(const String &p_path, List<ResourceImporter::ImportOption> *r_options);
- virtual Variant get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option, const Map<StringName, Variant> &p_options) const;
+ virtual Variant get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option, const HashMap<StringName, Variant> &p_options) const;
- virtual void pre_process(Node *p_scene, const Map<StringName, Variant> &p_options);
- virtual void post_process(Node *p_scene, const Map<StringName, Variant> &p_options);
+ virtual void pre_process(Node *p_scene, const HashMap<StringName, Variant> &p_options);
+ virtual void post_process(Node *p_scene, const HashMap<StringName, Variant> &p_options);
EditorScenePostImportPlugin() {}
};
@@ -259,20 +260,21 @@ public:
INTERNAL_IMPORT_CATEGORY_MATERIAL = EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_MATERIAL,
INTERNAL_IMPORT_CATEGORY_ANIMATION = EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_ANIMATION,
INTERNAL_IMPORT_CATEGORY_ANIMATION_NODE = EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_ANIMATION_NODE,
+ INTERNAL_IMPORT_CATEGORY_SKELETON_3D_NODE = EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_SKELETON_3D_NODE,
INTERNAL_IMPORT_CATEGORY_MAX = EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_MAX
};
void get_internal_import_options(InternalImportCategory p_category, List<ImportOption> *r_options) const;
- bool get_internal_option_visibility(InternalImportCategory p_category, const String &p_option, const Map<StringName, Variant> &p_options) const;
- bool get_internal_option_update_view_required(InternalImportCategory p_category, const String &p_option, const Map<StringName, Variant> &p_options) const;
+ bool get_internal_option_visibility(InternalImportCategory p_category, const String &p_option, const HashMap<StringName, Variant> &p_options) const;
+ bool get_internal_option_update_view_required(InternalImportCategory p_category, const String &p_option, const HashMap<StringName, Variant> &p_options) const;
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
- virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
+ virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override;
// Import scenes *after* everything else (such as textures).
virtual int get_import_order() const override { return ResourceImporter::IMPORT_ORDER_SCENE; }
- Node *_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> &r_collision_map, Pair<PackedVector3Array, PackedInt32Array> *r_occluder_arrays, List<Pair<NodePath, Node *>> &r_node_renames);
- Node *_post_fix_node(Node *p_node, Node *p_root, Map<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> &collision_map, Pair<PackedVector3Array, PackedInt32Array> &r_occluder_arrays, Set<Ref<ImporterMesh>> &r_scanned_meshes, const Dictionary &p_node_data, const Dictionary &p_material_data, const Dictionary &p_animation_data, float p_animation_fps);
+ Node *_pre_fix_node(Node *p_node, Node *p_root, HashMap<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> &r_collision_map, Pair<PackedVector3Array, PackedInt32Array> *r_occluder_arrays, List<Pair<NodePath, Node *>> &r_node_renames);
+ Node *_post_fix_node(Node *p_node, Node *p_root, HashMap<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> &collision_map, Pair<PackedVector3Array, PackedInt32Array> &r_occluder_arrays, HashSet<Ref<ImporterMesh>> &r_scanned_meshes, const Dictionary &p_node_data, const Dictionary &p_material_data, const Dictionary &p_animation_data, float p_animation_fps);
Ref<Animation> _save_animation_to_file(Ref<Animation> anim, bool p_save_to_file, String p_save_to_path, bool p_keep_custom_tracks);
void _create_clips(AnimationPlayer *anim, const Array &p_clips, bool p_bake_all);
@@ -280,7 +282,7 @@ public:
void _compress_animations(AnimationPlayer *anim, int p_page_size_kb);
Node *pre_import(const String &p_source_file);
- virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
+ virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
virtual bool has_advanced_options() const override;
virtual void show_advanced_options(const String &p_path) override;
@@ -302,7 +304,7 @@ class EditorSceneFormatImporterESCN : public EditorSceneFormatImporter {
public:
virtual uint32_t get_import_flags() const override;
virtual void get_extensions(List<String> *r_extensions) const override;
- virtual Node *import_scene(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr) override;
+ virtual Node *import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr) override;
};
#include "scene/resources/box_shape_3d.h"
diff --git a/editor/import/resource_importer_shader_file.cpp b/editor/import/resource_importer_shader_file.cpp
index 1d70a47daa..64839bf199 100644
--- a/editor/import/resource_importer_shader_file.cpp
+++ b/editor/import/resource_importer_shader_file.cpp
@@ -68,7 +68,7 @@ String ResourceImporterShaderFile::get_preset_name(int p_idx) const {
void ResourceImporterShaderFile::get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset) const {
}
-bool ResourceImporterShaderFile::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
+bool ResourceImporterShaderFile::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
return true;
}
@@ -89,7 +89,7 @@ static String _include_function(const String &p_path, void *userpointer) {
return file_inc->get_as_utf8_string();
}
-Error ResourceImporterShaderFile::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
+Error ResourceImporterShaderFile::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
/* STEP 1, Read shader code */
Error err;
diff --git a/editor/import/resource_importer_shader_file.h b/editor/import/resource_importer_shader_file.h
index 858c2e783c..9d0ef88b05 100644
--- a/editor/import/resource_importer_shader_file.h
+++ b/editor/import/resource_importer_shader_file.h
@@ -47,9 +47,9 @@ public:
virtual String get_preset_name(int p_idx) const override;
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
- virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
+ virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override;
- virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
+ virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
ResourceImporterShaderFile();
};
diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp
index 6770eef543..deb3047864 100644
--- a/editor/import/resource_importer_texture.cpp
+++ b/editor/import/resource_importer_texture.cpp
@@ -104,24 +104,30 @@ void ResourceImporterTexture::update_imports() {
bool changed = false;
if (E.value.flags & MAKE_NORMAL_FLAG && int(cf->get_value("params", "compress/normal_map")) == 0) {
+ print_line(vformat(TTR("%s: Texture detected as used as a normal map in 3D. Enabling red-green texture compression to reduce memory usage (blue channel is discarded)."), String(E.key)));
cf->set_value("params", "compress/normal_map", 1);
changed = true;
}
if (E.value.flags & MAKE_ROUGHNESS_FLAG && int(cf->get_value("params", "roughness/mode")) == 0) {
+ print_line(vformat(TTR("%s: Texture detected as used as a roughness map in 3D. Enabling roughness limiter based on the detected associated normal map at %s."), String(E.key), E.value.normal_path_for_roughness));
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.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");
+ const int compress_to = cf->get_value("params", "detect_3d/compress_to");
+ String compress_string;
cf->set_value("params", "detect_3d/compress_to", 0);
if (compress_to == 1) {
cf->set_value("params", "compress/mode", COMPRESS_VRAM_COMPRESSED);
+ compress_string = "VRAM Compressed (S3TC/ETC/BPTC)";
} else if (compress_to == 2) {
cf->set_value("params", "compress/mode", COMPRESS_BASIS_UNIVERSAL);
+ compress_string = "Basis Universal";
}
+ print_line(vformat(TTR("%s: Texture detected as used in 3D. Enabling mipmap generation and setting the texture compression mode to %s."), String(E.key), compress_string));
cf->set_value("params", "mipmaps/generate", true);
changed = true;
}
@@ -160,7 +166,7 @@ String ResourceImporterTexture::get_resource_type() const {
return "CompressedTexture2D";
}
-bool ResourceImporterTexture::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
+bool ResourceImporterTexture::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
if (p_option == "compress/lossy_quality") {
int compress_mode = int(p_options["compress/mode"]);
if (compress_mode != COMPRESS_LOSSY && compress_mode != COMPRESS_VRAM_COMPRESSED) {
@@ -402,7 +408,7 @@ void ResourceImporterTexture::_save_ctex(const Ref<Image> &p_image, const String
save_to_ctex_format(f, image, p_compress_mode, used_channels, p_vram_compression, p_lossy_quality);
}
-Error ResourceImporterTexture::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
+Error ResourceImporterTexture::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
CompressMode compress_mode = CompressMode(int(p_options["compress/mode"]));
const float lossy = p_options["compress/lossy_quality"];
const int pack_channels = p_options["compress/channel_pack"];
diff --git a/editor/import/resource_importer_texture.h b/editor/import/resource_importer_texture.h
index b932c598a2..7def2d4f77 100644
--- a/editor/import/resource_importer_texture.h
+++ b/editor/import/resource_importer_texture.h
@@ -65,7 +65,7 @@ protected:
RS::TextureDetectRoughnessChannel channel_for_roughness = RS::TEXTURE_DETECT_ROUGHNESS_R;
};
- Map<StringName, MakeInfo> make_flags;
+ HashMap<StringName, MakeInfo> make_flags;
static void _texture_reimport_roughness(const Ref<CompressedTexture2D> &p_tex, const String &p_normal_path, RenderingServer::TextureDetectRoughnessChannel p_channel);
static void _texture_reimport_3d(const Ref<CompressedTexture2D> &p_tex);
@@ -96,9 +96,9 @@ public:
virtual String get_preset_name(int p_idx) const override;
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
- virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
+ virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override;
- virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
+ virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
void update_imports();
diff --git a/editor/import/resource_importer_texture_atlas.cpp b/editor/import/resource_importer_texture_atlas.cpp
index cd481e009e..e5fe99890e 100644
--- a/editor/import/resource_importer_texture_atlas.cpp
+++ b/editor/import/resource_importer_texture_atlas.cpp
@@ -59,7 +59,7 @@ String ResourceImporterTextureAtlas::get_resource_type() const {
return "Texture2D";
}
-bool ResourceImporterTextureAtlas::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
+bool ResourceImporterTextureAtlas::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
return true;
}
@@ -82,7 +82,7 @@ String ResourceImporterTextureAtlas::get_option_group_file() const {
return "atlas_file";
}
-Error ResourceImporterTextureAtlas::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
+Error ResourceImporterTextureAtlas::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
/* If this happens, it's because the atlas_file field was not filled, so just import a broken texture */
//use an xpm because it's size independent, the editor images are vector and size dependent
@@ -188,7 +188,7 @@ static void _plot_triangle(Vector2i *vertices, const Vector2i &p_offset, bool p_
}
}
-Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file, const Map<String, Map<StringName, Variant>> &p_source_file_options, const Map<String, String> &p_base_paths) {
+Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file, const HashMap<String, HashMap<StringName, Variant>> &p_source_file_options, const HashMap<String, String> &p_base_paths) {
ERR_FAIL_COND_V(p_source_file_options.size() == 0, ERR_BUG); //should never happen
Vector<EditorAtlasPacker::Chart> charts;
@@ -197,10 +197,10 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file
pack_data_files.resize(p_source_file_options.size());
int idx = 0;
- for (const Map<String, Map<StringName, Variant>>::Element *E = p_source_file_options.front(); E; E = E->next(), idx++) {
+ for (const KeyValue<String, HashMap<StringName, Variant>> &E : p_source_file_options) {
PackData &pack_data = pack_data_files.write[idx];
- const String &source = E->key();
- const Map<StringName, Variant> &options = E->get();
+ const String &source = E.key;
+ const HashMap<StringName, Variant> &options = E.value;
Ref<Image> image;
image.instantiate();
@@ -271,6 +271,7 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file
pack_data.chart_vertices.push_back(polygons[j]);
}
}
+ idx++;
}
//pack the charts
@@ -305,10 +306,8 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file
//update cache if existing, else create
Ref<Texture2D> cache;
- if (ResourceCache::has(p_group_file)) {
- Resource *resptr = ResourceCache::get(p_group_file);
- cache.reference_ptr(resptr);
- } else {
+ cache = ResourceCache::get_ref(p_group_file);
+ if (!cache.is_valid()) {
Ref<ImageTexture> res_cache;
res_cache.instantiate();
res_cache->create_from_image(new_atlas);
@@ -318,7 +317,7 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file
//save the images
idx = 0;
- for (const Map<String, Map<StringName, Variant>>::Element *E = p_source_file_options.front(); E; E = E->next(), idx++) {
+ for (const KeyValue<String, HashMap<StringName, Variant>> &E : p_source_file_options) {
PackData &pack_data = pack_data_files.write[idx];
Ref<Texture2D> texture;
@@ -394,8 +393,9 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file
//mesh
}
- String save_path = p_base_paths[E->key()] + ".res";
+ String save_path = p_base_paths[E.key] + ".res";
ResourceSaver::save(save_path, texture);
+ idx++;
}
return OK;
diff --git a/editor/import/resource_importer_texture_atlas.h b/editor/import/resource_importer_texture_atlas.h
index a5e47dee99..971eb067df 100644
--- a/editor/import/resource_importer_texture_atlas.h
+++ b/editor/import/resource_importer_texture_atlas.h
@@ -61,11 +61,11 @@ public:
virtual String get_preset_name(int p_idx) const override;
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
- virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
+ virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override;
virtual String get_option_group_file() const override;
- virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
- virtual Error import_group_file(const String &p_group_file, const Map<String, Map<StringName, Variant>> &p_source_file_options, const Map<String, String> &p_base_paths) override;
+ virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
+ virtual Error import_group_file(const String &p_group_file, const HashMap<String, HashMap<StringName, Variant>> &p_source_file_options, const HashMap<String, String> &p_base_paths) override;
ResourceImporterTextureAtlas();
};
diff --git a/editor/import/resource_importer_wav.cpp b/editor/import/resource_importer_wav.cpp
index 154970f7ed..f0ba1eb7a1 100644
--- a/editor/import/resource_importer_wav.cpp
+++ b/editor/import/resource_importer_wav.cpp
@@ -58,7 +58,7 @@ String ResourceImporterWAV::get_resource_type() const {
return "AudioStreamSample";
}
-bool ResourceImporterWAV::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
+bool ResourceImporterWAV::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
if (p_option == "force/max_rate_hz" && !bool(p_options["force/max_rate"])) {
return false;
}
@@ -93,7 +93,7 @@ void ResourceImporterWAV::get_import_options(const String &p_path, List<ImportOp
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/mode", PROPERTY_HINT_ENUM, "Disabled,RAM (Ima-ADPCM)"), 0));
}
-Error ResourceImporterWAV::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
+Error ResourceImporterWAV::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
/* STEP 1, READ WAVE FILE */
Error err;
@@ -162,7 +162,7 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
//Consider revision for engine version 3.0
compression_code = file->get_16();
if (compression_code != 1 && compression_code != 3) {
- ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Format not supported for WAVE file (not PCM). Save WAVE files as uncompressed PCM instead.");
+ ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Format not supported for WAVE file (not PCM). Save WAVE files as uncompressed PCM or IEEE float instead.");
}
format_channels = file->get_16();
@@ -180,6 +180,10 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Invalid amount of bits in the sample (should be one of 8, 16, 24 or 32).");
}
+ if (compression_code == 3 && format_bits % 32) {
+ ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Invalid amount of bits in the IEEE float sample (should be 32 or 64).");
+ }
+
/* Don't need anything else, continue */
format_found = true;
}
@@ -208,36 +212,46 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
data.resize(frames * format_channels);
- if (format_bits == 8) {
- for (int i = 0; i < frames * format_channels; i++) {
- // 8 bit samples are UNSIGNED
+ if (compression_code == 1) {
+ if (format_bits == 8) {
+ for (int i = 0; i < frames * format_channels; i++) {
+ // 8 bit samples are UNSIGNED
- data.write[i] = int8_t(file->get_8() - 128) / 128.f;
- }
- } else if (format_bits == 32 && compression_code == 3) {
- for (int i = 0; i < frames * format_channels; i++) {
- //32 bit IEEE Float
+ data.write[i] = int8_t(file->get_8() - 128) / 128.f;
+ }
+ } else if (format_bits == 16) {
+ for (int i = 0; i < frames * format_channels; i++) {
+ //16 bit SIGNED
- data.write[i] = file->get_float();
- }
- } else if (format_bits == 16) {
- for (int i = 0; i < frames * format_channels; i++) {
- //16 bit SIGNED
+ data.write[i] = int16_t(file->get_16()) / 32768.f;
+ }
+ } else {
+ for (int i = 0; i < frames * format_channels; i++) {
+ //16+ bits samples are SIGNED
+ // if sample is > 16 bits, just read extra bytes
+
+ uint32_t s = 0;
+ for (int b = 0; b < (format_bits >> 3); b++) {
+ s |= ((uint32_t)file->get_8()) << (b * 8);
+ }
+ s <<= (32 - format_bits);
- data.write[i] = int16_t(file->get_16()) / 32768.f;
+ data.write[i] = (int32_t(s) >> 16) / 32768.f;
+ }
}
- } else {
- for (int i = 0; i < frames * format_channels; i++) {
- //16+ bits samples are SIGNED
- // if sample is > 16 bits, just read extra bytes
-
- uint32_t s = 0;
- for (int b = 0; b < (format_bits >> 3); b++) {
- s |= ((uint32_t)file->get_8()) << (b * 8);
+ } else if (compression_code == 3) {
+ if (format_bits == 32) {
+ for (int i = 0; i < frames * format_channels; i++) {
+ //32 bit IEEE Float
+
+ data.write[i] = file->get_float();
}
- s <<= (32 - format_bits);
+ } else if (format_bits == 64) {
+ for (int i = 0; i < frames * format_channels; i++) {
+ //64 bit IEEE Float
- data.write[i] = (int32_t(s) >> 16) / 32768.f;
+ data.write[i] = file->get_double();
+ }
}
}
diff --git a/editor/import/resource_importer_wav.h b/editor/import/resource_importer_wav.h
index 2316ce80e5..739ec9b181 100644
--- a/editor/import/resource_importer_wav.h
+++ b/editor/import/resource_importer_wav.h
@@ -47,7 +47,7 @@ public:
virtual String get_preset_name(int p_idx) const override;
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
- virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
+ virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override;
static void _compress_ima_adpcm(const Vector<float> &p_data, Vector<uint8_t> &dst_data) {
static const int16_t _ima_adpcm_step_table[89] = {
@@ -140,7 +140,7 @@ public:
}
}
- virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
+ virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
ResourceImporterWAV();
};
diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp
index 5ff2ac3c12..8ae05f046e 100644
--- a/editor/import/scene_import_settings.cpp
+++ b/editor/import/scene_import_settings.cpp
@@ -43,9 +43,9 @@
class SceneImportSettingsData : public Object {
GDCLASS(SceneImportSettingsData, Object)
friend class SceneImportSettings;
- Map<StringName, Variant> *settings = nullptr;
- Map<StringName, Variant> current;
- Map<StringName, Variant> defaults;
+ HashMap<StringName, Variant> *settings = nullptr;
+ HashMap<StringName, Variant> current;
+ HashMap<StringName, Variant> defaults;
List<ResourceImporter::ImportOption> options;
bool hide_options = false;
String path;
@@ -343,6 +343,8 @@ void SceneImportSettings::_fill_scene(Node *p_node, TreeItem *p_parent_item) {
category = ResourceImporterScene::INTERNAL_IMPORT_CATEGORY_MESH_3D_NODE;
} else if (Object::cast_to<AnimationPlayer>(p_node)) {
category = ResourceImporterScene::INTERNAL_IMPORT_CATEGORY_ANIMATION_NODE;
+ } else if (Object::cast_to<Skeleton3D>(p_node)) {
+ category = ResourceImporterScene::INTERNAL_IMPORT_CATEGORY_SKELETON_3D_NODE;
} else {
category = ResourceImporterScene::INTERNAL_IMPORT_CATEGORY_NODE;
}
@@ -505,7 +507,7 @@ void SceneImportSettings::_update_camera() {
camera->set_transform(xf);
}
-void SceneImportSettings::_load_default_subresource_settings(Map<StringName, Variant> &settings, const String &p_type, const String &p_import_id, ResourceImporterScene::InternalImportCategory p_category) {
+void SceneImportSettings::_load_default_subresource_settings(HashMap<StringName, Variant> &settings, const String &p_type, const String &p_import_id, ResourceImporterScene::InternalImportCategory p_category) {
if (base_subresource_settings.has(p_type)) {
Dictionary d = base_subresource_settings[p_type];
if (d.has(p_import_id)) {
@@ -624,6 +626,13 @@ SceneImportSettings *SceneImportSettings::get_singleton() {
return singleton;
}
+Node *SceneImportSettings::get_selected_node() {
+ if (selected_id == "") {
+ return nullptr;
+ }
+ return node_map[selected_id].node;
+}
+
void SceneImportSettings::_select(Tree *p_from, String p_type, String p_id) {
selecting = true;
scene_import_settings_data->hide_options = false;
@@ -664,6 +673,8 @@ void SceneImportSettings::_select(Tree *p_from, String p_type, String p_id) {
scene_import_settings_data->hide_options = editing_animation;
} else if (Object::cast_to<AnimationPlayer>(nd.node)) {
scene_import_settings_data->category = ResourceImporterScene::INTERNAL_IMPORT_CATEGORY_ANIMATION_NODE;
+ } else if (Object::cast_to<Skeleton3D>(nd.node)) {
+ scene_import_settings_data->category = ResourceImporterScene::INTERNAL_IMPORT_CATEGORY_SKELETON_3D_NODE;
} else {
scene_import_settings_data->category = ResourceImporterScene::INTERNAL_IMPORT_CATEGORY_NODE;
scene_import_settings_data->hide_options = editing_animation;
@@ -859,7 +870,7 @@ void SceneImportSettings::_viewport_input(const Ref<InputEvent> &p_input) {
}
void SceneImportSettings::_re_import() {
- Map<StringName, Variant> main_settings;
+ HashMap<StringName, Variant> main_settings;
main_settings = defaults;
main_settings.erase("_subresources");
@@ -976,7 +987,11 @@ void SceneImportSettings::_save_path_changed(const String &p_path) {
}
}
-void SceneImportSettings::_browse_save_callback(Object *p_item, int p_column, int p_id) {
+void SceneImportSettings::_browse_save_callback(Object *p_item, int p_column, int p_id, MouseButton p_button) {
+ if (p_button != MouseButton::LEFT) {
+ return;
+ }
+
TreeItem *item = Object::cast_to<TreeItem>(p_item);
String path = item->get_text(1);
@@ -1232,6 +1247,7 @@ SceneImportSettings::SceneImportSettings() {
data_mode = memnew(TabContainer);
tree_split->add_child(data_mode);
data_mode->set_custom_minimum_size(Size2(300 * EDSCALE, 0));
+ data_mode->set_theme_type_variation("TabContainerOdd");
property_split = memnew(HSplitContainer);
tree_split->add_child(property_split);
@@ -1338,7 +1354,7 @@ SceneImportSettings::SceneImportSettings() {
add_child(external_paths);
external_path_tree = memnew(Tree);
external_paths->add_child(external_path_tree);
- external_path_tree->connect("button_pressed", callable_mp(this, &SceneImportSettings::_browse_save_callback));
+ external_path_tree->connect("button_clicked", callable_mp(this, &SceneImportSettings::_browse_save_callback));
external_paths->connect("confirmed", callable_mp(this, &SceneImportSettings::_save_dir_confirm));
external_path_tree->set_columns(3);
external_path_tree->set_column_titles_visible(true);
@@ -1356,7 +1372,7 @@ SceneImportSettings::SceneImportSettings() {
HBoxContainer *extension_hb = memnew(HBoxContainer);
save_path->get_vbox()->add_child(extension_hb);
extension_hb->add_spacer();
- extension_hb->add_child(memnew(Label(TTR("Save Extension: "))));
+ extension_hb->add_child(memnew(Label(TTR("Save Extension:"))));
external_extension_type = memnew(OptionButton);
extension_hb->add_child(external_extension_type);
external_extension_type->add_item(TTR("Text: *.tres"));
diff --git a/editor/import/scene_import_settings.h b/editor/import/scene_import_settings.h
index ec24a8a5a5..b5cf82f64b 100644
--- a/editor/import/scene_import_settings.h
+++ b/editor/import/scene_import_settings.h
@@ -103,9 +103,9 @@ class SceneImportSettings : public ConfirmationDialog {
float cam_rot_y = -Math_PI / 4;
float cam_zoom = 1;
- Map<StringName, Variant> settings;
+ HashMap<StringName, Variant> settings;
};
- Map<String, MaterialData> material_map;
+ HashMap<String, MaterialData> material_map;
struct MeshData {
bool has_import_id;
@@ -116,31 +116,31 @@ class SceneImportSettings : public ConfirmationDialog {
float cam_rot_x = -Math_PI / 4;
float cam_rot_y = -Math_PI / 4;
float cam_zoom = 1;
- Map<StringName, Variant> settings;
+ HashMap<StringName, Variant> settings;
};
- Map<String, MeshData> mesh_map;
+ HashMap<String, MeshData> mesh_map;
struct AnimationData {
Ref<Animation> animation;
TreeItem *scene_node = nullptr;
- Map<StringName, Variant> settings;
+ HashMap<StringName, Variant> settings;
};
- Map<String, AnimationData> animation_map;
+ HashMap<String, AnimationData> animation_map;
struct NodeData {
Node *node = nullptr;
TreeItem *scene_node = nullptr;
- Map<StringName, Variant> settings;
+ HashMap<StringName, Variant> settings;
};
- Map<String, NodeData> node_map;
+ HashMap<String, NodeData> node_map;
void _fill_material(Tree *p_tree, const Ref<Material> &p_material, TreeItem *p_parent);
void _fill_mesh(Tree *p_tree, const Ref<Mesh> &p_mesh, TreeItem *p_parent);
void _fill_animation(Tree *p_tree, const Ref<Animation> &p_anim, const String &p_name, TreeItem *p_parent);
void _fill_scene(Node *p_node, TreeItem *p_parent_item);
- Set<Ref<Mesh>> mesh_set;
- Set<Ref<Material>> material_set;
+ HashSet<Ref<Mesh>> mesh_set;
+ HashSet<Ref<Material>> material_set;
String selected_type;
String selected_id;
@@ -156,7 +156,7 @@ class SceneImportSettings : public ConfirmationDialog {
void _viewport_input(const Ref<InputEvent> &p_input);
- Map<StringName, Variant> defaults;
+ HashMap<StringName, Variant> defaults;
SceneImportSettingsData *scene_import_settings_data = nullptr;
@@ -182,12 +182,12 @@ class SceneImportSettings : public ConfirmationDialog {
TreeItem *save_path_item = nullptr;
void _save_path_changed(const String &p_path);
- void _browse_save_callback(Object *p_item, int p_column, int p_id);
+ void _browse_save_callback(Object *p_item, int p_column, int p_id, MouseButton p_button);
void _save_dir_confirm();
Dictionary base_subresource_settings;
- void _load_default_subresource_settings(Map<StringName, Variant> &settings, const String &p_type, const String &p_import_id, ResourceImporterScene::InternalImportCategory p_category);
+ void _load_default_subresource_settings(HashMap<StringName, Variant> &settings, const String &p_type, const String &p_import_id, ResourceImporterScene::InternalImportCategory p_category);
bool editing_animation = false;
@@ -201,6 +201,7 @@ public:
void update_view();
void open_settings(const String &p_path, bool p_for_animation = false);
static SceneImportSettings *get_singleton();
+ Node *get_selected_node();
SceneImportSettings();
~SceneImportSettings();
};