summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/math/math_2d.h21
-rw-r--r--core/string_buffer.cpp2
-rw-r--r--doc/classes/TileMap.xml3
-rw-r--r--doc/classes/Timer.xml10
-rw-r--r--editor/editor_help.cpp5
-rw-r--r--editor/editor_settings.cpp12
-rw-r--r--editor/editor_themes.cpp95
-rw-r--r--editor/filesystem_dock.cpp4
-rw-r--r--editor/import/editor_scene_importer_gltf.cpp282
-rw-r--r--editor/import/editor_scene_importer_gltf.h39
-rw-r--r--editor/plugins/script_text_editor.cpp96
-rw-r--r--editor/plugins/shader_editor_plugin.cpp97
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp2
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp283
-rw-r--r--editor/plugins/tile_set_editor_plugin.h26
-rw-r--r--editor/settings_config_dialog.cpp2
-rw-r--r--main/main.cpp6
-rw-r--r--modules/bullet/bullet_physics_server.cpp2
-rw-r--r--modules/mono/csharp_script.cpp92
-rw-r--r--modules/mono/csharp_script.h15
-rw-r--r--modules/mono/editor/bindings_generator.cpp114
-rw-r--r--modules/mono/editor/bindings_generator.h23
-rw-r--r--modules/mono/editor/godotsharp_builds.cpp6
-rw-r--r--modules/mono/glue/glue_header.h8
-rw-r--r--modules/mono/mono_gc_handle.cpp5
-rw-r--r--modules/mono/mono_gd/gd_mono.cpp9
-rw-r--r--modules/mono/mono_gd/gd_mono.h2
-rw-r--r--platform/uwp/export/export.cpp70
-rw-r--r--platform/windows/detect.py6
-rw-r--r--scene/3d/skeleton.cpp24
-rw-r--r--scene/3d/skeleton.h2
-rw-r--r--scene/animation/animation_tree_player.cpp2
-rw-r--r--servers/visual/shader_language.cpp1
33 files changed, 854 insertions, 512 deletions
diff --git a/core/math/math_2d.h b/core/math/math_2d.h
index 4635a4da55..4939e7ae99 100644
--- a/core/math/math_2d.h
+++ b/core/math/math_2d.h
@@ -303,22 +303,31 @@ struct Rect2 {
inline real_t distance_to(const Vector2 &p_point) const {
- real_t dist = 1e20;
+ real_t dist;
+ bool inside = true;
if (p_point.x < position.x) {
- dist = MIN(dist, position.x - p_point.x);
+ real_t d = position.x - p_point.x;
+ dist = inside ? d : MIN(dist, d);
+ inside = false;
}
if (p_point.y < position.y) {
- dist = MIN(dist, position.y - p_point.y);
+ real_t d = position.y - p_point.y;
+ dist = inside ? d : MIN(dist, d);
+ inside = false;
}
if (p_point.x >= (position.x + size.x)) {
- dist = MIN(p_point.x - (position.x + size.x), dist);
+ real_t d = p_point.x - (position.x + size.x);
+ dist = inside ? d : MIN(dist, d);
+ inside = false;
}
if (p_point.y >= (position.y + size.y)) {
- dist = MIN(p_point.y - (position.y + size.y), dist);
+ real_t d = p_point.y - (position.y + size.y);
+ dist = inside ? d : MIN(dist, d);
+ inside = false;
}
- if (dist == 1e20)
+ if (inside)
return 0;
else
return dist;
diff --git a/core/string_buffer.cpp b/core/string_buffer.cpp
index 8489df2599..3b47685fc9 100644
--- a/core/string_buffer.cpp
+++ b/core/string_buffer.cpp
@@ -46,7 +46,7 @@ StringBuffer &StringBuffer::append(const char *p_str) {
reserve(string_length + len + 1);
CharType *buf = current_buffer_ptr();
- for (const char *c_ptr = p_str; c_ptr; ++c_ptr) {
+ for (const char *c_ptr = p_str; *c_ptr; ++c_ptr) {
buf[string_length++] = *c_ptr;
}
return *this;
diff --git a/doc/classes/TileMap.xml b/doc/classes/TileMap.xml
index 510a215fbc..a09f6b6dc3 100644
--- a/doc/classes/TileMap.xml
+++ b/doc/classes/TileMap.xml
@@ -188,6 +188,7 @@
<argument index="0" name="arg0" type="Vector2">
</argument>
<description>
+ Applies autotiling rules to the cell (and its adjacent cells) referenced by its grid-based X and Y coordinates.
</description>
</method>
<method name="update_bitmask_region">
@@ -198,6 +199,8 @@
<argument index="1" name="end" type="Vector2" default="Vector2( 0, 0 )">
</argument>
<description>
+ Applies autotiling rules to the cells in the given region (specified by grid-based X and Y coordinates).
+ Calling with invalid (or missing) parameters applies autotiling rules for the entire TileMap.
</description>
</method>
<method name="world_to_map" qualifiers="const">
diff --git a/doc/classes/Timer.xml b/doc/classes/Timer.xml
index 7ea83b0b22..09071b2ad1 100644
--- a/doc/classes/Timer.xml
+++ b/doc/classes/Timer.xml
@@ -15,20 +15,21 @@
<return type="float">
</return>
<description>
- Return the time left for timeout in seconds if the timer is active, 0 otherwise.
+ Returns the timer's remaining time in seconds. Returns 0 if the timer is inactive.
</description>
</method>
<method name="is_paused" qualifiers="const">
<return type="bool">
</return>
<description>
- Return if the timer is paused or not.
+ Returns [code]true[/code] if the timer is paused.
</description>
</method>
<method name="is_stopped" qualifiers="const">
<return type="bool">
</return>
<description>
+ Returns [code]true[/code] if the timer is stopped.
</description>
</method>
<method name="set_paused">
@@ -37,14 +38,15 @@
<argument index="0" name="paused" type="bool">
</argument>
<description>
- Set whether the timer is paused or not. A paused timer will be inactive until it is unpaused again.
+ Pauses the timer. If [code]paused[/code] is [code]true[/code], the timer will not process until it is started or unpaused again, even if [method start] is called.
</description>
</method>
<method name="start">
<return type="void">
</return>
<description>
- Start the Timer.
+ Starts the timer. This also resets the remaining time to [code]wait_time[/code].
+ Note: this method will not resume a paused timer. See [method set_paused].
</description>
</method>
<method name="stop">
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 814da4b5f4..41bcc7a1ea 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -947,6 +947,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) {
class_desc->pop();
class_desc->pop();
+ class_desc->push_font(doc_code_font);
class_desc->push_indent(1);
class_desc->push_table(2);
class_desc->set_table_column_expand(1, 1);
@@ -1002,6 +1003,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) {
class_desc->pop(); //table
class_desc->pop();
+ class_desc->pop(); // font
class_desc->add_newline();
class_desc->add_newline();
}
@@ -1072,6 +1074,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) {
class_desc->pop();
class_desc->add_newline();
+ class_desc->add_newline();
class_desc->push_indent(1);
@@ -1393,7 +1396,9 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) {
for (int i = 0; i < methods.size(); i++) {
+ class_desc->push_font(doc_code_font);
_add_method(methods[i], false);
+ class_desc->pop();
class_desc->add_newline();
class_desc->push_color(text_color);
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 3bd592e934..7450a6f0a9 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -310,7 +310,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("interface/scene_tabs/show_script_button", false);
_initial_set("text_editor/theme/color_theme", "Adaptive");
- hints["text_editor/theme/color_theme"] = PropertyInfo(Variant::STRING, "text_editor/theme/color_theme", PROPERTY_HINT_ENUM, "Adaptive,Default");
+ hints["text_editor/theme/color_theme"] = PropertyInfo(Variant::STRING, "text_editor/theme/color_theme", PROPERTY_HINT_ENUM, "Adaptive,Default,Custom");
_initial_set("text_editor/theme/line_spacing", 4);
@@ -1141,13 +1141,13 @@ void EditorSettings::load_favorites() {
}
void EditorSettings::list_text_editor_themes() {
- String themes = "Adaptive,Default";
+ String themes = "Adaptive,Default,Custom";
DirAccess *d = DirAccess::open(get_text_editor_themes_dir());
if (d) {
d->list_dir_begin();
String file = d->get_next();
while (file != String()) {
- if (file.get_extension() == "tet" && file.get_basename().to_lower() != "default" && file.get_basename().to_lower() != "adaptive") {
+ if (file.get_extension() == "tet" && file.get_basename().to_lower() != "default" && file.get_basename().to_lower() != "adaptive" && file.get_basename().to_lower() != "custom") {
themes += "," + file.get_basename();
}
file = d->get_next();
@@ -1159,7 +1159,7 @@ void EditorSettings::list_text_editor_themes() {
}
void EditorSettings::load_text_editor_theme() {
- if (get("text_editor/theme/color_theme") == "Default" || get("text_editor/theme/color_theme") == "Adaptive") {
+ if (get("text_editor/theme/color_theme") == "Default" || get("text_editor/theme/color_theme") == "Adaptive" || get("text_editor/theme/color_theme") == "Custom") {
_load_default_text_editor_theme(); // sorry for "Settings changed" console spam
return;
}
@@ -1216,7 +1216,7 @@ bool EditorSettings::save_text_editor_theme() {
String p_file = get("text_editor/theme/color_theme");
- if (p_file.get_file().to_lower() == "default" || p_file.get_file().to_lower() == "adaptive") {
+ if (p_file.get_file().to_lower() == "default" || p_file.get_file().to_lower() == "adaptive" || p_file.get_file().to_lower() == "custom") {
return false;
}
String theme_path = get_text_editor_themes_dir().plus_file(p_file + ".tet");
@@ -1228,7 +1228,7 @@ bool EditorSettings::save_text_editor_theme_as(String p_file) {
p_file += ".tet";
}
- if (p_file.get_file().to_lower() == "default.tet" || p_file.get_file().to_lower() == "adaptive.tet") {
+ if (p_file.get_file().to_lower() == "default.tet" || p_file.get_file().to_lower() == "adaptive.tet" || p_file.get_file().to_lower() == "custom.tet") {
return false;
}
if (_save_text_editor_theme(p_file)) {
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index 5610baa775..4964c78496 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -1056,36 +1056,71 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
const Color search_result_color = alpha1;
const Color search_result_border_color = alpha4;
- theme->set_color("text_editor/theme/symbol_color", "Editor", symbol_color);
- theme->set_color("text_editor/theme/keyword_color", "Editor", keyword_color);
- theme->set_color("text_editor/theme/basetype_color", "Editor", basetype_color);
- theme->set_color("text_editor/theme/type_color", "Editor", type_color);
- theme->set_color("text_editor/theme/comment_color", "Editor", comment_color);
- theme->set_color("text_editor/theme/string_color", "Editor", string_color);
- theme->set_color("text_editor/theme/background_color", "Editor", te_background_color);
- theme->set_color("text_editor/theme/completion_background_color", "Editor", completion_background_color);
- theme->set_color("text_editor/theme/completion_selected_color", "Editor", completion_selected_color);
- theme->set_color("text_editor/theme/completion_existing_color", "Editor", completion_existing_color);
- theme->set_color("text_editor/theme/completion_scroll_color", "Editor", completion_scroll_color);
- theme->set_color("text_editor/theme/completion_font_color", "Editor", completion_font_color);
- theme->set_color("text_editor/theme/text_color", "Editor", text_color);
- theme->set_color("text_editor/theme/line_number_color", "Editor", line_number_color);
- theme->set_color("text_editor/theme/caret_color", "Editor", caret_color);
- theme->set_color("text_editor/theme/caret_background_color", "Editor", caret_background_color);
- theme->set_color("text_editor/theme/text_selected_color", "Editor", text_selected_color);
- theme->set_color("text_editor/theme/selection_color", "Editor", selection_color);
- theme->set_color("text_editor/theme/brace_mismatch_color", "Editor", brace_mismatch_color);
- theme->set_color("text_editor/theme/current_line_color", "Editor", current_line_color);
- theme->set_color("text_editor/theme/line_length_guideline_color", "Editor", line_length_guideline_color);
- theme->set_color("text_editor/theme/word_highlighted_color", "Editor", word_highlighted_color);
- theme->set_color("text_editor/theme/number_color", "Editor", number_color);
- theme->set_color("text_editor/theme/function_color", "Editor", function_color);
- theme->set_color("text_editor/theme/member_variable_color", "Editor", member_variable_color);
- theme->set_color("text_editor/theme/mark_color", "Editor", mark_color);
- theme->set_color("text_editor/theme/breakpoint_color", "Editor", breakpoint_color);
- theme->set_color("text_editor/theme/code_folding_color", "Editor", code_folding_color);
- theme->set_color("text_editor/theme/search_result_color", "Editor", search_result_color);
- theme->set_color("text_editor/theme/search_result_border_color", "Editor", search_result_border_color);
+ EditorSettings *setting = EditorSettings::get_singleton();
+ String text_editor_color_theme = setting->get("text_editor/theme/color_theme");
+ if (text_editor_color_theme == "Adaptive") {
+ setting->set_manually("text_editor/highlighting/symbol_color", symbol_color);
+ setting->set_manually("text_editor/highlighting/keyword_color", keyword_color);
+ setting->set_manually("text_editor/highlighting/base_type_color", basetype_color);
+ setting->set_manually("text_editor/highlighting/engine_type_color", type_color);
+ setting->set_manually("text_editor/highlighting/comment_color", comment_color);
+ setting->set_manually("text_editor/highlighting/string_color", string_color);
+ setting->set_manually("text_editor/highlighting/background_color", background_color);
+ setting->set_manually("text_editor/highlighting/completion_background_color", completion_background_color);
+ setting->set_manually("text_editor/highlighting/completion_selected_color", completion_selected_color);
+ setting->set_manually("text_editor/highlighting/completion_existing_color", completion_existing_color);
+ setting->set_manually("text_editor/highlighting/completion_scroll_color", completion_scroll_color);
+ setting->set_manually("text_editor/highlighting/completion_font_color", completion_font_color);
+ setting->set_manually("text_editor/highlighting/text_color", text_color);
+ setting->set_manually("text_editor/highlighting/line_number_color", line_number_color);
+ setting->set_manually("text_editor/highlighting/caret_color", caret_color);
+ setting->set_manually("text_editor/highlighting/caret_background_color", caret_background_color);
+ setting->set_manually("text_editor/highlighting/text_selected_color", text_selected_color);
+ setting->set_manually("text_editor/highlighting/selection_color", selection_color);
+ setting->set_manually("text_editor/highlighting/brace_mismatch_color", brace_mismatch_color);
+ setting->set_manually("text_editor/highlighting/current_line_color", current_line_color);
+ setting->set_manually("text_editor/highlighting/line_length_guideline_color", line_length_guideline_color);
+ setting->set_manually("text_editor/highlighting/word_highlighted_color", word_highlighted_color);
+ setting->set_manually("text_editor/highlighting/number_color", number_color);
+ setting->set_manually("text_editor/highlighting/function_color", function_color);
+ setting->set_manually("text_editor/highlighting/member_variable_color", member_variable_color);
+ setting->set_manually("text_editor/highlighting/mark_color", mark_color);
+ setting->set_manually("text_editor/highlighting/breakpoint_color", breakpoint_color);
+ setting->set_manually("text_editor/highlighting/code_folding_color", code_folding_color);
+ setting->set_manually("text_editor/highlighting/search_result_color", search_result_color);
+ setting->set_manually("text_editor/highlighting/search_result_border_color", search_result_border_color);
+ } else if (text_editor_color_theme == "Default") {
+ setting->set_manually("text_editor/highlighting/symbol_color", Color::html("badfff"));
+ setting->set_manually("text_editor/highlighting/keyword_color", Color::html("ffffb3"));
+ setting->set_manually("text_editor/highlighting/base_type_color", Color::html("a4ffd4"));
+ setting->set_manually("text_editor/highlighting/engine_type_color", Color::html("83d3ff"));
+ setting->set_manually("text_editor/highlighting/comment_color", Color::html("676767"));
+ setting->set_manually("text_editor/highlighting/string_color", Color::html("ef6ebe"));
+ setting->set_manually("text_editor/highlighting/background_color", Color::html("3b000000"));
+ setting->set_manually("text_editor/highlighting/completion_background_color", Color::html("2C2A32"));
+ setting->set_manually("text_editor/highlighting/completion_selected_color", Color::html("434244"));
+ setting->set_manually("text_editor/highlighting/completion_existing_color", Color::html("21dfdfdf"));
+ setting->set_manually("text_editor/highlighting/completion_scroll_color", Color::html("ffffff"));
+ setting->set_manually("text_editor/highlighting/completion_font_color", Color::html("aaaaaa"));
+ setting->set_manually("text_editor/highlighting/text_color", Color::html("aaaaaa"));
+ setting->set_manually("text_editor/highlighting/line_number_color", Color::html("66aaaaaa"));
+ setting->set_manually("text_editor/highlighting/caret_color", Color::html("aaaaaa"));
+ setting->set_manually("text_editor/highlighting/caret_background_color", Color::html("000000"));
+ setting->set_manually("text_editor/highlighting/text_selected_color", Color::html("000000"));
+ setting->set_manually("text_editor/highlighting/selection_color", Color::html("6ca9c2"));
+ setting->set_manually("text_editor/highlighting/brace_mismatch_color", Color(1, 0.2, 0.2));
+ setting->set_manually("text_editor/highlighting/current_line_color", Color(0.3, 0.5, 0.8, 0.15));
+ setting->set_manually("text_editor/highlighting/line_length_guideline_color", Color(0.3, 0.5, 0.8, 0.1));
+ setting->set_manually("text_editor/highlighting/word_highlighted_color", Color(0.8, 0.9, 0.9, 0.15));
+ setting->set_manually("text_editor/highlighting/number_color", Color::html("EB9532"));
+ setting->set_manually("text_editor/highlighting/function_color", Color::html("66a2ce"));
+ setting->set_manually("text_editor/highlighting/member_variable_color", Color::html("e64e59"));
+ setting->set_manually("text_editor/highlighting/mark_color", Color(1.0, 0.4, 0.4, 0.4));
+ setting->set_manually("text_editor/highlighting/breakpoint_color", Color(0.8, 0.8, 0.4, 0.2));
+ setting->set_manually("text_editor/highlighting/code_folding_color", Color(0.8, 0.8, 0.8, 0.8));
+ setting->set_manually("text_editor/highlighting/search_result_color", Color(0.05, 0.25, 0.05, 1));
+ setting->set_manually("text_editor/highlighting/search_result_border_color", Color(0.1, 0.45, 0.1, 1));
+ }
return theme;
}
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index dce5a10d67..812379faca 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -403,12 +403,12 @@ void FileSystemDock::_search(EditorFileSystemDirectory *p_path, List<FileInfo> *
_search(p_path->get_subdir(i), matches, p_max_items);
}
- String match = search_box->get_text();
+ String match = search_box->get_text().to_lower();
for (int i = 0; i < p_path->get_file_count(); i++) {
String file = p_path->get_file(i);
- if (file.find(match) != -1) {
+ if (file.to_lower().find(match) != -1) {
FileInfo fi;
fi.name = file;
diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp
index 00eb69a568..189e98ea68 100644
--- a/editor/import/editor_scene_importer_gltf.cpp
+++ b/editor/import/editor_scene_importer_gltf.cpp
@@ -185,11 +185,13 @@ Error EditorSceneImporterGLTF::_parse_nodes(GLTFState &state) {
}
if (n.has("skin")) {
node->skin = n["skin"];
+ /*
if (!state.skin_users.has(node->skin)) {
state.skin_users[node->skin] = Vector<int>();
}
state.skin_users[node->skin].push_back(i);
+ */
}
if (n.has("matrix")) {
node->xform = _arr_to_xform(n["matrix"]);
@@ -1316,8 +1318,10 @@ Error EditorSceneImporterGLTF::_parse_skins(GLTFState &state) {
for (int j = 0; j < joints.size(); j++) {
int index = joints[j];
ERR_FAIL_INDEX_V(index, state.nodes.size(), ERR_PARSE_ERROR);
- state.nodes[index]->joint_skin = state.skins.size();
- state.nodes[index]->joint_bone = j;
+ GLTFNode::Joint joint;
+ joint.skin = state.skins.size();
+ joint.bone = j;
+ state.nodes[index]->joints.push_back(joint);
GLTFSkin::Bone bone;
bone.node = index;
if (bind_matrices.size()) {
@@ -1331,7 +1335,7 @@ Error EditorSceneImporterGLTF::_parse_skins(GLTFState &state) {
if (d.has("skeleton")) {
int skeleton = d["skeleton"];
ERR_FAIL_INDEX_V(skeleton, state.nodes.size(), ERR_PARSE_ERROR);
- state.nodes[skeleton]->skeleton_skin = state.skins.size();
+ //state.nodes[skeleton]->skeleton_skin = state.skins.size();
print_line("setting skeleton skin to" + itos(skeleton));
skin.skeleton = skeleton;
}
@@ -1341,7 +1345,7 @@ Error EditorSceneImporterGLTF::_parse_skins(GLTFState &state) {
}
//locate the right place to put a Skeleton node
-
+ /*
if (state.skin_users.has(i)) {
Vector<int> users = state.skin_users[i];
int skin_node = -1;
@@ -1382,6 +1386,7 @@ Error EditorSceneImporterGLTF::_parse_skins(GLTFState &state) {
state.nodes[skin_node]->skeleton_children.push_back(i);
}
}
+ */
state.skins.push_back(skin);
}
print_line("total skins: " + itos(state.skins.size()));
@@ -1577,7 +1582,7 @@ void EditorSceneImporterGLTF::_assign_scene_names(GLTFState &state) {
if (n->name == "") {
if (n->mesh >= 0) {
n->name = "Mesh";
- } else if (n->joint_skin >= 0) {
+ } else if (n->joints.size()) {
n->name = "Bone";
} else {
n->name = "Node";
@@ -1607,6 +1612,7 @@ void EditorSceneImporterGLTF::_generate_node(GLTFState &state, int p_node, Node
}
node = mi;
+
} else if (n->camera >= 0) {
ERR_FAIL_INDEX(n->camera, state.cameras.size());
Camera *camera = memnew(Camera);
@@ -1625,18 +1631,20 @@ void EditorSceneImporterGLTF::_generate_node(GLTFState &state, int p_node, Node
node->set_name(n->name);
- if (n->child_of_skeleton >= 0) {
- //move skeleton around and place it on node, as the node _is_ a skeleton.
- Skeleton *s = skeletons[n->child_of_skeleton];
- p_parent = s;
- }
-
p_parent->add_child(node);
node->set_owner(p_owner);
node->set_transform(n->xform);
- n->godot_node = node;
+ n->godot_nodes.push_back(node);
+
+ if (n->skin >= 0 && Object::cast_to<MeshInstance>(node)) {
+ MeshInstance *mi = Object::cast_to<MeshInstance>(node);
+ //move skeleton around and place it on node, as the node _is_ a skeleton.
+ Skeleton *s = skeletons[n->skin];
+ mi->set_skeleton_path(mi->get_path_to(s));
+ }
+#if 0
for (int i = 0; i < n->skeleton_children.size(); i++) {
Skeleton *s = skeletons[n->skeleton_children[i]];
@@ -1644,36 +1652,39 @@ void EditorSceneImporterGLTF::_generate_node(GLTFState &state, int p_node, Node
node->add_child(s);
s->set_owner(p_owner);
}
-
+#endif
for (int i = 0; i < n->children.size(); i++) {
- if (state.nodes[n->children[i]]->joint_skin >= 0) {
- _generate_bone(state, n->children[i], skeletons, -1);
+ if (state.nodes[n->children[i]]->joints.size()) {
+ _generate_bone(state, n->children[i], skeletons, Vector<int>());
} else {
_generate_node(state, n->children[i], node, p_owner, skeletons);
}
}
}
-void EditorSceneImporterGLTF::_generate_bone(GLTFState &state, int p_node, Vector<Skeleton *> &skeletons, int p_parent_bone) {
+void EditorSceneImporterGLTF::_generate_bone(GLTFState &state, int p_node, Vector<Skeleton *> &skeletons, const Vector<int> &p_parent_bones) {
ERR_FAIL_INDEX(p_node, state.nodes.size());
GLTFNode *n = state.nodes[p_node];
+ Vector<int> parent_bones;
- ERR_FAIL_COND(n->joint_skin < 0);
+ for (int i = 0; i < n->joints.size(); i++) {
+ ERR_FAIL_COND(n->joints[i].skin < 0);
- int bone_index = skeletons[n->joint_skin]->get_bone_count();
- skeletons[n->joint_skin]->add_bone(n->name);
- if (p_parent_bone >= 0) {
- skeletons[n->joint_skin]->set_bone_parent(bone_index, p_parent_bone);
- }
- skeletons[n->joint_skin]->set_bone_rest(bone_index, state.skins[n->joint_skin].bones[n->joint_bone].inverse_bind.affine_inverse());
+ int bone_index = skeletons[n->joints[i].skin]->get_bone_count();
+ skeletons[n->joints[i].skin]->add_bone(n->name);
+ if (p_parent_bones.size()) {
+ skeletons[n->joints[i].skin]->set_bone_parent(bone_index, p_parent_bones[i]);
+ }
+ skeletons[n->joints[i].skin]->set_bone_rest(bone_index, state.skins[n->joints[i].skin].bones[n->joints[i].bone].inverse_bind.affine_inverse());
- n->godot_node = skeletons[n->joint_skin];
- n->godot_bone_index = bone_index;
+ n->godot_nodes.push_back(skeletons[n->joints[i].skin]);
+ n->joints[i].godot_bone_index = bone_index;
+ parent_bones.push_back(bone_index);
+ }
for (int i = 0; i < n->children.size(); i++) {
- ERR_CONTINUE(state.nodes[n->children[i]]->joint_skin < 0);
- _generate_bone(state, n->children[i], skeletons, bone_index);
+ _generate_bone(state, n->children[i], skeletons, parent_bones);
}
}
@@ -1818,141 +1829,104 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye
NodePath node_path;
GLTFNode *node = state.nodes[E->key()];
- ERR_CONTINUE(!node->godot_node);
-
- if (node->godot_bone_index >= 0) {
- Skeleton *sk = (Skeleton *)node->godot_node;
- String path = ap->get_parent()->get_path_to(sk);
- String bone = sk->get_bone_name(node->godot_bone_index);
- node_path = path + ":" + bone;
- } else {
- node_path = ap->get_parent()->get_path_to(node->godot_node);
- }
-
- float length = 0;
+ for (int i = 0; i < node->godot_nodes.size(); i++) {
- for (int i = 0; i < track.rotation_track.times.size(); i++) {
- length = MAX(length, track.rotation_track.times[i]);
- }
- for (int i = 0; i < track.translation_track.times.size(); i++) {
- length = MAX(length, track.translation_track.times[i]);
- }
- for (int i = 0; i < track.scale_track.times.size(); i++) {
- length = MAX(length, track.scale_track.times[i]);
- }
-
- for (int i = 0; i < track.weight_tracks.size(); i++) {
- for (int j = 0; j < track.weight_tracks[i].times.size(); j++) {
- length = MAX(length, track.weight_tracks[i].times[j]);
+ if (node->joints.size()) {
+ Skeleton *sk = (Skeleton *)node->godot_nodes[i];
+ String path = ap->get_parent()->get_path_to(sk);
+ String bone = sk->get_bone_name(node->joints[i].godot_bone_index);
+ node_path = path + ":" + bone;
+ } else {
+ node_path = ap->get_parent()->get_path_to(node->godot_nodes[i]);
}
- }
-
- animation->set_length(length);
-
- if (track.rotation_track.values.size() || track.translation_track.values.size() || track.scale_track.values.size()) {
- //make transform track
- int track_idx = animation->get_track_count();
- animation->add_track(Animation::TYPE_TRANSFORM);
- animation->track_set_path(track_idx, node_path);
- //first determine animation length
- float increment = 1.0 / float(bake_fps);
- float time = 0.0;
+ float length = 0;
- Vector3 base_pos;
- Quat base_rot;
- Vector3 base_scale = Vector3(1, 1, 1);
-
- if (!track.rotation_track.values.size()) {
- base_rot = state.nodes[E->key()]->rotation;
+ for (int i = 0; i < track.rotation_track.times.size(); i++) {
+ length = MAX(length, track.rotation_track.times[i]);
}
-
- if (!track.translation_track.values.size()) {
- base_pos = state.nodes[E->key()]->translation;
+ for (int i = 0; i < track.translation_track.times.size(); i++) {
+ length = MAX(length, track.translation_track.times[i]);
+ }
+ for (int i = 0; i < track.scale_track.times.size(); i++) {
+ length = MAX(length, track.scale_track.times[i]);
}
- if (!track.scale_track.values.size()) {
- base_scale = state.nodes[E->key()]->scale;
+ for (int i = 0; i < track.weight_tracks.size(); i++) {
+ for (int j = 0; j < track.weight_tracks[i].times.size(); j++) {
+ length = MAX(length, track.weight_tracks[i].times[j]);
+ }
}
- bool last = false;
- while (true) {
+ animation->set_length(length);
+
+ if (track.rotation_track.values.size() || track.translation_track.values.size() || track.scale_track.values.size()) {
+ //make transform track
+ int track_idx = animation->get_track_count();
+ animation->add_track(Animation::TYPE_TRANSFORM);
+ animation->track_set_path(track_idx, node_path);
+ //first determine animation length
- Vector3 pos = base_pos;
- Quat rot = base_rot;
- Vector3 scale = base_scale;
+ float increment = 1.0 / float(bake_fps);
+ float time = 0.0;
- if (track.translation_track.times.size()) {
+ Vector3 base_pos;
+ Quat base_rot;
+ Vector3 base_scale = Vector3(1, 1, 1);
- pos = _interpolate_track<Vector3>(track.translation_track.times, track.translation_track.values, time, track.translation_track.interpolation);
+ if (!track.rotation_track.values.size()) {
+ base_rot = state.nodes[E->key()]->rotation;
}
- if (track.rotation_track.times.size()) {
+ if (!track.translation_track.values.size()) {
+ base_pos = state.nodes[E->key()]->translation;
+ }
- rot = _interpolate_track<Quat>(track.rotation_track.times, track.rotation_track.values, time, track.rotation_track.interpolation);
+ if (!track.scale_track.values.size()) {
+ base_scale = state.nodes[E->key()]->scale;
}
- if (track.scale_track.times.size()) {
+ bool last = false;
+ while (true) {
- scale = _interpolate_track<Vector3>(track.scale_track.times, track.scale_track.values, time, track.scale_track.interpolation);
- }
+ Vector3 pos = base_pos;
+ Quat rot = base_rot;
+ Vector3 scale = base_scale;
- if (node->godot_bone_index >= 0) {
+ if (track.translation_track.times.size()) {
- Transform xform;
- xform.basis = Basis(rot);
- xform.basis.scale(scale);
- xform.origin = pos;
+ pos = _interpolate_track<Vector3>(track.translation_track.times, track.translation_track.values, time, track.translation_track.interpolation);
+ }
- Skeleton *skeleton = skeletons[node->joint_skin];
- int bone = node->godot_bone_index;
- xform = skeleton->get_bone_rest(bone).affine_inverse() * xform;
+ if (track.rotation_track.times.size()) {
- rot = xform.basis;
- rot.normalize();
- scale = xform.basis.get_scale();
- pos = xform.origin;
- }
+ rot = _interpolate_track<Quat>(track.rotation_track.times, track.rotation_track.values, time, track.rotation_track.interpolation);
+ }
- animation->transform_track_insert_key(track_idx, time, pos, rot, scale);
+ if (track.scale_track.times.size()) {
- if (last) {
- break;
- }
- time += increment;
- if (time >= length) {
- last = true;
- time = length;
- }
- }
- }
+ scale = _interpolate_track<Vector3>(track.scale_track.times, track.scale_track.values, time, track.scale_track.interpolation);
+ }
- for (int i = 0; i < track.weight_tracks.size(); i++) {
- ERR_CONTINUE(node->mesh < 0 || node->mesh >= state.meshes.size());
- const GLTFMesh &mesh = state.meshes[node->mesh];
- String prop = "blend_shapes/" + mesh.mesh->get_blend_shape_name(i);
- node_path = String(node_path) + ":" + prop;
+ if (node->joints.size()) {
- int track_idx = animation->get_track_count();
- animation->add_track(Animation::TYPE_VALUE);
- animation->track_set_path(track_idx, node_path);
+ Transform xform;
+ xform.basis = Basis(rot);
+ xform.basis.scale(scale);
+ xform.origin = pos;
- if (track.weight_tracks[i].interpolation <= GLTFAnimation::INTERP_STEP) {
- animation->track_set_interpolation_type(track_idx, track.weight_tracks[i].interpolation == GLTFAnimation::INTERP_STEP ? Animation::INTERPOLATION_NEAREST : Animation::INTERPOLATION_NEAREST);
- for (int j = 0; j < track.weight_tracks[i].times.size(); j++) {
- float t = track.weight_tracks[i].times[j];
- float w = track.weight_tracks[i].values[j];
- animation->track_insert_key(track_idx, t, w);
- }
- } else {
- //must bake, apologies.
- float increment = 1.0 / float(bake_fps);
- float time = 0.0;
+ Skeleton *skeleton = skeletons[node->joints[i].skin];
+ int bone = node->joints[i].godot_bone_index;
+ xform = skeleton->get_bone_rest(bone).affine_inverse() * xform;
- bool last = false;
- while (true) {
+ rot = xform.basis;
+ rot.normalize();
+ scale = xform.basis.get_scale();
+ pos = xform.origin;
+ }
+
+ animation->transform_track_insert_key(track_idx, time, pos, rot, scale);
- _interpolate_track<float>(track.weight_tracks[i].times, track.weight_tracks[i].values, time, track.weight_tracks[i].interpolation);
if (last) {
break;
}
@@ -1963,6 +1937,44 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye
}
}
}
+
+ for (int i = 0; i < track.weight_tracks.size(); i++) {
+ ERR_CONTINUE(node->mesh < 0 || node->mesh >= state.meshes.size());
+ const GLTFMesh &mesh = state.meshes[node->mesh];
+ String prop = "blend_shapes/" + mesh.mesh->get_blend_shape_name(i);
+ node_path = String(node_path) + ":" + prop;
+
+ int track_idx = animation->get_track_count();
+ animation->add_track(Animation::TYPE_VALUE);
+ animation->track_set_path(track_idx, node_path);
+
+ if (track.weight_tracks[i].interpolation <= GLTFAnimation::INTERP_STEP) {
+ animation->track_set_interpolation_type(track_idx, track.weight_tracks[i].interpolation == GLTFAnimation::INTERP_STEP ? Animation::INTERPOLATION_NEAREST : Animation::INTERPOLATION_NEAREST);
+ for (int j = 0; j < track.weight_tracks[i].times.size(); j++) {
+ float t = track.weight_tracks[i].times[j];
+ float w = track.weight_tracks[i].values[j];
+ animation->track_insert_key(track_idx, t, w);
+ }
+ } else {
+ //must bake, apologies.
+ float increment = 1.0 / float(bake_fps);
+ float time = 0.0;
+
+ bool last = false;
+ while (true) {
+
+ _interpolate_track<float>(track.weight_tracks[i].times, track.weight_tracks[i].values, time, track.weight_tracks[i].interpolation);
+ if (last) {
+ break;
+ }
+ time += increment;
+ if (time >= length) {
+ last = true;
+ time = length;
+ }
+ }
+ }
+ }
}
}
@@ -1987,8 +1999,8 @@ Spatial *EditorSceneImporterGLTF::_generate_scene(GLTFState &state, int p_bake_f
skeletons.push_back(s);
}
for (int i = 0; i < state.root_nodes.size(); i++) {
- if (state.nodes[state.root_nodes[i]]->joint_skin >= 0) {
- _generate_bone(state, state.root_nodes[i], skeletons, -1);
+ if (state.nodes[state.root_nodes[i]]->joints.size()) {
+ _generate_bone(state, state.root_nodes[i], skeletons, Vector<int>());
} else {
_generate_node(state, state.root_nodes[i], root, root, skeletons);
}
diff --git a/editor/import/editor_scene_importer_gltf.h b/editor/import/editor_scene_importer_gltf.h
index 91c584a05a..abbdfa418b 100644
--- a/editor/import/editor_scene_importer_gltf.h
+++ b/editor/import/editor_scene_importer_gltf.h
@@ -52,18 +52,29 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
Transform xform;
String name;
- Node *godot_node;
- int godot_bone_index;
+ //Node *godot_node;
+ //int godot_bone_index;
int mesh;
int camera;
int skin;
- int skeleton_skin;
- int child_of_skeleton; // put as children of skeleton
- Vector<int> skeleton_children; //skeleton put as children of this
+ //int skeleton_skin;
+ //int child_of_skeleton; // put as children of skeleton
+ //Vector<int> skeleton_children; //skeleton put as children of this
+
+ struct Joint {
+ int skin;
+ int bone;
+ int godot_bone_index;
+
+ Joint() {
+ skin = -1;
+ bone = -1;
+ godot_bone_index = -1;
+ }
+ };
- int joint_skin;
- int joint_bone;
+ Vector<Joint> joints;
//keep them for animation
Vector3 translation;
@@ -71,17 +82,15 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
Vector3 scale;
Vector<int> children;
+ Vector<Node *> godot_nodes;
GLTFNode() {
- godot_node = NULL;
- godot_bone_index = -1;
- joint_skin = -1;
- joint_bone = -1;
- child_of_skeleton = -1;
- skeleton_skin = -1;
+ // child_of_skeleton = -1;
+ // skeleton_skin = -1;
mesh = -1;
camera = -1;
parent = -1;
+ skin = -1;
scale = Vector3(1, 1, 1);
}
};
@@ -235,7 +244,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
Vector<GLTFAnimation> animations;
- Map<int, Vector<int> > skin_users; //cache skin users
+ //Map<int, Vector<int> > skin_users; //cache skin users
~GLTFState() {
for (int i = 0; i < nodes.size(); i++) {
@@ -269,7 +278,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
Vector<Basis> _decode_accessor_as_basis(GLTFState &state, int p_accessor, bool p_for_vertex);
Vector<Transform> _decode_accessor_as_xform(GLTFState &state, int p_accessor, bool p_for_vertex);
- void _generate_bone(GLTFState &state, int p_node, Vector<Skeleton *> &skeletons, int p_parent_bone);
+ void _generate_bone(GLTFState &state, int p_node, Vector<Skeleton *> &skeletons, const Vector<int> &p_parent_bones);
void _generate_node(GLTFState &state, int p_node, Node *p_parent, Node *p_owner, Vector<Skeleton *> &skeletons);
void _import_animation(GLTFState &state, AnimationPlayer *ap, int index, int bake_fps, Vector<Skeleton *> skeletons);
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 3c9cd74aa1..a59f1a3690 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -75,72 +75,36 @@ void ScriptTextEditor::_load_theme_settings() {
text_edit->clear_colors();
- Color background_color = EDITOR_DEF("text_editor/highlighting/background_color", Color(0, 0, 0, 0));
- Color completion_background_color = EDITOR_DEF("text_editor/highlighting/completion_background_color", Color(0, 0, 0, 0));
- Color completion_selected_color = EDITOR_DEF("text_editor/highlighting/completion_selected_color", Color::html("434244"));
- Color completion_existing_color = EDITOR_DEF("text_editor/highlighting/completion_existing_color", Color::html("21dfdfdf"));
- Color completion_scroll_color = EDITOR_DEF("text_editor/highlighting/completion_scroll_color", Color::html("ffffff"));
- Color completion_font_color = EDITOR_DEF("text_editor/highlighting/completion_font_color", Color::html("aaaaaa"));
- Color text_color = EDITOR_DEF("text_editor/highlighting/text_color", Color(0, 0, 0));
- Color line_number_color = EDITOR_DEF("text_editor/highlighting/line_number_color", Color(0, 0, 0));
- Color caret_color = EDITOR_DEF("text_editor/highlighting/caret_color", Color(0, 0, 0));
- Color caret_background_color = EDITOR_DEF("text_editor/highlighting/caret_background_color", Color(0, 0, 0));
- Color text_selected_color = EDITOR_DEF("text_editor/highlighting/text_selected_color", Color(1, 1, 1));
- Color selection_color = EDITOR_DEF("text_editor/highlighting/selection_color", Color(0.2, 0.2, 1));
- Color brace_mismatch_color = EDITOR_DEF("text_editor/highlighting/brace_mismatch_color", Color(1, 0.2, 0.2));
- Color current_line_color = EDITOR_DEF("text_editor/highlighting/current_line_color", Color(0.3, 0.5, 0.8, 0.15));
- Color line_length_guideline_color = EDITOR_DEF("text_editor/highlighting/line_length_guideline_color", Color(0, 0, 0));
- Color word_highlighted_color = EDITOR_DEF("text_editor/highlighting/word_highlighted_color", Color(0.8, 0.9, 0.9, 0.15));
- Color number_color = EDITOR_DEF("text_editor/highlighting/number_color", Color(0.9, 0.6, 0.0, 2));
- Color function_color = EDITOR_DEF("text_editor/highlighting/function_color", Color(0.4, 0.6, 0.8));
- Color member_variable_color = EDITOR_DEF("text_editor/highlighting/member_variable_color", Color(0.9, 0.3, 0.3));
- Color mark_color = EDITOR_DEF("text_editor/highlighting/mark_color", Color(1.0, 0.4, 0.4, 0.4));
- Color breakpoint_color = EDITOR_DEF("text_editor/highlighting/breakpoint_color", Color(0.8, 0.8, 0.4, 0.2));
- Color code_folding_color = EDITOR_DEF("text_editor/highlighting/code_folding_color", Color(0.8, 0.8, 0.8, 0.8));
- Color search_result_color = EDITOR_DEF("text_editor/highlighting/search_result_color", Color(0.05, 0.25, 0.05, 1));
- Color search_result_border_color = EDITOR_DEF("text_editor/highlighting/search_result_border_color", Color(0.1, 0.45, 0.1, 1));
- Color symbol_color = EDITOR_DEF("text_editor/highlighting/symbol_color", Color::hex(0x005291ff));
- Color keyword_color = EDITOR_DEF("text_editor/highlighting/keyword_color", Color(0.5, 0.0, 0.2));
- Color basetype_color = EDITOR_DEF("text_editor/highlighting/base_type_color", Color(0.3, 0.3, 0.0));
- Color type_color = EDITOR_DEF("text_editor/highlighting/engine_type_color", Color(0.0, 0.2, 0.4));
- Color comment_color = EDITOR_DEF("text_editor/highlighting/comment_color", Color::hex(0x797e7eff));
- Color string_color = EDITOR_DEF("text_editor/highlighting/string_color", Color::hex(0x6b6f00ff));
-
- // Adapt
- if (EditorSettings::get_singleton()->get("text_editor/theme/color_theme") == "Adaptive") {
- Ref<Theme> tm = EditorNode::get_singleton()->get_theme_base()->get_theme();
-
- symbol_color = tm->get_color("text_editor/theme/symbol_color", "Editor");
- keyword_color = tm->get_color("text_editor/theme/keyword_color", "Editor");
- basetype_color = tm->get_color("text_editor/theme/basetype_color", "Editor");
- type_color = tm->get_color("text_editor/theme/type_color", "Editor");
- comment_color = tm->get_color("text_editor/theme/comment_color", "Editor");
- string_color = tm->get_color("text_editor/theme/string_color", "Editor");
- background_color = tm->get_color("text_editor/theme/background_color", "Editor");
- completion_background_color = tm->get_color("text_editor/theme/completion_background_color", "Editor");
- completion_selected_color = tm->get_color("text_editor/theme/completion_selected_color", "Editor");
- completion_existing_color = tm->get_color("text_editor/theme/completion_existing_color", "Editor");
- completion_scroll_color = tm->get_color("text_editor/theme/completion_scroll_color", "Editor");
- completion_font_color = tm->get_color("text_editor/theme/completion_font_color", "Editor");
- text_color = tm->get_color("text_editor/theme/text_color", "Editor");
- line_number_color = tm->get_color("text_editor/theme/line_number_color", "Editor");
- caret_color = tm->get_color("text_editor/theme/caret_color", "Editor");
- caret_background_color = tm->get_color("text_editor/theme/caret_background_color", "Editor");
- text_selected_color = tm->get_color("text_editor/theme/text_selected_color", "Editor");
- selection_color = tm->get_color("text_editor/theme/selection_color", "Editor");
- brace_mismatch_color = tm->get_color("text_editor/theme/brace_mismatch_color", "Editor");
- current_line_color = tm->get_color("text_editor/theme/current_line_color", "Editor");
- line_length_guideline_color = tm->get_color("text_editor/theme/line_length_guideline_color", "Editor");
- word_highlighted_color = tm->get_color("text_editor/theme/word_highlighted_color", "Editor");
- number_color = tm->get_color("text_editor/theme/number_color", "Editor");
- function_color = tm->get_color("text_editor/theme/function_color", "Editor");
- member_variable_color = tm->get_color("text_editor/theme/member_variable_color", "Editor");
- mark_color = tm->get_color("text_editor/theme/mark_color", "Editor");
- breakpoint_color = tm->get_color("text_editor/theme/breakpoint_color", "Editor");
- code_folding_color = tm->get_color("text_editor/theme/code_folding_color", "Editor");
- search_result_color = tm->get_color("text_editor/theme/search_result_color", "Editor");
- search_result_border_color = tm->get_color("text_editor/theme/search_result_border_color", "Editor");
- }
+ Color background_color = EDITOR_GET("text_editor/highlighting/background_color");
+ Color completion_background_color = EDITOR_GET("text_editor/highlighting/completion_background_color");
+ Color completion_selected_color = EDITOR_GET("text_editor/highlighting/completion_selected_color");
+ Color completion_existing_color = EDITOR_GET("text_editor/highlighting/completion_existing_color");
+ Color completion_scroll_color = EDITOR_GET("text_editor/highlighting/completion_scroll_color");
+ Color completion_font_color = EDITOR_GET("text_editor/highlighting/completion_font_color");
+ Color text_color = EDITOR_GET("text_editor/highlighting/text_color");
+ Color line_number_color = EDITOR_GET("text_editor/highlighting/line_number_color");
+ Color caret_color = EDITOR_GET("text_editor/highlighting/caret_color");
+ Color caret_background_color = EDITOR_GET("text_editor/highlighting/caret_background_color");
+ Color text_selected_color = EDITOR_GET("text_editor/highlighting/text_selected_color");
+ Color selection_color = EDITOR_GET("text_editor/highlighting/selection_color");
+ Color brace_mismatch_color = EDITOR_GET("text_editor/highlighting/brace_mismatch_color");
+ Color current_line_color = EDITOR_GET("text_editor/highlighting/current_line_color");
+ Color line_length_guideline_color = EDITOR_GET("text_editor/highlighting/line_length_guideline_color");
+ Color word_highlighted_color = EDITOR_GET("text_editor/highlighting/word_highlighted_color");
+ Color number_color = EDITOR_GET("text_editor/highlighting/number_color");
+ Color function_color = EDITOR_GET("text_editor/highlighting/function_color");
+ Color member_variable_color = EDITOR_GET("text_editor/highlighting/member_variable_color");
+ Color mark_color = EDITOR_GET("text_editor/highlighting/mark_color");
+ Color breakpoint_color = EDITOR_GET("text_editor/highlighting/breakpoint_color");
+ Color code_folding_color = EDITOR_GET("text_editor/highlighting/code_folding_color");
+ Color search_result_color = EDITOR_GET("text_editor/highlighting/search_result_color");
+ Color search_result_border_color = EDITOR_GET("text_editor/highlighting/search_result_border_color");
+ Color symbol_color = EDITOR_GET("text_editor/highlighting/symbol_color");
+ Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_color");
+ Color basetype_color = EDITOR_GET("text_editor/highlighting/base_type_color");
+ Color type_color = EDITOR_GET("text_editor/highlighting/engine_type_color");
+ Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color");
+ Color string_color = EDITOR_GET("text_editor/highlighting/string_color");
text_edit->add_color_override("background_color", background_color);
text_edit->add_color_override("completion_background_color", completion_background_color);
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index d0b0d3690a..aa0607dfc0 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -60,73 +60,36 @@ void ShaderTextEditor::_load_theme_settings() {
get_text_edit()->clear_colors();
- Color background_color = EDITOR_DEF("text_editor/highlighting/background_color", Color(0, 0, 0, 0));
- Color completion_background_color = EDITOR_DEF("text_editor/highlighting/completion_background_color", Color(0, 0, 0, 0));
- Color completion_selected_color = EDITOR_DEF("text_editor/highlighting/completion_selected_color", Color::html("434244"));
- Color completion_existing_color = EDITOR_DEF("text_editor/highlighting/completion_existing_color", Color::html("21dfdfdf"));
- Color completion_scroll_color = EDITOR_DEF("text_editor/highlighting/completion_scroll_color", Color::html("ffffff"));
- Color completion_font_color = EDITOR_DEF("text_editor/highlighting/completion_font_color", Color::html("aaaaaa"));
- Color text_color = EDITOR_DEF("text_editor/highlighting/text_color", Color(0, 0, 0));
- Color line_number_color = EDITOR_DEF("text_editor/highlighting/line_number_color", Color(0, 0, 0));
- Color caret_color = EDITOR_DEF("text_editor/highlighting/caret_color", Color(0, 0, 0));
- Color caret_background_color = EDITOR_DEF("text_editor/highlighting/caret_background_color", Color(0, 0, 0));
- Color text_selected_color = EDITOR_DEF("text_editor/highlighting/text_selected_color", Color(1, 1, 1));
- Color selection_color = EDITOR_DEF("text_editor/highlighting/selection_color", Color(0.2, 0.2, 1));
- Color brace_mismatch_color = EDITOR_DEF("text_editor/highlighting/brace_mismatch_color", Color(1, 0.2, 0.2));
- Color current_line_color = EDITOR_DEF("text_editor/highlighting/current_line_color", Color(0.3, 0.5, 0.8, 0.15));
- Color line_length_guideline_color = EDITOR_DEF("text_editor/highlighting/line_length_guideline_color", Color(0, 0, 0));
- Color word_highlighted_color = EDITOR_DEF("text_editor/highlighting/word_highlighted_color", Color(0.8, 0.9, 0.9, 0.15));
- Color number_color = EDITOR_DEF("text_editor/highlighting/number_color", Color(0.9, 0.6, 0.0, 2));
- Color function_color = EDITOR_DEF("text_editor/highlighting/function_color", Color(0.4, 0.6, 0.8));
- Color member_variable_color = EDITOR_DEF("text_editor/highlighting/member_variable_color", Color(0.9, 0.3, 0.3));
- Color mark_color = EDITOR_DEF("text_editor/highlighting/mark_color", Color(1.0, 0.4, 0.4, 0.4));
- Color breakpoint_color = EDITOR_DEF("text_editor/highlighting/breakpoint_color", Color(0.8, 0.8, 0.4, 0.2));
- Color code_folding_color = EDITOR_DEF("text_editor/highlighting/code_folding_color", Color(0.8, 0.8, 0.8, 0.8));
- Color search_result_color = EDITOR_DEF("text_editor/highlighting/search_result_color", Color(0.05, 0.25, 0.05, 1));
- Color search_result_border_color = EDITOR_DEF("text_editor/highlighting/search_result_border_color", Color(0.1, 0.45, 0.1, 1));
- Color symbol_color = EDITOR_DEF("text_editor/highlighting/symbol_color", Color::hex(0x005291ff));
-
- Color keyword_color = EDITOR_DEF("text_editor/highlighting/keyword_color", Color(0.5, 0.0, 0.2));
- Color basetype_color = EDITOR_DEF("text_editor/highlighting/base_type_color", Color(0.3, 0.3, 0.0));
- Color type_color = EDITOR_DEF("text_editor/highlighting/engine_type_color", Color(0.0, 0.2, 0.4));
- Color comment_color = EDITOR_DEF("text_editor/highlighting/comment_color", Color::hex(0x797e7eff));
- Color string_color = EDITOR_DEF("text_editor/highlighting/string_color", Color::hex(0x6b6f00ff));
-
- // Adapt
- if (EditorSettings::get_singleton()->get("text_editor/theme/color_theme") == "Adaptive") {
- Ref<Theme> tm = EditorNode::get_singleton()->get_theme_base()->get_theme();
-
- symbol_color = tm->get_color("text_editor/theme/symbol_color", "Editor");
- keyword_color = tm->get_color("text_editor/theme/keyword_color", "Editor");
- basetype_color = tm->get_color("text_editor/theme/basetype_color", "Editor");
- type_color = tm->get_color("text_editor/theme/type_color", "Editor");
- comment_color = tm->get_color("text_editor/theme/comment_color", "Editor");
- string_color = tm->get_color("text_editor/theme/string_color", "Editor");
- background_color = tm->get_color("text_editor/theme/background_color", "Editor");
- completion_background_color = tm->get_color("text_editor/theme/completion_background_color", "Editor");
- completion_selected_color = tm->get_color("text_editor/theme/completion_selected_color", "Editor");
- completion_existing_color = tm->get_color("text_editor/theme/completion_existing_color", "Editor");
- completion_scroll_color = tm->get_color("text_editor/theme/completion_scroll_color", "Editor");
- completion_font_color = tm->get_color("text_editor/theme/completion_font_color", "Editor");
- text_color = tm->get_color("text_editor/theme/text_color", "Editor");
- line_number_color = tm->get_color("text_editor/theme/line_number_color", "Editor");
- caret_color = tm->get_color("text_editor/theme/caret_color", "Editor");
- caret_background_color = tm->get_color("text_editor/theme/caret_background_color", "Editor");
- text_selected_color = tm->get_color("text_editor/theme/text_selected_color", "Editor");
- selection_color = tm->get_color("text_editor/theme/selection_color", "Editor");
- brace_mismatch_color = tm->get_color("text_editor/theme/brace_mismatch_color", "Editor");
- current_line_color = tm->get_color("text_editor/theme/current_line_color", "Editor");
- line_length_guideline_color = tm->get_color("text_editor/theme/line_length_guideline_color", "Editor");
- word_highlighted_color = tm->get_color("text_editor/theme/word_highlighted_color", "Editor");
- number_color = tm->get_color("text_editor/theme/number_color", "Editor");
- function_color = tm->get_color("text_editor/theme/function_color", "Editor");
- member_variable_color = tm->get_color("text_editor/theme/member_variable_color", "Editor");
- mark_color = tm->get_color("text_editor/theme/mark_color", "Editor");
- breakpoint_color = tm->get_color("text_editor/theme/breakpoint_color", "Editor");
- code_folding_color = tm->get_color("text_editor/theme/code_folding_color", "Editor");
- search_result_color = tm->get_color("text_editor/theme/search_result_color", "Editor");
- search_result_border_color = tm->get_color("text_editor/theme/search_result_border_color", "Editor");
- }
+ Color background_color = EDITOR_GET("text_editor/highlighting/background_color");
+ Color completion_background_color = EDITOR_GET("text_editor/highlighting/completion_background_color");
+ Color completion_selected_color = EDITOR_GET("text_editor/highlighting/completion_selected_color");
+ Color completion_existing_color = EDITOR_GET("text_editor/highlighting/completion_existing_color");
+ Color completion_scroll_color = EDITOR_GET("text_editor/highlighting/completion_scroll_color");
+ Color completion_font_color = EDITOR_GET("text_editor/highlighting/completion_font_color");
+ Color text_color = EDITOR_GET("text_editor/highlighting/text_color");
+ Color line_number_color = EDITOR_GET("text_editor/highlighting/line_number_color");
+ Color caret_color = EDITOR_GET("text_editor/highlighting/caret_color");
+ Color caret_background_color = EDITOR_GET("text_editor/highlighting/caret_background_color");
+ Color text_selected_color = EDITOR_GET("text_editor/highlighting/text_selected_color");
+ Color selection_color = EDITOR_GET("text_editor/highlighting/selection_color");
+ Color brace_mismatch_color = EDITOR_GET("text_editor/highlighting/brace_mismatch_color");
+ Color current_line_color = EDITOR_GET("text_editor/highlighting/current_line_color");
+ Color line_length_guideline_color = EDITOR_GET("text_editor/highlighting/line_length_guideline_color");
+ Color word_highlighted_color = EDITOR_GET("text_editor/highlighting/word_highlighted_color");
+ Color number_color = EDITOR_GET("text_editor/highlighting/number_color");
+ Color function_color = EDITOR_GET("text_editor/highlighting/function_color");
+ Color member_variable_color = EDITOR_GET("text_editor/highlighting/member_variable_color");
+ Color mark_color = EDITOR_GET("text_editor/highlighting/mark_color");
+ Color breakpoint_color = EDITOR_GET("text_editor/highlighting/breakpoint_color");
+ Color code_folding_color = EDITOR_GET("text_editor/highlighting/code_folding_color");
+ Color search_result_color = EDITOR_GET("text_editor/highlighting/search_result_color");
+ Color search_result_border_color = EDITOR_GET("text_editor/highlighting/search_result_border_color");
+ Color symbol_color = EDITOR_GET("text_editor/highlighting/symbol_color");
+ Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_color");
+ Color basetype_color = EDITOR_GET("text_editor/highlighting/base_type_color");
+ Color type_color = EDITOR_GET("text_editor/highlighting/engine_type_color");
+ Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color");
+ Color string_color = EDITOR_GET("text_editor/highlighting/string_color");
get_text_edit()->add_color_override("background_color", background_color);
get_text_edit()->add_color_override("completion_background_color", completion_background_color);
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index b26038fe09..e0a697ec26 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -3213,7 +3213,7 @@ bool SpatialEditorViewport::can_drop_data_fw(const Point2 &p_point, const Varian
continue;
}
memdelete(instanced_scene);
- } else if (type == "Mesh" || "ArrayMesh" || "PrimitiveMesh") {
+ } else if (type == "Mesh" || type == "ArrayMesh" || type == "PrimitiveMesh") {
Ref<Mesh> mesh = ResourceLoader::load(files[i]);
if (!mesh.is_valid()) {
continue;
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index b56585f62c..a8e4d73cd2 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -343,12 +343,13 @@ AutotileEditor::AutotileEditor(EditorNode *p_editor) {
split->add_child(property_editor);
helper = memnew(AutotileEditorHelper(this));
- property_editor->call_deferred("edit", helper);
+ property_editor->edit(helper);
// Editor
dragging_point = -1;
creating_shape = false;
+ snap_step = Vector2(32, 32);
set_custom_minimum_size(Size2(0, 150));
@@ -426,10 +427,78 @@ AutotileEditor::AutotileEditor(EditorNode *p_editor) {
tools[SHAPE_KEEP_INSIDE_TILE]->set_toggle_mode(true);
tools[SHAPE_KEEP_INSIDE_TILE]->set_pressed(true);
tool_containers[TOOLBAR_SHAPE]->add_child(tools[SHAPE_KEEP_INSIDE_TILE]);
- tools[SHAPE_SNAP_TO_BITMASK_GRID] = memnew(ToolButton);
- tools[SHAPE_SNAP_TO_BITMASK_GRID]->set_toggle_mode(true);
- tools[SHAPE_SNAP_TO_BITMASK_GRID]->set_pressed(true);
- tool_containers[TOOLBAR_SHAPE]->add_child(tools[SHAPE_SNAP_TO_BITMASK_GRID]);
+ tools[SHAPE_GRID_SNAP] = memnew(ToolButton);
+ tools[SHAPE_GRID_SNAP]->set_toggle_mode(true);
+ tools[SHAPE_GRID_SNAP]->connect("toggled", this, "_on_grid_snap_toggled");
+ tool_containers[TOOLBAR_SHAPE]->add_child(tools[SHAPE_GRID_SNAP]);
+
+ hb_grid = memnew(HBoxContainer);
+ tool_containers[TOOLBAR_SHAPE]->add_child(hb_grid);
+
+ hb_grid->add_child(memnew(VSeparator));
+ hb_grid->add_child(memnew(Label(TTR("Offset:"))));
+
+ sb_off_x = memnew(SpinBox);
+ sb_off_x->set_min(-256);
+ sb_off_x->set_max(256);
+ sb_off_x->set_step(1);
+ sb_off_x->set_value(snap_offset.x);
+ sb_off_x->set_suffix("px");
+ sb_off_x->connect("value_changed", this, "_set_snap_off_x");
+ hb_grid->add_child(sb_off_x);
+
+ sb_off_y = memnew(SpinBox);
+ sb_off_y->set_min(-256);
+ sb_off_y->set_max(256);
+ sb_off_y->set_step(1);
+ sb_off_y->set_value(snap_offset.y);
+ sb_off_y->set_suffix("px");
+ sb_off_y->connect("value_changed", this, "_set_snap_off_y");
+ hb_grid->add_child(sb_off_y);
+
+ hb_grid->add_child(memnew(VSeparator));
+ hb_grid->add_child(memnew(Label(TTR("Step:"))));
+
+ sb_step_x = memnew(SpinBox);
+ sb_step_x->set_min(-256);
+ sb_step_x->set_max(256);
+ sb_step_x->set_step(1);
+ sb_step_x->set_value(snap_step.x);
+ sb_step_x->set_suffix("px");
+ sb_step_x->connect("value_changed", this, "_set_snap_step_x");
+ hb_grid->add_child(sb_step_x);
+
+ sb_step_y = memnew(SpinBox);
+ sb_step_y->set_min(-256);
+ sb_step_y->set_max(256);
+ sb_step_y->set_step(1);
+ sb_step_y->set_value(snap_step.y);
+ sb_step_y->set_suffix("px");
+ sb_step_y->connect("value_changed", this, "_set_snap_step_y");
+ hb_grid->add_child(sb_step_y);
+
+ hb_grid->add_child(memnew(VSeparator));
+ hb_grid->add_child(memnew(Label(TTR("Separation:"))));
+
+ sb_sep_x = memnew(SpinBox);
+ sb_sep_x->set_min(0);
+ sb_sep_x->set_max(256);
+ sb_sep_x->set_step(1);
+ sb_sep_x->set_value(snap_separation.x);
+ sb_sep_x->set_suffix("px");
+ sb_sep_x->connect("value_changed", this, "_set_snap_sep_x");
+ hb_grid->add_child(sb_sep_x);
+
+ sb_sep_y = memnew(SpinBox);
+ sb_sep_y->set_min(0);
+ sb_sep_y->set_max(256);
+ sb_sep_y->set_step(1);
+ sb_sep_y->set_value(snap_separation.y);
+ sb_sep_y->set_suffix("px");
+ sb_sep_y->connect("value_changed", this, "_set_snap_sep_y");
+ hb_grid->add_child(sb_sep_y);
+
+ hb_grid->hide();
spin_priority = memnew(SpinBox);
spin_priority->set_min(1);
@@ -489,6 +558,13 @@ void AutotileEditor::_bind_methods() {
ClassDB::bind_method("_on_workspace_input", &AutotileEditor::_on_workspace_input);
ClassDB::bind_method("_on_tool_clicked", &AutotileEditor::_on_tool_clicked);
ClassDB::bind_method("_on_priority_changed", &AutotileEditor::_on_priority_changed);
+ ClassDB::bind_method("_on_grid_snap_toggled", &AutotileEditor::_on_grid_snap_toggled);
+ ClassDB::bind_method("_set_snap_step_x", &AutotileEditor::_set_snap_step_x);
+ ClassDB::bind_method("_set_snap_step_y", &AutotileEditor::_set_snap_step_y);
+ ClassDB::bind_method("_set_snap_off_x", &AutotileEditor::_set_snap_off_x);
+ ClassDB::bind_method("_set_snap_off_y", &AutotileEditor::_set_snap_off_y);
+ ClassDB::bind_method("_set_snap_sep_x", &AutotileEditor::_set_snap_sep_x);
+ ClassDB::bind_method("_set_snap_sep_y", &AutotileEditor::_set_snap_sep_y);
}
void AutotileEditor::_notification(int p_what) {
@@ -501,7 +577,7 @@ void AutotileEditor::_notification(int p_what) {
tools[SHAPE_NEW_POLYGON]->set_icon(get_icon("CollisionPolygon2D", "EditorIcons"));
tools[SHAPE_DELETE]->set_icon(get_icon("Remove", "EditorIcons"));
tools[SHAPE_KEEP_INSIDE_TILE]->set_icon(get_icon("Snap", "EditorIcons"));
- tools[SHAPE_SNAP_TO_BITMASK_GRID]->set_icon(get_icon("SnapGrid", "EditorIcons"));
+ tools[SHAPE_GRID_SNAP]->set_icon(get_icon("SnapGrid", "EditorIcons"));
tools[ZOOM_OUT]->set_icon(get_icon("ZoomLess", "EditorIcons"));
tools[ZOOM_1]->set_icon(get_icon("ZoomReset", "EditorIcons"));
tools[ZOOM_IN]->set_icon(get_icon("ZoomMore", "EditorIcons"));
@@ -632,6 +708,7 @@ void AutotileEditor::_on_workspace_draw() {
Vector2 coord = edited_shape_coord;
draw_highlight_tile(coord);
draw_polygon_shapes();
+ draw_grid_snap();
} break;
case EDITMODE_PRIORITY: {
spin_priority->set_value(tile_set->autotile_get_subtile_priority(get_current_tile(), edited_shape_coord));
@@ -880,15 +957,15 @@ void AutotileEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
Vector<TileSet::ShapeData> sd = tile_set->tile_get_shapes(get_current_tile());
for (int i = 0; i < sd.size(); i++) {
if (sd[i].autotile_coord == coord) {
- Ref<ConcavePolygonShape2D> shape = sd[i].shape;
+ Ref<ConvexPolygonShape2D> shape = sd[i].shape;
if (shape.is_valid()) {
- //FIXME: i need a way to know if the point is countained on the polygon instead of the rect
+
Rect2 bounding_rect;
PoolVector2Array polygon;
- bounding_rect.position = shape->get_segments()[0];
- for (int j = 0; j < shape->get_segments().size(); j += 2) {
- polygon.push_back(shape->get_segments()[j] + shape_anchor);
- bounding_rect.expand_to(shape->get_segments()[j] + shape_anchor);
+ bounding_rect.position = shape->get_points()[0];
+ for (int j = 0; j < shape->get_points().size(); j++) {
+ polygon.push_back(shape->get_points()[j] + shape_anchor);
+ bounding_rect.expand_to(shape->get_points()[j] + shape_anchor);
}
if (bounding_rect.has_point(mb->get_position())) {
current_shape = polygon;
@@ -905,17 +982,17 @@ void AutotileEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
if (dragging_point >= 0) {
dragging_point = -1;
- PoolVector<Vector2> segments;
- segments.resize(current_shape.size() * 2);
- PoolVector<Vector2>::Write w = segments.write();
+ Vector<Vector2> points;
for (int i = 0; i < current_shape.size(); i++) {
- w[(i << 1) + 0] = current_shape[i] - shape_anchor;
- w[(i << 1) + 1] = current_shape[(i + 1) % current_shape.size()] - shape_anchor;
+ Vector2 p = current_shape[i];
+ if (tools[SHAPE_GRID_SNAP]->is_pressed() || tools[SHAPE_KEEP_INSIDE_TILE]->is_pressed()) {
+ p = snap_point(p);
+ }
+ points.push_back(p - shape_anchor);
}
- w = PoolVector<Vector2>::Write();
- edited_collision_shape->set_segments(segments);
+ edited_collision_shape->set_points(points);
workspace->update();
}
@@ -982,11 +1059,30 @@ void AutotileEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
current_shape.push_back(pos);
workspace->update();
} else {
+ int t_id = get_current_tile();
+ if (t_id >= 0) {
+ Vector<TileSet::ShapeData> sd = tile_set->tile_get_shapes(t_id);
+ for (int i = 0; i < sd.size(); i++) {
+ if (sd[i].autotile_coord == edited_shape_coord) {
+ Ref<ConvexPolygonShape2D> shape = sd[i].shape;
+
+ if (!shape.is_null()) {
+ sd.remove(i);
+ tile_set->tile_set_shapes(get_current_tile(), sd);
+ edited_collision_shape = Ref<Shape2D>();
+ current_shape.resize(0);
+ workspace->update();
+ }
+ break;
+ }
+ }
+ }
+
creating_shape = true;
current_shape.resize(0);
current_shape.push_back(snap_point(pos));
}
- } else if (mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) {
+ } else if (mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT && current_shape.size() > 2) {
if (creating_shape) {
close_shape(shape_anchor);
}
@@ -1034,7 +1130,7 @@ void AutotileEditor::_on_tool_clicked(int p_tool) {
if (index >= 0) {
sd.remove(index);
tile_set->tile_set_shapes(get_current_tile(), sd);
- edited_collision_shape = Ref<ConcavePolygonShape2D>();
+ edited_collision_shape = Ref<Shape2D>();
current_shape.resize(0);
workspace->update();
}
@@ -1081,6 +1177,43 @@ void AutotileEditor::_on_priority_changed(float val) {
workspace->update();
}
+void AutotileEditor::_on_grid_snap_toggled(bool p_val) {
+ if (p_val)
+ hb_grid->show();
+ else
+ hb_grid->hide();
+ workspace->update();
+}
+
+void AutotileEditor::_set_snap_step_x(float p_val) {
+ snap_step.x = p_val;
+ workspace->update();
+}
+
+void AutotileEditor::_set_snap_step_y(float p_val) {
+ snap_step.y = p_val;
+ workspace->update();
+}
+
+void AutotileEditor::_set_snap_off_x(float p_val) {
+ snap_offset.x = p_val;
+ workspace->update();
+}
+
+void AutotileEditor::_set_snap_off_y(float p_val) {
+ snap_offset.y = p_val;
+ workspace->update();
+}
+void AutotileEditor::_set_snap_sep_x(float p_val) {
+ snap_separation.x = p_val;
+ workspace->update();
+}
+
+void AutotileEditor::_set_snap_sep_y(float p_val) {
+ snap_separation.y = p_val;
+ workspace->update();
+}
+
void AutotileEditor::draw_highlight_tile(Vector2 coord, const Vector<Vector2> &other_highlighted) {
Vector2 size = tile_set->autotile_get_size(get_current_tile());
@@ -1103,6 +1236,49 @@ void AutotileEditor::draw_highlight_tile(Vector2 coord, const Vector<Vector2> &o
}
}
+void AutotileEditor::draw_grid_snap() {
+ if (tools[SHAPE_GRID_SNAP]->is_pressed()) {
+ Color grid_color = Color(0.39, 0, 1, 0.2f);
+ Size2 s = workspace->get_size();
+
+ Vector2 size = tile_set->autotile_get_size(get_current_tile());
+
+ int width_count = (int)(s.width / (snap_step.x + snap_separation.x));
+ int height_count = (int)(s.height / (snap_step.y + snap_separation.y));
+
+ if (snap_step.x != 0) {
+ int last_p = 0;
+ for (int i = 0; i <= width_count; i++) {
+ if (i == 0 && snap_offset.x != 0) {
+ last_p = snap_offset.x;
+ }
+ if (snap_separation.x != 0 && i != 0) {
+ workspace->draw_rect(Rect2(last_p, 0, snap_separation.x, s.height), grid_color);
+ last_p += snap_separation.x;
+ } else
+ workspace->draw_line(Point2(last_p, 0), Point2(last_p, s.height), grid_color);
+
+ last_p += snap_step.x;
+ }
+ }
+
+ if (snap_step.y != 0) {
+ int last_p = 0;
+ for (int i = 0; i <= height_count; i++) {
+ if (i == 0 && snap_offset.y != 0) {
+ last_p = snap_offset.y;
+ }
+ if (snap_separation.x != 0 && i != 0) {
+ workspace->draw_rect(Rect2(0, last_p, s.width, snap_separation.y), grid_color);
+ last_p += snap_separation.y;
+ } else
+ workspace->draw_line(Point2(0, last_p), Point2(s.width, last_p), grid_color);
+ last_p += snap_step.y;
+ }
+ }
+ }
+}
+
void AutotileEditor::draw_polygon_shapes() {
int t_id = get_current_tile();
@@ -1119,7 +1295,7 @@ void AutotileEditor::draw_polygon_shapes() {
anchor.y += tile_set->autotile_get_spacing(t_id);
anchor.x *= coord.x;
anchor.y *= coord.y;
- Ref<ConcavePolygonShape2D> shape = sd[i].shape;
+ Ref<ConvexPolygonShape2D> shape = sd[i].shape;
if (shape.is_valid()) {
Color c_bg;
Color c_border;
@@ -1138,19 +1314,22 @@ void AutotileEditor::draw_polygon_shapes() {
colors.push_back(c_bg);
}
} else {
- for (int j = 0; j < shape->get_segments().size(); j += 2) {
- polygon.push_back(shape->get_segments()[j] + anchor);
+ for (int j = 0; j < shape->get_points().size(); j++) {
+ polygon.push_back(shape->get_points()[j] + anchor);
colors.push_back(c_bg);
}
}
- workspace->draw_polygon(polygon, colors);
+ if (polygon.size() > 2) {
+ workspace->draw_polygon(polygon, colors);
+ }
if (coord == edited_shape_coord) {
- for (int j = 0; j < shape->get_segments().size(); j += 2) {
- workspace->draw_line(shape->get_segments()[j] + anchor, shape->get_segments()[j + 1] + anchor, c_border, 1, true);
+ for (int j = 0; j < shape->get_points().size() - 1; j++) {
+ workspace->draw_line(shape->get_points()[j] + anchor, shape->get_points()[j + 1] + anchor, c_border, 1, true);
}
+
if (shape == edited_collision_shape) {
for (int j = 0; j < current_shape.size(); j++) {
- workspace->draw_circle(current_shape[j], 5, Color(1, 0, 0));
+ workspace->draw_circle(current_shape[j], 8 / workspace->get_scale().x, Color(1, 0, 0, 0.7f));
}
}
}
@@ -1198,7 +1377,7 @@ void AutotileEditor::draw_polygon_shapes() {
workspace->draw_line(shape->get_polygon()[shape->get_polygon().size() - 1] + anchor, shape->get_polygon()[0] + anchor, c_border, 1, true);
if (shape == edited_occlusion_shape) {
for (int j = 0; j < current_shape.size(); j++) {
- workspace->draw_circle(current_shape[j], 5, Color(1, 0, 0));
+ workspace->draw_circle(current_shape[j], 8 / workspace->get_scale().x, Color(1, 0, 0));
}
}
}
@@ -1248,7 +1427,7 @@ void AutotileEditor::draw_polygon_shapes() {
}
if (shape == edited_navigation_shape) {
for (int j = 0; j < current_shape.size(); j++) {
- workspace->draw_circle(current_shape[j], 5, Color(1, 0, 0));
+ workspace->draw_circle(current_shape[j], 8 / workspace->get_scale().x, Color(1, 0, 0));
}
}
}
@@ -1270,22 +1449,21 @@ void AutotileEditor::close_shape(const Vector2 &shape_anchor) {
creating_shape = false;
if (edit_mode == EDITMODE_COLLISION) {
- Ref<ConcavePolygonShape2D> shape = memnew(ConcavePolygonShape2D);
+ if (current_shape.size() >= 3) {
+ Ref<ConvexPolygonShape2D> shape = memnew(ConvexPolygonShape2D);
- PoolVector<Vector2> segments;
- segments.resize(current_shape.size() * 2);
- PoolVector<Vector2>::Write w = segments.write();
+ Vector<Vector2> segments;
- for (int i = 0; i < current_shape.size(); i++) {
- w[(i << 1) + 0] = current_shape[i] - shape_anchor;
- w[(i << 1) + 1] = current_shape[(i + 1) % current_shape.size()] - shape_anchor;
- }
+ for (int i = 0; i < current_shape.size(); i++) {
+ segments.push_back(current_shape[i] - shape_anchor);
+ }
- w = PoolVector<Vector2>::Write();
- shape->set_segments(segments);
+ shape->set_points(segments);
+
+ tile_set->tile_add_shape(get_current_tile(), shape, Transform2D(), false, edited_shape_coord);
+ edited_collision_shape = shape;
+ }
- tile_set->tile_add_shape(get_current_tile(), shape, Transform2D(), false, edited_shape_coord);
- edited_collision_shape = shape;
tools[TOOL_SELECT]->set_pressed(true);
workspace->update();
} else if (edit_mode == EDITMODE_OCCLUSION) {
@@ -1338,6 +1516,10 @@ Vector2 AutotileEditor::snap_point(const Vector2 &point) {
anchor.x *= (tile_size.x + spacing);
anchor.y *= (tile_size.y + spacing);
Rect2 region(anchor, tile_size);
+ if (tools[SHAPE_GRID_SNAP]->is_pressed()) {
+ p.x = Math::snap_scalar_seperation(snap_offset.x, snap_step.x, p.x, snap_separation.x);
+ p.y = Math::snap_scalar_seperation(snap_offset.y, snap_step.y, p.y, snap_separation.y);
+ }
if (tools[SHAPE_KEEP_INSIDE_TILE]->is_pressed()) {
if (p.x < region.position.x)
p.x = region.position.x;
@@ -1348,23 +1530,6 @@ Vector2 AutotileEditor::snap_point(const Vector2 &point) {
if (p.y > region.position.y + region.size.y)
p.y = region.position.y + region.size.y;
}
- if (tools[SHAPE_SNAP_TO_BITMASK_GRID]->is_pressed()) {
- Vector2 p2 = p;
- if (tile_set->autotile_get_bitmask_mode(get_current_tile()) == TileSet::BITMASK_2X2) {
- p2.x = Math::stepify(p2.x, tile_size.x / 2);
- p2.y = Math::stepify(p2.y, tile_size.y / 2);
- if ((p2 - p).length_squared() <= MAX(tile_size.y / 4, MIN_DISTANCE_SQUARED)) {
- p = p2;
- }
- } else if (tile_set->autotile_get_bitmask_mode(get_current_tile()) == TileSet::BITMASK_3X3) {
- p2.x = Math::stepify(p2.x, tile_size.x / 3);
- p2.y = Math::stepify(p2.y, tile_size.y / 3);
- if ((p2 - p).length_squared() <= MAX(tile_size.y / 6, MIN_DISTANCE_SQUARED)) {
- p = p2;
- }
- }
- }
- p.floor();
return p;
}
diff --git a/editor/plugins/tile_set_editor_plugin.h b/editor/plugins/tile_set_editor_plugin.h
index d60d0d5c3c..34284cb90f 100644
--- a/editor/plugins/tile_set_editor_plugin.h
+++ b/editor/plugins/tile_set_editor_plugin.h
@@ -33,7 +33,7 @@
#include "editor/editor_name_dialog.h"
#include "editor/editor_node.h"
#include "scene/2d/sprite.h"
-#include "scene/resources/concave_polygon_shape_2d.h"
+#include "scene/resources/convex_polygon_shape_2d.h"
#include "scene/resources/tile_set.h"
class AutotileEditorHelper;
@@ -70,7 +70,7 @@ class AutotileEditor : public Control {
SHAPE_CREATE_FROM_BITMASK,
SHAPE_CREATE_FROM_NOT_BITMASK,
SHAPE_KEEP_INSIDE_TILE,
- SHAPE_SNAP_TO_BITMASK_GRID,
+ SHAPE_GRID_SNAP,
ZOOM_OUT,
ZOOM_1,
ZOOM_IN,
@@ -78,7 +78,7 @@ class AutotileEditor : public Control {
};
Ref<TileSet> tile_set;
- Ref<ConcavePolygonShape2D> edited_collision_shape;
+ Ref<ConvexPolygonShape2D> edited_collision_shape;
Ref<OccluderPolygon2D> edited_occlusion_shape;
Ref<NavigationPolygon> edited_navigation_shape;
@@ -91,10 +91,21 @@ class AutotileEditor : public Control {
Button *tool_editmode[EDITMODE_MAX];
HBoxContainer *tool_containers[TOOLBAR_MAX];
HBoxContainer *toolbar;
+ HBoxContainer *hb_grid;
ToolButton *tools[TOOL_MAX];
SpinBox *spin_priority;
+ SpinBox *sb_step_y;
+ SpinBox *sb_step_x;
+ SpinBox *sb_off_y;
+ SpinBox *sb_off_x;
+ SpinBox *sb_sep_y;
+ SpinBox *sb_sep_x;
EditMode edit_mode;
+ Vector2 snap_step;
+ Vector2 snap_offset;
+ Vector2 snap_separation;
+
bool creating_shape;
int dragging_point;
Vector2 edited_shape_coord;
@@ -119,9 +130,16 @@ private:
void _on_workspace_input(const Ref<InputEvent> &p_ie);
void _on_tool_clicked(int p_tool);
void _on_priority_changed(float val);
+ void _on_grid_snap_toggled(bool p_val);
+ void _set_snap_step_x(float p_val);
+ void _set_snap_step_y(float p_val);
+ void _set_snap_off_x(float p_val);
+ void _set_snap_off_y(float p_val);
+ void _set_snap_sep_x(float p_val);
+ void _set_snap_sep_y(float p_val);
void draw_highlight_tile(Vector2 coord, const Vector<Vector2> &other_highlighted = Vector<Vector2>());
- void draw_grid(const Vector2 &size, int spacing);
+ void draw_grid_snap();
void draw_polygon_shapes();
void close_shape(const Vector2 &shape_anchor);
Vector2 snap_point(const Vector2 &point);
diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp
index 2bdc824248..345f647608 100644
--- a/editor/settings_config_dialog.cpp
+++ b/editor/settings_config_dialog.cpp
@@ -61,6 +61,8 @@ void EditorSettingsDialog::_settings_property_edited(const String &p_name) {
property_editor->get_property_editor()->update_tree();
} else if (full_name == "interface/theme/accent_color" || full_name == "interface/theme/base_color" || full_name == "interface/theme/contrast") {
EditorSettings::get_singleton()->set_manually("interface/theme/preset", 6); // set preset to Custom
+ } else if (full_name.begins_with("text_editor/highlighting")) {
+ EditorSettings::get_singleton()->set_manually("text_editor/theme/color_theme", "Custom");
}
}
diff --git a/main/main.cpp b/main/main.cpp
index 5648676c4c..b72ffb9850 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -755,8 +755,10 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
if (editor) {
Engine::get_singleton()->set_editor_hint(true);
main_args.push_back("--editor");
- init_maximized = true;
- video_mode.maximized = true;
+ if (!init_windowed) {
+ init_maximized = true;
+ video_mode.maximized = true;
+ }
use_custom_res = false;
}
diff --git a/modules/bullet/bullet_physics_server.cpp b/modules/bullet/bullet_physics_server.cpp
index b233edc0d4..ae062904b4 100644
--- a/modules/bullet/bullet_physics_server.cpp
+++ b/modules/bullet/bullet_physics_server.cpp
@@ -121,7 +121,7 @@ RID BulletPhysicsServer::shape_create(ShapeType p_shape) {
shape = bulletnew(RayShapeBullet);
} break;
case SHAPE_CUSTOM:
- defaul:
+ default:
ERR_FAIL_V(RID());
break;
}
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 44dd776e9a..61dedbf1d7 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -122,6 +122,16 @@ void CSharpLanguage::init() {
void CSharpLanguage::finish() {
+ finalizing = true;
+
+#ifdef TOOLS_ENABLED
+ // Must be here, to avoid StringName leaks
+ if (BindingsGenerator::singleton) {
+ memdelete(BindingsGenerator::singleton);
+ BindingsGenerator::singleton = NULL;
+ }
+#endif
+
// Release gchandle bindings before finalizing mono runtime
gchandle_bindings.clear();
@@ -129,6 +139,8 @@ void CSharpLanguage::finish() {
memdelete(gdmono);
gdmono = NULL;
}
+
+ finalizing = false;
}
void CSharpLanguage::get_reserved_words(List<String> *p_words) const {
@@ -742,6 +754,8 @@ CSharpLanguage::CSharpLanguage() {
ERR_FAIL_COND(singleton);
singleton = this;
+ finalizing = false;
+
gdmono = NULL;
#ifdef NO_THREADS
@@ -798,12 +812,9 @@ void *CSharpLanguage::alloc_instance_binding_data(Object *p_object) {
ERR_FAIL_NULL_V(mono_object, NULL);
// Tie managed to unmanaged
- bool strong_handle = true;
Reference *ref = Object::cast_to<Reference>(p_object);
if (ref) {
- strong_handle = false;
-
// Unsafe refcount increment. The managed instance also counts as a reference.
// This way if the unmanaged world has no references to our owner
// but the managed instance is alive, the refcount will be 1 instead of 0.
@@ -812,8 +823,7 @@ void *CSharpLanguage::alloc_instance_binding_data(Object *p_object) {
ref->reference();
}
- Ref<MonoGCHandle> gchandle = strong_handle ? MonoGCHandle::create_strong(mono_object) :
- MonoGCHandle::create_weak(mono_object);
+ Ref<MonoGCHandle> gchandle = MonoGCHandle::create_strong(mono_object);
#ifndef NO_THREADS
script_bind_lock->lock();
@@ -838,27 +848,38 @@ void CSharpLanguage::free_instance_binding_data(void *p_data) {
return;
}
+ if (finalizing)
+ return; // inside CSharpLanguage::finish(), all the gchandle bindings are released there
+
#ifndef NO_THREADS
script_bind_lock->lock();
#endif
- gchandle_bindings.erase((Map<Object *, Ref<MonoGCHandle> >::Element *)p_data);
+ Map<Object *, Ref<MonoGCHandle> >::Element *data = (Map<Object *, Ref<MonoGCHandle> >::Element *)p_data;
+
+ // Set the native instance field to IntPtr.Zero, if not yet garbage collected
+ MonoObject *mono_object = data->value()->get_target();
+ if (mono_object) {
+ CACHED_FIELD(GodotObject, ptr)->set_value_raw(mono_object, NULL);
+ }
+
+ gchandle_bindings.erase(data);
#ifndef NO_THREADS
script_bind_lock->unlock();
#endif
}
-void CSharpInstance::_ml_call_reversed(GDMonoClass *klass, const StringName &p_method, const Variant **p_args, int p_argcount) {
+void CSharpInstance::_ml_call_reversed(MonoObject *p_mono_object, GDMonoClass *p_klass, const StringName &p_method, const Variant **p_args, int p_argcount) {
- GDMonoClass *base = klass->get_parent_class();
+ GDMonoClass *base = p_klass->get_parent_class();
if (base && base != script->native)
- _ml_call_reversed(base, p_method, p_args, p_argcount);
+ _ml_call_reversed(p_mono_object, base, p_method, p_args, p_argcount);
- GDMonoMethod *method = klass->get_method(p_method, p_argcount);
+ GDMonoMethod *method = p_klass->get_method(p_method, p_argcount);
if (method) {
- method->invoke(get_mono_object(), p_args);
+ method->invoke(p_mono_object, p_args);
}
}
@@ -1020,7 +1041,6 @@ Variant CSharpInstance::call(const StringName &p_method, const Variant **p_args,
MonoObject *mono_object = get_mono_object();
- ERR_EXPLAIN("Reference has been garbage collected?");
ERR_FAIL_NULL_V(mono_object, Variant());
if (!script.is_valid())
@@ -1054,23 +1074,34 @@ void CSharpInstance::call_multilevel(const StringName &p_method, const Variant *
if (script.is_valid()) {
MonoObject *mono_object = get_mono_object();
- GDMonoClass *top = script->script_class;
+ ERR_FAIL_NULL(mono_object);
- while (top && top != script->native) {
- GDMonoMethod *method = top->get_method(p_method, p_argcount);
+ _call_multilevel(mono_object, p_method, p_args, p_argcount);
+ }
+}
- if (method)
- method->invoke(mono_object, p_args);
+void CSharpInstance::_call_multilevel(MonoObject *p_mono_object, const StringName &p_method, const Variant **p_args, int p_argcount) {
- top = top->get_parent_class();
- }
+ GDMonoClass *top = script->script_class;
+
+ while (top && top != script->native) {
+ GDMonoMethod *method = top->get_method(p_method, p_argcount);
+
+ if (method)
+ method->invoke(p_mono_object, p_args);
+
+ top = top->get_parent_class();
}
}
void CSharpInstance::call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount) {
if (script.is_valid()) {
- _ml_call_reversed(script->script_class, p_method, p_args, p_argcount);
+ MonoObject *mono_object = get_mono_object();
+
+ ERR_FAIL_NULL(mono_object);
+
+ _ml_call_reversed(mono_object, script->script_class, p_method, p_args, p_argcount);
}
}
@@ -1118,7 +1149,7 @@ void CSharpInstance::refcount_incremented() {
Reference *ref_owner = Object::cast_to<Reference>(owner);
- if (ref_owner->reference_get_count() > 1) { // Remember the managed side holds a reference, hence 1 instead of 0 here
+ if (ref_owner->reference_get_count() > 1) { // The managed side also holds a reference, hence 1 instead of 0
// The reference count was increased after the managed side was the only one referencing our owner.
// This means the owner is being referenced again by the unmanaged side,
// so the owner must hold the managed side alive again to avoid it from being GCed.
@@ -1138,7 +1169,7 @@ bool CSharpInstance::refcount_decremented() {
int refcount = ref_owner->reference_get_count();
- if (refcount == 1) { // Remember the managed side holds a reference, hence 1 instead of 0 here
+ if (refcount == 1) { // The managed side also holds a reference, hence 1 instead of 0
// If owner owner is no longer referenced by the unmanaged side,
// the managed instance takes responsibility of deleting the owner when GCed.
@@ -1207,10 +1238,25 @@ ScriptInstance::RPCMode CSharpInstance::get_rset_mode(const StringName &p_variab
void CSharpInstance::notification(int p_notification) {
+ MonoObject *mono_object = get_mono_object();
+
+ if (p_notification == Object::NOTIFICATION_PREDELETE) {
+ if (mono_object != NULL) { // otherwise it was collected, and the finalizer already called NOTIFICATION_PREDELETE
+ call_notification_no_check(mono_object, p_notification);
+ // Set the native instance field to IntPtr.Zero
+ CACHED_FIELD(GodotObject, ptr)->set_value_raw(mono_object, NULL);
+ }
+ return;
+ }
+
+ call_notification_no_check(mono_object, p_notification);
+}
+
+void CSharpInstance::call_notification_no_check(MonoObject *p_mono_object, int p_notification) {
Variant value = p_notification;
const Variant *args[1] = { &value };
- call_multilevel(CACHED_STRING_NAME(_notification), args, 1);
+ _call_multilevel(p_mono_object, CACHED_STRING_NAME(_notification), args, 1);
}
Ref<Script> CSharpInstance::get_script() const {
diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h
index 255665b495..1a07cf6835 100644
--- a/modules/mono/csharp_script.h
+++ b/modules/mono/csharp_script.h
@@ -167,7 +167,7 @@ class CSharpInstance : public ScriptInstance {
bool base_ref;
bool ref_dying;
- void _ml_call_reversed(GDMonoClass *klass, const StringName &p_method, const Variant **p_args, int p_argcount);
+ void _ml_call_reversed(MonoObject *p_mono_object, GDMonoClass *klass, const StringName &p_method, const Variant **p_args, int p_argcount);
void _reference_owner_unsafe();
void _unreference_owner_unsafe();
@@ -176,6 +176,8 @@ class CSharpInstance : public ScriptInstance {
friend void GDMonoInternals::tie_managed_to_unmanaged(MonoObject *, Object *);
static CSharpInstance *create_for_managed_type(Object *p_owner, CSharpScript *p_script, const Ref<MonoGCHandle> &p_gchandle);
+ void _call_multilevel(MonoObject *p_mono_object, const StringName &p_method, const Variant **p_args, int p_argcount);
+
public:
MonoObject *get_mono_object() const;
@@ -192,13 +194,14 @@ public:
void mono_object_disposed();
- void refcount_incremented();
- bool refcount_decremented();
+ virtual void refcount_incremented();
+ virtual bool refcount_decremented();
- RPCMode get_rpc_mode(const StringName &p_method) const;
- RPCMode get_rset_mode(const StringName &p_variable) const;
+ virtual RPCMode get_rpc_mode(const StringName &p_method) const;
+ virtual RPCMode get_rset_mode(const StringName &p_variable) const;
virtual void notification(int p_notification);
+ void call_notification_no_check(MonoObject *p_mono_object, int p_notification);
virtual Ref<Script> get_script() const;
@@ -215,6 +218,8 @@ class CSharpLanguage : public ScriptLanguage {
static CSharpLanguage *singleton;
+ bool finalizing;
+
GDMono *gdmono;
SelfList<CSharpScript>::List script_list;
diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp
index d7885ade61..cd12afb5dd 100644
--- a/modules/mono/editor/bindings_generator.cpp
+++ b/modules/mono/editor/bindings_generator.cpp
@@ -108,6 +108,8 @@ const char *BindingsGenerator::TypeInterface::DEFAULT_VARARG_C_IN = "\t%0 %1_in
bool BindingsGenerator::verbose_output = false;
+BindingsGenerator *BindingsGenerator::singleton = NULL;
+
static String snake_to_pascal_case(const String &p_identifier, bool p_input_is_upper = false) {
String ret;
@@ -200,7 +202,7 @@ void BindingsGenerator::_generate_header_icalls() {
core_custom_icalls.clear();
core_custom_icalls.push_back(InternalCall(ICALL_GET_METHODBIND, "IntPtr", "string type, string method"));
- core_custom_icalls.push_back(InternalCall(ICALL_OBJECT_DTOR, "void", "IntPtr ptr"));
+ core_custom_icalls.push_back(InternalCall(ICALL_OBJECT_DTOR, "void", "object obj, IntPtr ptr"));
core_custom_icalls.push_back(InternalCall(ICALL_CONNECT_SIGNAL_AWAITER, "Error",
"IntPtr source, string signal, IntPtr target, " CS_CLASS_SIGNALAWAITER " awaiter"));
@@ -931,8 +933,8 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
"if (" BINDINGS_PTR_FIELD " != IntPtr.Zero)\n" OPEN_BLOCK_L3
"if (" CS_FIELD_MEMORYOWN ")\n" OPEN_BLOCK_L4 CS_FIELD_MEMORYOWN
" = false;\n" INDENT5 CS_CLASS_NATIVECALLS "." ICALL_OBJECT_DTOR
- "(" BINDINGS_PTR_FIELD ");\n" INDENT5 BINDINGS_PTR_FIELD
- " = IntPtr.Zero;\n" CLOSE_BLOCK_L4 CLOSE_BLOCK_L3 INDENT3
+ "(this, " BINDINGS_PTR_FIELD ");\n" CLOSE_BLOCK_L4 CLOSE_BLOCK_L3 INDENT3
+ "this." BINDINGS_PTR_FIELD " = IntPtr.Zero;\n" INDENT3
"GC.SuppressFinalize(this);\n" INDENT3 "disposed = true;\n" CLOSE_BLOCK_L2);
Map<StringName, TypeInterface>::Element *array_itype = builtin_types.find(name_cache.type_Array);
@@ -1717,6 +1719,51 @@ void BindingsGenerator::_populate_object_type_interfaces() {
itype.im_type_in = "IntPtr";
itype.im_type_out = itype.proxy_name;
+ List<PropertyInfo> property_list;
+ ClassDB::get_property_list(type_cname, &property_list, true);
+
+ // Populate properties
+
+ for (const List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) {
+ const PropertyInfo &property = E->get();
+
+ if (property.usage & PROPERTY_USAGE_GROUP || property.usage & PROPERTY_USAGE_CATEGORY)
+ continue;
+
+ PropertyInterface iprop;
+ iprop.cname = property.name;
+ iprop.proxy_name = escape_csharp_keyword(snake_to_pascal_case(iprop.cname));
+ iprop.setter = ClassDB::get_property_setter(type_cname, iprop.cname);
+ iprop.getter = ClassDB::get_property_getter(type_cname, iprop.cname);
+
+ bool valid = false;
+ iprop.index = ClassDB::get_property_index(type_cname, iprop.cname, &valid);
+ ERR_FAIL_COND(!valid);
+
+ // Prevent property and enclosing type from sharing the same name
+ if (iprop.proxy_name == itype.proxy_name) {
+ if (verbose_output) {
+ WARN_PRINTS("Name of property `" + iprop.proxy_name + "` is ambiguous with the name of its class `" +
+ itype.proxy_name + "`. Renaming property to `" + iprop.proxy_name + "_`");
+ }
+
+ iprop.proxy_name += "_";
+ }
+
+ iprop.prop_doc = NULL;
+
+ for (int i = 0; i < itype.class_doc->properties.size(); i++) {
+ const DocData::PropertyDoc &prop_doc = itype.class_doc->properties[i];
+
+ if (prop_doc.name == iprop.cname) {
+ iprop.prop_doc = &prop_doc;
+ break;
+ }
+ }
+
+ itype.properties.push_back(iprop);
+ }
+
// Populate methods
List<MethodInfo> virtual_method_list;
@@ -1851,12 +1898,10 @@ void BindingsGenerator::_populate_object_type_interfaces() {
}
if (!imethod.is_virtual && imethod.name[0] == '_') {
- const Vector<DocData::PropertyDoc> &properties = itype.class_doc->properties;
+ for (const List<PropertyInterface>::Element *E = itype.properties.front(); E; E = E->next()) {
+ const PropertyInterface &iprop = E->get();
- for (int i = 0; i < properties.size(); i++) {
- const DocData::PropertyDoc &prop_doc = properties[i];
-
- if (prop_doc.getter == imethod.name || prop_doc.setter == imethod.name) {
+ if (iprop.setter == imethod.name || iprop.getter == imethod.name) {
imethod.is_internal = true;
itype.methods.push_back(imethod);
break;
@@ -1867,50 +1912,6 @@ void BindingsGenerator::_populate_object_type_interfaces() {
}
}
- // Populate properties
-
- List<PropertyInfo> property_list;
- ClassDB::get_property_list(type_cname, &property_list, true);
- for (const List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) {
- const PropertyInfo &property = E->get();
-
- if (property.usage & PROPERTY_USAGE_GROUP || property.usage & PROPERTY_USAGE_CATEGORY)
- continue;
-
- PropertyInterface iprop;
- iprop.cname = property.name;
- iprop.proxy_name = escape_csharp_keyword(snake_to_pascal_case(iprop.cname));
- iprop.setter = ClassDB::get_property_setter(type_cname, iprop.cname);
- iprop.getter = ClassDB::get_property_getter(type_cname, iprop.cname);
-
- bool valid = false;
- iprop.index = ClassDB::get_property_index(type_cname, iprop.cname, &valid);
- ERR_FAIL_COND(!valid);
-
- // Prevent property and enclosing type from sharing the same name
- if (iprop.proxy_name == itype.proxy_name) {
- if (verbose_output) {
- WARN_PRINTS("Name of property `" + iprop.proxy_name + "` is ambiguous with the name of its class `" +
- itype.proxy_name + "`. Renaming property to `" + iprop.proxy_name + "_`");
- }
-
- iprop.proxy_name += "_";
- }
-
- iprop.prop_doc = NULL;
-
- for (int i = 0; i < itype.class_doc->properties.size(); i++) {
- const DocData::PropertyDoc &prop_doc = itype.class_doc->properties[i];
-
- if (prop_doc.name == iprop.cname) {
- iprop.prop_doc = &prop_doc;
- break;
- }
- }
-
- itype.properties.push_back(iprop);
- }
-
// Populate enums and constants
List<String> constant_list;
@@ -2467,8 +2468,7 @@ void BindingsGenerator::_populate_global_constants() {
}
}
-BindingsGenerator::BindingsGenerator() :
- name_cache(NameCache::get_singleton()) {
+void BindingsGenerator::initialize() {
EditorHelp::generate_doc();
@@ -2510,7 +2510,7 @@ void BindingsGenerator::handle_cmdline_args(const List<String> &p_cmdline_args)
const List<String>::Element *path_elem = elem->next();
if (path_elem) {
- if (get_singleton().generate_glue(path_elem->get()) != OK)
+ if (get_singleton()->generate_glue(path_elem->get()) != OK)
ERR_PRINT("Mono glue generation failed");
elem = elem->next();
} else {
@@ -2524,7 +2524,7 @@ void BindingsGenerator::handle_cmdline_args(const List<String> &p_cmdline_args)
const List<String>::Element *path_elem = elem->next();
if (path_elem) {
- if (get_singleton().generate_cs_core_project(path_elem->get()) != OK)
+ if (get_singleton()->generate_cs_core_project(path_elem->get()) != OK)
ERR_PRINT("Generation of solution and C# project for the Core API failed");
elem = elem->next();
} else {
@@ -2539,7 +2539,7 @@ void BindingsGenerator::handle_cmdline_args(const List<String> &p_cmdline_args)
if (path_elem) {
if (path_elem->next()) {
- if (get_singleton().generate_cs_editor_project(path_elem->get(), path_elem->next()->get()) != OK)
+ if (get_singleton()->generate_cs_editor_project(path_elem->get(), path_elem->next()->get()) != OK)
ERR_PRINT("Generation of solution and C# project for the Editor API failed");
elem = path_elem->next();
} else {
diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h
index eac00690ff..5934f3f27f 100644
--- a/modules/mono/editor/bindings_generator.h
+++ b/modules/mono/editor/bindings_generator.h
@@ -145,7 +145,7 @@ class BindingsGenerator {
}
MethodInterface() {
- return_type = NameCache::get_singleton().type_void;
+ return_type = BindingsGenerator::get_singleton()->name_cache.type_void;
is_vararg = false;
is_virtual = false;
requires_object_call = false;
@@ -469,16 +469,11 @@ class BindingsGenerator {
enum_Error = StaticCString::create("Error");
}
- static NameCache &get_singleton() {
- static NameCache singleton;
- return singleton;
- }
-
NameCache(const NameCache &);
NameCache &operator=(const NameCache &);
};
- const NameCache &name_cache;
+ NameCache name_cache;
const List<InternalCall>::Element *find_icall_by_name(const String &p_name, const List<InternalCall> &p_list) {
const List<InternalCall>::Element *it = p_list.front();
@@ -525,18 +520,26 @@ class BindingsGenerator {
Error _save_file(const String &path, const List<String> &content);
- BindingsGenerator();
+ BindingsGenerator() {}
BindingsGenerator(const BindingsGenerator &);
BindingsGenerator &operator=(const BindingsGenerator &);
+ friend class CSharpLanguage;
+ static BindingsGenerator *singleton;
+
public:
Error generate_cs_core_project(const String &p_output_dir, bool p_verbose_output = true);
Error generate_cs_editor_project(const String &p_output_dir, const String &p_core_dll_path, bool p_verbose_output = true);
Error generate_glue(const String &p_output_dir);
- static BindingsGenerator &get_singleton() {
- static BindingsGenerator singleton;
+ void initialize();
+
+ _FORCE_INLINE_ static BindingsGenerator *get_singleton() {
+ if (!singleton) {
+ singleton = memnew(BindingsGenerator);
+ singleton->initialize();
+ }
return singleton;
}
diff --git a/modules/mono/editor/godotsharp_builds.cpp b/modules/mono/editor/godotsharp_builds.cpp
index 3750a2b02a..3c06537816 100644
--- a/modules/mono/editor/godotsharp_builds.cpp
+++ b/modules/mono/editor/godotsharp_builds.cpp
@@ -238,12 +238,12 @@ bool GodotSharpBuilds::make_api_sln(GodotSharpBuilds::APIType p_api_type) {
#error "How am I supposed to generate the bindings?"
#endif
- BindingsGenerator &gen = BindingsGenerator::get_singleton();
+ BindingsGenerator *gen = BindingsGenerator::get_singleton();
bool gen_verbose = OS::get_singleton()->is_stdout_verbose();
Error err = p_api_type == API_CORE ?
- gen.generate_cs_core_project(api_sln_dir, gen_verbose) :
- gen.generate_cs_editor_project(api_sln_dir, core_api_assembly, gen_verbose);
+ gen->generate_cs_core_project(api_sln_dir, gen_verbose) :
+ gen->generate_cs_editor_project(api_sln_dir, core_api_assembly, gen_verbose);
if (err != OK) {
show_build_error_dialog("Failed to generate " + api_name + " solution. Error: " + itos(err));
diff --git a/modules/mono/glue/glue_header.h b/modules/mono/glue/glue_header.h
index 75a4eb2b40..5e41da299b 100644
--- a/modules/mono/glue/glue_header.h
+++ b/modules/mono/glue/glue_header.h
@@ -53,9 +53,11 @@
} \
Object *m_instance = ci->creation_func();
-void godot_icall_Object_Dtor(Object *ptr) {
- ERR_FAIL_NULL(ptr);
- _GodotSharp::get_singleton()->queue_dispose(ptr);
+void godot_icall_Object_Dtor(MonoObject *obj, Object *ptr) {
+#ifdef DEBUG_ENABLED
+ CRASH_COND(ptr == NULL);
+#endif
+ _GodotSharp::get_singleton()->queue_dispose(obj, ptr);
}
// -- ClassDB --
diff --git a/modules/mono/mono_gc_handle.cpp b/modules/mono/mono_gc_handle.cpp
index 121392b3f8..d407aa6981 100644
--- a/modules/mono/mono_gc_handle.cpp
+++ b/modules/mono/mono_gc_handle.cpp
@@ -41,10 +41,7 @@ uint32_t MonoGCHandle::make_strong_handle(MonoObject *p_object) {
uint32_t MonoGCHandle::make_weak_handle(MonoObject *p_object) {
- return mono_gchandle_new_weakref(
- p_object,
- true /* track_resurrection: allows us to invoke _notification(NOTIFICATION_PREDELETE) while disposing */
- );
+ return mono_gchandle_new_weakref(p_object, false);
}
Ref<MonoGCHandle> MonoGCHandle::create_strong(MonoObject *p_object) {
diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp
index c997b0f000..08059c9ba9 100644
--- a/modules/mono/mono_gd/gd_mono.cpp
+++ b/modules/mono/mono_gd/gd_mono.cpp
@@ -703,7 +703,7 @@ bool _GodotSharp::is_domain_loaded() {
call_deferred("_dispose_callback"); \
}
-void _GodotSharp::queue_dispose(Object *p_object) {
+void _GodotSharp::queue_dispose(MonoObject *p_mono_object, Object *p_object) {
if (GDMonoUtils::is_main_thread() && !GDMono::get_singleton()->is_finalizing_scripts_domain()) {
_dispose_object(p_object);
@@ -712,6 +712,13 @@ void _GodotSharp::queue_dispose(Object *p_object) {
queue_mutex->lock();
#endif
+ // This is our last chance to invoke notification predelete (this is being called from the finalizer)
+ // We must use the MonoObject* passed by the finalizer, because the weak GC handle target returns NULL at this point
+ CSharpInstance *si = CAST_CSHARP_INSTANCE(p_object->get_script_instance());
+ if (si) {
+ si->call_notification_no_check(p_mono_object, Object::NOTIFICATION_PREDELETE);
+ }
+
ENQUEUE_FOR_DISPOSAL(obj_delete_queue, p_object);
#ifndef NO_THREADS
diff --git a/modules/mono/mono_gd/gd_mono.h b/modules/mono/mono_gd/gd_mono.h
index b188c0730a..862f171dc9 100644
--- a/modules/mono/mono_gd/gd_mono.h
+++ b/modules/mono/mono_gd/gd_mono.h
@@ -215,7 +215,7 @@ public:
bool is_finalizing_domain();
bool is_domain_loaded();
- void queue_dispose(Object *p_object);
+ void queue_dispose(MonoObject *p_mono_object, Object *p_object);
void queue_dispose(NodePath *p_node_path);
void queue_dispose(RID *p_rid);
diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp
index 45ca097de5..9fbbca0716 100644
--- a/platform/uwp/export/export.cpp
+++ b/platform/uwp/export/export.cpp
@@ -1041,6 +1041,10 @@ public:
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "identity/product_guid"), "00000000-0000-0000-0000-000000000000"));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "identity/publisher_guid"), "00000000-0000-0000-0000-000000000000"));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "signing/certificate", PROPERTY_HINT_GLOBAL_FILE, "*.pfx"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "signing/password"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "signing/algorithm", PROPERTY_HINT_ENUM, "MD5,SHA1,SHA256"), 2));
+
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "version/major"), 1));
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "version/minor"), 0));
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "version/build"), 0));
@@ -1370,6 +1374,58 @@ public:
packager.finish();
+#ifdef WINDOWS_ENABLED
+ // Sign with signtool
+ String signtool_path = EditorSettings::get_singleton()->get("export/uwp/signtool");
+ if (signtool_path == String()) {
+ return OK;
+ }
+
+ if (!FileAccess::exists(signtool_path)) {
+ ERR_PRINTS("Could not find signtool executable at " + signtool_path + ", aborting.");
+ return ERR_FILE_NOT_FOUND;
+ }
+
+ static String algs[] = { "MD5", "SHA1", "SHA256" };
+
+ String cert_path = EditorSettings::get_singleton()->get("export/uwp/debug_certificate");
+ String cert_pass = EditorSettings::get_singleton()->get("export/uwp/debug_password");
+ int cert_alg = EditorSettings::get_singleton()->get("export/uwp/debug_algorithm");
+
+ if (!p_debug) {
+ cert_path = p_preset->get("signing/certificate");
+ cert_pass = p_preset->get("signing/password");
+ cert_alg = p_preset->get("signing/algorithm");
+ }
+
+ if (cert_path == String()) {
+ return OK; // Certificate missing, don't try to sign
+ }
+
+ if (!FileAccess::exists(cert_path)) {
+ ERR_PRINTS("Could not find certificate file at " + cert_path + ", aborting.");
+ return ERR_FILE_NOT_FOUND;
+ }
+
+ if (cert_alg < 0 || cert_alg > 2) {
+ ERR_PRINTS("Invalid certificate algorithm " + itos(cert_alg) + ", aborting.");
+ return ERR_INVALID_DATA;
+ }
+
+ List<String> args;
+ args.push_back("sign");
+ args.push_back("/fd");
+ args.push_back(algs[cert_alg]);
+ args.push_back("/a");
+ args.push_back("/f");
+ args.push_back(cert_path);
+ args.push_back("/p");
+ args.push_back(cert_pass);
+ args.push_back(p_path);
+
+ OS::get_singleton()->execute(signtool_path, args, true);
+#endif // WINDOWS_ENABLED
+
return OK;
}
@@ -1387,6 +1443,18 @@ public:
};
void register_uwp_exporter() {
- Ref<EditorExportUWP> exporter = Ref<EditorExportUWP>(memnew(EditorExportUWP));
+
+#ifdef WINDOWS_ENABLED
+ EDITOR_DEF("export/uwp/signtool", "");
+ EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/uwp/signtool", PROPERTY_HINT_GLOBAL_FILE, "*.exe"));
+ EDITOR_DEF("export/uwp/debug_certificate", "");
+ EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/uwp/debug_certificate", PROPERTY_HINT_GLOBAL_FILE, "*.pfx"));
+ EDITOR_DEF("export/uwp/debug_password", "");
+ EDITOR_DEF("export/uwp/debug_algorithm", 2); // SHA256 is the default
+ EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "export/uwp/debug_algorithm", PROPERTY_HINT_ENUM, "MD5,SHA1,SHA256"));
+#endif // WINDOWS_ENABLED
+
+ Ref<EditorExportUWP> exporter;
+ exporter.instance();
EditorExport::get_singleton()->add_export_platform(exporter);
}
diff --git a/platform/windows/detect.py b/platform/windows/detect.py
index 3b8de2caf4..489bac50f5 100644
--- a/platform/windows/detect.py
+++ b/platform/windows/detect.py
@@ -190,7 +190,11 @@ def configure(env):
if (env["use_lto"]):
env.Append(CCFLAGS=['/GL'])
- env.Append(LINKFLAGS=['/LTCG'])
+ env.Append(ARFLAGS=['/LTCG'])
+ if env["progress"]:
+ env.Append(LINKFLAGS=['/LTCG:STATUS'])
+ else:
+ env.Append(LINKFLAGS=['/LTCG'])
env.Append(CCFLAGS=["/I" + p for p in os.getenv("INCLUDE").split(";")])
env.Append(LIBPATH=[p for p in os.getenv("LIB").split(";")])
diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp
index 3d40bb299a..417fe90d7c 100644
--- a/scene/3d/skeleton.cpp
+++ b/scene/3d/skeleton.cpp
@@ -153,6 +153,24 @@ void Skeleton::_notification(int p_what) {
case NOTIFICATION_EXIT_WORLD: {
} break;
+ case NOTIFICATION_TRANSFORM_CHANGED: {
+
+ if (dirty)
+ break; //will be eventually updated
+
+ //if moved, just update transforms
+ VisualServer *vs = VisualServer::get_singleton();
+ Bone *bonesptr = &bones[0];
+ int len = bones.size();
+ Transform global_transform = get_global_transform();
+ Transform global_transform_inverse = global_transform.affine_inverse();
+
+ for (int i = 0; i < len; i++) {
+
+ Bone &b = bonesptr[i];
+ vs->skeleton_bone_set_transform(skeleton, i, global_transform * (b.transform_final * global_transform_inverse));
+ }
+ } break;
case NOTIFICATION_UPDATE_SKELETON: {
VisualServer *vs = VisualServer::get_singleton();
@@ -242,9 +260,8 @@ void Skeleton::_notification(int p_what) {
}
}
- Transform transform = b.pose_global * b.rest_global_inverse;
-
- vs->skeleton_bone_set_transform(skeleton, i, global_transform * (transform * global_transform_inverse));
+ b.transform_final = b.pose_global * b.rest_global_inverse;
+ vs->skeleton_bone_set_transform(skeleton, i, global_transform * (b.transform_final * global_transform_inverse));
for (List<uint32_t>::Element *E = b.nodes_bound.front(); E; E = E->next()) {
@@ -548,6 +565,7 @@ Skeleton::Skeleton() {
rest_global_inverse_dirty = true;
dirty = false;
skeleton = VisualServer::get_singleton()->skeleton_create();
+ set_notify_transform(true);
}
Skeleton::~Skeleton() {
diff --git a/scene/3d/skeleton.h b/scene/3d/skeleton.h
index fdc1100472..11ff728474 100644
--- a/scene/3d/skeleton.h
+++ b/scene/3d/skeleton.h
@@ -57,6 +57,8 @@ class Skeleton : public Spatial {
bool custom_pose_enable;
Transform custom_pose;
+ Transform transform_final;
+
List<uint32_t> nodes_bound;
Bone() {
diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp
index a50047e426..d110984bbc 100644
--- a/scene/animation/animation_tree_player.cpp
+++ b/scene/animation/animation_tree_player.cpp
@@ -556,7 +556,7 @@ float AnimationTreePlayer::_process_node(const StringName &p_node, AnimationNode
return _process_node(osn->inputs[0].node, r_prev_anim, p_time, p_seek, p_fallback_weight, p_weights);
}
- float os_seek = p_seek;
+ bool os_seek = p_seek;
if (p_seek)
osn->time = p_time;
diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp
index 834505df9a..076f337635 100644
--- a/servers/visual/shader_language.cpp
+++ b/servers/visual/shader_language.cpp
@@ -334,6 +334,7 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
while (true) {
if (GETCHAR(0) == '\n') {
+ tk_line++;
char_idx++;
break;
}