diff options
27 files changed, 203 insertions, 93 deletions
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 1904c70f42..bfa272e859 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -173,6 +173,7 @@ Error HTTPClient::request_raw(Method p_method, const String &p_url, const Vector } status = STATUS_REQUESTING; + head_request = p_method == METHOD_HEAD; return OK; } @@ -228,6 +229,7 @@ Error HTTPClient::request(Method p_method, const String &p_url, const Vector<Str } status = STATUS_REQUESTING; + head_request = p_method == METHOD_HEAD; return OK; } @@ -269,6 +271,7 @@ void HTTPClient::close() { connection.unref(); status = STATUS_DISCONNECTED; + head_request = false; if (resolving != IP::RESOLVER_INVALID_ID) { IP::get_singleton()->erase_resolve_item(resolving); @@ -470,6 +473,12 @@ Error HTTPClient::poll() { } } + // This is a HEAD request, we wont receive anything. + if (head_request) { + body_size = 0; + body_left = 0; + } + if (body_size != -1 || chunked) { status = STATUS_BODY; @@ -724,6 +733,7 @@ HTTPClient::HTTPClient() { tcp_connection.instance(); resolving = IP::RESOLVER_INVALID_ID; status = STATUS_DISCONNECTED; + head_request = false; conn_port = -1; body_size = -1; chunked = false; diff --git a/core/io/http_client.h b/core/io/http_client.h index ce7fe0491b..27c6711bcf 100644 --- a/core/io/http_client.h +++ b/core/io/http_client.h @@ -166,6 +166,7 @@ private: bool ssl_verify_host; bool blocking; bool handshaking; + bool head_request; Vector<uint8_t> response_str; diff --git a/doc/classes/AABB.xml b/doc/classes/AABB.xml index 61e1ea9b8d..44f1d9a921 100644 --- a/doc/classes/AABB.xml +++ b/doc/classes/AABB.xml @@ -182,6 +182,7 @@ <argument index="0" name="aabb" type="AABB"> </argument> <description> + Returns [code]true[/code] if this [AABB] and [code]aabb[/code] are approximately equal, by calling [code]is_equal_approx[/code] on each component. </description> </method> <method name="merge"> @@ -190,7 +191,7 @@ <argument index="0" name="with" type="AABB"> </argument> <description> - Returns a larger AABB that contains this AABB and [code]with[/code]. + Returns a larger [AABB] that contains both this [AABB] and [code]with[/code]. </description> </method> </methods> diff --git a/doc/classes/Basis.xml b/doc/classes/Basis.xml index df9438e695..5a7fc0a41b 100644 --- a/doc/classes/Basis.xml +++ b/doc/classes/Basis.xml @@ -102,6 +102,7 @@ <argument index="1" name="epsilon" type="float" default="0.00001"> </argument> <description> + Returns [code]true[/code] if this basis and [code]b[/code] are approximately equal, by calling [code]is_equal_approx[/code] on each component. </description> </method> <method name="orthonormalized"> diff --git a/doc/classes/Color.xml b/doc/classes/Color.xml index deba30712e..1d4225542a 100644 --- a/doc/classes/Color.xml +++ b/doc/classes/Color.xml @@ -157,6 +157,7 @@ <argument index="0" name="color" type="Color"> </argument> <description> + Returns [code]true[/code] if this color and [code]color[/code] are approximately equal, by running [method @GDScript.is_equal_approx] on each component. </description> </method> <method name="lightened"> diff --git a/doc/classes/MeshLibrary.xml b/doc/classes/MeshLibrary.xml index 44dc4f334f..49278be44e 100644 --- a/doc/classes/MeshLibrary.xml +++ b/doc/classes/MeshLibrary.xml @@ -4,7 +4,7 @@ Library of meshes. </brief_description> <description> - A library of meshes. Contains a list of [Mesh] resources, each with a name and ID. This resource is used in [GridMap]. + A library of meshes. Contains a list of [Mesh] resources, each with a name and ID. Each item can also include collision and navigation shapes. This resource is used in [GridMap]. </description> <tutorials> </tutorials> @@ -22,7 +22,8 @@ <argument index="0" name="id" type="int"> </argument> <description> - Create a new item in the library, supplied as an ID. + Creates a new item in the library with the given ID. + You can get an unused ID from [method get_last_unused_item_id]. </description> </method> <method name="find_item_by_name" qualifiers="const"> @@ -31,13 +32,14 @@ <argument index="0" name="name" type="String"> </argument> <description> + Returns the first item with the given name. </description> </method> <method name="get_item_list" qualifiers="const"> <return type="PoolIntArray"> </return> <description> - Returns the list of items. + Returns the list of item IDs in use. </description> </method> <method name="get_item_mesh" qualifiers="const"> @@ -46,7 +48,7 @@ <argument index="0" name="id" type="int"> </argument> <description> - Returns the mesh of the item. + Returns the item's mesh. </description> </method> <method name="get_item_name" qualifiers="const"> @@ -55,7 +57,7 @@ <argument index="0" name="id" type="int"> </argument> <description> - Returns the name of the item. + Returns the item's name. </description> </method> <method name="get_item_navmesh" qualifiers="const"> @@ -64,6 +66,7 @@ <argument index="0" name="id" type="int"> </argument> <description> + Returns the item's navigation mesh. </description> </method> <method name="get_item_navmesh_transform" qualifiers="const"> @@ -72,6 +75,7 @@ <argument index="0" name="id" type="int"> </argument> <description> + Returns the transform applied to the item's navigation mesh. </description> </method> <method name="get_item_preview" qualifiers="const"> @@ -90,6 +94,8 @@ <argument index="0" name="id" type="int"> </argument> <description> + Returns an item's collision shapes. + The array consists of each [Shape] followed by its [Transform]. </description> </method> <method name="get_last_unused_item_id" qualifiers="const"> @@ -128,6 +134,7 @@ </argument> <description> Sets the item's name. + This name is shown in the editor. It can also be used to look up the item later using [method find_item_by_name]. </description> </method> <method name="set_item_navmesh"> @@ -138,6 +145,7 @@ <argument index="1" name="navmesh" type="NavigationMesh"> </argument> <description> + Sets the item's navigation mesh. </description> </method> <method name="set_item_navmesh_transform"> @@ -148,6 +156,7 @@ <argument index="1" name="navmesh" type="Transform"> </argument> <description> + Sets the transform to apply to the item's navigation mesh. </description> </method> <method name="set_item_preview"> @@ -158,6 +167,7 @@ <argument index="1" name="texture" type="Texture"> </argument> <description> + Sets a texture to use as the item's preview icon in the editor. </description> </method> <method name="set_item_shapes"> @@ -168,6 +178,8 @@ <argument index="1" name="shapes" type="Array"> </argument> <description> + Sets an item's collision shapes. + The array should consist of [Shape] objects, each followed by a [Transform] that will be applied to it. For shapes that should not have a transform, use [constant Transform.IDENTITY]. </description> </method> </methods> diff --git a/doc/classes/Plane.xml b/doc/classes/Plane.xml index bb72f2734e..f179041327 100644 --- a/doc/classes/Plane.xml +++ b/doc/classes/Plane.xml @@ -122,6 +122,7 @@ <argument index="0" name="plane" type="Plane"> </argument> <description> + Returns [code]true[/code] if this plane and [code]plane[/code] are approximately equal, by running [method @GDScript.is_equal_approx] on each component. </description> </method> <method name="is_point_over"> diff --git a/doc/classes/Quat.xml b/doc/classes/Quat.xml index f5ee99d30c..eeb633f480 100644 --- a/doc/classes/Quat.xml +++ b/doc/classes/Quat.xml @@ -100,6 +100,7 @@ <argument index="0" name="quat" type="Quat"> </argument> <description> + Returns [code]true[/code] if this quaterion and [code]quat[/code] are approximately equal, by running [method @GDScript.is_equal_approx] on each component. </description> </method> <method name="is_normalized"> diff --git a/doc/classes/Rect2.xml b/doc/classes/Rect2.xml index 07fa7777fe..90dd996691 100644 --- a/doc/classes/Rect2.xml +++ b/doc/classes/Rect2.xml @@ -143,6 +143,7 @@ <argument index="0" name="rect" type="Rect2"> </argument> <description> + Returns [code]true[/code] if this [Rect2] and [code]rect[/code] are approximately equal, by calling [code]is_equal_approx[/code] on each component. </description> </method> <method name="merge"> @@ -151,7 +152,7 @@ <argument index="0" name="b" type="Rect2"> </argument> <description> - Returns a larger Rect2 that contains this Rect2 and [code]b[/code]. + Returns a larger [Rect2] that contains this [Rect2] and [code]b[/code]. </description> </method> </methods> diff --git a/doc/classes/Script.xml b/doc/classes/Script.xml index e8a88acdb5..91014580d3 100644 --- a/doc/classes/Script.xml +++ b/doc/classes/Script.xml @@ -4,7 +4,7 @@ A class stored as a resource. </brief_description> <description> - A class stored as a resource. A script exends the functionality of all objects that instance it. + A class stored as a resource. A script extends the functionality of all objects that instance it. The [code]new[/code] method of a script subclass creates a new instance. [method Object.set_script] extends an existing object, if that object's class matches one of the script's base classes. </description> <tutorials> diff --git a/doc/classes/Transform.xml b/doc/classes/Transform.xml index 034a1b2f5b..4c4022b3b5 100644 --- a/doc/classes/Transform.xml +++ b/doc/classes/Transform.xml @@ -95,6 +95,7 @@ <argument index="0" name="transform" type="Transform"> </argument> <description> + Returns [code]true[/code] if this transform and [code]transform[/code] are approximately equal, by calling [code]is_equal_approx[/code] on each component. </description> </method> <method name="looking_at"> diff --git a/doc/classes/Transform2D.xml b/doc/classes/Transform2D.xml index 89ccffc2e9..6288bb074c 100644 --- a/doc/classes/Transform2D.xml +++ b/doc/classes/Transform2D.xml @@ -112,6 +112,7 @@ <argument index="0" name="transform" type="Transform2D"> </argument> <description> + Returns [code]true[/code] if this transform and [code]transform[/code] are approximately equal, by calling [code]is_equal_approx[/code] on each component. </description> </method> <method name="orthonormalized"> diff --git a/doc/classes/Vector2.xml b/doc/classes/Vector2.xml index 8ae5caf68c..b23c69de60 100644 --- a/doc/classes/Vector2.xml +++ b/doc/classes/Vector2.xml @@ -159,6 +159,7 @@ <argument index="0" name="v" type="Vector2"> </argument> <description> + Returns [code]true[/code] if this vector and [code]v[/code] are approximately equal, by running [method @GDScript.is_equal_approx] on each component. </description> </method> <method name="is_normalized"> diff --git a/doc/classes/Vector3.xml b/doc/classes/Vector3.xml index 29c24709e2..d838e6d2f7 100644 --- a/doc/classes/Vector3.xml +++ b/doc/classes/Vector3.xml @@ -135,6 +135,7 @@ <argument index="0" name="v" type="Vector3"> </argument> <description> + Returns [code]true[/code] if this vector and [code]v[/code] are approximately equal, by running [method @GDScript.is_equal_approx] on each component. </description> </method> <method name="is_normalized"> diff --git a/doc/tools/makerst.py b/doc/tools/makerst.py index ef38299680..de53259827 100755 --- a/doc/tools/makerst.py +++ b/doc/tools/makerst.py @@ -148,6 +148,8 @@ class State: setter = property.get("setter") or None # Use or None so '' gets turned into None. getter = property.get("getter") or None default_value = property.get("default") or None + if default_value is not None: + default_value = escape_rst(default_value) overridden = property.get("override") or False property_def = PropertyDef(property_name, type_name, setter, getter, property.text, default_value, overridden) @@ -622,6 +624,40 @@ def make_class_list(class_list, columns): # type: (List[str], int) -> None f.close() +def escape_rst(text, until_pos=-1): # type: (str) -> str + # Escape \ character, otherwise it ends up as an escape character in rst + pos = 0 + while True: + pos = text.find('\\', pos, until_pos) + if pos == -1: + break + text = text[:pos] + "\\\\" + text[pos + 1:] + pos += 2 + + # Escape * character to avoid interpreting it as emphasis + pos = 0 + while True: + pos = text.find('*', pos, until_pos) + if pos == -1: + break + text = text[:pos] + "\*" + text[pos + 1:] + pos += 2 + + # Escape _ character at the end of a word to avoid interpreting it as an inline hyperlink + pos = 0 + while True: + pos = text.find('_', pos, until_pos) + if pos == -1: + break + if not text[pos + 1].isalnum(): # don't escape within a snake_case word + text = text[:pos] + "\_" + text[pos + 1:] + pos += 2 + else: + pos += 1 + + return text + + def rstize_text(text, state): # type: (str, State) -> str # Linebreak + tabs in the XML should become two line breaks unless in a "codeblock" pos = 0 @@ -677,36 +713,7 @@ def rstize_text(text, state): # type: (str, State) -> str pos += 2 next_brac_pos = text.find('[') - - # Escape \ character, otherwise it ends up as an escape character in rst - pos = 0 - while True: - pos = text.find('\\', pos, next_brac_pos) - if pos == -1: - break - text = text[:pos] + "\\\\" + text[pos + 1:] - pos += 2 - - # Escape * character to avoid interpreting it as emphasis - pos = 0 - while True: - pos = text.find('*', pos, next_brac_pos) - if pos == -1: - break - text = text[:pos] + "\*" + text[pos + 1:] - pos += 2 - - # Escape _ character at the end of a word to avoid interpreting it as an inline hyperlink - pos = 0 - while True: - pos = text.find('_', pos, next_brac_pos) - if pos == -1: - break - if not text[pos + 1].isalnum(): # don't escape within a snake_case word - text = text[:pos] + "\_" + text[pos + 1:] - pos += 2 - else: - pos += 1 + text = escape_rst(text, next_brac_pos) # Handle [tags] inside_code = False diff --git a/editor/plugins/skeleton_editor_plugin.cpp b/editor/plugins/skeleton_editor_plugin.cpp index cd360d4caf..1adf0be108 100644 --- a/editor/plugins/skeleton_editor_plugin.cpp +++ b/editor/plugins/skeleton_editor_plugin.cpp @@ -65,7 +65,6 @@ void SkeletonEditor::create_physical_skeleton() { for (int bone_id = 0; bc > bone_id; ++bone_id) { const int parent = skeleton->get_bone_parent(bone_id); - const int parent_parent = skeleton->get_bone_parent(parent); if (parent < 0) { @@ -73,6 +72,8 @@ void SkeletonEditor::create_physical_skeleton() { } else { + const int parent_parent = skeleton->get_bone_parent(parent); + bones_infos.write[bone_id].relative_rest = bones_infos[parent].relative_rest * skeleton->get_bone_rest(bone_id); /// create physical bone on parent diff --git a/main/main.cpp b/main/main.cpp index 22a31d597e..e6fba3c7b4 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -2090,6 +2090,11 @@ void Main::cleanup() { ERR_FAIL_COND(!_start_success); + if (script_debugger) { + // Flush any remaining messages + script_debugger->idle_poll(); + } + ResourceLoader::remove_custom_loaders(); ResourceSaver::remove_custom_savers(); diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index 7c313c983f..768b12baea 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -119,7 +119,10 @@ String NativeScript::get_class_name() const { void NativeScript::set_library(Ref<GDNativeLibrary> p_library) { if (!library.is_null()) { - WARN_PRINT("library on NativeScript already set. Do nothing."); + WARN_PRINT("Library in NativeScript already set. Do nothing."); + return; + } + if (p_library.is_null()) { return; } library = p_library; diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml index a22d18b970..949663c5ea 100644 --- a/modules/gdscript/doc_classes/@GDScript.xml +++ b/modules/gdscript/doc_classes/@GDScript.xml @@ -502,7 +502,7 @@ <argument index="1" name="b" type="float"> </argument> <description> - Returns True/False whether [code]a[/code] and [code]b[/code] are approximately equal to each other. + Returns [code]true[/code] if [code]a[/code] and [code]b[/code] are approximately equal to each other. </description> </method> <method name="is_inf"> @@ -538,7 +538,7 @@ <argument index="0" name="s" type="float"> </argument> <description> - Returns True/False whether [code]s[/code] is zero or almost zero. + Returns [code]true[/code] if [code]s[/code] is zero or almost zero. </description> </method> <method name="len"> diff --git a/modules/gdscript/doc_classes/GDScript.xml b/modules/gdscript/doc_classes/GDScript.xml index 6f43361914..8e175a7ab8 100644 --- a/modules/gdscript/doc_classes/GDScript.xml +++ b/modules/gdscript/doc_classes/GDScript.xml @@ -4,7 +4,7 @@ A script implemented in the GDScript programming language. </brief_description> <description> - A script implemented in the GDScript programming language. The script exends the functionality of all objects that instance it. + A script implemented in the GDScript programming language. The script extends the functionality of all objects that instance it. [method new] creates a new instance of the script. [method Object.set_script] extends an existing object, if that object's class matches one of the script's base classes. </description> <tutorials> diff --git a/modules/gridmap/doc_classes/GridMap.xml b/modules/gridmap/doc_classes/GridMap.xml index b762868f2c..3de971db6d 100644 --- a/modules/gridmap/doc_classes/GridMap.xml +++ b/modules/gridmap/doc_classes/GridMap.xml @@ -4,10 +4,10 @@ Node for 3D tile-based maps. </brief_description> <description> - GridMap lets you place meshes on a grid interactively. It works both from the editor and can help you create in-game level editors. - GridMaps use a [MeshLibrary] which contain a list of tiles: meshes with materials plus optional collisions and extra elements. - A GridMap contains a collection of cells. Each grid cell refers to a [MeshLibrary] item. All cells in the map have the same dimensions. - A GridMap is split into a sparse collection of octants for efficient rendering and physics processing. Every octant has the same dimensions and can contain several cells. + GridMap lets you place meshes on a grid interactively. It works both from the editor and from scripts, which can help you create in-game level editors. + GridMaps use a [MeshLibrary] which contains a list of tiles. Each tile is a mesh with materials plus optional collision and navigation shapes. + A GridMap contains a collection of cells. Each grid cell refers to a tile in the [MeshLibrary]. All cells in the map have the same dimensions. + Internally, a GridMap is split into a sparse collection of octants for efficient rendering and physics processing. Every octant has the same dimensions and can contain several cells. </description> <tutorials> <link>https://docs.godotengine.org/en/latest/tutorials/3d/using_gridmaps.html</link> @@ -72,6 +72,7 @@ <argument index="0" name="bit" type="int"> </argument> <description> + Returns an individual bit on the [member collision_layer]. </description> </method> <method name="get_collision_mask_bit" qualifiers="const"> @@ -80,20 +81,21 @@ <argument index="0" name="bit" type="int"> </argument> <description> + Returns an individual bit on the [member collision_mask]. </description> </method> <method name="get_meshes"> <return type="Array"> </return> <description> - Array of [Transform] and [Mesh] references corresponding to the non-empty cells in the grid. The transforms are specified in world space. + Returns an array of [Transform] and [Mesh] references corresponding to the non-empty cells in the grid. The transforms are specified in world space. </description> </method> <method name="get_used_cells" qualifiers="const"> <return type="Array"> </return> <description> - Array of [Vector3] with the non-empty cell coordinates in the grid map. + Returns an array of [Vector3] with the non-empty cell coordinates in the grid map. </description> </method> <method name="make_baked_meshes"> @@ -116,6 +118,7 @@ <argument index="2" name="z" type="int"> </argument> <description> + Returns the position of a grid cell in the GridMap's local coordinate space. </description> </method> <method name="resource_changed"> @@ -140,9 +143,9 @@ <argument index="4" name="orientation" type="int" default="0"> </argument> <description> - Set the mesh index for the cell referenced by its grid-based X, Y and Z coordinates. - A negative item index will clear the cell. - Optionally, the item's orientation can be passed. + Sets the mesh index for the cell referenced by its grid-based X, Y and Z coordinates. + A negative item index such as [constant INVALID_CELL_ITEM] will clear the cell. + Optionally, the item's orientation can be passed. For valid orientation values, see [method Basis.get_orthogonal_index]. </description> </method> <method name="set_clip"> @@ -167,6 +170,7 @@ <argument index="1" name="value" type="bool"> </argument> <description> + Sets an individual bit on the [member collision_layer]. </description> </method> <method name="set_collision_mask_bit"> @@ -177,6 +181,7 @@ <argument index="1" name="value" type="bool"> </argument> <description> + Sets an individual bit on the [member collision_mask]. </description> </method> <method name="world_to_map" qualifiers="const"> @@ -185,6 +190,8 @@ <argument index="0" name="pos" type="Vector3"> </argument> <description> + Returns the coordinates of the grid cell containing the given point. + [code]pos[/code] should be in the GridMap's local coordinate space. </description> </method> </methods> @@ -202,26 +209,30 @@ The size of each octant measured in number of cells. This applies to all three axis. </member> <member name="cell_scale" type="float" setter="set_cell_scale" getter="get_cell_scale" default="1.0"> + The scale of the cell items. + This does not affect the size of the grid cells themselves, only the items in them. This can be used to make cell items overlap their neighbors. </member> <member name="cell_size" type="Vector3" setter="set_cell_size" getter="get_cell_size" default="Vector3( 2, 2, 2 )"> The dimensions of the grid's cells. + This does not affect the size of the meshes. See [member cell_scale]. </member> <member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="1"> + The physics layers this GridMap is in. + GridMaps act as static bodies, meaning they aren't affected by gravity or other forces. They only affect other physics bodies that collide with them. </member> <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1"> + The physics layers this GridMap detects collisions in. </member> <member name="mesh_library" type="MeshLibrary" setter="set_mesh_library" getter="get_mesh_library"> The assigned [MeshLibrary]. </member> - <member name="theme" type="MeshLibrary" setter="set_theme" getter="get_theme"> - Deprecated, use [member mesh_library] instead. - </member> </members> <signals> <signal name="cell_size_changed"> <argument index="0" name="cell_size" type="Vector3"> </argument> <description> + Emitted when [member cell_size] changes. </description> </signal> </signals> diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp index 55c8c7f229..18ace5892a 100644 --- a/scene/2d/path_2d.cpp +++ b/scene/2d/path_2d.cpp @@ -173,16 +173,10 @@ void PathFollow2D::_update_transform() { if (path_length == 0) { return; } - float bounded_offset = offset; - if (loop) - bounded_offset = Math::fposmod(bounded_offset, path_length); - else - bounded_offset = CLAMP(bounded_offset, 0, path_length); - - Vector2 pos = c->interpolate_baked(bounded_offset, cubic); + Vector2 pos = c->interpolate_baked(offset, cubic); if (rotate) { - float ahead = bounded_offset + lookahead; + float ahead = offset + lookahead; if (loop && ahead >= path_length) { // If our lookahead will loop, we need to check if the path is closed. @@ -206,7 +200,7 @@ void PathFollow2D::_update_transform() { // This will happen at the end of non-looping or non-closed paths. // We'll try a look behind instead, in order to get a meaningful angle. tangent_to_curve = - (pos - c->interpolate_baked(bounded_offset - lookahead, cubic)).normalized(); + (pos - c->interpolate_baked(offset - lookahead, cubic)).normalized(); } else { tangent_to_curve = (ahead_pos - pos).normalized(); } diff --git a/scene/3d/path.cpp b/scene/3d/path.cpp index d55c795d38..62684bd1e1 100644 --- a/scene/3d/path.cpp +++ b/scene/3d/path.cpp @@ -111,18 +111,15 @@ void PathFollow::_update_transform() { return; } float bi = c->get_bake_interval(); - float o = offset; float o_next = offset + bi; if (loop) { - o = Math::fposmod(o, bl); o_next = Math::fposmod(o_next, bl); } else if (rotation_mode == ROTATION_ORIENTED && o_next >= bl) { - o = bl - bi; o_next = bl; } - Vector3 pos = c->interpolate_baked(o, cubic); + Vector3 pos = c->interpolate_baked(offset, cubic); Transform t = get_transform(); // Vector3 pos_offset = Vector3(h_offset, v_offset, 0); not used in all cases // will be replaced by "Vector3(h_offset, v_offset, 0)" where it was formerly used @@ -136,9 +133,9 @@ void PathFollow::_update_transform() { else forward.normalize(); - Vector3 up = c->interpolate_baked_up_vector(o, true); + Vector3 up = c->interpolate_baked_up_vector(offset, true); - if (o_next < o) { + if (o_next < offset) { Vector3 up1 = c->interpolate_baked_up_vector(o_next, true); Vector3 axis = up.cross(up1); @@ -166,8 +163,8 @@ void PathFollow::_update_transform() { t.origin = pos; - Vector3 t_prev = (pos - c->interpolate_baked(o - delta_offset, cubic)).normalized(); - Vector3 t_cur = (c->interpolate_baked(o + delta_offset, cubic) - pos).normalized(); + Vector3 t_prev = (pos - c->interpolate_baked(offset - delta_offset, cubic)).normalized(); + Vector3 t_cur = (c->interpolate_baked(offset + delta_offset, cubic) - pos).normalized(); Vector3 axis = t_prev.cross(t_cur); float dot = t_prev.dot(t_cur); @@ -190,7 +187,7 @@ void PathFollow::_update_transform() { } // do the additional tilting - float tilt_angle = c->interpolate_baked_tilt(o); + float tilt_angle = c->interpolate_baked_tilt(offset); Vector3 tilt_axis = t_cur; // not sure what tilt is supposed to do, is this correct?? if (likely(!Math::is_zero_approx(Math::abs(tilt_angle)))) { @@ -256,7 +253,7 @@ void PathFollow::_validate_property(PropertyInfo &property) const { if (path && path->get_curve().is_valid()) max = path->get_curve()->get_baked_length(); - property.hint_string = "0," + rtos(max) + ",0.01,or_greater"; + property.hint_string = "0," + rtos(max) + ",0.01,or_lesser"; } } @@ -300,8 +297,8 @@ void PathFollow::_bind_methods() { ClassDB::bind_method(D_METHOD("set_loop", "loop"), &PathFollow::set_loop); ClassDB::bind_method(D_METHOD("has_loop"), &PathFollow::has_loop); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "offset", PROPERTY_HINT_RANGE, "0,10000,0.01,or_greater"), "set_offset", "get_offset"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "unit_offset", PROPERTY_HINT_RANGE, "0,1,0.0001,or_greater", PROPERTY_USAGE_EDITOR), "set_unit_offset", "get_unit_offset"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "offset", PROPERTY_HINT_RANGE, "0,10000,0.01,or_lesser"), "set_offset", "get_offset"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "unit_offset", PROPERTY_HINT_RANGE, "0,1,0.0001,or_lesser", PROPERTY_USAGE_EDITOR), "set_unit_offset", "get_unit_offset"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "h_offset"), "set_h_offset", "get_h_offset"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "v_offset"), "set_v_offset", "get_v_offset"); ADD_PROPERTY(PropertyInfo(Variant::INT, "rotation_mode", PROPERTY_HINT_ENUM, "None,Y,XY,XYZ,Oriented"), "set_rotation_mode", "get_rotation_mode"); @@ -319,8 +316,24 @@ void PathFollow::set_offset(float p_offset) { delta_offset = p_offset - offset; offset = p_offset; - if (path) + if (path) { + if (path->get_curve().is_valid() && path->get_curve()->get_baked_length()) { + float path_length = path->get_curve()->get_baked_length(); + + if (loop) { + while (offset > path_length) + offset -= path_length; + + while (offset < 0) + offset += path_length; + + } else { + offset = CLAMP(offset, 0, path_length); + } + } + _update_transform(); + } _change_notify("offset"); _change_notify("unit_offset"); } diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp index 9a659ef4af..043d5d5548 100644 --- a/scene/3d/spatial.cpp +++ b/scene/3d/spatial.cpp @@ -322,6 +322,7 @@ Transform Spatial::get_relative_transform(const Node *p_parent) const { void Spatial::set_translation(const Vector3 &p_translation) { data.local_transform.origin = p_translation; + _change_notify("transform"); _propagate_transform_changed(this); if (data.notify_local_transform) { notification(NOTIFICATION_LOCAL_TRANSFORM_CHANGED); @@ -337,6 +338,7 @@ void Spatial::set_rotation(const Vector3 &p_euler_rad) { data.rotation = p_euler_rad; data.dirty |= DIRTY_LOCAL; + _change_notify("transform"); _propagate_transform_changed(this); if (data.notify_local_transform) { notification(NOTIFICATION_LOCAL_TRANSFORM_CHANGED); @@ -357,6 +359,7 @@ void Spatial::set_scale(const Vector3 &p_scale) { data.scale = p_scale; data.dirty |= DIRTY_LOCAL; + _change_notify("transform"); _propagate_transform_changed(this); if (data.notify_local_transform) { notification(NOTIFICATION_LOCAL_TRANSFORM_CHANGED); diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp index 65bf1e0134..a37b75d428 100644 --- a/scene/animation/animation_node_state_machine.cpp +++ b/scene/animation/animation_node_state_machine.cpp @@ -312,27 +312,36 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st bool play_start = false; if (start_request != StringName()) { - if (start_request_travel) { if (!playing) { - String node_name = start_request; - start_request = StringName(); - ERR_FAIL_V_MSG(0, "Can't travel to '" + node_name + "' if state machine is not playing."); - } - - if (!_travel(p_state_machine, start_request)) { - //can't travel, then teleport - path.clear(); - current = start_request; + if (!stop_request && p_state_machine->start_node) { + // can restart, just postpone traveling + path.clear(); + current = p_state_machine->start_node; + playing = true; + play_start = true; + } else { + // stopped, invalid state + String node_name = start_request; + start_request = StringName(); //clear start request + ERR_FAIL_V_MSG(0, "Can't travel to '" + node_name + "' if state machine is not playing."); + } + } else { + if (!_travel(p_state_machine, start_request)) { + // can't travel, then teleport + path.clear(); + current = start_request; + } + start_request = StringName(); //clear start request } } else { + // teleport to start path.clear(); current = start_request; playing = true; play_start = true; + start_request = StringName(); //clear start request } - - start_request = StringName(); //clear start request } bool do_start = (p_seek && p_time == 0) || play_start || current == StringName(); diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index ab6f80bfa9..e6a27aa63f 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -823,7 +823,7 @@ void LineEdit::_notification(int p_what) { int yofs = y_ofs + (caret_height - font->get_height()) / 2; drawer.draw_char(ci, Point2(x_ofs, yofs + font_ascent), cchar, next, selected ? font_color_selected : font_color); - if (char_ofs == cursor_pos && draw_caret) { + if (char_ofs == cursor_pos && draw_caret && !using_placeholder) { if (ime_text.length() == 0) { #ifdef TOOLS_ENABLED VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(Math::round(EDSCALE), caret_height)), cursor_color); @@ -866,12 +866,27 @@ void LineEdit::_notification(int p_what) { } } - if (char_ofs == cursor_pos && draw_caret) { // May be at the end. + if ((char_ofs == cursor_pos || using_placeholder) && draw_caret) { // May be at the end, or placeholder. if (ime_text.length() == 0) { + int caret_x_ofs = x_ofs; + if (using_placeholder) { + switch (align) { + case ALIGN_LEFT: + case ALIGN_FILL: { + caret_x_ofs = style->get_offset().x; + } break; + case ALIGN_CENTER: { + caret_x_ofs = ofs_max / 2; + } break; + case ALIGN_RIGHT: { + caret_x_ofs = ofs_max; + } break; + } + } #ifdef TOOLS_ENABLED - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(Math::round(EDSCALE), caret_height)), cursor_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(caret_x_ofs, y_ofs), Size2(Math::round(EDSCALE), caret_height)), cursor_color); #else - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(1, caret_height)), cursor_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(caret_x_ofs, y_ofs), Size2(1, caret_height)), cursor_color); #endif } } @@ -970,6 +985,8 @@ void LineEdit::undo() { undo_stack_pos = undo_stack_pos->prev(); TextOperation op = undo_stack_pos->get(); text = op.text; + cached_width = op.cached_width; + window_pos = op.window_pos; set_cursor_position(op.cursor_pos); if (expand_to_text_length) @@ -988,6 +1005,8 @@ void LineEdit::redo() { undo_stack_pos = undo_stack_pos->next(); TextOperation op = undo_stack_pos->get(); text = op.text; + cached_width = op.cached_width; + window_pos = op.window_pos; set_cursor_position(op.cursor_pos); if (expand_to_text_length) @@ -1169,6 +1188,10 @@ 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); + } + _text_changed(); } @@ -1196,6 +1219,10 @@ void LineEdit::delete_text(int p_from_column, int p_to_column) { window_pos = cursor_pos; } + if (align == ALIGN_CENTER || align == ALIGN_RIGHT) { + window_pos = CLAMP(window_pos - (p_to_column - p_from_column), 0, text.length() - 1); + } + if (!text_changed_dirty) { if (is_inside_tree()) { MessageQueue::get_singleton()->push_call(this, "_text_changed"); @@ -1677,7 +1704,9 @@ void LineEdit::_clear_undo_stack() { void LineEdit::_create_undo_state() { TextOperation op; op.text = text; + op.cached_width = cached_width; op.cursor_pos = cursor_pos; + op.window_pos = window_pos; undo_stack.push_back(op); } diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h index 3424131dad..ebe49091eb 100644 --- a/scene/gui/line_edit.h +++ b/scene/gui/line_edit.h @@ -106,6 +106,8 @@ private: struct TextOperation { int cursor_pos; + int window_pos; + int cached_width; String text; }; List<TextOperation> undo_stack; |