summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/bind/core_bind.cpp2
-rw-r--r--core/io/marshalls.cpp12
-rw-r--r--core/os/os.cpp6
-rw-r--r--core/os/os.h1
-rw-r--r--core/project_settings.cpp10
-rw-r--r--doc/classes/Array.xml7
-rw-r--r--doc/classes/AudioStreamPlayer.xml2
-rw-r--r--doc/classes/AudioStreamPlayer2D.xml2
-rw-r--r--doc/classes/AudioStreamPlayer3D.xml2
-rw-r--r--doc/classes/CanvasItem.xml1
-rw-r--r--doc/classes/Control.xml2
-rw-r--r--doc/classes/Engine.xml3
-rw-r--r--doc/classes/Font.xml1
-rw-r--r--doc/classes/HScrollBar.xml11
-rw-r--r--doc/classes/InputMap.xml1
-rw-r--r--doc/classes/LineEdit.xml22
-rw-r--r--doc/classes/MainLoop.xml2
-rw-r--r--doc/classes/NinePatchRect.xml2
-rw-r--r--doc/classes/OS.xml9
-rw-r--r--doc/classes/ProjectSettings.xml2
-rw-r--r--doc/classes/ScriptCreateDialog.xml2
-rw-r--r--doc/classes/ScrollBar.xml1
-rw-r--r--doc/classes/VScrollBar.xml12
-rw-r--r--doc/classes/VisibilityEnabler.xml2
-rw-r--r--doc/classes/VisibilityEnabler2D.xml3
-rw-r--r--editor/animation_track_editor.cpp5
-rw-r--r--editor/code_editor.cpp2
-rw-r--r--editor/editor_data.cpp2
-rw-r--r--editor/filesystem_dock.cpp2
-rw-r--r--editor/groups_editor.cpp12
-rw-r--r--editor/import/editor_scene_importer_gltf.cpp10
-rw-r--r--editor/import/editor_scene_importer_gltf.h1
-rw-r--r--editor/import/resource_importer_obj.cpp14
-rw-r--r--editor/plugins/animation_tree_editor_plugin.cpp3
-rw-r--r--editor/plugins/audio_stream_editor_plugin.cpp3
-rw-r--r--editor/plugins/resource_preloader_editor_plugin.cpp3
-rw-r--r--editor/plugins/script_editor_plugin.cpp2
-rw-r--r--editor/plugins/shader_editor_plugin.cpp3
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp28
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp2
-rw-r--r--editor/script_create_dialog.cpp40
-rw-r--r--editor/script_create_dialog.h3
-rw-r--r--main/main.cpp30
-rw-r--r--misc/dist/shell/_godot.zsh-completion77
-rw-r--r--modules/assimp/editor_scene_importer_assimp.cpp4
-rw-r--r--modules/bullet/space_bullet.cpp4
-rw-r--r--modules/gdnative/gdnative/gdnative.cpp4
-rw-r--r--modules/gdnative/gdnative_api.json7
-rw-r--r--modules/gdnative/include/gdnative/gdnative.h3
-rw-r--r--modules/gdscript/gdscript_compiler.cpp16
-rw-r--r--modules/gdscript/gdscript_compiler.h6
-rw-r--r--modules/gdscript/gdscript_function.cpp7
-rw-r--r--modules/gdscript/gdscript_parser.cpp16
-rw-r--r--modules/gdscript/language_server/gdscript_language_server.cpp50
-rw-r--r--modules/gdscript/language_server/gdscript_language_server.h5
-rw-r--r--modules/gdscript/language_server/gdscript_text_document.cpp2
-rw-r--r--modules/gdscript/language_server/lsp.hpp2
-rw-r--r--modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml2
-rw-r--r--platform/android/dir_access_jandroid.cpp1
-rw-r--r--platform/android/export/export.cpp270
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/GodotLib.java10
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/GodotView.java5
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/input/GodotGestureHandler.java106
-rw-r--r--platform/android/java_godot_lib_jni.cpp14
-rw-r--r--platform/android/java_godot_lib_jni.h2
-rw-r--r--platform/android/os_android.cpp20
-rw-r--r--platform/android/os_android.h3
-rw-r--r--platform/osx/export/export.cpp49
-rw-r--r--platform/osx/godot_main_osx.mm29
-rw-r--r--platform/osx/os_osx.h1
-rw-r--r--platform/osx/os_osx.mm13
-rw-r--r--platform/x11/crash_handler_x11.cpp2
-rw-r--r--scene/2d/animated_sprite.cpp2
-rw-r--r--scene/2d/animated_sprite.h2
-rw-r--r--scene/2d/back_buffer_copy.cpp2
-rw-r--r--scene/2d/back_buffer_copy.h2
-rw-r--r--scene/2d/canvas_item.cpp7
-rw-r--r--scene/2d/canvas_item.h3
-rw-r--r--scene/2d/collision_polygon_2d.cpp2
-rw-r--r--scene/2d/collision_polygon_2d.h10
-rw-r--r--scene/2d/light_2d.cpp2
-rw-r--r--scene/2d/light_2d.h2
-rw-r--r--scene/2d/light_occluder_2d.cpp5
-rw-r--r--scene/2d/light_occluder_2d.h4
-rw-r--r--scene/2d/line_2d.cpp2
-rw-r--r--scene/2d/line_2d.h6
-rw-r--r--scene/2d/mesh_instance_2d.cpp2
-rw-r--r--scene/2d/mesh_instance_2d.h6
-rw-r--r--scene/2d/multimesh_instance_2d.cpp2
-rw-r--r--scene/2d/multimesh_instance_2d.h6
-rw-r--r--scene/2d/navigation_polygon.cpp5
-rw-r--r--scene/2d/navigation_polygon.h4
-rw-r--r--scene/2d/node_2d.cpp3
-rw-r--r--scene/2d/node_2d.h2
-rw-r--r--scene/2d/path_2d.cpp2
-rw-r--r--scene/2d/path_2d.h2
-rw-r--r--scene/2d/physics_body_2d.cpp31
-rw-r--r--scene/2d/physics_body_2d.h6
-rw-r--r--scene/2d/polygon_2d.cpp2
-rw-r--r--scene/2d/polygon_2d.h2
-rw-r--r--scene/2d/position_2d.cpp2
-rw-r--r--scene/2d/position_2d.h2
-rw-r--r--scene/2d/sprite.cpp12
-rw-r--r--scene/2d/sprite.h6
-rw-r--r--scene/2d/tile_map.cpp2
-rw-r--r--scene/2d/tile_map.h2
-rw-r--r--scene/2d/touch_screen_button.cpp12
-rw-r--r--scene/2d/touch_screen_button.h7
-rw-r--r--scene/2d/visibility_notifier_2d.cpp19
-rw-r--r--scene/2d/visibility_notifier_2d.h2
-rw-r--r--scene/3d/camera.cpp4
-rw-r--r--scene/3d/physics_body.cpp33
-rw-r--r--scene/3d/physics_body.h6
-rw-r--r--scene/gui/base_button.cpp2
-rw-r--r--scene/gui/control.cpp11
-rw-r--r--scene/gui/control.h2
-rw-r--r--scene/gui/label.cpp8
-rw-r--r--scene/gui/line_edit.cpp15
-rw-r--r--servers/visual/shader_language.cpp18
119 files changed, 963 insertions, 343 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 0eacffeb88..4586dc6d14 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -1393,7 +1393,7 @@ void _OS::_bind_methods() {
ADD_PROPERTY_DEFAULT("current_screen", 0);
ADD_PROPERTY_DEFAULT("exit_code", 0);
ADD_PROPERTY_DEFAULT("vsync_enabled", true);
- ADD_PROPERTY_DEFAULT("vsync_via_compositor", false);
+ ADD_PROPERTY_DEFAULT("vsync_via_compositor", true);
ADD_PROPERTY_DEFAULT("low_processor_usage_mode", false);
ADD_PROPERTY_DEFAULT("low_processor_usage_mode_sleep_usec", 6900);
ADD_PROPERTY_DEFAULT("keep_screen_on", true);
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index 8c8f65c3a0..e847a9cf0c 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -803,6 +803,18 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
}
} break;
case Variant::OBJECT: {
+#ifdef DEBUG_ENABLED
+ // Test for potential wrong values sent by the debugger when it breaks.
+ Object *obj = p_variant;
+ if (!obj || !ObjectDB::instance_validate(obj)) {
+ // Object is invalid, send a NULL instead.
+ if (buf) {
+ encode_uint32(Variant::NIL, buf);
+ }
+ r_len += 4;
+ return OK;
+ }
+#endif // DEBUG_ENABLED
if (!p_full_objects) {
flags |= ENCODE_FLAG_OBJECT_AS_ID;
}
diff --git a/core/os/os.cpp b/core/os/os.cpp
index edb2416b67..81dea159a6 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -343,6 +343,12 @@ String OS::get_cache_path() const {
return ".";
}
+// Path to macOS .app bundle resources
+String OS::get_bundle_resource_dir() const {
+
+ return ".";
+};
+
// OS specific path for user://
String OS::get_user_data_dir() const {
diff --git a/core/os/os.h b/core/os/os.h
index 593ea2b645..714c4e3f09 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -411,6 +411,7 @@ public:
virtual String get_data_path() const;
virtual String get_config_path() const;
virtual String get_cache_path() const;
+ virtual String get_bundle_resource_dir() const;
virtual String get_user_data_dir() const;
virtual String get_resource_dir() const;
diff --git a/core/project_settings.cpp b/core/project_settings.cpp
index a30967dcca..a01a8a35c6 100644
--- a/core/project_settings.cpp
+++ b/core/project_settings.cpp
@@ -383,8 +383,16 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
}
}
- // Attempt with PCK bundled into executable
+#ifdef OSX_ENABLED
+ // Attempt to load PCK from macOS .app bundle resources
+ if (!found) {
+ if (_load_resource_pack(OS::get_singleton()->get_bundle_resource_dir().plus_file(exec_basename + ".pck"))) {
+ found = true;
+ }
+ }
+#endif
+ // Attempt with PCK bundled into executable
if (!found) {
if (_load_resource_pack(exec_path)) {
found = true;
diff --git a/doc/classes/Array.xml b/doc/classes/Array.xml
index 2d330fc935..c192cee1fe 100644
--- a/doc/classes/Array.xml
+++ b/doc/classes/Array.xml
@@ -331,17 +331,18 @@
<argument index="1" name="func" type="String">
</argument>
<description>
- Sorts the array using a custom method. The arguments are an object that holds the method and the name of such method. The custom method receives two arguments (a pair of elements from the array) and must return [code]true[/code] if the first argument is less than the second, and return [code]false[/code] otherwise.
+ Sorts the array using a custom method. The arguments are an object that holds the method and the name of such method. The custom method receives two arguments (a pair of elements from the array) and must return either [code]true[/code] or [code]false[/code].
[b]Note:[/b] you cannot randomize the return value as the heapsort algorithm expects a deterministic result. Doing so will result in unexpected behavior.
[codeblock]
class MyCustomSorter:
- static func sort(a, b):
+ static func sort_ascending(a, b):
if a[0] &lt; b[0]:
return true
return false
var my_items = [[5, "Potato"], [9, "Rice"], [4, "Tomato"]]
- my_items.sort_custom(MyCustomSorter, "sort")
+ my_items.sort_custom(MyCustomSorter, "sort_ascending")
+ print(my_items) # Prints [[4, Tomato], [5, Potato], [9, Rice]]
[/codeblock]
</description>
</method>
diff --git a/doc/classes/AudioStreamPlayer.xml b/doc/classes/AudioStreamPlayer.xml
index 89fc18476b..0eadf27c4d 100644
--- a/doc/classes/AudioStreamPlayer.xml
+++ b/doc/classes/AudioStreamPlayer.xml
@@ -21,6 +21,7 @@
<return type="AudioStreamPlayback">
</return>
<description>
+ Returns the [AudioStreamPlayback] object associated with this [AudioStreamPlayer].
</description>
</method>
<method name="play">
@@ -69,6 +70,7 @@
The [AudioStream] object to be played.
</member>
<member name="stream_paused" type="bool" setter="set_stream_paused" getter="get_stream_paused" default="false">
+ If [code]true[/code], the playback is paused. You can resume it by setting [code]stream_paused[/code] to [code]false[/code].
</member>
<member name="volume_db" type="float" setter="set_volume_db" getter="get_volume_db" default="0.0">
Volume of sound, in dB.
diff --git a/doc/classes/AudioStreamPlayer2D.xml b/doc/classes/AudioStreamPlayer2D.xml
index 4734aff770..ec3b7872b7 100644
--- a/doc/classes/AudioStreamPlayer2D.xml
+++ b/doc/classes/AudioStreamPlayer2D.xml
@@ -21,6 +21,7 @@
<return type="AudioStreamPlayback">
</return>
<description>
+ Returns the [AudioStreamPlayback] object associated with this [AudioStreamPlayer2D].
</description>
</method>
<method name="play">
@@ -75,6 +76,7 @@
The [AudioStream] object to be played.
</member>
<member name="stream_paused" type="bool" setter="set_stream_paused" getter="get_stream_paused" default="false">
+ If [code]true[/code], the playback is paused. You can resume it by setting [code]stream_paused[/code] to [code]false[/code].
</member>
<member name="volume_db" type="float" setter="set_volume_db" getter="get_volume_db" default="0.0">
Base volume without dampening.
diff --git a/doc/classes/AudioStreamPlayer3D.xml b/doc/classes/AudioStreamPlayer3D.xml
index a73f96d082..5e12e06650 100644
--- a/doc/classes/AudioStreamPlayer3D.xml
+++ b/doc/classes/AudioStreamPlayer3D.xml
@@ -21,6 +21,7 @@
<return type="AudioStreamPlayback">
</return>
<description>
+ Returns the [AudioStreamPlayback] object associated with this [AudioStreamPlayer3D].
</description>
</method>
<method name="play">
@@ -99,6 +100,7 @@
The [AudioStream] object to be played.
</member>
<member name="stream_paused" type="bool" setter="set_stream_paused" getter="get_stream_paused" default="false">
+ If [code]true[/code], the playback is paused. You can resume it by setting [code]stream_paused[/code] to [code]false[/code].
</member>
<member name="unit_db" type="float" setter="set_unit_db" getter="get_unit_db" default="0.0">
Base sound level unaffected by dampening, in dB.
diff --git a/doc/classes/CanvasItem.xml b/doc/classes/CanvasItem.xml
index 8372d15324..54d917c931 100644
--- a/doc/classes/CanvasItem.xml
+++ b/doc/classes/CanvasItem.xml
@@ -42,6 +42,7 @@
<argument index="7" name="antialiased" type="bool" default="false">
</argument>
<description>
+ Draws an arc between the given angles. The larger the value of [code]point_count[/code], the smoother the curve.
</description>
</method>
<method name="draw_char">
diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml
index 75d5a72fb1..d309015453 100644
--- a/doc/classes/Control.xml
+++ b/doc/classes/Control.xml
@@ -504,7 +504,7 @@
<description>
Virtual method to be implemented by the user. Returns whether the given [code]point[/code] is inside this control.
If not overridden, default behavior is checking if the point is within control's Rect.
- [b]Node:[/b] If you want to check if a point is inside the control, you can use [code]get_rect().has_point(point)[/code].
+ [b]Note:[/b] If you want to check if a point is inside the control, you can use [code]get_rect().has_point(point)[/code].
</description>
</method>
<method name="has_shader_override" qualifiers="const">
diff --git a/doc/classes/Engine.xml b/doc/classes/Engine.xml
index 187e13d7bd..04e203793b 100644
--- a/doc/classes/Engine.xml
+++ b/doc/classes/Engine.xml
@@ -85,6 +85,7 @@
<argument index="0" name="name" type="String">
</argument>
<description>
+ Returns a global singleton with given [code]name[/code]. Often used for plugins, e.g. GodotPayments.
</description>
</method>
<method name="get_version_info" qualifiers="const">
@@ -116,6 +117,7 @@
<argument index="0" name="name" type="String">
</argument>
<description>
+ Returns [code]true[/code] if a singleton with given [code]name[/code] exists in global scope.
</description>
</method>
<method name="is_in_physics_frame" qualifiers="const">
@@ -134,6 +136,7 @@
The number of fixed iterations per second (for fixed process and physics).
</member>
<member name="physics_jitter_fix" type="float" setter="set_physics_jitter_fix" getter="get_physics_jitter_fix" default="0.5">
+ Controls how much physic ticks are synchronized with real time. For 0 or less, the ticks are synchronized. Such values are recommended for network games, where clock synchronization matters. Higher values cause higher deviation of in-game clock and real clock, but allows to smooth out framerate jitters. The default value of 0.5 should be fine for most; values above 2 could cause the game to react to dropped frames with a noticeable delay and are not recommended.
</member>
<member name="target_fps" type="int" setter="set_target_fps" getter="get_target_fps" default="0">
The desired frames per second. If the hardware cannot keep up, this setting may not be respected. A value of 0 means no limit.
diff --git a/doc/classes/Font.xml b/doc/classes/Font.xml
index f7de79913c..e751a07082 100644
--- a/doc/classes/Font.xml
+++ b/doc/classes/Font.xml
@@ -91,6 +91,7 @@
<return type="bool">
</return>
<description>
+ Returns [code]true[/code] if the font has an outline.
</description>
</method>
<method name="is_distance_field_hint" qualifiers="const">
diff --git a/doc/classes/HScrollBar.xml b/doc/classes/HScrollBar.xml
index 14ace8bc76..90f14dd344 100644
--- a/doc/classes/HScrollBar.xml
+++ b/doc/classes/HScrollBar.xml
@@ -4,7 +4,7 @@
Horizontal scroll bar.
</brief_description>
<description>
- Horizontal scroll bar. See [ScrollBar]. This one goes from left (min) to right (max).
+ Horizontal version of [ScrollBar], which goes from left (min) to right (max).
</description>
<tutorials>
</tutorials>
@@ -14,22 +14,31 @@
</constants>
<theme_items>
<theme_item name="decrement" type="Texture">
+ Icon used as a button to scroll the [ScrollBar] left. Supports custom step using the [member ScrollBar.custom_step] property.
</theme_item>
<theme_item name="decrement_highlight" type="Texture">
+ Displayed when the mouse cursor hovers over the decrement button.
</theme_item>
<theme_item name="grabber" type="StyleBox">
+ Used as texture for the grabber, the draggable element representing current scroll.
</theme_item>
<theme_item name="grabber_highlight" type="StyleBox">
+ Used when the mouse hovers over the grabber.
</theme_item>
<theme_item name="grabber_pressed" type="StyleBox">
+ Used when the grabber is being dragged.
</theme_item>
<theme_item name="increment" type="Texture">
+ Icon used as a button to scroll the [ScrollBar] right. Supports custom step using the [member ScrollBar.custom_step] property.
</theme_item>
<theme_item name="increment_highlight" type="Texture">
+ Displayed when the mouse cursor hovers over the increment button.
</theme_item>
<theme_item name="scroll" type="StyleBox">
+ Used as background of this [ScrollBar].
</theme_item>
<theme_item name="scroll_focus" type="StyleBox">
+ Used as background when the [ScrollBar] has the GUI focus.
</theme_item>
</theme_items>
</class>
diff --git a/doc/classes/InputMap.xml b/doc/classes/InputMap.xml
index 6bbb402b15..5b83f943cf 100644
--- a/doc/classes/InputMap.xml
+++ b/doc/classes/InputMap.xml
@@ -60,6 +60,7 @@
<argument index="1" name="deadzone" type="float">
</argument>
<description>
+ Sets a deadzone value for the action.
</description>
</method>
<method name="add_action">
diff --git a/doc/classes/LineEdit.xml b/doc/classes/LineEdit.xml
index 78459d2839..d428c133af 100644
--- a/doc/classes/LineEdit.xml
+++ b/doc/classes/LineEdit.xml
@@ -96,7 +96,7 @@
The cursor's position inside the [LineEdit]. When set, the text may scroll to accommodate it.
</member>
<member name="clear_button_enabled" type="bool" setter="set_clear_button_enabled" getter="is_clear_button_enabled" default="false">
- If [code]true[/code], the [LineEdit] will show a clear button if [code]text[/code] is not empty.
+ If [code]true[/code], the [LineEdit] will show a clear button if [code]text[/code] is not empty, which can be used to clear the text quickly.
</member>
<member name="context_menu_enabled" type="bool" setter="set_context_menu_enabled" getter="is_context_menu_enabled" default="true">
If [code]true[/code], the context menu will appear when right-clicked.
@@ -128,8 +128,10 @@
The character to use to mask secret input (defaults to "*"). Only a single character can be used as the secret character.
</member>
<member name="selecting_enabled" type="bool" setter="set_selecting_enabled" getter="is_selecting_enabled" default="true">
+ If [code]false[/code], it's impossible to select the text using mouse nor keyboard.
</member>
<member name="shortcut_keys_enabled" type="bool" setter="set_shortcut_keys_enabled" getter="is_shortcut_keys_enabled" default="true">
+ If [code]false[/code], using shortcuts will be disabled.
</member>
<member name="text" type="String" setter="set_text" getter="get_text" default="&quot;&quot;">
String value of the [LineEdit].
@@ -143,6 +145,11 @@
Emitted when the text changes.
</description>
</signal>
+ <signal name="text_change_rejected">
+ <description>
+ Emitted when trying to append text that would overflow the [member max_length].
+ </description>
+ </signal>
<signal name="text_entered">
<argument index="0" name="new_text" type="String">
</argument>
@@ -192,30 +199,43 @@
</constants>
<theme_items>
<theme_item name="clear" type="Texture">
+ Texture for the clear button. See [member clear_button_enabled].
</theme_item>
<theme_item name="clear_button_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )">
+ Color used as default tint for the clear button.
</theme_item>
<theme_item name="clear_button_color_pressed" type="Color" default="Color( 1, 1, 1, 1 )">
+ Color used for the clear button when it's pressed.
</theme_item>
<theme_item name="cursor_color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )">
+ Color of the [LineEdit]'s visual cursor (caret).
</theme_item>
<theme_item name="focus" type="StyleBox">
+ Background used when [LineEdit] has GUI focus.
</theme_item>
<theme_item name="font" type="Font">
+ Font used for the text.
</theme_item>
<theme_item name="font_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )">
+ Default font color.
</theme_item>
<theme_item name="font_color_selected" type="Color" default="Color( 0, 0, 0, 1 )">
+ Font color for selected text (inside the selection rectangle).
</theme_item>
<theme_item name="font_color_uneditable" type="Color" default="Color( 0.88, 0.88, 0.88, 0.5 )">
+ Font color when editing is disabled.
</theme_item>
<theme_item name="minimum_spaces" type="int" default="12">
+ Minimum horizontal space for the text (not counting the clear button and content margins).
</theme_item>
<theme_item name="normal" type="StyleBox">
+ Default background for the [LineEdit].
</theme_item>
<theme_item name="read_only" type="StyleBox">
+ Background used when [LineEdit] is in read-only mode ([member editable] is set to [code]false[/code]).
</theme_item>
<theme_item name="selection_color" type="Color" default="Color( 0.49, 0.49, 0.49, 1 )">
+ Color of the selection rectangle.
</theme_item>
</theme_items>
</class>
diff --git a/doc/classes/MainLoop.xml b/doc/classes/MainLoop.xml
index 9457800825..d5ca39e09a 100644
--- a/doc/classes/MainLoop.xml
+++ b/doc/classes/MainLoop.xml
@@ -174,7 +174,7 @@
<argument index="1" name="granted" type="bool">
</argument>
<description>
- Emitted when an user responds to permission request.
+ Emitted when a user responds to a permission request.
</description>
</signal>
</signals>
diff --git a/doc/classes/NinePatchRect.xml b/doc/classes/NinePatchRect.xml
index 221a3c22c1..8935ac9d94 100644
--- a/doc/classes/NinePatchRect.xml
+++ b/doc/classes/NinePatchRect.xml
@@ -61,7 +61,7 @@
<signals>
<signal name="texture_changed">
<description>
- Fired when the node's texture changes.
+ Emitted when the node's texture changes.
</description>
</signal>
</signals>
diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml
index 71d0c1a6fe..2236c42094 100644
--- a/doc/classes/OS.xml
+++ b/doc/classes/OS.xml
@@ -613,9 +613,9 @@
<return type="bool">
</return>
<description>
- Returns [code]true[/code] if the build is a debug build.
- Returns [code]true[/code] when running in the editor.
- Returns [code]false[/code] if the build is a release build.
+ Returns [code]true[/code] if the Godot binary used to run the project is a [i]debug[/i] export template, or when running in the editor.
+ Returns [code]false[/code] if the Godot binary used to run the project is a [i]release[/i] export template.
+ To check whether the Godot binary used to run the project is an export template (debug or release), use [code]OS.has_feature("standalone")[/code] instead.
</description>
</method>
<method name="is_ok_left_and_cancel_right" qualifiers="const">
@@ -937,8 +937,9 @@
<member name="vsync_enabled" type="bool" setter="set_use_vsync" getter="is_vsync_enabled" default="true">
If [code]true[/code], vertical synchronization (Vsync) is enabled.
</member>
- <member name="vsync_via_compositor" type="bool" setter="set_vsync_via_compositor" getter="is_vsync_via_compositor_enabled" default="false">
+ <member name="vsync_via_compositor" type="bool" setter="set_vsync_via_compositor" getter="is_vsync_via_compositor_enabled" default="true">
If [code]true[/code] and [code]vsync_enabled[/code] is true, the operating system's window compositor will be used for vsync when the compositor is enabled and the game is in windowed mode.
+ [b]Note:[/b] This property is only implemented on Windows.
</member>
<member name="window_borderless" type="bool" setter="set_borderless_window" getter="get_borderless_window" default="false">
If [code]true[/code], removes the window frame.
diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml
index 126f11a4ed..1bc43dc964 100644
--- a/doc/classes/ProjectSettings.xml
+++ b/doc/classes/ProjectSettings.xml
@@ -437,7 +437,7 @@
<member name="display/window/vsync/use_vsync" type="bool" setter="" getter="" default="true">
If [code]true[/code], enables vertical synchronization. This eliminates tearing that may appear in moving scenes, at the cost of higher input latency and stuttering at lower framerates. If [code]false[/code], vertical synchronization will be disabled, however, many platforms will enforce it regardless (such as mobile platforms and HTML5).
</member>
- <member name="display/window/vsync/vsync_via_compositor" type="bool" setter="" getter="" default="false">
+ <member name="display/window/vsync/vsync_via_compositor" type="bool" setter="" getter="" default="true">
If [code]Use Vsync[/code] is enabled and this setting is [code]true[/code], enables vertical synchronization via the operating system's window compositor when in windowed mode and the compositor is enabled. This will prevent stutter in certain situations. (Windows only.)
</member>
<member name="editor/script_templates_search_path" type="String" setter="" getter="" default="&quot;res://script_templates&quot;">
diff --git a/doc/classes/ScriptCreateDialog.xml b/doc/classes/ScriptCreateDialog.xml
index 3d0fa9a0d5..2991d76bec 100644
--- a/doc/classes/ScriptCreateDialog.xml
+++ b/doc/classes/ScriptCreateDialog.xml
@@ -24,6 +24,8 @@
</argument>
<argument index="2" name="built_in_enabled" type="bool" default="true">
</argument>
+ <argument index="3" name="load_enabled" type="bool" default="true">
+ </argument>
<description>
Prefills required fields to configure the ScriptCreateDialog for use.
</description>
diff --git a/doc/classes/ScrollBar.xml b/doc/classes/ScrollBar.xml
index ea30b9d48c..e4ace8e8ae 100644
--- a/doc/classes/ScrollBar.xml
+++ b/doc/classes/ScrollBar.xml
@@ -12,6 +12,7 @@
</methods>
<members>
<member name="custom_step" type="float" setter="set_custom_step" getter="get_custom_step" default="-1.0">
+ Overrides the step used when clicking increment and decrement buttons or when using arrow keys when the [ScrollBar] is focused.
</member>
<member name="size_flags_vertical" type="int" setter="set_v_size_flags" getter="get_v_size_flags" override="true" default="0" />
<member name="step" type="float" setter="set_step" getter="get_step" override="true" default="0.0" />
diff --git a/doc/classes/VScrollBar.xml b/doc/classes/VScrollBar.xml
index 6240178b82..add695ef2c 100644
--- a/doc/classes/VScrollBar.xml
+++ b/doc/classes/VScrollBar.xml
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VScrollBar" inherits="ScrollBar" category="Core" version="3.2">
<brief_description>
- Vertical version of [ScrollBar], which goes from top (min) to bottom (max).
+ Vertical scroll bar.
</brief_description>
<description>
+ Vertical version of [ScrollBar], which goes from top (min) to bottom (max).
</description>
<tutorials>
</tutorials>
@@ -17,22 +18,31 @@
</constants>
<theme_items>
<theme_item name="decrement" type="Texture">
+ Icon used as a button to scroll the [ScrollBar] up. Supports custom step using the [member ScrollBar.custom_step] property.
</theme_item>
<theme_item name="decrement_highlight" type="Texture">
+ Displayed when the mouse cursor hovers over the decrement button.
</theme_item>
<theme_item name="grabber" type="StyleBox">
+ Used as texture for the grabber, the draggable element representing current scroll.
</theme_item>
<theme_item name="grabber_highlight" type="StyleBox">
+ Used when the mouse hovers over the grabber.
</theme_item>
<theme_item name="grabber_pressed" type="StyleBox">
+ Used when the grabber is being dragged.
</theme_item>
<theme_item name="increment" type="Texture">
+ Icon used as a button to scroll the [ScrollBar] down. Supports custom step using the [member ScrollBar.custom_step] property.
</theme_item>
<theme_item name="increment_highlight" type="Texture">
+ Displayed when the mouse cursor hovers over the increment button.
</theme_item>
<theme_item name="scroll" type="StyleBox">
+ Used as background of this [ScrollBar].
</theme_item>
<theme_item name="scroll_focus" type="StyleBox">
+ Used as background when the [ScrollBar] has the GUI focus.
</theme_item>
</theme_items>
</class>
diff --git a/doc/classes/VisibilityEnabler.xml b/doc/classes/VisibilityEnabler.xml
index e3c7d05fce..56fa7b77a9 100644
--- a/doc/classes/VisibilityEnabler.xml
+++ b/doc/classes/VisibilityEnabler.xml
@@ -15,6 +15,7 @@
<argument index="0" name="enabler" type="int" enum="VisibilityEnabler.Enabler">
</argument>
<description>
+ Returns whether the enabler identified by given [enum Enabler] constant is active.
</description>
</method>
<method name="set_enabler">
@@ -25,6 +26,7 @@
<argument index="1" name="enabled" type="bool">
</argument>
<description>
+ Sets active state of the enabler identified by given [enum Enabler] constant.
</description>
</method>
</methods>
diff --git a/doc/classes/VisibilityEnabler2D.xml b/doc/classes/VisibilityEnabler2D.xml
index 96f6a42cdf..547793c385 100644
--- a/doc/classes/VisibilityEnabler2D.xml
+++ b/doc/classes/VisibilityEnabler2D.xml
@@ -15,6 +15,7 @@
<argument index="0" name="enabler" type="int" enum="VisibilityEnabler2D.Enabler">
</argument>
<description>
+ Returns whether the enabler identified by given [enum Enabler] constant is active.
</description>
</method>
<method name="set_enabler">
@@ -25,6 +26,7 @@
<argument index="1" name="enabled" type="bool">
</argument>
<description>
+ Sets active state of the enabler identified by given [enum Enabler] constant.
</description>
</method>
</methods>
@@ -65,6 +67,7 @@
This enabler will stop the parent's _physics_process function.
</constant>
<constant name="ENABLER_PAUSE_ANIMATED_SPRITES" value="5" enum="Enabler">
+ This enabler will stop [AnimatedSprite] nodes animations.
</constant>
<constant name="ENABLER_MAX" value="6" enum="Enabler">
Represents the size of the [enum Enabler] enum.
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index cd19ceb868..f6d5312fc7 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -3790,8 +3790,9 @@ void AnimationTrackEditor::insert_value_key(const String &p_property, const Vari
value = p_value; //all good
} else {
String tpath = animation->track_get_path(i);
- if (NodePath(tpath.get_basename()) == np) {
- String subindex = tpath.get_extension();
+ int index = tpath.find_last(":");
+ if (NodePath(tpath.substr(0, index + 1)) == np) {
+ String subindex = tpath.substr(index + 1, tpath.length() - index);
value = p_value.get(subindex);
} else {
continue;
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index e5b4cbdda1..fa713349d4 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -900,7 +900,7 @@ void CodeTextEditor::update_editor_settings() {
text_editor->set_smooth_scroll_enabled(EditorSettings::get_singleton()->get("text_editor/navigation/smooth_scrolling"));
text_editor->set_v_scroll_speed(EditorSettings::get_singleton()->get("text_editor/navigation/v_scroll_speed"));
text_editor->set_draw_minimap(EditorSettings::get_singleton()->get("text_editor/navigation/show_minimap"));
- text_editor->set_minimap_width(EditorSettings::get_singleton()->get("text_editor/navigation/minimap_width"));
+ text_editor->set_minimap_width((int)EditorSettings::get_singleton()->get("text_editor/navigation/minimap_width") * EDSCALE);
text_editor->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/appearance/show_line_numbers"));
text_editor->set_line_numbers_zero_padded(EditorSettings::get_singleton()->get("text_editor/appearance/line_numbers_zero_padded"));
text_editor->set_bookmark_gutter_enabled(EditorSettings::get_singleton()->get("text_editor/appearance/show_bookmark_gutter"));
diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp
index 8ca202a411..0b43fd5ac0 100644
--- a/editor/editor_data.cpp
+++ b/editor/editor_data.cpp
@@ -314,7 +314,7 @@ void EditorData::copy_object_params(Object *p_object) {
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
- if (!(E->get().usage & PROPERTY_USAGE_EDITOR))
+ if (!(E->get().usage & PROPERTY_USAGE_EDITOR) || E->get().name == "script" || E->get().name == "scripts")
continue;
PropertyData pd;
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index f74cadf67e..93e9cc58fb 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -1761,7 +1761,7 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
if (!fpath.ends_with("/")) {
fpath = fpath.get_base_dir();
}
- make_script_dialog->config("Node", fpath.plus_file("new_script.gd"), false);
+ make_script_dialog->config("Node", fpath.plus_file("new_script.gd"), false, false);
make_script_dialog->popup_centered();
} break;
diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp
index c19bee321a..83259afb35 100644
--- a/editor/groups_editor.cpp
+++ b/editor/groups_editor.cpp
@@ -215,7 +215,7 @@ void GroupDialog::_group_renamed() {
return;
}
- String name = renamed_group->get_text(0).strip_edges();
+ const String name = renamed_group->get_text(0).strip_edges();
for (TreeItem *E = groups_root->get_children(); E; E = E->get_next()) {
if (E != renamed_group && E->get_text(0) == name) {
renamed_group->set_text(0, selected_group);
@@ -232,6 +232,8 @@ void GroupDialog::_group_renamed() {
return;
}
+ renamed_group->set_text(0, name); // Spaces trimmed.
+
undo_redo->create_action(TTR("Rename Group"));
List<Node *> nodes;
@@ -254,8 +256,8 @@ void GroupDialog::_group_renamed() {
undo_redo->add_undo_method(this, "_delete_group_item", selected_group);
}
- undo_redo->add_do_method(this, "_rename_group_item", selected_group, renamed_group->get_text(0));
- undo_redo->add_undo_method(this, "_rename_group_item", renamed_group->get_text(0), selected_group);
+ undo_redo->add_do_method(this, "_rename_group_item", selected_group, name);
+ undo_redo->add_undo_method(this, "_rename_group_item", name, selected_group);
undo_redo->add_do_method(this, "_group_selected");
undo_redo->add_undo_method(this, "_group_selected");
undo_redo->add_do_method(this, "emit_signal", "group_edited");
@@ -550,8 +552,8 @@ void GroupsEditor::_add_group(const String &p_group) {
if (!node)
return;
- String name = group_name->get_text();
- if (name.strip_edges() == "")
+ const String name = group_name->get_text().strip_edges();
+ if (name.empty())
return;
if (node->is_in_group(name))
diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp
index f5128103f3..7de6db7add 100644
--- a/editor/import/editor_scene_importer_gltf.cpp
+++ b/editor/import/editor_scene_importer_gltf.cpp
@@ -2329,7 +2329,11 @@ Error EditorSceneImporterGLTF::_parse_animations(GLTFState &state) {
Array samplers = d["samplers"];
if (d.has("name")) {
- animation.name = _sanitize_scene_name(d["name"]);
+ String name = d["name"];
+ if (name.begins_with("loop") || name.ends_with("loop") || name.begins_with("cycle") || name.ends_with("cycle")) {
+ animation.loop = true;
+ }
+ animation.name = _sanitize_scene_name(name);
}
for (int j = 0; j < channels.size(); j++) {
@@ -2735,6 +2739,10 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye
animation.instance();
animation->set_name(name);
+ if (anim.loop) {
+ animation->set_loop(true);
+ }
+
float length = 0;
for (Map<int, GLTFAnimation::Track>::Element *E = anim.tracks.front(); E; E = E->next()) {
diff --git a/editor/import/editor_scene_importer_gltf.h b/editor/import/editor_scene_importer_gltf.h
index 4a91b99aa7..78d7106b0d 100644
--- a/editor/import/editor_scene_importer_gltf.h
+++ b/editor/import/editor_scene_importer_gltf.h
@@ -262,6 +262,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
};
struct GLTFAnimation {
+ bool loop = false;
enum Interpolation {
INTERP_LINEAR,
diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp
index 06bbe17785..b1ed59a2db 100644
--- a/editor/import/resource_importer_obj.cpp
+++ b/editor/import/resource_importer_obj.cpp
@@ -203,7 +203,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati
return OK;
}
-static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p_single_mesh, bool p_generate_tangents, bool p_optimize, Vector3 p_scale_mesh, List<String> *r_missing_deps) {
+static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p_single_mesh, bool p_generate_tangents, bool p_optimize, Vector3 p_scale_mesh, Vector3 p_offset_mesh, List<String> *r_missing_deps) {
FileAccessRef f = FileAccess::open(p_path, FileAccess::READ);
ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, vformat("Couldn't open OBJ file '%s', it may not exist or not be readable.", p_path));
@@ -213,6 +213,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p
bool generate_tangents = p_generate_tangents;
Vector3 scale_mesh = p_scale_mesh;
+ Vector3 offset_mesh = p_offset_mesh;
int mesh_flags = p_optimize ? Mesh::ARRAY_COMPRESS_DEFAULT : 0;
Vector<Vector3> vertices;
@@ -245,9 +246,9 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p
Vector<String> v = l.split(" ", false);
ERR_FAIL_COND_V(v.size() < 4, ERR_FILE_CORRUPT);
Vector3 vtx;
- vtx.x = v[1].to_float() * scale_mesh.x;
- vtx.y = v[2].to_float() * scale_mesh.y;
- vtx.z = v[3].to_float() * scale_mesh.z;
+ vtx.x = v[1].to_float() * scale_mesh.x + offset_mesh.x;
+ vtx.y = v[2].to_float() * scale_mesh.y + offset_mesh.y;
+ vtx.z = v[3].to_float() * scale_mesh.z + offset_mesh.z;
vertices.push_back(vtx);
} else if (l.begins_with("vt ")) {
//uv
@@ -421,7 +422,7 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in
List<Ref<Mesh> > meshes;
- Error err = _parse_obj(p_path, meshes, false, p_flags & IMPORT_GENERATE_TANGENT_ARRAYS, p_flags & IMPORT_USE_COMPRESSION, Vector3(1, 1, 1), r_missing_deps);
+ Error err = _parse_obj(p_path, meshes, false, p_flags & IMPORT_GENERATE_TANGENT_ARRAYS, p_flags & IMPORT_USE_COMPRESSION, Vector3(1, 1, 1), Vector3(0, 0, 0), r_missing_deps);
if (err != OK) {
if (r_err) {
@@ -489,6 +490,7 @@ void ResourceImporterOBJ::get_import_options(List<ImportOption> *r_options, int
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "generate_tangents"), true));
r_options->push_back(ImportOption(PropertyInfo(Variant::VECTOR3, "scale_mesh"), Vector3(1, 1, 1)));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::VECTOR3, "offset_mesh"), Vector3(0, 0, 0)));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "optimize_mesh"), true));
}
bool ResourceImporterOBJ::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
@@ -500,7 +502,7 @@ Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_s
List<Ref<Mesh> > meshes;
- Error err = _parse_obj(p_source_file, meshes, true, p_options["generate_tangents"], p_options["optimize_mesh"], p_options["scale_mesh"], NULL);
+ Error err = _parse_obj(p_source_file, meshes, true, p_options["generate_tangents"], p_options["optimize_mesh"], p_options["scale_mesh"], p_options["offset_mesh"], NULL);
ERR_FAIL_COND_V(err != OK, err);
ERR_FAIL_COND_V(meshes.size() != 1, ERR_BUG);
diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp
index a0b58b8f7e..8dc7e4638d 100644
--- a/editor/plugins/animation_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_tree_editor_plugin.cpp
@@ -39,6 +39,7 @@
#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "core/project_settings.h"
+#include "editor/editor_scale.h"
#include "scene/animation/animation_blend_tree.h"
#include "scene/animation/animation_player.h"
#include "scene/gui/menu_button.h"
@@ -284,7 +285,7 @@ AnimationTreeEditorPlugin::AnimationTreeEditorPlugin(EditorNode *p_node) {
editor = p_node;
anim_tree_editor = memnew(AnimationTreeEditor);
- anim_tree_editor->set_custom_minimum_size(Size2(0, 300));
+ anim_tree_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE);
button = editor->add_bottom_panel_item(TTR("AnimationTree"), anim_tree_editor);
button->hide();
diff --git a/editor/plugins/audio_stream_editor_plugin.cpp b/editor/plugins/audio_stream_editor_plugin.cpp
index b6e5d48a83..60cb2ff54d 100644
--- a/editor/plugins/audio_stream_editor_plugin.cpp
+++ b/editor/plugins/audio_stream_editor_plugin.cpp
@@ -33,6 +33,7 @@
#include "core/io/resource_loader.h"
#include "core/project_settings.h"
#include "editor/audio_stream_preview.h"
+#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
void AudioStreamEditor::_notification(int p_what) {
@@ -208,7 +209,7 @@ void AudioStreamEditor::_bind_methods() {
AudioStreamEditor::AudioStreamEditor() {
- set_custom_minimum_size(Size2(1, 100));
+ set_custom_minimum_size(Size2(1, 100) * EDSCALE);
_current = 0;
_dragging = false;
diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp
index d423be7d24..fb04f50827 100644
--- a/editor/plugins/resource_preloader_editor_plugin.cpp
+++ b/editor/plugins/resource_preloader_editor_plugin.cpp
@@ -32,6 +32,7 @@
#include "core/io/resource_loader.h"
#include "core/project_settings.h"
+#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
void ResourcePreloaderEditor::_gui_input(Ref<InputEvent> p_event) {
@@ -438,7 +439,7 @@ ResourcePreloaderEditorPlugin::ResourcePreloaderEditorPlugin(EditorNode *p_node)
editor = p_node;
preloader_editor = memnew(ResourcePreloaderEditor);
- preloader_editor->set_custom_minimum_size(Size2(0, 250));
+ preloader_editor->set_custom_minimum_size(Size2(0, 250) * EDSCALE);
button = editor->add_bottom_panel_item(TTR("ResourcePreloader"), preloader_editor);
button->hide();
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index d0bd57d658..f13abd47a9 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -1004,7 +1004,7 @@ void ScriptEditor::_menu_option(int p_option) {
ScriptEditorBase *current = _get_current_editor();
switch (p_option) {
case FILE_NEW: {
- script_create_dialog->config("Node", "new_script", false);
+ script_create_dialog->config("Node", "new_script", false, false);
script_create_dialog->popup_centered();
} break;
case FILE_NEW_TEXTFILE: {
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 7e55415134..c0b5053f9d 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -35,6 +35,7 @@
#include "core/os/keyboard.h"
#include "core/os/os.h"
#include "editor/editor_node.h"
+#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/property_editor.h"
#include "servers/visual/shader_types.h"
@@ -756,7 +757,7 @@ ShaderEditorPlugin::ShaderEditorPlugin(EditorNode *p_node) {
editor = p_node;
shader_editor = memnew(ShaderEditor(p_node));
- shader_editor->set_custom_minimum_size(Size2(0, 300));
+ shader_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE);
button = editor->add_bottom_panel_item(TTR("Shader"), shader_editor);
button->hide();
}
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index b64ff6119c..b24d5add9f 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -1303,12 +1303,14 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
Size2 tile_workspace_size = edited_region.position + edited_region.size + WORKSPACE_MARGIN * 2;
Size2 workspace_minsize = workspace->get_custom_minimum_size();
- if (tile_workspace_size.x > workspace_minsize.x && tile_workspace_size.y > workspace_minsize.y) {
- undo_redo->add_do_method(workspace, "set_custom_minimum_size", tile_workspace_size);
+ // If the new region is bigger, just directly change the workspace size to avoid checking all other tiles.
+ if (tile_workspace_size.x > workspace_minsize.x || tile_workspace_size.y > workspace_minsize.y) {
+ Size2 max_workspace_size = Size2(MAX(tile_workspace_size.x, workspace_minsize.x), MAX(tile_workspace_size.y, workspace_minsize.y));
+ undo_redo->add_do_method(workspace, "set_custom_minimum_size", max_workspace_size);
undo_redo->add_undo_method(workspace, "set_custom_minimum_size", workspace_minsize);
- undo_redo->add_do_method(workspace_container, "set_custom_minimum_size", tile_workspace_size);
+ undo_redo->add_do_method(workspace_container, "set_custom_minimum_size", max_workspace_size);
undo_redo->add_undo_method(workspace_container, "set_custom_minimum_size", workspace_minsize);
- undo_redo->add_do_method(workspace_overlay, "set_custom_minimum_size", tile_workspace_size);
+ undo_redo->add_do_method(workspace_overlay, "set_custom_minimum_size", max_workspace_size);
undo_redo->add_undo_method(workspace_overlay, "set_custom_minimum_size", workspace_minsize);
} else if (workspace_minsize.x > get_current_texture()->get_size().x + WORKSPACE_MARGIN.x * 2 || workspace_minsize.y > get_current_texture()->get_size().y + WORKSPACE_MARGIN.y * 2) {
undo_redo->add_do_method(this, "update_workspace_minsize");
@@ -1803,8 +1805,6 @@ void TileSetEditor::_on_tool_clicked(int p_tool) {
Ref<ConvexPolygonShape2D> _convex = memnew(ConvexPolygonShape2D);
edited_collision_shape = _convex;
_set_edited_shape_points(_get_collision_shape_points(concave));
- } else {
- // Shouldn't happen
}
for (int i = 0; i < sd.size(); i++) {
if (sd[i].get("shape") == previous_shape) {
@@ -3267,12 +3267,16 @@ void TileSetEditor::update_workspace_minsize() {
List<int> *tiles = new List<int>();
tileset->get_tile_list(tiles);
for (List<int>::Element *E = tiles->front(); E; E = E->next()) {
- if (tileset->tile_get_texture(E->get())->get_rid() == current_texture_rid) {
- Rect2i region = tileset->tile_get_region(E->get());
- if (region.position.x + region.size.x > workspace_min_size.x)
- workspace_min_size.x = region.position.x + region.size.x;
- if (region.position.y + region.size.y > workspace_min_size.y)
- workspace_min_size.y = region.position.y + region.size.y;
+ if (tileset->tile_get_texture(E->get())->get_rid() != current_texture_rid) {
+ continue;
+ }
+
+ Rect2i region = tileset->tile_get_region(E->get());
+ if (region.position.x + region.size.x > workspace_min_size.x) {
+ workspace_min_size.x = region.position.x + region.size.x;
+ }
+ if (region.position.y + region.size.y > workspace_min_size.y) {
+ workspace_min_size.y = region.position.y + region.size.y;
}
}
delete tiles;
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 972e4f2172..e334d4b093 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -2852,7 +2852,7 @@ VisualShaderEditorPlugin::VisualShaderEditorPlugin(EditorNode *p_node) {
editor = p_node;
visual_shader_editor = memnew(VisualShaderEditor);
- visual_shader_editor->set_custom_minimum_size(Size2(0, 300));
+ visual_shader_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE);
button = editor->add_bottom_panel_item(TTR("VisualShader"), visual_shader_editor);
button->hide();
diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp
index 25bc13033c..35d5fe5f70 100644
--- a/editor/script_create_dialog.cpp
+++ b/editor/script_create_dialog.cpp
@@ -99,7 +99,7 @@ bool ScriptCreateDialog::_can_be_built_in() {
return (supports_built_in && built_in_enabled);
}
-void ScriptCreateDialog::config(const String &p_base_name, const String &p_base_path, bool p_built_in_enabled) {
+void ScriptCreateDialog::config(const String &p_base_name, const String &p_base_path, bool p_built_in_enabled, bool p_load_enabled) {
class_name->set_text("");
class_name->deselect();
@@ -117,6 +117,7 @@ void ScriptCreateDialog::config(const String &p_base_name, const String &p_base_
file_path->deselect();
built_in_enabled = p_built_in_enabled;
+ load_enabled = p_load_enabled;
_lang_changed(current_language);
_class_name_changed("");
@@ -623,12 +624,12 @@ void ScriptCreateDialog::_msg_path_valid(bool valid, const String &p_msg) {
void ScriptCreateDialog::_update_dialog() {
+ /* "Add Script Dialog" GUI logic and script checks. */
+
bool script_ok = true;
- /* "Add Script Dialog" gui logic and script checks */
+ // Is script path/name valid (order from top to bottom)?
- // Is Script Valid (order from top to bottom)
- get_ok()->set_disabled(true);
if (!is_built_in && !is_path_valid) {
_msg_script_valid(false, TTR("Invalid path."));
script_ok = false;
@@ -641,12 +642,12 @@ void ScriptCreateDialog::_update_dialog() {
_msg_script_valid(false, TTR("Invalid inherited parent name or path."));
script_ok = false;
}
+
if (script_ok) {
_msg_script_valid(true, TTR("Script is valid."));
- get_ok()->set_disabled(false);
}
- /* Does script have named classes */
+ // Does script have named classes?
if (has_named_classes) {
if (is_new_script_created) {
@@ -663,7 +664,7 @@ void ScriptCreateDialog::_update_dialog() {
class_name->set_text("");
}
- /* Is script Built-in */
+ // Is script Built-in?
if (is_built_in) {
file_path->set_editable(false);
@@ -683,7 +684,7 @@ void ScriptCreateDialog::_update_dialog() {
}
internal->set_disabled(!_can_be_built_in());
- /* Is Script created or loaded from existing file */
+ // Is Script created or loaded from existing file?
if (is_built_in) {
get_ok()->set_text(TTR("Create"));
@@ -692,7 +693,8 @@ void ScriptCreateDialog::_update_dialog() {
parent_browse_button->set_disabled(!can_inherit_from_file);
_msg_path_valid(true, TTR("Built-in script (into scene file)."));
} else if (is_new_script_created) {
- // New Script Created
+ // New script created.
+
get_ok()->set_text(TTR("Create"));
parent_name->set_editable(true);
parent_search_button->set_disabled(false);
@@ -700,8 +702,9 @@ void ScriptCreateDialog::_update_dialog() {
if (is_path_valid) {
_msg_path_valid(true, TTR("Will create a new script file."));
}
- } else {
- // Script Loaded
+ } else if (load_enabled) {
+ // Script loaded.
+
get_ok()->set_text(TTR("Load"));
parent_name->set_editable(false);
parent_search_button->set_disabled(true);
@@ -709,7 +712,17 @@ void ScriptCreateDialog::_update_dialog() {
if (is_path_valid) {
_msg_path_valid(true, TTR("Will load an existing script file."));
}
+ } else {
+ get_ok()->set_text(TTR("Create"));
+ parent_name->set_editable(true);
+ parent_search_button->set_disabled(false);
+ parent_browse_button->set_disabled(!can_inherit_from_file);
+ _msg_path_valid(false, TTR("Script file already exists."));
+
+ script_ok = false;
}
+
+ get_ok()->set_disabled(!script_ok);
}
void ScriptCreateDialog::_bind_methods() {
@@ -727,7 +740,7 @@ void ScriptCreateDialog::_bind_methods() {
ClassDB::bind_method("_create", &ScriptCreateDialog::_create);
ClassDB::bind_method("_browse_class_in_tree", &ScriptCreateDialog::_browse_class_in_tree);
- ClassDB::bind_method(D_METHOD("config", "inherits", "path", "built_in_enabled"), &ScriptCreateDialog::config, DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("config", "inherits", "path", "built_in_enabled", "load_enabled"), &ScriptCreateDialog::config, DEFVAL(true), DEFVAL(true));
ADD_SIGNAL(MethodInfo("script_created", PropertyInfo(Variant::OBJECT, "script", PROPERTY_HINT_RESOURCE_TYPE, "Script")));
}
@@ -884,8 +897,9 @@ ScriptCreateDialog::ScriptCreateDialog() {
has_named_classes = false;
supports_built_in = false;
can_inherit_from_file = false;
- built_in_enabled = true;
is_built_in = false;
+ built_in_enabled = true;
+ load_enabled = true;
is_new_script_created = true;
}
diff --git a/editor/script_create_dialog.h b/editor/script_create_dialog.h
index 91d6315a78..00f642fcf7 100644
--- a/editor/script_create_dialog.h
+++ b/editor/script_create_dialog.h
@@ -74,6 +74,7 @@ class ScriptCreateDialog : public ConfirmationDialog {
bool is_class_name_valid;
bool is_built_in;
bool built_in_enabled;
+ bool load_enabled;
int current_language;
int default_language;
bool re_check_path;
@@ -126,7 +127,7 @@ protected:
static void _bind_methods();
public:
- void config(const String &p_base_name, const String &p_base_path, bool p_built_in_enabled = true);
+ void config(const String &p_base_name, const String &p_base_path, bool p_built_in_enabled = true, bool p_load_enabled = true);
void set_inheritance_base_type(const String &p_base);
ScriptCreateDialog();
};
diff --git a/main/main.cpp b/main/main.cpp
index c29a5a0aa6..5cfab3dc4a 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -815,6 +815,13 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
I = N;
}
+#ifdef TOOLS_ENABLED
+ if (editor && project_manager) {
+ OS::get_singleton()->print("Error: Command line arguments implied opening both editor and project manager, which is not possible. Aborting.\n");
+ goto error;
+ }
+#endif
+
// Network file system needs to be configured before globals, since globals are based on the
// 'project.godot' file which will only be available through the network if this is enabled
FileAccessNetwork::configure();
@@ -930,7 +937,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
}
}
- if (!project_manager) {
+ if (!project_manager && !editor) {
// Determine if the project manager should be requested
project_manager = main_args.size() == 0 && !found_project;
}
@@ -1028,7 +1035,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
// window compositor ("--enable-vsync-via-compositor" or
// "--disable-vsync-via-compositor") was present then it overrides the
// project setting.
- video_mode.vsync_via_compositor = GLOBAL_DEF("display/window/vsync/vsync_via_compositor", false);
+ video_mode.vsync_via_compositor = GLOBAL_DEF("display/window/vsync/vsync_via_compositor", true);
}
OS::get_singleton()->_vsync_via_compositor = video_mode.vsync_via_compositor;
@@ -1395,6 +1402,7 @@ bool Main::start() {
bool hasicon = false;
String doc_tool;
List<String> removal_docs;
+ String positional_arg;
String game_path;
String script;
String test;
@@ -1422,8 +1430,18 @@ bool Main::start() {
} else if (args[i] == "-p" || args[i] == "--project-manager") {
project_manager = true;
#endif
- } else if (args[i].length() && args[i][0] != '-' && game_path == "") {
- game_path = args[i];
+ } else if (args[i].length() && args[i][0] != '-' && positional_arg == "") {
+ positional_arg = args[i];
+
+ if (args[i].ends_with(".scn") || args[i].ends_with(".tscn") || args[i].ends_with(".escn")) {
+ // Only consider the positional argument to be a scene path if it ends with
+ // a file extension associated with Godot scenes. This makes it possible
+ // for projects to parse command-line arguments for custom CLI arguments
+ // or other file extensions without trouble. This can be used to implement
+ // "drag-and-drop onto executable" logic, which can prove helpful
+ // for non-game applications.
+ game_path = args[i];
+ }
}
//parameters that have an argument to the right
else if (i < (args.size() - 1)) {
@@ -1518,7 +1536,7 @@ bool Main::start() {
}
if (_export_preset != "") {
- if (game_path == "") {
+ if (positional_arg == "") {
String err = "Command line includes export parameter option, but no destination path was given.\n";
err += "Please specify the binary's file path to export to. Aborting export.";
ERR_PRINT(err);
@@ -1709,7 +1727,7 @@ bool Main::start() {
sml->get_root()->add_child(editor_node);
if (_export_preset != "") {
- editor_node->export_preset(_export_preset, game_path, export_debug, export_pack_only);
+ editor_node->export_preset(_export_preset, positional_arg, export_debug, export_pack_only);
game_path = ""; // Do not load anything.
}
}
diff --git a/misc/dist/shell/_godot.zsh-completion b/misc/dist/shell/_godot.zsh-completion
new file mode 100644
index 0000000000..4945ecbabc
--- /dev/null
+++ b/misc/dist/shell/_godot.zsh-completion
@@ -0,0 +1,77 @@
+#compdef godot
+
+# zsh completion for the Godot editor
+# To use it, install this file as `_godot` in a directory specified in your
+# `fpath` environment variable then restart your shell.
+#
+# Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur.
+# Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md).
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in all
+# copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+_arguments \
+ "1::path to scene or 'project.godot' file:_files" \
+ '(-h --help)'{-h,--help}'[display the full help message]' \
+ '--version[display the version string]' \
+ '(-v --verbose)'{-v,--verbose}'[use verbose stdout mode]' \
+ '--quiet[quiet mode, silences stdout messages (errors are still displayed)]' \
+ '(-e --editor)'{-e,--editor}'[start the editor instead of running the scene]' \
+ '(-p --project-manager)'{-p,--project-manager}'[start the project manager, even if a project is auto-detected]' \
+ '(-q --quit)'{-q,--quit}'[quit after the first iteration]' \
+ '(-l --language)'{-l,--language}'[use a specific locale (<locale> being a two-letter code)]:two-letter locale code' \
+ "--path[path to a project (<directory> must contain a 'project.godot' file)]:path to directory with 'project.godot' file:_dirs" \
+ '(-u --upwards)'{-u,--upwards}'[scan folders upwards for project.godot file]' \
+ '--main-pack[path to a pack (.pck) file to load]:path to .pck file:_files' \
+ '--render-thread[set the render thread mode]:render thread mode:(unsafe safe separate)' \
+ '--remote-fs[use a remote filesystem]:remote filesystem address' \
+ '--remote-fs-password[password for remote filesystem]:remote filesystem password' \
+ '--audio-driver[set the audio driver]:audio driver name' \
+ "--video-driver[set the video driver]:video driver name:((GLES3\:'OpenGL ES 3.0 renderer' GLES2\:'OpenGL ES 2.0 renderer'))" \
+ '(-f --fullscreen)'{-f,--fullscreen}'[request fullscreen mode]' \
+ '(-m --maximized)'{-m,--maximized}'[request a maximized window]' \
+ '(-w --windowed)'{-w,--windowed}'[request windowed mode]' \
+ '(-t --always-on-top)'{-t,--always-on-top}'[request an always-on-top window]' \
+ '--resolution[request window resolution]:resolution in WxH format' \
+ '--position[request window position]:position in X,Y format' \
+ '--low-dpi[force low-DPI mode (macOS and Windows only)]' \
+ '--no-window[disable window creation (Windows only), useful together with --script]' \
+ "--enable-vsync-via-compositor[when Vsync is enabled, Vsync via the OS' window compositor (Windows only)]" \
+ "--disable-vsync-via-compositor[disable Vsync via the OS' window compositor (Windows only)]" \
+ '(-d --debug)'{-d,--debug}'[debug (local stdout debugger)]' \
+ '(-b --breakpoints)'{-b,--breakpoints}'[specify the breakpoint list as source::line comma-separated pairs, no spaces (use %20 instead)]:breakpoint list' \
+ '--profiling[enable profiling in the script debugger]' \
+ '--remote-debug[enable remote debugging]:remote debugger address' \
+ '--debug-collisions[show collision shapes when running the scene]' \
+ '--debug-navigation[show navigation polygons when running the scene]' \
+ '--frame-delay[simulate high CPU load (delay each frame by the given number of milliseconds)]:number of milliseconds' \
+ '--time-scale[force time scale (higher values are faster, 1.0 is normal speed)]:time scale' \
+ '--disable-render-loop[disable render loop so rendering only occurs when called explicitly from script]' \
+ '--disable-crash-handler[disable crash handler when supported by the platform code]' \
+ '--fixed-fps[force a fixed number of frames per second (this setting disables real-time synchronization)]:frames per second' \
+ '--print-fps[print the frames per second to the stdout]' \
+ '(-s, --script)'{-s,--script}'[run a script]:path to script:_files' \
+ '--check-only[only parse for errors and quit (use with --script)]' \
+ '--export[export the project using the given preset and matching release template]:export preset name' \
+ '--export-debug[same as --export, but using the debug template]:export preset name' \
+ '--export-pack[same as --export, but only export the game pack for the given preset]:export preset name' \
+ '--doctool[dump the engine API reference to the given path in XML format, merging if existing files are found]:path to base Godot build directory:_dirs' \
+ '--no-docbase[disallow dumping the base types (used with --doctool)]' \
+ '--build-solutions[build the scripting solutions (e.g. for C# projects)]' \
+ '--gdnative-generate-json-api[generate JSON dump of the Godot API for GDNative bindings]' \
+ '--test[run a unit test]:unit test name'
diff --git a/modules/assimp/editor_scene_importer_assimp.cpp b/modules/assimp/editor_scene_importer_assimp.cpp
index 1bc84ce3a0..726f4c1ed0 100644
--- a/modules/assimp/editor_scene_importer_assimp.cpp
+++ b/modules/assimp/editor_scene_importer_assimp.cpp
@@ -732,6 +732,10 @@ void EditorSceneImporterAssimp::_import_animation(ImportState &state, int p_anim
animation->set_name(name);
animation->set_length(anim->mDuration / ticks_per_second);
+ if (name.begins_with("loop") || name.ends_with("loop") || name.begins_with("cycle") || name.ends_with("cycle")) {
+ animation->set_loop(true);
+ }
+
// generate bone stack for animation import
RegenerateBoneStack(state);
diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp
index e5b2ac3808..0f50d31611 100644
--- a/modules/bullet/space_bullet.cpp
+++ b/modules/bullet/space_bullet.cpp
@@ -945,7 +945,7 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f
btVector3 motion;
G_TO_B(p_motion, motion);
- if (!motion.fuzzyZero()) {
+ {
// Phase two - sweep test, from a secure position without margin
const int shape_count(p_body->get_shape_count());
@@ -960,7 +960,7 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f
motionVec->end();
#endif
- for (int shIndex = 0; shIndex < shape_count; ++shIndex) {
+ for (int shIndex = 0; shIndex < shape_count && !motion.fuzzyZero(); ++shIndex) {
if (p_body->is_shape_disabled(shIndex)) {
continue;
}
diff --git a/modules/gdnative/gdnative/gdnative.cpp b/modules/gdnative/gdnative/gdnative.cpp
index 6ef1f2f4b9..06334556d9 100644
--- a/modules/gdnative/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative/gdnative.cpp
@@ -170,6 +170,10 @@ bool GDAPI godot_is_instance_valid(const godot_object *p_object) {
return ObjectDB::instance_validate((Object *)p_object);
}
+godot_object GDAPI *godot_instance_from_id(godot_int p_instance_id) {
+ return (godot_object *)ObjectDB::get_instance((ObjectID)p_instance_id);
+}
+
void *godot_get_class_tag(const godot_string_name *p_class) {
StringName class_name = *(StringName *)p_class;
ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(class_name);
diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json
index 7e2ca49f8d..8ccb8d2286 100644
--- a/modules/gdnative/gdnative_api.json
+++ b/modules/gdnative/gdnative_api.json
@@ -155,6 +155,13 @@
["const godot_object *", "p_object"],
["void *", "p_class_tag"]
]
+ },
+ {
+ "name": "godot_instance_from_id",
+ "return_type": "godot_object *",
+ "arguments": [
+ ["godot_int", "p_instance_id"]
+ ]
}
]
},
diff --git a/modules/gdnative/include/gdnative/gdnative.h b/modules/gdnative/include/gdnative/gdnative.h
index 2fe59b8a73..e19a2ec149 100644
--- a/modules/gdnative/include/gdnative/gdnative.h
+++ b/modules/gdnative/include/gdnative/gdnative.h
@@ -290,6 +290,9 @@ bool GDAPI godot_is_instance_valid(const godot_object *p_object);
void GDAPI *godot_get_class_tag(const godot_string_name *p_class);
godot_object GDAPI *godot_object_cast_to(const godot_object *p_object, void *p_class_tag);
+// equivalent of GDScript's instance_from_id
+godot_object GDAPI *godot_instance_from_id(godot_int p_instance_id);
+
#ifdef __cplusplus
}
#endif
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp
index 11e015b473..7b3175d9cd 100644
--- a/modules/gdscript/gdscript_compiler.cpp
+++ b/modules/gdscript/gdscript_compiler.cpp
@@ -90,11 +90,11 @@ bool GDScriptCompiler::_create_unary_operator(CodeGen &codegen, const GDScriptPa
return true;
}
-bool GDScriptCompiler::_create_binary_operator(CodeGen &codegen, const GDScriptParser::OperatorNode *on, Variant::Operator op, int p_stack_level, bool p_initializer) {
+bool GDScriptCompiler::_create_binary_operator(CodeGen &codegen, const GDScriptParser::OperatorNode *on, Variant::Operator op, int p_stack_level, bool p_initializer, int p_index_addr) {
ERR_FAIL_COND_V(on->arguments.size() != 2, false);
- int src_address_a = _parse_expression(codegen, on->arguments[0], p_stack_level, false, p_initializer);
+ int src_address_a = _parse_expression(codegen, on->arguments[0], p_stack_level, false, p_initializer, p_index_addr);
if (src_address_a < 0)
return false;
if (src_address_a & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS)
@@ -171,7 +171,7 @@ GDScriptDataType GDScriptCompiler::_gdtype_from_datatype(const GDScriptParser::D
return result;
}
-int GDScriptCompiler::_parse_assign_right_expression(CodeGen &codegen, const GDScriptParser::OperatorNode *p_expression, int p_stack_level) {
+int GDScriptCompiler::_parse_assign_right_expression(CodeGen &codegen, const GDScriptParser::OperatorNode *p_expression, int p_stack_level, int p_index_addr) {
Variant::Operator var_op = Variant::OP_MAX;
@@ -205,7 +205,7 @@ int GDScriptCompiler::_parse_assign_right_expression(CodeGen &codegen, const GDS
return _parse_expression(codegen, p_expression->arguments[1], p_stack_level, false, initializer);
}
- if (!_create_binary_operator(codegen, p_expression, var_op, p_stack_level, initializer))
+ if (!_create_binary_operator(codegen, p_expression, var_op, p_stack_level, initializer, p_index_addr))
return -1;
int dst_addr = (p_stack_level) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
@@ -214,7 +214,7 @@ int GDScriptCompiler::_parse_assign_right_expression(CodeGen &codegen, const GDS
return dst_addr;
}
-int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::Node *p_expression, int p_stack_level, bool p_root, bool p_initializer) {
+int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::Node *p_expression, int p_stack_level, bool p_root, bool p_initializer, int p_index_addr) {
switch (p_expression->type) {
//should parse variable declaration and adjust stack accordingly...
@@ -704,7 +704,9 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
return from;
int index;
- if (named) {
+ if (p_index_addr != 0) {
+ index = p_index_addr;
+ } else if (named) {
if (on->arguments[0]->type == GDScriptParser::Node::TYPE_SELF && codegen.script && codegen.function_node && !codegen.function_node->_static) {
GDScriptParser::IdentifierNode *identifier = static_cast<GDScriptParser::IdentifierNode *>(on->arguments[1]);
@@ -1091,7 +1093,7 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
codegen.alloc_stack(slevel);
}
- int set_value = _parse_assign_right_expression(codegen, on, slevel + 1);
+ int set_value = _parse_assign_right_expression(codegen, on, slevel + 1, named ? 0 : set_index);
if (set_value < 0) //error
return set_value;
diff --git a/modules/gdscript/gdscript_compiler.h b/modules/gdscript/gdscript_compiler.h
index bb3ee881f8..7d5234a023 100644
--- a/modules/gdscript/gdscript_compiler.h
+++ b/modules/gdscript/gdscript_compiler.h
@@ -140,12 +140,12 @@ class GDScriptCompiler {
void _set_error(const String &p_error, const GDScriptParser::Node *p_node);
bool _create_unary_operator(CodeGen &codegen, const GDScriptParser::OperatorNode *on, Variant::Operator op, int p_stack_level);
- bool _create_binary_operator(CodeGen &codegen, const GDScriptParser::OperatorNode *on, Variant::Operator op, int p_stack_level, bool p_initializer = false);
+ bool _create_binary_operator(CodeGen &codegen, const GDScriptParser::OperatorNode *on, Variant::Operator op, int p_stack_level, bool p_initializer = false, int p_index_addr = 0);
GDScriptDataType _gdtype_from_datatype(const GDScriptParser::DataType &p_datatype) const;
- int _parse_assign_right_expression(CodeGen &codegen, const GDScriptParser::OperatorNode *p_expression, int p_stack_level);
- int _parse_expression(CodeGen &codegen, const GDScriptParser::Node *p_expression, int p_stack_level, bool p_root = false, bool p_initializer = false);
+ int _parse_assign_right_expression(CodeGen &codegen, const GDScriptParser::OperatorNode *p_expression, int p_stack_level, int p_index_addr = 0);
+ int _parse_expression(CodeGen &codegen, const GDScriptParser::Node *p_expression, int p_stack_level, bool p_root = false, bool p_initializer = false, int p_index_addr = 0);
Error _parse_block(CodeGen &codegen, const GDScriptParser::BlockNode *p_block, int p_stack_level = 0, int p_break_addr = -1, int p_continue_addr = -1);
Error _parse_function(GDScript *p_script, const GDScriptParser::ClassNode *p_class, const GDScriptParser::FunctionNode *p_func, bool p_for_ready = false);
Error _parse_class_level(GDScript *p_script, const GDScriptParser::ClassNode *p_class, bool p_keep_state);
diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp
index a01a7397fe..eef39da8b5 100644
--- a/modules/gdscript/gdscript_function.cpp
+++ b/modules/gdscript/gdscript_function.cpp
@@ -500,6 +500,13 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
Object *obj_A = *a;
Object *obj_B = *b;
+#ifdef DEBUG_ENABLED
+ if (!ObjectDB::instance_validate(obj_A)) {
+ err_text = "Left operand of 'is' was already freed.";
+ OPCODE_BREAK;
+ }
+#endif // DEBUG_ENABLED
+
GDScript *scr_B = Object::cast_to<GDScript>(obj_B);
if (scr_B) {
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index a33d20e433..dcf5d35e36 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -7648,6 +7648,11 @@ GDScriptParser::DataType GDScriptParser::_reduce_identifier_type(const DataType
void GDScriptParser::_check_class_level_types(ClassNode *p_class) {
+ // Names of internal object properties that we check to avoid overriding them.
+ // "__meta__" could also be in here, but since it doesn't really affect object metadata,
+ // it is okay to override it on script.
+ StringName script_name = CoreStringNames::get_singleton()->_script;
+
_mark_line_as_safe(p_class->line);
// Constants
@@ -7668,8 +7673,9 @@ void GDScriptParser::_check_class_level_types(ClassNode *p_class) {
c.expression->set_datatype(expr);
DataType tmp;
- if (_get_member_type(p_class->base_type, E->key(), tmp)) {
- _set_error("The member \"" + String(E->key()) + "\" already exists in a parent class.", c.expression->line);
+ const StringName &constant_name = E->key();
+ if (constant_name == script_name || _get_member_type(p_class->base_type, constant_name, tmp)) {
+ _set_error("The member \"" + String(constant_name) + "\" already exists in a parent class.", c.expression->line);
return;
}
}
@@ -7690,7 +7696,7 @@ void GDScriptParser::_check_class_level_types(ClassNode *p_class) {
ClassNode::Member &v = p_class->variables.write[i];
DataType tmp;
- if (_get_member_type(p_class->base_type, v.identifier, tmp)) {
+ if (v.identifier == script_name || _get_member_type(p_class->base_type, v.identifier, tmp)) {
_set_error("The member \"" + String(v.identifier) + "\" already exists in a parent class.", v.line);
return;
}
@@ -7867,12 +7873,12 @@ void GDScriptParser::_check_function_types(FunctionNode *p_function) {
def_type.is_constant = false;
p_function->argument_types.write[i] = def_type;
} else {
- p_function->return_type = _resolve_type(p_function->return_type, p_function->line);
+ p_function->argument_types.write[i] = _resolve_type(p_function->argument_types[i], p_function->line);
if (!_is_type_compatible(p_function->argument_types[i], def_type, true)) {
String arg_name = p_function->arguments[i];
_set_error("Value type (" + def_type.to_string() + ") doesn't match the type of argument '" +
- arg_name + "' (" + p_function->arguments[i] + ").",
+ arg_name + "' (" + p_function->argument_types[i].to_string() + ").",
p_function->line);
}
}
diff --git a/modules/gdscript/language_server/gdscript_language_server.cpp b/modules/gdscript/language_server/gdscript_language_server.cpp
index 9675c07c00..19bb3ed1ee 100644
--- a/modules/gdscript/language_server/gdscript_language_server.cpp
+++ b/modules/gdscript/language_server/gdscript_language_server.cpp
@@ -36,10 +36,15 @@
GDScriptLanguageServer::GDScriptLanguageServer() {
thread = NULL;
- thread_exit = false;
- _EDITOR_DEF("network/language_server/remote_port", 6008);
+ thread_running = false;
+ started = false;
+
+ use_thread = false;
+ port = 6008;
+ _EDITOR_DEF("network/language_server/remote_port", port);
_EDITOR_DEF("network/language_server/enable_smart_resolve", true);
_EDITOR_DEF("network/language_server/show_native_symbols_in_editor", false);
+ _EDITOR_DEF("network/language_server/use_thread", use_thread);
}
void GDScriptLanguageServer::_notification(int p_what) {
@@ -51,12 +56,25 @@ void GDScriptLanguageServer::_notification(int p_what) {
case NOTIFICATION_EXIT_TREE:
stop();
break;
+ case NOTIFICATION_INTERNAL_PROCESS: {
+ if (started && !use_thread) {
+ protocol.poll();
+ }
+ } break;
+ case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
+ int port = (int)_EDITOR_GET("network/language_server/remote_port");
+ bool use_thread = (bool)_EDITOR_GET("network/language_server/use_thread");
+ if (port != this->port || use_thread != this->use_thread) {
+ this->stop();
+ this->start();
+ }
+ } break;
}
}
void GDScriptLanguageServer::thread_main(void *p_userdata) {
GDScriptLanguageServer *self = static_cast<GDScriptLanguageServer *>(p_userdata);
- while (!self->thread_exit) {
+ while (self->thread_running) {
// Poll 20 times per second
self->protocol.poll();
OS::get_singleton()->delay_usec(50000);
@@ -64,22 +82,30 @@ void GDScriptLanguageServer::thread_main(void *p_userdata) {
}
void GDScriptLanguageServer::start() {
- int port = (int)_EDITOR_GET("network/language_server/remote_port");
+ port = (int)_EDITOR_GET("network/language_server/remote_port");
+ use_thread = (bool)_EDITOR_GET("network/language_server/use_thread");
if (protocol.start(port) == OK) {
EditorNode::get_log()->add_message("--- GDScript language server started ---", EditorLog::MSG_TYPE_EDITOR);
- ERR_FAIL_COND(thread != NULL || thread_exit);
- thread_exit = false;
- thread = Thread::create(GDScriptLanguageServer::thread_main, this);
+ if (use_thread) {
+ ERR_FAIL_COND(thread != NULL);
+ thread_running = true;
+ thread = Thread::create(GDScriptLanguageServer::thread_main, this);
+ }
+ set_process_internal(!use_thread);
+ started = true;
}
}
void GDScriptLanguageServer::stop() {
- ERR_FAIL_COND(NULL == thread || thread_exit);
- thread_exit = true;
- Thread::wait_to_finish(thread);
- memdelete(thread);
- thread = NULL;
+ if (use_thread) {
+ ERR_FAIL_COND(NULL == thread);
+ thread_running = false;
+ Thread::wait_to_finish(thread);
+ memdelete(thread);
+ thread = NULL;
+ }
protocol.stop();
+ started = false;
EditorNode::get_log()->add_message("--- GDScript language server stopped ---", EditorLog::MSG_TYPE_EDITOR);
}
diff --git a/modules/gdscript/language_server/gdscript_language_server.h b/modules/gdscript/language_server/gdscript_language_server.h
index 191b8bfa85..228d29bf42 100644
--- a/modules/gdscript/language_server/gdscript_language_server.h
+++ b/modules/gdscript/language_server/gdscript_language_server.h
@@ -41,7 +41,10 @@ class GDScriptLanguageServer : public EditorPlugin {
GDScriptLanguageProtocol protocol;
Thread *thread;
- bool thread_exit;
+ bool thread_running;
+ bool started;
+ bool use_thread;
+ int port;
static void thread_main(void *p_userdata);
private:
diff --git a/modules/gdscript/language_server/gdscript_text_document.cpp b/modules/gdscript/language_server/gdscript_text_document.cpp
index 33ca4a5d15..0572c5f746 100644
--- a/modules/gdscript/language_server/gdscript_text_document.cpp
+++ b/modules/gdscript/language_server/gdscript_text_document.cpp
@@ -269,7 +269,7 @@ Dictionary GDScriptTextDocument::resolve(const Dictionary &p_params) {
if ((item.kind == lsp::CompletionItemKind::Method || item.kind == lsp::CompletionItemKind::Function) && !item.label.ends_with("):")) {
item.insertText = item.label + "(";
- if (symbol && symbol->detail.find(",") == -1) {
+ if (symbol && symbol->children.empty()) {
item.insertText += ")";
}
} else if (item.kind == lsp::CompletionItemKind::Event) {
diff --git a/modules/gdscript/language_server/lsp.hpp b/modules/gdscript/language_server/lsp.hpp
index 379024844e..a2dcc48820 100644
--- a/modules/gdscript/language_server/lsp.hpp
+++ b/modules/gdscript/language_server/lsp.hpp
@@ -330,8 +330,6 @@ struct CompletionOptions {
triggerCharacters.push_back("$");
triggerCharacters.push_back("'");
triggerCharacters.push_back("\"");
- triggerCharacters.push_back("(");
- triggerCharacters.push_back(",");
}
Dictionary to_json() const {
diff --git a/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml b/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml
index 9403199398..102a9b4236 100644
--- a/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml
+++ b/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml
@@ -15,8 +15,10 @@
Contains the audio data in bytes.
</member>
<member name="loop" type="bool" setter="set_loop" getter="has_loop" default="false">
+ If [code]true[/code], the stream will automatically loop when it reaches the end.
</member>
<member name="loop_offset" type="float" setter="set_loop_offset" getter="get_loop_offset" default="0.0">
+ Time in seconds at which the stream starts after being looped.
</member>
</members>
<constants>
diff --git a/platform/android/dir_access_jandroid.cpp b/platform/android/dir_access_jandroid.cpp
index 69178317f7..f52b511522 100644
--- a/platform/android/dir_access_jandroid.cpp
+++ b/platform/android/dir_access_jandroid.cpp
@@ -110,7 +110,6 @@ String DirAccessJAndroid::get_drive(int p_drive) {
Error DirAccessJAndroid::change_dir(String p_dir) {
JNIEnv *env = ThreadAndroid::get_env();
- p_dir = p_dir.simplify_path();
if (p_dir == "" || p_dir == "." || (p_dir == ".." && current_dir == ""))
return OK;
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index d7a72779e6..8f784dd943 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -680,7 +680,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
bool screen_support_large = p_preset->get("screen/support_large");
bool screen_support_xlarge = p_preset->get("screen/support_xlarge");
- int xr_mode_index = p_preset->get("graphics/xr_mode");
+ int xr_mode_index = p_preset->get("xr_features/xr_mode");
Vector<String> perms;
@@ -859,135 +859,174 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
uint32_t name = decode_uint32(&p_manifest[iofs + 12]);
String tname = string_table[name];
- int dof_index = p_preset->get("graphics/degrees_of_freedom"); // 0: none, 1: 3dof and 6dof, 2: 6dof
+ if (tname == "uses-feature") {
+ Vector<String> feature_names;
+ Vector<bool> feature_required_list;
+ Vector<int> feature_versions;
- if (tname == "uses-feature" && dof_index > 0) {
- if (xr_mode_index == 0) {
- WARN_PRINT("VR DOF feature setting is only valid for oculus HMDs with an XR mode set to VR");
+ if (xr_mode_index == 1 /* XRMode.OVR */) {
+ // Check for degrees of freedom
+ int dof_index = p_preset->get("xr_features/degrees_of_freedom"); // 0: none, 1: 3dof and 6dof, 2: 6dof
+
+ if (dof_index > 0) {
+ feature_names.push_back("android.hardware.vr.headtracking");
+ feature_required_list.push_back(dof_index == 2);
+ feature_versions.push_back(1);
+ }
+
+ // Check for hand tracking
+ int hand_tracking_index = p_preset->get("xr_features/hand_tracking"); // 0: none, 1: optional, 2: required
+ if (hand_tracking_index > 0) {
+ feature_names.push_back("oculus.software.handtracking");
+ feature_required_list.push_back(hand_tracking_index == 2);
+ feature_versions.push_back(-1); // no version attribute should be added.
+
+ if (perms.find("oculus.permission.handtracking") == -1) {
+ perms.push_back("oculus.permission.handtracking");
+ }
+ }
}
- ofs += 24; // skip over end tag
- // save manifest ending so we can restore it
- Vector<uint8_t> manifest_end;
- uint32_t manifest_cur_size = p_manifest.size();
+ if (feature_names.size() > 0) {
+ ofs += 24; // skip over end tag
- manifest_end.resize(p_manifest.size() - ofs);
- memcpy(manifest_end.ptrw(), &p_manifest[ofs], manifest_end.size());
+ // save manifest ending so we can restore it
+ Vector<uint8_t> manifest_end;
+ uint32_t manifest_cur_size = p_manifest.size();
- int32_t attr_name_string = string_table.find("name");
- ERR_FAIL_COND_MSG(attr_name_string == -1, "Template does not have 'name' attribute.");
+ manifest_end.resize(p_manifest.size() - ofs);
+ memcpy(manifest_end.ptrw(), &p_manifest[ofs], manifest_end.size());
- int32_t ns_android_string = string_table.find("http://schemas.android.com/apk/res/android");
- if (ns_android_string == -1) {
- string_table.push_back("http://schemas.android.com/apk/res/android");
- ns_android_string = string_table.size() - 1;
- }
+ int32_t attr_name_string = string_table.find("name");
+ ERR_FAIL_COND_MSG(attr_name_string == -1, "Template does not have 'name' attribute.");
- int32_t attr_uses_permission_string = string_table.find("uses-feature");
- if (attr_uses_permission_string == -1) {
- string_table.push_back("uses-feature");
- attr_uses_permission_string = string_table.size() - 1;
- }
+ int32_t ns_android_string = string_table.find("http://schemas.android.com/apk/res/android");
+ if (ns_android_string == -1) {
+ string_table.push_back("http://schemas.android.com/apk/res/android");
+ ns_android_string = string_table.size() - 1;
+ }
- int32_t attr_required_string = string_table.find("required");
- if (attr_required_string == -1) {
- string_table.push_back("required");
- attr_required_string = string_table.size() - 1;
- }
+ int32_t attr_uses_feature_string = string_table.find("uses-feature");
+ if (attr_uses_feature_string == -1) {
+ string_table.push_back("uses-feature");
+ attr_uses_feature_string = string_table.size() - 1;
+ }
- int32_t attr_version_string = string_table.find("version");
- if (attr_version_string == -1) {
- string_table.push_back("version");
- attr_version_string = string_table.size() - 1;
- }
+ int32_t attr_required_string = string_table.find("required");
+ if (attr_required_string == -1) {
+ string_table.push_back("required");
+ attr_required_string = string_table.size() - 1;
+ }
- String required_value_string;
- if (dof_index == 1) {
- required_value_string = "false";
- } else if (dof_index == 2) {
- required_value_string = "true";
- } else {
- ERR_FAIL_MSG("Unknown DoF index: " + itos(dof_index) + ".");
- }
- int32_t required_value = string_table.find(required_value_string);
- if (required_value == -1) {
- string_table.push_back(required_value_string);
- required_value = string_table.size() - 1;
- }
+ for (int i = 0; i < feature_names.size(); i++) {
+ String feature_name = feature_names[i];
+ bool feature_required = feature_required_list[i];
+ int feature_version = feature_versions[i];
+ bool has_version_attribute = feature_version != -1;
- int32_t version_value = string_table.find("1");
- if (version_value == -1) {
- string_table.push_back("1");
- version_value = string_table.size() - 1;
- }
+ print_line("Adding feature " + feature_name);
- int32_t feature_string = string_table.find("android.hardware.vr.headtracking");
- if (feature_string == -1) {
- string_table.push_back("android.hardware.vr.headtracking");
- feature_string = string_table.size() - 1;
- }
+ int32_t feature_string = string_table.find(feature_name);
+ if (feature_string == -1) {
+ string_table.push_back(feature_name);
+ feature_string = string_table.size() - 1;
+ }
- {
- manifest_cur_size += 96 + 20; // node and three attrs + end node
- p_manifest.resize(manifest_cur_size);
+ String required_value_string = feature_required ? "true" : "false";
+ int32_t required_value = string_table.find(required_value_string);
+ if (required_value == -1) {
+ string_table.push_back(required_value_string);
+ required_value = string_table.size() - 1;
+ }
- // start tag
- encode_uint16(0x102, &p_manifest.write[ofs]); // type
- encode_uint16(16, &p_manifest.write[ofs + 2]); // headersize
- encode_uint32(96, &p_manifest.write[ofs + 4]); // size
- encode_uint32(0, &p_manifest.write[ofs + 8]); // lineno
- encode_uint32(-1, &p_manifest.write[ofs + 12]); // comment
- encode_uint32(-1, &p_manifest.write[ofs + 16]); // ns
- encode_uint32(attr_uses_permission_string, &p_manifest.write[ofs + 20]); // name
- encode_uint16(20, &p_manifest.write[ofs + 24]); // attr_start
- encode_uint16(20, &p_manifest.write[ofs + 26]); // attr_size
- encode_uint16(3, &p_manifest.write[ofs + 28]); // num_attrs
- encode_uint16(0, &p_manifest.write[ofs + 30]); // id_index
- encode_uint16(0, &p_manifest.write[ofs + 32]); // class_index
- encode_uint16(0, &p_manifest.write[ofs + 34]); // style_index
+ int32_t attr_version_string = -1;
+ int32_t version_value = -1;
+ int tag_size;
+ int attr_count;
+ if (has_version_attribute) {
+ attr_version_string = string_table.find("version");
+ if (attr_version_string == -1) {
+ string_table.push_back("version");
+ attr_version_string = string_table.size() - 1;
+ }
- // android:name attribute
- encode_uint32(ns_android_string, &p_manifest.write[ofs + 36]); // ns
- encode_uint32(attr_name_string, &p_manifest.write[ofs + 40]); // 'name'
- encode_uint32(feature_string, &p_manifest.write[ofs + 44]); // raw_value
- encode_uint16(8, &p_manifest.write[ofs + 48]); // typedvalue_size
- p_manifest.write[ofs + 50] = 0; // typedvalue_always0
- p_manifest.write[ofs + 51] = 0x03; // typedvalue_type (string)
- encode_uint32(feature_string, &p_manifest.write[ofs + 52]); // typedvalue reference
-
- // android:required attribute
- encode_uint32(ns_android_string, &p_manifest.write[ofs + 56]); // ns
- encode_uint32(attr_required_string, &p_manifest.write[ofs + 60]); // 'name'
- encode_uint32(required_value, &p_manifest.write[ofs + 64]); // raw_value
- encode_uint16(8, &p_manifest.write[ofs + 68]); // typedvalue_size
- p_manifest.write[ofs + 70] = 0; // typedvalue_always0
- p_manifest.write[ofs + 71] = 0x03; // typedvalue_type (string)
- encode_uint32(required_value, &p_manifest.write[ofs + 72]); // typedvalue reference
-
- // android:version attribute
- encode_uint32(ns_android_string, &p_manifest.write[ofs + 76]); // ns
- encode_uint32(attr_version_string, &p_manifest.write[ofs + 80]); // 'name'
- encode_uint32(version_value, &p_manifest.write[ofs + 84]); // raw_value
- encode_uint16(8, &p_manifest.write[ofs + 88]); // typedvalue_size
- p_manifest.write[ofs + 90] = 0; // typedvalue_always0
- p_manifest.write[ofs + 91] = 0x03; // typedvalue_type (string)
- encode_uint32(version_value, &p_manifest.write[ofs + 92]); // typedvalue reference
-
- ofs += 96;
+ version_value = string_table.find(itos(feature_version));
+ if (version_value == -1) {
+ string_table.push_back(itos(feature_version));
+ version_value = string_table.size() - 1;
+ }
- // end tag
- encode_uint16(0x103, &p_manifest.write[ofs]); // type
- encode_uint16(16, &p_manifest.write[ofs + 2]); // headersize
- encode_uint32(24, &p_manifest.write[ofs + 4]); // size
- encode_uint32(0, &p_manifest.write[ofs + 8]); // lineno
- encode_uint32(-1, &p_manifest.write[ofs + 12]); // comment
- encode_uint32(-1, &p_manifest.write[ofs + 16]); // ns
- encode_uint32(attr_uses_permission_string, &p_manifest.write[ofs + 20]); // name
+ tag_size = 96; // node and three attrs + end node
+ attr_count = 3;
+ } else {
+ tag_size = 76; // node and two attrs + end node
+ attr_count = 2;
+ }
+ manifest_cur_size += tag_size + 24;
+ p_manifest.resize(manifest_cur_size);
+
+ // start tag
+ encode_uint16(0x102, &p_manifest.write[ofs]); // type
+ encode_uint16(16, &p_manifest.write[ofs + 2]); // headersize
+ encode_uint32(tag_size, &p_manifest.write[ofs + 4]); // size
+ encode_uint32(0, &p_manifest.write[ofs + 8]); // lineno
+ encode_uint32(-1, &p_manifest.write[ofs + 12]); // comment
+ encode_uint32(-1, &p_manifest.write[ofs + 16]); // ns
+ encode_uint32(attr_uses_feature_string, &p_manifest.write[ofs + 20]); // name
+ encode_uint16(20, &p_manifest.write[ofs + 24]); // attr_start
+ encode_uint16(20, &p_manifest.write[ofs + 26]); // attr_size
+ encode_uint16(attr_count, &p_manifest.write[ofs + 28]); // num_attrs
+ encode_uint16(0, &p_manifest.write[ofs + 30]); // id_index
+ encode_uint16(0, &p_manifest.write[ofs + 32]); // class_index
+ encode_uint16(0, &p_manifest.write[ofs + 34]); // style_index
+
+ // android:name attribute
+ encode_uint32(ns_android_string, &p_manifest.write[ofs + 36]); // ns
+ encode_uint32(attr_name_string, &p_manifest.write[ofs + 40]); // 'name'
+ encode_uint32(feature_string, &p_manifest.write[ofs + 44]); // raw_value
+ encode_uint16(8, &p_manifest.write[ofs + 48]); // typedvalue_size
+ p_manifest.write[ofs + 50] = 0; // typedvalue_always0
+ p_manifest.write[ofs + 51] = 0x03; // typedvalue_type (string)
+ encode_uint32(feature_string, &p_manifest.write[ofs + 52]); // typedvalue reference
+
+ // android:required attribute
+ encode_uint32(ns_android_string, &p_manifest.write[ofs + 56]); // ns
+ encode_uint32(attr_required_string, &p_manifest.write[ofs + 60]); // 'name'
+ encode_uint32(required_value, &p_manifest.write[ofs + 64]); // raw_value
+ encode_uint16(8, &p_manifest.write[ofs + 68]); // typedvalue_size
+ p_manifest.write[ofs + 70] = 0; // typedvalue_always0
+ p_manifest.write[ofs + 71] = 0x03; // typedvalue_type (string)
+ encode_uint32(required_value, &p_manifest.write[ofs + 72]); // typedvalue reference
+
+ ofs += 76;
+
+ if (has_version_attribute) {
+ // android:version attribute
+ encode_uint32(ns_android_string, &p_manifest.write[ofs]); // ns
+ encode_uint32(attr_version_string, &p_manifest.write[ofs + 4]); // 'name'
+ encode_uint32(version_value, &p_manifest.write[ofs + 8]); // raw_value
+ encode_uint16(8, &p_manifest.write[ofs + 12]); // typedvalue_size
+ p_manifest.write[ofs + 14] = 0; // typedvalue_always0
+ p_manifest.write[ofs + 15] = 0x03; // typedvalue_type (string)
+ encode_uint32(version_value, &p_manifest.write[ofs + 16]); // typedvalue reference
+
+ ofs += 20;
+ }
- ofs += 24;
+ // end tag
+ encode_uint16(0x103, &p_manifest.write[ofs]); // type
+ encode_uint16(16, &p_manifest.write[ofs + 2]); // headersize
+ encode_uint32(24, &p_manifest.write[ofs + 4]); // size
+ encode_uint32(0, &p_manifest.write[ofs + 8]); // lineno
+ encode_uint32(-1, &p_manifest.write[ofs + 12]); // comment
+ encode_uint32(-1, &p_manifest.write[ofs + 16]); // ns
+ encode_uint32(attr_uses_feature_string, &p_manifest.write[ofs + 20]); // name
+
+ ofs += 24;
+ }
+ memcpy(&p_manifest.write[ofs], manifest_end.ptr(), manifest_end.size());
+ ofs -= 24; // go back over back end
}
- memcpy(&p_manifest.write[ofs], manifest_end.ptr(), manifest_end.size());
- ofs -= 24; // go back over back end
}
if (tname == "manifest") {
@@ -1295,9 +1334,10 @@ public:
virtual void get_export_options(List<ExportOption> *r_options) {
- r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "graphics/xr_mode", PROPERTY_HINT_ENUM, "Regular,Oculus Mobile VR"), 0));
- r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "graphics/degrees_of_freedom", PROPERTY_HINT_ENUM, "None,3DOF and 6DOF,6DOF"), 0));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "graphics/32_bits_framebuffer"), true));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "xr_features/xr_mode", PROPERTY_HINT_ENUM, "Regular,Oculus Mobile VR"), 0));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "xr_features/degrees_of_freedom", PROPERTY_HINT_ENUM, "None,3DOF and 6DOF,6DOF"), 0));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "xr_features/hand_tracking", PROPERTY_HINT_ENUM, "None,Optional,Required"), 0));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "one_click_deploy/clear_previous_install"), false));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, "*.apk"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, "*.apk"), ""));
@@ -2264,7 +2304,7 @@ public:
}
}
- int xr_mode_index = p_preset->get("graphics/xr_mode");
+ int xr_mode_index = p_preset->get("xr_features/xr_mode");
if (xr_mode_index == 1 /* XRMode.OVR */) {
cl.push_back("--xr_mode_ovr");
} else {
diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java b/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java
index 8447af10e4..0ff37e3c37 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java
@@ -100,6 +100,16 @@ public class GodotLib {
public static native void hover(int type, int x, int y);
/**
+ * Forward double_tap events from the main thread to the GL thread.
+ */
+ public static native void double_tap(int x, int y);
+
+ /**
+ * Forward scroll events from the main thread to the GL thread.
+ */
+ public static native void scroll(int x, int y);
+
+ /**
* Forward accelerometer sensor events from the main thread to the GL thread.
* @see android.hardware.SensorEventListener#onSensorChanged(SensorEvent)
*/
diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotView.java b/platform/android/java/lib/src/org/godotengine/godot/GodotView.java
index 78f3763d84..f938583082 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/GodotView.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/GodotView.java
@@ -32,8 +32,10 @@ package org.godotengine.godot;
import android.annotation.SuppressLint;
import android.graphics.PixelFormat;
import android.opengl.GLSurfaceView;
+import android.view.GestureDetector;
import android.view.KeyEvent;
import android.view.MotionEvent;
+import org.godotengine.godot.input.GodotGestureHandler;
import org.godotengine.godot.input.GodotInputHandler;
import org.godotengine.godot.utils.GLUtils;
import org.godotengine.godot.xr.XRMode;
@@ -68,6 +70,7 @@ public class GodotView extends GLSurfaceView {
private final Godot activity;
private final GodotInputHandler inputHandler;
+ private final GestureDetector detector;
private final GodotRenderer godotRenderer;
public GodotView(Godot activity, XRMode xrMode, boolean p_use_gl3, boolean p_use_32_bits, boolean p_use_debug_opengl) {
@@ -78,6 +81,7 @@ public class GodotView extends GLSurfaceView {
this.activity = activity;
this.inputHandler = new GodotInputHandler(this);
+ this.detector = new GestureDetector(activity, new GodotGestureHandler(this));
this.godotRenderer = new GodotRenderer();
init(xrMode, false, 16, 0);
}
@@ -90,6 +94,7 @@ public class GodotView extends GLSurfaceView {
@Override
public boolean onTouchEvent(MotionEvent event) {
super.onTouchEvent(event);
+ this.detector.onTouchEvent(event);
return activity.gotTouchEvent(event);
}
diff --git a/platform/android/java/lib/src/org/godotengine/godot/input/GodotGestureHandler.java b/platform/android/java/lib/src/org/godotengine/godot/input/GodotGestureHandler.java
new file mode 100644
index 0000000000..b42b13894c
--- /dev/null
+++ b/platform/android/java/lib/src/org/godotengine/godot/input/GodotGestureHandler.java
@@ -0,0 +1,106 @@
+/*************************************************************************/
+/* GodotGestureHandler.java */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+package org.godotengine.godot.input;
+
+import android.util.Log;
+import android.view.GestureDetector;
+import android.view.MotionEvent;
+import org.godotengine.godot.GodotLib;
+import org.godotengine.godot.GodotView;
+
+/**
+ * Handles gesture input related events for the {@link GodotView} view.
+ * https://developer.android.com/reference/android/view/GestureDetector.SimpleOnGestureListener
+ */
+public class GodotGestureHandler extends GestureDetector.SimpleOnGestureListener {
+
+ private final GodotView godotView;
+
+ public GodotGestureHandler(GodotView godotView) {
+ this.godotView = godotView;
+ }
+
+ private void queueEvent(Runnable task) {
+ godotView.queueEvent(task);
+ }
+
+ @Override
+ public boolean onDown(MotionEvent event) {
+ super.onDown(event);
+ //Log.i("GodotGesture", "onDown");
+ return true;
+ }
+
+ @Override
+ public boolean onSingleTapConfirmed(MotionEvent event) {
+ super.onSingleTapConfirmed(event);
+ return true;
+ }
+
+ @Override
+ public void onLongPress(MotionEvent event) {
+ //Log.i("GodotGesture", "onLongPress");
+ }
+
+ @Override
+ public boolean onDoubleTap(MotionEvent event) {
+ //Log.i("GodotGesture", "onDoubleTap");
+ final int x = Math.round(event.getX());
+ final int y = Math.round(event.getY());
+ queueEvent(new Runnable() {
+ @Override
+ public void run() {
+ GodotLib.double_tap(x, y);
+ }
+ });
+ return true;
+ }
+
+ @Override
+ public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
+ //Log.i("GodotGesture", "onScroll");
+ final int x = Math.round(distanceX);
+ final int y = Math.round(distanceY);
+ queueEvent(new Runnable() {
+ @Override
+ public void run() {
+ GodotLib.scroll(x, y);
+ }
+ });
+ return true;
+ }
+
+ @Override
+ public boolean onFling(MotionEvent event1, MotionEvent event2, float velocityX, float velocityY) {
+ //Log.i("GodotGesture", "onFling");
+ return true;
+ }
+}
diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp
index 0a32f4423b..d3bc216608 100644
--- a/platform/android/java_godot_lib_jni.cpp
+++ b/platform/android/java_godot_lib_jni.cpp
@@ -835,6 +835,20 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_hover(JNIEnv *env, jo
os_android->process_hover(p_type, Point2(p_x, p_y));
}
+JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_double_tap(JNIEnv *env, jobject obj, jint p_x, jint p_y) {
+ if (step == 0)
+ return;
+
+ os_android->process_double_tap(Point2(p_x, p_y));
+}
+
+JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_scroll(JNIEnv *env, jobject obj, jint p_x, jint p_y) {
+ if (step == 0)
+ return;
+
+ os_android->process_scroll(Point2(p_x, p_y));
+}
+
/*
* Android Key codes.
*/
diff --git a/platform/android/java_godot_lib_jni.h b/platform/android/java_godot_lib_jni.h
index 8c18c52d2b..08029c3c30 100644
--- a/platform/android/java_godot_lib_jni.h
+++ b/platform/android/java_godot_lib_jni.h
@@ -46,6 +46,8 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, job
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_back(JNIEnv *env, jobject obj);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_touch(JNIEnv *env, jobject obj, jint ev, jint pointer, jint count, jintArray positions);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_hover(JNIEnv *env, jobject obj, jint p_type, jint p_x, jint p_y);
+JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_double_tap(JNIEnv *env, jobject obj, jint p_x, jint p_y);
+JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_scroll(JNIEnv *env, jobject obj, jint p_x, jint p_y);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_key(JNIEnv *env, jobject obj, jint p_scancode, jint p_unicode_char, jboolean p_pressed);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joybutton(JNIEnv *env, jobject obj, jint p_device, jint p_button, jboolean p_pressed);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyaxis(JNIEnv *env, jobject obj, jint p_device, jint p_axis, jfloat p_value);
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp
index 4c560273e8..bbea5e3699 100644
--- a/platform/android/os_android.cpp
+++ b/platform/android/os_android.cpp
@@ -502,6 +502,26 @@ void OS_Android::process_hover(int p_type, Point2 p_pos) {
}
}
+void OS_Android::process_double_tap(Point2 p_pos) {
+ Ref<InputEventMouseButton> ev;
+ ev.instance();
+ ev->set_position(p_pos);
+ ev->set_global_position(p_pos);
+ ev->set_pressed(true);
+ ev->set_doubleclick(true);
+ ev->set_button_index(1);
+ input->parse_input_event(ev);
+}
+
+void OS_Android::process_scroll(Point2 p_pos) {
+ Ref<InputEventPanGesture> ev;
+ ev.instance();
+ ev->set_position(p_pos);
+ ev->set_delta(p_pos - scroll_prev_pos);
+ input->parse_input_event(ev);
+ scroll_prev_pos = p_pos;
+}
+
void OS_Android::process_accelerometer(const Vector3 &p_accelerometer) {
input->set_accelerometer(p_accelerometer);
diff --git a/platform/android/os_android.h b/platform/android/os_android.h
index 5ac50ddef2..1cf64a2e84 100644
--- a/platform/android/os_android.h
+++ b/platform/android/os_android.h
@@ -70,6 +70,7 @@ public:
private:
Vector<TouchPos> touch;
Point2 hover_prev_pos; // needed to calculate the relative position on hover events
+ Point2 scroll_prev_pos; // needed to calculate the relative position on scroll events
bool use_gl2;
bool use_apk_expansion;
@@ -187,6 +188,8 @@ public:
void process_gyroscope(const Vector3 &p_gyroscope);
void process_touch(int p_what, int p_pointer, const Vector<TouchPos> &p_points);
void process_hover(int p_type, Point2 p_pos);
+ void process_double_tap(Point2 p_pos);
+ void process_scroll(Point2 p_pos);
void process_joy_event(JoypadEvent p_event);
void process_event(Ref<InputEvent> p_event);
void init_video_mode(int p_video_width, int p_video_height);
diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp
index ce7b47c414..cf38664022 100644
--- a/platform/osx/export/export.cpp
+++ b/platform/osx/export/export.cpp
@@ -502,6 +502,8 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
else
pkg_name = "Unnamed";
+ String pkg_name_safe = OS::get_singleton()->get_safe_dir_name(pkg_name);
+
Error err = OK;
String tmp_app_path_name = "";
zlib_filefunc_def io2 = io;
@@ -509,12 +511,13 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
io2.opaque = &dst_f;
zipFile dst_pkg_zip = NULL;
+ DirAccess *tmp_app_path = NULL;
String export_format = use_dmg() && p_path.ends_with("dmg") ? "dmg" : "zip";
if (export_format == "dmg") {
// We're on OSX so we can export to DMG, but first we create our application bundle
tmp_app_path_name = EditorSettings::get_singleton()->get_cache_dir().plus_file(pkg_name + ".app");
print_line("Exporting to " + tmp_app_path_name);
- DirAccess *tmp_app_path = DirAccess::create_for_path(tmp_app_path_name);
+ tmp_app_path = DirAccess::create_for_path(tmp_app_path_name);
if (!tmp_app_path) {
err = ERR_CANT_CREATE;
}
@@ -611,25 +614,45 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
}
if (data.size() > 0) {
+
+ if (file.find("/data.mono.osx.64.release_debug/") != -1) {
+ if (!p_debug) {
+ ret = unzGoToNextFile(src_pkg_zip);
+ continue; //skip
+ }
+ file = file.replace("/data.mono.osx.64.release_debug/", "/data_" + pkg_name_safe + "/");
+ }
+ if (file.find("/data.mono.osx.64.release/") != -1) {
+ if (p_debug) {
+ ret = unzGoToNextFile(src_pkg_zip);
+ continue; //skip
+ }
+ file = file.replace("/data.mono.osx.64.release/", "/data_" + pkg_name_safe + "/");
+ }
+
print_line("ADDING: " + file + " size: " + itos(data.size()));
total_size += data.size();
if (export_format == "dmg") {
// write it into our application bundle
file = tmp_app_path_name.plus_file(file);
-
- // write the file, need to add chmod
- FileAccess *f = FileAccess::open(file, FileAccess::WRITE);
- if (f) {
- f->store_buffer(data.ptr(), data.size());
- f->close();
- if (is_execute) {
- // Chmod with 0755 if the file is executable
- FileAccess::set_unix_permissions(file, 0755);
+ if (err == OK) {
+ err = tmp_app_path->make_dir_recursive(file.get_base_dir());
+ }
+ if (err == OK) {
+ // write the file, need to add chmod
+ FileAccess *f = FileAccess::open(file, FileAccess::WRITE);
+ if (f) {
+ f->store_buffer(data.ptr(), data.size());
+ f->close();
+ if (is_execute) {
+ // Chmod with 0755 if the file is executable
+ FileAccess::set_unix_permissions(file, 0755);
+ }
+ memdelete(f);
+ } else {
+ err = ERR_CANT_CREATE;
}
- memdelete(f);
- } else {
- err = ERR_CANT_CREATE;
}
} else {
// add it to our zip file
diff --git a/platform/osx/godot_main_osx.mm b/platform/osx/godot_main_osx.mm
index 73fd4632ab..e6f8cbecf1 100644
--- a/platform/osx/godot_main_osx.mm
+++ b/platform/osx/godot_main_osx.mm
@@ -45,35 +45,6 @@ int main(int argc, char **argv) {
printf("%i: %s\n", i, argv[i]);
};
- if (argc >= 1 && argv[0][0] == '/') {
- //potentially launched from finder
- int len = strlen(argv[0]);
- while (len--) {
- if (argv[0][len] == '/') break;
- }
- if (len >= 0) {
- char *path = (char *)malloc(len + 1);
- memcpy(path, argv[0], len);
- path[len] = 0;
-
- char *pathinfo = (char *)malloc(strlen(path) + strlen("/../Info.plist") + 1);
- //in real code you would check for errors in malloc here
- strcpy(pathinfo, path);
- strcat(pathinfo, "/../Info.plist");
-
- FILE *f = fopen(pathinfo, "rb");
- if (f) {
- //running from app bundle, as Info.plist was found
- fclose(f);
- chdir(path);
- chdir("../Resources"); //data.pck, or just the files are here
- }
-
- free(path);
- free(pathinfo);
- }
- }
-
#ifdef DEBUG_ENABLED
// lets report the path we made current after all that
char cwd[4096];
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index 44c5412a39..58a47c102a 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -223,6 +223,7 @@ public:
virtual String get_config_path() const;
virtual String get_data_path() const;
virtual String get_cache_path() const;
+ virtual String get_bundle_resource_dir() const;
virtual String get_godot_dir_name() const;
virtual String get_system_dir(SystemDir p_dir) const;
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 95c103bd28..2b002d3b5d 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -2111,6 +2111,19 @@ String OS_OSX::get_cache_path() const {
}
}
+String OS_OSX::get_bundle_resource_dir() const {
+
+ NSBundle *main = [NSBundle mainBundle];
+ NSString *resourcePath = [main resourcePath];
+
+ char *utfs = strdup([resourcePath UTF8String]);
+ String ret;
+ ret.parse_utf8(utfs);
+ free(utfs);
+
+ return ret;
+}
+
// Get properly capitalized engine name for system paths
String OS_OSX::get_godot_dir_name() const {
diff --git a/platform/x11/crash_handler_x11.cpp b/platform/x11/crash_handler_x11.cpp
index 3a91c62546..19c8f71d0e 100644
--- a/platform/x11/crash_handler_x11.cpp
+++ b/platform/x11/crash_handler_x11.cpp
@@ -107,7 +107,7 @@ static void handle_crash(int sig) {
output.erase(output.length() - 1, 1);
}
- fprintf(stderr, "[%ld] %s (%ls)\n", i, fname, output.c_str());
+ fprintf(stderr, "[%ld] %s (%ls)\n", (long int)i, fname, output.c_str());
}
free(strings);
diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp
index 28a8c4d658..917ced5feb 100644
--- a/scene/2d/animated_sprite.cpp
+++ b/scene/2d/animated_sprite.cpp
@@ -35,6 +35,7 @@
#define NORMAL_SUFFIX "_normal"
+#ifdef TOOLS_ENABLED
Dictionary AnimatedSprite::_edit_get_state() const {
Dictionary state = Node2D::_edit_get_state();
state["offset"] = offset;
@@ -72,6 +73,7 @@ bool AnimatedSprite::_edit_use_rect() const {
t = frames->get_frame(animation, frame);
return t.is_valid();
}
+#endif
Rect2 AnimatedSprite::get_anchorable_rect() const {
return _get_rect();
diff --git a/scene/2d/animated_sprite.h b/scene/2d/animated_sprite.h
index 2017c62a48..cd00a4e181 100644
--- a/scene/2d/animated_sprite.h
+++ b/scene/2d/animated_sprite.h
@@ -156,6 +156,7 @@ protected:
virtual void _validate_property(PropertyInfo &property) const;
public:
+#ifdef TOOLS_ENABLED
virtual Dictionary _edit_get_state() const;
virtual void _edit_set_state(const Dictionary &p_state);
@@ -164,6 +165,7 @@ public:
virtual bool _edit_use_pivot() const;
virtual Rect2 _edit_get_rect() const;
virtual bool _edit_use_rect() const;
+#endif
virtual Rect2 get_anchorable_rect() const;
diff --git a/scene/2d/back_buffer_copy.cpp b/scene/2d/back_buffer_copy.cpp
index 1a6f30e0fd..faeb6b7169 100644
--- a/scene/2d/back_buffer_copy.cpp
+++ b/scene/2d/back_buffer_copy.cpp
@@ -50,6 +50,7 @@ void BackBufferCopy::_update_copy_mode() {
}
}
+#ifdef TOOLS_ENABLED
Rect2 BackBufferCopy::_edit_get_rect() const {
return rect;
@@ -58,6 +59,7 @@ Rect2 BackBufferCopy::_edit_get_rect() const {
bool BackBufferCopy::_edit_use_rect() const {
return true;
}
+#endif
Rect2 BackBufferCopy::get_anchorable_rect() const {
diff --git a/scene/2d/back_buffer_copy.h b/scene/2d/back_buffer_copy.h
index 91acd81e00..4b26bf1bdc 100644
--- a/scene/2d/back_buffer_copy.h
+++ b/scene/2d/back_buffer_copy.h
@@ -53,8 +53,10 @@ protected:
static void _bind_methods();
public:
+#ifdef TOOLS_ENABLED
Rect2 _edit_get_rect() const;
virtual bool _edit_use_rect() const;
+#endif
void set_rect(const Rect2 &p_rect);
Rect2 get_rect() const;
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index 9895dba027..5631aa3355 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -351,7 +351,7 @@ CanvasItemMaterial::~CanvasItemMaterial() {
}
///////////////////////////////////////////////////////////////////
-
+#ifdef TOOLS_ENABLED
bool CanvasItem::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
if (_edit_use_rect()) {
return _edit_get_rect().has_point(p_point);
@@ -363,6 +363,7 @@ bool CanvasItem::_edit_is_selected_on_click(const Point2 &p_point, double p_tole
Transform2D CanvasItem::_edit_get_transform() const {
return Transform2D(_edit_get_rotation(), _edit_get_position() + _edit_get_pivot());
}
+#endif
bool CanvasItem::is_visible_in_tree() const {
@@ -1121,9 +1122,10 @@ void CanvasItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("_toplevel_raise_self"), &CanvasItem::_toplevel_raise_self);
ClassDB::bind_method(D_METHOD("_update_callback"), &CanvasItem::_update_callback);
+
+#ifdef TOOLS_ENABLED
ClassDB::bind_method(D_METHOD("_edit_set_state", "state"), &CanvasItem::_edit_set_state);
ClassDB::bind_method(D_METHOD("_edit_get_state"), &CanvasItem::_edit_get_state);
-
ClassDB::bind_method(D_METHOD("_edit_set_position", "position"), &CanvasItem::_edit_set_position);
ClassDB::bind_method(D_METHOD("_edit_get_position"), &CanvasItem::_edit_get_position);
ClassDB::bind_method(D_METHOD("_edit_set_scale", "scale"), &CanvasItem::_edit_set_scale);
@@ -1138,6 +1140,7 @@ void CanvasItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("_edit_get_pivot"), &CanvasItem::_edit_get_pivot);
ClassDB::bind_method(D_METHOD("_edit_use_pivot"), &CanvasItem::_edit_use_pivot);
ClassDB::bind_method(D_METHOD("_edit_get_transform"), &CanvasItem::_edit_get_transform);
+#endif
ClassDB::bind_method(D_METHOD("get_canvas_item"), &CanvasItem::get_canvas_item);
diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h
index 82645051e8..8814d99edd 100644
--- a/scene/2d/canvas_item.h
+++ b/scene/2d/canvas_item.h
@@ -249,7 +249,7 @@ public:
};
/* EDITOR */
-
+#ifdef TOOLS_ENABLED
// Select the node
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
@@ -282,6 +282,7 @@ public:
virtual Point2 _edit_get_pivot() const { return Point2(); };
virtual Transform2D _edit_get_transform() const;
+#endif
/* VISIBILITY */
diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp
index 3090c9956e..d9cc94c6eb 100644
--- a/scene/2d/collision_polygon_2d.cpp
+++ b/scene/2d/collision_polygon_2d.cpp
@@ -227,6 +227,7 @@ CollisionPolygon2D::BuildMode CollisionPolygon2D::get_build_mode() const {
return build_mode;
}
+#ifdef TOOLS_ENABLED
Rect2 CollisionPolygon2D::_edit_get_rect() const {
return aabb;
@@ -240,6 +241,7 @@ bool CollisionPolygon2D::_edit_is_selected_on_click(const Point2 &p_point, doubl
return Geometry::is_point_in_polygon(p_point, Variant(polygon));
}
+#endif
String CollisionPolygon2D::get_configuration_warning() const {
diff --git a/scene/2d/collision_polygon_2d.h b/scene/2d/collision_polygon_2d.h
index e5e18b2674..d8dfec8fd2 100644
--- a/scene/2d/collision_polygon_2d.h
+++ b/scene/2d/collision_polygon_2d.h
@@ -67,16 +67,18 @@ protected:
static void _bind_methods();
public:
+#ifdef TOOLS_ENABLED
+ virtual Rect2 _edit_get_rect() const;
+ virtual bool _edit_use_rect() const;
+ virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
+#endif
+
void set_build_mode(BuildMode p_mode);
BuildMode get_build_mode() const;
void set_polygon(const Vector<Point2> &p_polygon);
Vector<Point2> get_polygon() const;
- virtual Rect2 _edit_get_rect() const;
- virtual bool _edit_use_rect() const;
- virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
-
virtual String get_configuration_warning() const;
void set_disabled(bool p_disabled);
diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp
index 1843cbed67..eb66265010 100644
--- a/scene/2d/light_2d.cpp
+++ b/scene/2d/light_2d.cpp
@@ -33,6 +33,7 @@
#include "core/engine.h"
#include "servers/visual_server.h"
+#ifdef TOOLS_ENABLED
Dictionary Light2D::_edit_get_state() const {
Dictionary state = Node2D::_edit_get_state();
state["offset"] = get_texture_offset();
@@ -68,6 +69,7 @@ Rect2 Light2D::_edit_get_rect() const {
bool Light2D::_edit_use_rect() const {
return !texture.is_null();
}
+#endif
Rect2 Light2D::get_anchorable_rect() const {
if (texture.is_null())
diff --git a/scene/2d/light_2d.h b/scene/2d/light_2d.h
index f8476e8389..65db5c6ee6 100644
--- a/scene/2d/light_2d.h
+++ b/scene/2d/light_2d.h
@@ -85,6 +85,7 @@ protected:
static void _bind_methods();
public:
+#ifdef TOOLS_ENABLED
virtual Dictionary _edit_get_state() const;
virtual void _edit_set_state(const Dictionary &p_state);
@@ -93,6 +94,7 @@ public:
virtual bool _edit_use_pivot() const;
virtual Rect2 _edit_get_rect() const;
virtual bool _edit_use_rect() const;
+#endif
virtual Rect2 get_anchorable_rect() const;
diff --git a/scene/2d/light_occluder_2d.cpp b/scene/2d/light_occluder_2d.cpp
index 6a930683d1..0e8e8f6679 100644
--- a/scene/2d/light_occluder_2d.cpp
+++ b/scene/2d/light_occluder_2d.cpp
@@ -33,6 +33,8 @@
#include "core/engine.h"
#define LINE_GRAB_WIDTH 8
+
+#ifdef TOOLS_ENABLED
Rect2 OccluderPolygon2D::_edit_get_rect() const {
if (rect_cache_dirty) {
@@ -80,6 +82,7 @@ bool OccluderPolygon2D::_edit_is_selected_on_click(const Point2 &p_point, double
return false;
}
}
+#endif
void OccluderPolygon2D::set_polygon(const PoolVector<Vector2> &p_polygon) {
@@ -215,6 +218,7 @@ void LightOccluder2D::_notification(int p_what) {
}
}
+#ifdef TOOLS_ENABLED
Rect2 LightOccluder2D::_edit_get_rect() const {
return occluder_polygon.is_valid() ? occluder_polygon->_edit_get_rect() : Rect2();
@@ -224,6 +228,7 @@ bool LightOccluder2D::_edit_is_selected_on_click(const Point2 &p_point, double p
return occluder_polygon.is_valid() ? occluder_polygon->_edit_is_selected_on_click(p_point, p_tolerance) : false;
}
+#endif
void LightOccluder2D::set_occluder_polygon(const Ref<OccluderPolygon2D> &p_polygon) {
diff --git a/scene/2d/light_occluder_2d.h b/scene/2d/light_occluder_2d.h
index 32d527093d..b20e347c35 100644
--- a/scene/2d/light_occluder_2d.h
+++ b/scene/2d/light_occluder_2d.h
@@ -57,8 +57,10 @@ protected:
static void _bind_methods();
public:
+#ifdef TOOLS_ENABLED
virtual Rect2 _edit_get_rect() const;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
+#endif
void set_polygon(const PoolVector<Vector2> &p_polygon);
PoolVector<Vector2> get_polygon() const;
@@ -91,8 +93,10 @@ protected:
static void _bind_methods();
public:
+#ifdef TOOLS_ENABLED
virtual Rect2 _edit_get_rect() const;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
+#endif
void set_occluder_polygon(const Ref<OccluderPolygon2D> &p_polygon);
Ref<OccluderPolygon2D> get_occluder_polygon() const;
diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp
index 4a022f0a9c..c31840c8e1 100644
--- a/scene/2d/line_2d.cpp
+++ b/scene/2d/line_2d.cpp
@@ -50,6 +50,7 @@ Line2D::Line2D() {
_antialiased = false;
}
+#ifdef TOOLS_ENABLED
Rect2 Line2D::_edit_get_rect() const {
if (_points.size() == 0)
@@ -79,6 +80,7 @@ bool Line2D::_edit_is_selected_on_click(const Point2 &p_point, double p_toleranc
return false;
}
+#endif
void Line2D::set_points(const PoolVector<Vector2> &p_points) {
_points = p_points;
diff --git a/scene/2d/line_2d.h b/scene/2d/line_2d.h
index bc2deba8c6..3c7239f67c 100644
--- a/scene/2d/line_2d.h
+++ b/scene/2d/line_2d.h
@@ -56,11 +56,13 @@ public:
LINE_TEXTURE_STRETCH
};
- Line2D();
-
+#ifdef TOOLS_ENABLED
virtual Rect2 _edit_get_rect() const;
virtual bool _edit_use_rect() const;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
+#endif
+
+ Line2D();
void set_points(const PoolVector<Vector2> &p_points);
PoolVector<Vector2> get_points() const;
diff --git a/scene/2d/mesh_instance_2d.cpp b/scene/2d/mesh_instance_2d.cpp
index 8f9c4e2a4d..93432ec40b 100644
--- a/scene/2d/mesh_instance_2d.cpp
+++ b/scene/2d/mesh_instance_2d.cpp
@@ -94,6 +94,7 @@ Ref<Texture> MeshInstance2D::get_texture() const {
return texture;
}
+#ifdef TOOLS_ENABLED
Rect2 MeshInstance2D::_edit_get_rect() const {
if (mesh.is_valid()) {
@@ -103,6 +104,7 @@ Rect2 MeshInstance2D::_edit_get_rect() const {
return Node2D::_edit_get_rect();
}
+#endif
MeshInstance2D::MeshInstance2D() {
}
diff --git a/scene/2d/mesh_instance_2d.h b/scene/2d/mesh_instance_2d.h
index e7f8b7c0c3..51f75a3ead 100644
--- a/scene/2d/mesh_instance_2d.h
+++ b/scene/2d/mesh_instance_2d.h
@@ -46,6 +46,10 @@ protected:
static void _bind_methods();
public:
+#ifdef TOOLS_ENABLED
+ virtual Rect2 _edit_get_rect() const;
+#endif
+
void set_mesh(const Ref<Mesh> &p_mesh);
Ref<Mesh> get_mesh() const;
@@ -55,8 +59,6 @@ public:
void set_normal_map(const Ref<Texture> &p_texture);
Ref<Texture> get_normal_map() const;
- virtual Rect2 _edit_get_rect() const;
-
MeshInstance2D();
};
diff --git a/scene/2d/multimesh_instance_2d.cpp b/scene/2d/multimesh_instance_2d.cpp
index 69d687229b..028459e778 100644
--- a/scene/2d/multimesh_instance_2d.cpp
+++ b/scene/2d/multimesh_instance_2d.cpp
@@ -94,6 +94,7 @@ Ref<Texture> MultiMeshInstance2D::get_normal_map() const {
return normal_map;
}
+#ifdef TOOLS_ENABLED
Rect2 MultiMeshInstance2D::_edit_get_rect() const {
if (multimesh.is_valid()) {
@@ -103,6 +104,7 @@ Rect2 MultiMeshInstance2D::_edit_get_rect() const {
return Node2D::_edit_get_rect();
}
+#endif
MultiMeshInstance2D::MultiMeshInstance2D() {
}
diff --git a/scene/2d/multimesh_instance_2d.h b/scene/2d/multimesh_instance_2d.h
index 253f4c77ca..c3f3e52920 100644
--- a/scene/2d/multimesh_instance_2d.h
+++ b/scene/2d/multimesh_instance_2d.h
@@ -47,6 +47,10 @@ protected:
static void _bind_methods();
public:
+#ifdef TOOLS_ENABLED
+ virtual Rect2 _edit_get_rect() const;
+#endif
+
void set_multimesh(const Ref<MultiMesh> &p_multimesh);
Ref<MultiMesh> get_multimesh() const;
@@ -56,8 +60,6 @@ public:
void set_normal_map(const Ref<Texture> &p_texture);
Ref<Texture> get_normal_map() const;
- virtual Rect2 _edit_get_rect() const;
-
MultiMeshInstance2D();
~MultiMeshInstance2D();
};
diff --git a/scene/2d/navigation_polygon.cpp b/scene/2d/navigation_polygon.cpp
index bd930bdda5..ea79f89dd9 100644
--- a/scene/2d/navigation_polygon.cpp
+++ b/scene/2d/navigation_polygon.cpp
@@ -36,6 +36,7 @@
#include "thirdparty/misc/triangulator.h"
+#ifdef TOOLS_ENABLED
Rect2 NavigationPolygon::_edit_get_rect() const {
if (rect_cache_dirty) {
@@ -75,6 +76,7 @@ bool NavigationPolygon::_edit_is_selected_on_click(const Point2 &p_point, double
}
return false;
}
+#endif
void NavigationPolygon::set_vertices(const PoolVector<Vector2> &p_vertices) {
@@ -357,7 +359,7 @@ bool NavigationPolygonInstance::is_enabled() const {
}
/////////////////////////////
-
+#ifdef TOOLS_ENABLED
Rect2 NavigationPolygonInstance::_edit_get_rect() const {
return navpoly.is_valid() ? navpoly->_edit_get_rect() : Rect2();
@@ -367,6 +369,7 @@ bool NavigationPolygonInstance::_edit_is_selected_on_click(const Point2 &p_point
return navpoly.is_valid() ? navpoly->_edit_is_selected_on_click(p_point, p_tolerance) : false;
}
+#endif
void NavigationPolygonInstance::_notification(int p_what) {
diff --git a/scene/2d/navigation_polygon.h b/scene/2d/navigation_polygon.h
index 9bbaa864f4..cbc1711a32 100644
--- a/scene/2d/navigation_polygon.h
+++ b/scene/2d/navigation_polygon.h
@@ -57,8 +57,10 @@ protected:
Array _get_outlines() const;
public:
+#ifdef TOOLS_ENABLED
Rect2 _edit_get_rect() const;
bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
+#endif
void set_vertices(const PoolVector<Vector2> &p_vertices);
PoolVector<Vector2> get_vertices() const;
@@ -100,8 +102,10 @@ protected:
static void _bind_methods();
public:
+#ifdef TOOLS_ENABLED
virtual Rect2 _edit_get_rect() const;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
+#endif
void set_enabled(bool p_enabled);
bool is_enabled() const;
diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp
index ad04dc8d9e..7bbc7577ed 100644
--- a/scene/2d/node_2d.cpp
+++ b/scene/2d/node_2d.cpp
@@ -35,6 +35,7 @@
#include "scene/main/viewport.h"
#include "servers/visual_server.h"
+#ifdef TOOLS_ENABLED
Dictionary Node2D::_edit_get_state() const {
Dictionary state;
@@ -44,6 +45,7 @@ Dictionary Node2D::_edit_get_state() const {
return state;
}
+
void Node2D::_edit_set_state(const Dictionary &p_state) {
pos = p_state["position"];
@@ -119,6 +121,7 @@ void Node2D::_edit_set_rect(const Rect2 &p_edit_rect) {
_change_notify("scale");
_change_notify("position");
}
+#endif
void Node2D::_update_xform_values() {
diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h
index a03ccc5a80..00202481a6 100644
--- a/scene/2d/node_2d.h
+++ b/scene/2d/node_2d.h
@@ -55,6 +55,7 @@ protected:
static void _bind_methods();
public:
+#ifdef TOOLS_ENABLED
virtual Dictionary _edit_get_state() const;
virtual void _edit_set_state(const Dictionary &p_state);
@@ -69,6 +70,7 @@ public:
virtual bool _edit_use_rotation() const;
virtual void _edit_set_rect(const Rect2 &p_edit_rect);
+#endif
void set_position(const Point2 &p_pos);
void set_rotation(float p_radians);
diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp
index e6ae95af89..e9296b0fe7 100644
--- a/scene/2d/path_2d.cpp
+++ b/scene/2d/path_2d.cpp
@@ -37,6 +37,7 @@
#include "editor/editor_scale.h"
#endif
+#ifdef TOOLS_ENABLED
Rect2 Path2D::_edit_get_rect() const {
if (!curve.is_valid() || curve->get_point_count() == 0)
@@ -85,6 +86,7 @@ bool Path2D::_edit_is_selected_on_click(const Point2 &p_point, double p_toleranc
return false;
}
+#endif
void Path2D::_notification(int p_what) {
diff --git a/scene/2d/path_2d.h b/scene/2d/path_2d.h
index 21cb4374bd..35cf8211f4 100644
--- a/scene/2d/path_2d.h
+++ b/scene/2d/path_2d.h
@@ -47,9 +47,11 @@ protected:
static void _bind_methods();
public:
+#ifdef TOOLS_ENABLED
virtual Rect2 _edit_get_rect() const;
virtual bool _edit_use_rect() const;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
+#endif
void set_curve(const Ref<Curve2D> &p_curve);
Ref<Curve2D> get_curve() const;
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index 3fd0bef7e9..90663bd675 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -1212,7 +1212,7 @@ bool KinematicBody2D::move_and_collide(const Vector2 &p_motion, bool p_infinite_
//so, if you pass 45 as limit, avoid numerical precision errors when angle is 45.
#define FLOOR_ANGLE_THRESHOLD 0.01
-Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const Vector2 &p_floor_direction, bool p_stop_on_slope, int p_max_slides, float p_floor_max_angle, bool p_infinite_inertia) {
+Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const Vector2 &p_up_direction, bool p_stop_on_slope, int p_max_slides, float p_floor_max_angle, bool p_infinite_inertia) {
Vector2 body_velocity = p_linear_velocity;
Vector2 body_velocity_normal = body_velocity.normalized();
@@ -1234,6 +1234,7 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const
on_ceiling = false;
on_wall = false;
colliders.clear();
+ floor_normal = p_up_direction;
floor_velocity = Vector2();
while (p_max_slides) {
@@ -1262,25 +1263,26 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const
colliders.push_back(collision);
motion = collision.remainder;
- if (p_floor_direction == Vector2()) {
+ if (p_up_direction == Vector2()) {
//all is a wall
on_wall = true;
} else {
- if (Math::acos(collision.normal.dot(p_floor_direction)) <= p_floor_max_angle + FLOOR_ANGLE_THRESHOLD) { //floor
+ if (Math::acos(collision.normal.dot(p_up_direction)) <= p_floor_max_angle + FLOOR_ANGLE_THRESHOLD) { //floor
on_floor = true;
+ floor_normal = collision.normal;
on_floor_body = collision.collider_rid;
floor_velocity = collision.collider_vel;
if (p_stop_on_slope) {
- if ((body_velocity_normal + p_floor_direction).length() < 0.01 && collision.travel.length() < 1) {
+ if ((body_velocity_normal + p_up_direction).length() < 0.01 && collision.travel.length() < 1) {
Transform2D gt = get_global_transform();
- gt.elements[2] -= collision.travel.slide(p_floor_direction);
+ gt.elements[2] -= collision.travel.slide(p_up_direction);
set_global_transform(gt);
return Vector2();
}
}
- } else if (Math::acos(collision.normal.dot(-p_floor_direction)) <= p_floor_max_angle + FLOOR_ANGLE_THRESHOLD) { //ceiling
+ } else if (Math::acos(collision.normal.dot(-p_up_direction)) <= p_floor_max_angle + FLOOR_ANGLE_THRESHOLD) { //ceiling
on_ceiling = true;
} else {
on_wall = true;
@@ -1301,11 +1303,11 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const
return body_velocity;
}
-Vector2 KinematicBody2D::move_and_slide_with_snap(const Vector2 &p_linear_velocity, const Vector2 &p_snap, const Vector2 &p_floor_direction, bool p_stop_on_slope, int p_max_slides, float p_floor_max_angle, bool p_infinite_inertia) {
+Vector2 KinematicBody2D::move_and_slide_with_snap(const Vector2 &p_linear_velocity, const Vector2 &p_snap, const Vector2 &p_up_direction, bool p_stop_on_slope, int p_max_slides, float p_floor_max_angle, bool p_infinite_inertia) {
bool was_on_floor = on_floor;
- Vector2 ret = move_and_slide(p_linear_velocity, p_floor_direction, p_stop_on_slope, p_max_slides, p_floor_max_angle, p_infinite_inertia);
+ Vector2 ret = move_and_slide(p_linear_velocity, p_up_direction, p_stop_on_slope, p_max_slides, p_floor_max_angle, p_infinite_inertia);
if (!was_on_floor || p_snap == Vector2()) {
return ret;
}
@@ -1315,15 +1317,16 @@ Vector2 KinematicBody2D::move_and_slide_with_snap(const Vector2 &p_linear_veloci
if (move_and_collide(p_snap, p_infinite_inertia, col, false, true)) {
bool apply = true;
- if (p_floor_direction != Vector2()) {
- if (Math::acos(p_floor_direction.normalized().dot(col.normal)) < p_floor_max_angle) {
+ if (p_up_direction != Vector2()) {
+ if (Math::acos(p_up_direction.normalized().dot(col.normal)) < p_floor_max_angle) {
on_floor = true;
+ floor_normal = col.normal;
on_floor_body = col.collider_rid;
floor_velocity = col.collider_vel;
if (p_stop_on_slope) {
// move and collide may stray the object a bit because of pre un-stucking,
// so only ensure that motion happens on floor direction in this case.
- col.travel = p_floor_direction * p_floor_direction.dot(col.travel);
+ col.travel = p_up_direction * p_up_direction.dot(col.travel);
}
} else {
@@ -1353,6 +1356,11 @@ bool KinematicBody2D::is_on_ceiling() const {
return on_ceiling;
}
+Vector2 KinematicBody2D::get_floor_normal() const {
+
+ return floor_normal;
+}
+
Vector2 KinematicBody2D::get_floor_velocity() const {
return floor_velocity;
@@ -1473,6 +1481,7 @@ void KinematicBody2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_on_floor"), &KinematicBody2D::is_on_floor);
ClassDB::bind_method(D_METHOD("is_on_ceiling"), &KinematicBody2D::is_on_ceiling);
ClassDB::bind_method(D_METHOD("is_on_wall"), &KinematicBody2D::is_on_wall);
+ ClassDB::bind_method(D_METHOD("get_floor_normal"), &KinematicBody2D::get_floor_normal);
ClassDB::bind_method(D_METHOD("get_floor_velocity"), &KinematicBody2D::get_floor_velocity);
ClassDB::bind_method(D_METHOD("set_safe_margin", "pixels"), &KinematicBody2D::set_safe_margin);
diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h
index 7f2b42b554..6766bafde3 100644
--- a/scene/2d/physics_body_2d.h
+++ b/scene/2d/physics_body_2d.h
@@ -306,6 +306,7 @@ public:
private:
float margin;
+ Vector2 floor_normal;
Vector2 floor_velocity;
RID on_floor_body;
bool on_floor;
@@ -339,11 +340,12 @@ public:
void set_safe_margin(float p_margin);
float get_safe_margin() const;
- Vector2 move_and_slide(const Vector2 &p_linear_velocity, const Vector2 &p_floor_direction = Vector2(0, 0), bool p_stop_on_slope = false, int p_max_slides = 4, float p_floor_max_angle = Math::deg2rad((float)45), bool p_infinite_inertia = true);
- Vector2 move_and_slide_with_snap(const Vector2 &p_linear_velocity, const Vector2 &p_snap, const Vector2 &p_floor_direction = Vector2(0, 0), bool p_stop_on_slope = false, int p_max_slides = 4, float p_floor_max_angle = Math::deg2rad((float)45), bool p_infinite_inertia = true);
+ Vector2 move_and_slide(const Vector2 &p_linear_velocity, const Vector2 &p_up_direction = Vector2(0, 0), bool p_stop_on_slope = false, int p_max_slides = 4, float p_floor_max_angle = Math::deg2rad((float)45), bool p_infinite_inertia = true);
+ Vector2 move_and_slide_with_snap(const Vector2 &p_linear_velocity, const Vector2 &p_snap, const Vector2 &p_up_direction = Vector2(0, 0), bool p_stop_on_slope = false, int p_max_slides = 4, float p_floor_max_angle = Math::deg2rad((float)45), bool p_infinite_inertia = true);
bool is_on_floor() const;
bool is_on_wall() const;
bool is_on_ceiling() const;
+ Vector2 get_floor_normal() const;
Vector2 get_floor_velocity() const;
int get_slide_count() const;
diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp
index 7b03193fe0..c480423eca 100644
--- a/scene/2d/polygon_2d.cpp
+++ b/scene/2d/polygon_2d.cpp
@@ -33,6 +33,7 @@
#include "core/math/geometry.h"
#include "skeleton_2d.h"
+#ifdef TOOLS_ENABLED
Dictionary Polygon2D::_edit_get_state() const {
Dictionary state = Node2D::_edit_get_state();
state["offset"] = offset;
@@ -87,6 +88,7 @@ bool Polygon2D::_edit_is_selected_on_click(const Point2 &p_point, double p_toler
}
return Geometry::is_point_in_polygon(p_point - get_offset(), polygon2d);
}
+#endif
void Polygon2D::_skeleton_bone_setup_changed() {
update();
diff --git a/scene/2d/polygon_2d.h b/scene/2d/polygon_2d.h
index 84ad221760..07b8828532 100644
--- a/scene/2d/polygon_2d.h
+++ b/scene/2d/polygon_2d.h
@@ -77,6 +77,7 @@ protected:
static void _bind_methods();
public:
+#ifdef TOOLS_ENABLED
virtual Dictionary _edit_get_state() const;
virtual void _edit_set_state(const Dictionary &p_state);
@@ -87,6 +88,7 @@ public:
virtual bool _edit_use_rect() const;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
+#endif
void set_polygon(const PoolVector<Vector2> &p_polygon);
PoolVector<Vector2> get_polygon() const;
diff --git a/scene/2d/position_2d.cpp b/scene/2d/position_2d.cpp
index 49ef92b861..cdeb905c0c 100644
--- a/scene/2d/position_2d.cpp
+++ b/scene/2d/position_2d.cpp
@@ -43,6 +43,7 @@ void Position2D::_draw_cross() {
draw_line(Point2(0, -extents), Point2(0, +extents), Color(0.53, 0.84, 0.01));
}
+#ifdef TOOLS_ENABLED
Rect2 Position2D::_edit_get_rect() const {
float extents = get_gizmo_extents();
@@ -52,6 +53,7 @@ Rect2 Position2D::_edit_get_rect() const {
bool Position2D::_edit_use_rect() const {
return false;
}
+#endif
void Position2D::_notification(int p_what) {
diff --git a/scene/2d/position_2d.h b/scene/2d/position_2d.h
index 711c4ec02f..3ea636171d 100644
--- a/scene/2d/position_2d.h
+++ b/scene/2d/position_2d.h
@@ -44,8 +44,10 @@ protected:
static void _bind_methods();
public:
+#ifdef TOOLS_ENABLED
virtual Rect2 _edit_get_rect() const;
virtual bool _edit_use_rect() const;
+#endif
void set_gizmo_extents(float p_extents);
float get_gizmo_extents() const;
diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp
index 837444532c..55daed0585 100644
--- a/scene/2d/sprite.cpp
+++ b/scene/2d/sprite.cpp
@@ -34,6 +34,7 @@
#include "scene/main/viewport.h"
#include "scene/scene_string_names.h"
+#ifdef TOOLS_ENABLED
Dictionary Sprite::_edit_get_state() const {
Dictionary state = Node2D::_edit_get_state();
state["offset"] = offset;
@@ -58,6 +59,11 @@ bool Sprite::_edit_use_pivot() const {
return true;
}
+bool Sprite::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
+
+ return is_pixel_opaque(p_point);
+}
+
Rect2 Sprite::_edit_get_rect() const {
return get_rect();
}
@@ -65,6 +71,7 @@ Rect2 Sprite::_edit_get_rect() const {
bool Sprite::_edit_use_rect() const {
return texture.is_valid();
}
+#endif
Rect2 Sprite::get_anchorable_rect() const {
return get_rect();
@@ -305,11 +312,6 @@ int Sprite::get_hframes() const {
return hframes;
}
-bool Sprite::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
-
- return is_pixel_opaque(p_point);
-}
-
bool Sprite::is_pixel_opaque(const Point2 &p_point) const {
if (texture.is_null())
diff --git a/scene/2d/sprite.h b/scene/2d/sprite.h
index 2fd97f6611..d72bf3168d 100644
--- a/scene/2d/sprite.h
+++ b/scene/2d/sprite.h
@@ -67,6 +67,7 @@ protected:
virtual void _validate_property(PropertyInfo &property) const;
public:
+#ifdef TOOLS_ENABLED
virtual Dictionary _edit_get_state() const;
virtual void _edit_set_state(const Dictionary &p_state);
@@ -75,10 +76,11 @@ public:
virtual bool _edit_use_pivot() const;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
- bool is_pixel_opaque(const Point2 &p_point) const;
-
virtual Rect2 _edit_get_rect() const;
virtual bool _edit_use_rect() const;
+#endif
+
+ bool is_pixel_opaque(const Point2 &p_point) const;
void set_texture(const Ref<Texture> &p_texture);
Ref<Texture> get_texture() const;
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 04ec13e415..b6db025d44 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -1282,6 +1282,7 @@ PoolVector<int> TileMap::_get_tile_data() const {
return data;
}
+#ifdef TOOLS_ENABLED
Rect2 TileMap::_edit_get_rect() const {
if (pending_update) {
const_cast<TileMap *>(this)->update_dirty_quadrants();
@@ -1290,6 +1291,7 @@ Rect2 TileMap::_edit_get_rect() const {
}
return rect_cache;
}
+#endif
void TileMap::set_collision_layer(uint32_t p_layer) {
diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h
index 53bb696ba2..0875d197eb 100644
--- a/scene/2d/tile_map.h
+++ b/scene/2d/tile_map.h
@@ -244,7 +244,9 @@ public:
INVALID_CELL = -1
};
+#ifdef TOOLS_ENABLED
virtual Rect2 _edit_get_rect() const;
+#endif
void set_tileset(const Ref<TileSet> &p_tileset);
Ref<TileSet> get_tileset() const;
diff --git a/scene/2d/touch_screen_button.cpp b/scene/2d/touch_screen_button.cpp
index f6a888fa09..42d9f88a60 100644
--- a/scene/2d/touch_screen_button.cpp
+++ b/scene/2d/touch_screen_button.cpp
@@ -135,7 +135,9 @@ void TouchScreenButton::_notification(int p_what) {
return;
if (shape.is_valid()) {
Color draw_col = get_tree()->get_debug_collisions_color();
- Vector2 pos = shape_centered ? _edit_get_rect().size * 0.5f : Vector2();
+
+ Vector2 size = texture.is_null() ? shape->get_rect().size : texture->get_size();
+ Vector2 pos = shape_centered ? size * 0.5f : Vector2();
draw_set_transform_matrix(get_canvas_transform().translated(pos));
shape->draw(get_canvas_item(), draw_col);
}
@@ -251,9 +253,7 @@ void TouchScreenButton::_input(const Ref<InputEvent> &p_event) {
}
bool TouchScreenButton::_is_point_inside(const Point2 &p_point) {
-
Point2 coord = (get_global_transform_with_canvas()).affine_inverse().xform(p_point);
- Rect2 item_rect = _edit_get_rect();
bool touched = false;
bool check_rect = true;
@@ -261,7 +261,7 @@ bool TouchScreenButton::_is_point_inside(const Point2 &p_point) {
if (shape.is_valid()) {
check_rect = false;
- Transform2D xform = shape_centered ? Transform2D().translated(item_rect.size * 0.5f) : Transform2D();
+ Transform2D xform = shape_centered ? Transform2D().translated(shape->get_rect().size * 0.5f) : Transform2D();
touched = shape->collide(xform, unit_rect, Transform2D(0, coord + Vector2(0.5, 0.5)));
}
@@ -277,7 +277,7 @@ bool TouchScreenButton::_is_point_inside(const Point2 &p_point) {
if (!touched && check_rect) {
if (texture.is_valid())
- touched = item_rect.has_point(coord);
+ touched = Rect2(Size2(), texture->get_size()).has_point(coord);
}
return touched;
@@ -324,6 +324,7 @@ void TouchScreenButton::_release(bool p_exiting_tree) {
}
}
+#ifdef TOOLS_ENABLED
Rect2 TouchScreenButton::_edit_get_rect() const {
if (texture.is_null())
return CanvasItem::_edit_get_rect();
@@ -334,6 +335,7 @@ Rect2 TouchScreenButton::_edit_get_rect() const {
bool TouchScreenButton::_edit_use_rect() const {
return !texture.is_null();
}
+#endif
Rect2 TouchScreenButton::get_anchorable_rect() const {
if (texture.is_null())
diff --git a/scene/2d/touch_screen_button.h b/scene/2d/touch_screen_button.h
index 9c9fc6125a..28dba59402 100644
--- a/scene/2d/touch_screen_button.h
+++ b/scene/2d/touch_screen_button.h
@@ -74,6 +74,11 @@ protected:
static void _bind_methods();
public:
+#ifdef TOOLS_ENABLED
+ virtual Rect2 _edit_get_rect() const;
+ virtual bool _edit_use_rect() const;
+#endif
+
void set_texture(const Ref<Texture> &p_texture);
Ref<Texture> get_texture() const;
@@ -103,8 +108,6 @@ public:
bool is_pressed() const;
- virtual Rect2 _edit_get_rect() const;
- virtual bool _edit_use_rect() const;
virtual Rect2 get_anchorable_rect() const;
TouchScreenButton();
diff --git a/scene/2d/visibility_notifier_2d.cpp b/scene/2d/visibility_notifier_2d.cpp
index 223e57f39f..0ac725b7dd 100644
--- a/scene/2d/visibility_notifier_2d.cpp
+++ b/scene/2d/visibility_notifier_2d.cpp
@@ -38,6 +38,16 @@
#include "scene/main/viewport.h"
#include "scene/scene_string_names.h"
+#ifdef TOOLS_ENABLED
+Rect2 VisibilityNotifier2D::_edit_get_rect() const {
+ return rect;
+}
+
+bool VisibilityNotifier2D::_edit_use_rect() const {
+ return true;
+}
+#endif
+
void VisibilityNotifier2D::_enter_viewport(Viewport *p_viewport) {
ERR_FAIL_COND(viewports.has(p_viewport));
@@ -84,15 +94,6 @@ void VisibilityNotifier2D::set_rect(const Rect2 &p_rect) {
_change_notify("rect");
}
-Rect2 VisibilityNotifier2D::_edit_get_rect() const {
-
- return rect;
-}
-
-bool VisibilityNotifier2D::_edit_use_rect() const {
- return true;
-}
-
Rect2 VisibilityNotifier2D::get_rect() const {
return rect;
diff --git a/scene/2d/visibility_notifier_2d.h b/scene/2d/visibility_notifier_2d.h
index f9d4c238eb..a3b79d29e9 100644
--- a/scene/2d/visibility_notifier_2d.h
+++ b/scene/2d/visibility_notifier_2d.h
@@ -55,8 +55,10 @@ protected:
static void _bind_methods();
public:
+#ifdef TOOLS_ENABLED
virtual Rect2 _edit_get_rect() const;
virtual bool _edit_use_rect() const;
+#endif
void set_rect(const Rect2 &p_rect);
Rect2 get_rect() const;
diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp
index 289dc0ba07..3a30755f7f 100644
--- a/scene/3d/camera.cpp
+++ b/scene/3d/camera.cpp
@@ -398,9 +398,9 @@ Vector3 Camera::project_position(const Point2 &p_point, float p_z_depth) const {
CameraMatrix cm;
if (mode == PROJECTION_ORTHOGONAL)
- cm.set_orthogonal(size, viewport_size.aspect(), near, far, keep_aspect == KEEP_WIDTH);
+ cm.set_orthogonal(size, viewport_size.aspect(), p_z_depth, far, keep_aspect == KEEP_WIDTH);
else
- cm.set_perspective(fov, viewport_size.aspect(), near, far, keep_aspect == KEEP_WIDTH);
+ cm.set_perspective(fov, viewport_size.aspect(), p_z_depth, far, keep_aspect == KEEP_WIDTH);
Size2 vp_size;
cm.get_viewport_size(vp_size.x, vp_size.y);
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index c2860c25d8..999f39c841 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -1140,7 +1140,7 @@ bool KinematicBody::move_and_collide(const Vector3 &p_motion, bool p_infinite_in
//so, if you pass 45 as limit, avoid numerical precision errors when angle is 45.
#define FLOOR_ANGLE_THRESHOLD 0.01
-Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Vector3 &p_floor_direction, bool p_stop_on_slope, int p_max_slides, float p_floor_max_angle, bool p_infinite_inertia) {
+Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Vector3 &p_up_direction, bool p_stop_on_slope, int p_max_slides, float p_floor_max_angle, bool p_infinite_inertia) {
Vector3 body_velocity = p_linear_velocity;
Vector3 body_velocity_normal = body_velocity.normalized();
@@ -1159,6 +1159,7 @@ Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Ve
on_ceiling = false;
on_wall = false;
colliders.clear();
+ floor_normal = p_up_direction;
floor_velocity = Vector3();
while (p_max_slides) {
@@ -1187,25 +1188,26 @@ Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Ve
colliders.push_back(collision);
motion = collision.remainder;
- if (p_floor_direction == Vector3()) {
+ if (p_up_direction == Vector3()) {
//all is a wall
on_wall = true;
} else {
- if (Math::acos(collision.normal.dot(p_floor_direction)) <= p_floor_max_angle + FLOOR_ANGLE_THRESHOLD) { //floor
+ if (Math::acos(collision.normal.dot(p_up_direction)) <= p_floor_max_angle + FLOOR_ANGLE_THRESHOLD) { //floor
on_floor = true;
+ floor_normal = collision.normal;
on_floor_body = collision.collider_rid;
floor_velocity = collision.collider_vel;
if (p_stop_on_slope) {
- if ((body_velocity_normal + p_floor_direction).length() < 0.01 && collision.travel.length() < 1) {
+ if ((body_velocity_normal + p_up_direction).length() < 0.01 && collision.travel.length() < 1) {
Transform gt = get_global_transform();
- gt.origin -= collision.travel.slide(p_floor_direction);
+ gt.origin -= collision.travel.slide(p_up_direction);
set_global_transform(gt);
return Vector3();
}
}
- } else if (Math::acos(collision.normal.dot(-p_floor_direction)) <= p_floor_max_angle + FLOOR_ANGLE_THRESHOLD) { //ceiling
+ } else if (Math::acos(collision.normal.dot(-p_up_direction)) <= p_floor_max_angle + FLOOR_ANGLE_THRESHOLD) { //ceiling
on_ceiling = true;
} else {
on_wall = true;
@@ -1232,11 +1234,11 @@ Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Ve
return body_velocity;
}
-Vector3 KinematicBody::move_and_slide_with_snap(const Vector3 &p_linear_velocity, const Vector3 &p_snap, const Vector3 &p_floor_direction, bool p_stop_on_slope, int p_max_slides, float p_floor_max_angle, bool p_infinite_inertia) {
+Vector3 KinematicBody::move_and_slide_with_snap(const Vector3 &p_linear_velocity, const Vector3 &p_snap, const Vector3 &p_up_direction, bool p_stop_on_slope, int p_max_slides, float p_floor_max_angle, bool p_infinite_inertia) {
bool was_on_floor = on_floor;
- Vector3 ret = move_and_slide(p_linear_velocity, p_floor_direction, p_stop_on_slope, p_max_slides, p_floor_max_angle, p_infinite_inertia);
+ Vector3 ret = move_and_slide(p_linear_velocity, p_up_direction, p_stop_on_slope, p_max_slides, p_floor_max_angle, p_infinite_inertia);
if (!was_on_floor || p_snap == Vector3()) {
return ret;
}
@@ -1247,15 +1249,16 @@ Vector3 KinematicBody::move_and_slide_with_snap(const Vector3 &p_linear_velocity
if (move_and_collide(p_snap, p_infinite_inertia, col, false, true)) {
bool apply = true;
- if (p_floor_direction != Vector3()) {
- if (Math::acos(p_floor_direction.normalized().dot(col.normal)) < p_floor_max_angle) {
+ if (p_up_direction != Vector3()) {
+ if (Math::acos(p_up_direction.normalized().dot(col.normal)) < p_floor_max_angle) {
on_floor = true;
+ floor_normal = col.normal;
on_floor_body = col.collider_rid;
floor_velocity = col.collider_vel;
if (p_stop_on_slope) {
// move and collide may stray the object a bit because of pre un-stucking,
// so only ensure that motion happens on floor direction in this case.
- col.travel = col.travel.project(p_floor_direction);
+ col.travel = col.travel.project(p_up_direction);
}
} else {
apply = false; //snapped with floor direction, but did not snap to a floor, do not snap.
@@ -1284,6 +1287,11 @@ bool KinematicBody::is_on_ceiling() const {
return on_ceiling;
}
+Vector3 KinematicBody::get_floor_normal() const {
+
+ return floor_normal;
+}
+
Vector3 KinematicBody::get_floor_velocity() const {
return floor_velocity;
@@ -1392,7 +1400,7 @@ void KinematicBody::_notification(int p_what) {
void KinematicBody::_bind_methods() {
ClassDB::bind_method(D_METHOD("move_and_collide", "rel_vec", "infinite_inertia", "exclude_raycast_shapes", "test_only"), &KinematicBody::_move, DEFVAL(true), DEFVAL(true), DEFVAL(false));
- ClassDB::bind_method(D_METHOD("move_and_slide", "linear_velocity", "floor_normal", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody::move_and_slide, DEFVAL(Vector3(0, 0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("move_and_slide", "linear_velocity", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody::move_and_slide, DEFVAL(Vector3(0, 0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true));
ClassDB::bind_method(D_METHOD("move_and_slide_with_snap", "linear_velocity", "snap", "floor_normal", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody::move_and_slide_with_snap, DEFVAL(Vector3(0, 0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true));
ClassDB::bind_method(D_METHOD("test_move", "from", "rel_vec", "infinite_inertia"), &KinematicBody::test_move, DEFVAL(true));
@@ -1400,6 +1408,7 @@ void KinematicBody::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_on_floor"), &KinematicBody::is_on_floor);
ClassDB::bind_method(D_METHOD("is_on_ceiling"), &KinematicBody::is_on_ceiling);
ClassDB::bind_method(D_METHOD("is_on_wall"), &KinematicBody::is_on_wall);
+ ClassDB::bind_method(D_METHOD("get_floor_normal"), &KinematicBody::get_floor_normal);
ClassDB::bind_method(D_METHOD("get_floor_velocity"), &KinematicBody::get_floor_velocity);
ClassDB::bind_method(D_METHOD("set_axis_lock", "axis", "lock"), &KinematicBody::set_axis_lock);
diff --git a/scene/3d/physics_body.h b/scene/3d/physics_body.h
index 06b31804b2..05bcbe22f0 100644
--- a/scene/3d/physics_body.h
+++ b/scene/3d/physics_body.h
@@ -300,6 +300,7 @@ private:
float margin;
+ Vector3 floor_normal;
Vector3 floor_velocity;
RID on_floor_body;
bool on_floor;
@@ -330,11 +331,12 @@ public:
void set_safe_margin(float p_margin);
float get_safe_margin() const;
- Vector3 move_and_slide(const Vector3 &p_linear_velocity, const Vector3 &p_floor_direction = Vector3(0, 0, 0), bool p_stop_on_slope = false, int p_max_slides = 4, float p_floor_max_angle = Math::deg2rad((float)45), bool p_infinite_inertia = true);
- Vector3 move_and_slide_with_snap(const Vector3 &p_linear_velocity, const Vector3 &p_snap, const Vector3 &p_floor_direction = Vector3(0, 0, 0), bool p_stop_on_slope = false, int p_max_slides = 4, float p_floor_max_angle = Math::deg2rad((float)45), bool p_infinite_inertia = true);
+ Vector3 move_and_slide(const Vector3 &p_linear_velocity, const Vector3 &p_up_direction = Vector3(0, 0, 0), bool p_stop_on_slope = false, int p_max_slides = 4, float p_floor_max_angle = Math::deg2rad((float)45), bool p_infinite_inertia = true);
+ Vector3 move_and_slide_with_snap(const Vector3 &p_linear_velocity, const Vector3 &p_snap, const Vector3 &p_up_direction = Vector3(0, 0, 0), bool p_stop_on_slope = false, int p_max_slides = 4, float p_floor_max_angle = Math::deg2rad((float)45), bool p_infinite_inertia = true);
bool is_on_floor() const;
bool is_on_wall() const;
bool is_on_ceiling() const;
+ Vector3 get_floor_normal() const;
Vector3 get_floor_velocity() const;
int get_slide_count() const;
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index 65912c1c07..b2020d44e8 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -165,7 +165,7 @@ void BaseButton::on_action_event(Ref<InputEvent> p_event) {
_pressed();
}
} else {
- if (!p_event->is_pressed()) {
+ if ((p_event->is_pressed() && action_mode == ACTION_MODE_BUTTON_PRESS) || (!p_event->is_pressed() && action_mode == ACTION_MODE_BUTTON_RELEASE)) {
_pressed();
}
}
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 5e656eea70..9a67745e0d 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -47,6 +47,7 @@
#include "editor/plugins/canvas_item_editor_plugin.h"
#endif
+#ifdef TOOLS_ENABLED
Dictionary Control::_edit_get_state() const {
Dictionary s;
@@ -155,6 +156,11 @@ bool Control::_edit_use_pivot() const {
return true;
}
+Size2 Control::_edit_get_minimum_size() const {
+ return get_combined_minimum_size();
+}
+#endif
+
void Control::set_custom_minimum_size(const Size2 &p_custom) {
if (p_custom == data.custom_minimum_size)
@@ -193,11 +199,6 @@ Size2 Control::get_combined_minimum_size() const {
return data.minimum_size_cache;
}
-Size2 Control::_edit_get_minimum_size() const {
-
- return get_combined_minimum_size();
-}
-
Transform2D Control::_get_internal_transform() const {
Transform2D rot_scale;
diff --git a/scene/gui/control.h b/scene/gui/control.h
index a9831b9793..357858beb6 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -279,6 +279,7 @@ public:
};
/* EDITOR */
+#ifdef TOOLS_ENABLED
virtual Dictionary _edit_get_state() const;
virtual void _edit_set_state(const Dictionary &p_state);
@@ -301,6 +302,7 @@ public:
virtual bool _edit_use_pivot() const;
virtual Size2 _edit_get_minimum_size() const;
+#endif
void accept_event();
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index 6b12947651..77913efd1c 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -35,9 +35,17 @@
void Label::set_autowrap(bool p_autowrap) {
+ if (autowrap == p_autowrap) {
+ return;
+ }
+
autowrap = p_autowrap;
word_cache_dirty = true;
update();
+
+ if (clip) {
+ minimum_size_changed();
+ }
}
bool Label::has_autowrap() const {
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 8f5f6beac3..a6cd9a0665 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -557,8 +557,11 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
if (editable) {
selection_delete();
CharType ucodestr[2] = { (CharType)k->get_unicode(), 0 };
+ int prev_len = text.length();
append_at_cursor(ucodestr);
- _text_changed();
+ if (text.length() != prev_len) {
+ _text_changed();
+ }
accept_event();
}
@@ -961,11 +964,12 @@ void LineEdit::paste_text() {
if (paste_buffer != "") {
+ int prev_len = text.length();
if (selection.enabled) selection_delete();
append_at_cursor(paste_buffer);
if (!text_changed_dirty) {
- if (is_inside_tree()) {
+ if (is_inside_tree() && text.length() != prev_len) {
MessageQueue::get_singleton()->push_call(this, "_text_changed");
}
text_changed_dirty = true;
@@ -1189,7 +1193,7 @@ void LineEdit::delete_char() {
set_cursor_position(get_cursor_position() - 1);
if (align == ALIGN_CENTER || align == ALIGN_RIGHT) {
- window_pos = CLAMP(window_pos - 1, 0, text.length() - 1);
+ window_pos = CLAMP(window_pos - 1, 0, MAX(text.length() - 1, 0));
}
_text_changed();
@@ -1220,7 +1224,7 @@ void LineEdit::delete_text(int p_from_column, int p_to_column) {
}
if (align == ALIGN_CENTER || align == ALIGN_RIGHT) {
- window_pos = CLAMP(window_pos - (p_to_column - p_from_column), 0, text.length() - 1);
+ window_pos = CLAMP(window_pos - (p_to_column - p_from_column), 0, MAX(text.length() - 1, 0));
}
if (!text_changed_dirty) {
@@ -1362,6 +1366,8 @@ void LineEdit::append_at_cursor(String p_text) {
String post = text.substr(cursor_pos, text.length() - cursor_pos);
text = pre + p_text + post;
set_cursor_position(cursor_pos + p_text.length());
+ } else {
+ emit_signal("text_change_rejected");
}
}
@@ -1781,6 +1787,7 @@ void LineEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_right_icon"), &LineEdit::get_right_icon);
ADD_SIGNAL(MethodInfo("text_changed", PropertyInfo(Variant::STRING, "new_text")));
+ ADD_SIGNAL(MethodInfo("text_change_rejected"));
ADD_SIGNAL(MethodInfo("text_entered", PropertyInfo(Variant::STRING, "new_text")));
BIND_ENUM_CONSTANT(ALIGN_LEFT);
diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp
index 9505c0af39..225b382524 100644
--- a/servers/visual/shader_language.cpp
+++ b/servers/visual/shader_language.cpp
@@ -4542,8 +4542,13 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
}
p_block->statements.push_back(flow);
- if (p_block->block_type == BlockNode::BLOCK_TYPE_CASE || p_block->block_type == BlockNode::BLOCK_TYPE_DEFAULT) {
- return OK;
+
+ BlockNode *block = p_block;
+ while (block) {
+ if (block->block_type == BlockNode::BLOCK_TYPE_CASE || block->block_type == BlockNode::BLOCK_TYPE_DEFAULT) {
+ return OK;
+ }
+ block = block->parent_block;
}
} else if (tk.type == TK_CF_DISCARD) {
@@ -4591,8 +4596,13 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
}
p_block->statements.push_back(flow);
- if (p_block->block_type == BlockNode::BLOCK_TYPE_CASE || p_block->block_type == BlockNode::BLOCK_TYPE_DEFAULT) {
- return OK;
+
+ BlockNode *block = p_block;
+ while (block) {
+ if (block->block_type == BlockNode::BLOCK_TYPE_CASE || block->block_type == BlockNode::BLOCK_TYPE_DEFAULT) {
+ return OK;
+ }
+ block = block->parent_block;
}
} else if (tk.type == TK_CF_CONTINUE) {