diff options
26 files changed, 571 insertions, 60 deletions
diff --git a/SConstruct b/SConstruct index ce2566559c..7358494123 100644 --- a/SConstruct +++ b/SConstruct @@ -327,6 +327,8 @@ if selected_platform in platform_list: env.Append(CCFLAGS=['/EHsc']) if (env["werror"]): env.Append(CCFLAGS=['/WX']) + # Force to use Unicode encoding + env.Append(MSVC_FLAGS=['/utf8']) else: # Rest of the world shadow_local_warning = [] all_plus_warnings = ['-Wwrite-strings'] diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp index 359446dde6..7ce3824505 100644 --- a/core/math/a_star.cpp +++ b/core/math/a_star.cpp @@ -458,13 +458,12 @@ void AStar::_bind_methods() { ClassDB::bind_method(D_METHOD("set_point_weight_scale", "id", "weight_scale"), &AStar::set_point_weight_scale); ClassDB::bind_method(D_METHOD("remove_point", "id"), &AStar::remove_point); ClassDB::bind_method(D_METHOD("has_point", "id"), &AStar::has_point); + ClassDB::bind_method(D_METHOD("get_point_connections", "id"), &AStar::get_point_connections); ClassDB::bind_method(D_METHOD("get_points"), &AStar::get_points); ClassDB::bind_method(D_METHOD("set_point_disabled", "id", "disabled"), &AStar::set_point_disabled, DEFVAL(true)); ClassDB::bind_method(D_METHOD("is_point_disabled", "id"), &AStar::is_point_disabled); - ClassDB::bind_method(D_METHOD("get_point_connections", "id"), &AStar::get_point_connections); - ClassDB::bind_method(D_METHOD("connect_points", "id", "to_id", "bidirectional"), &AStar::connect_points, DEFVAL(true)); ClassDB::bind_method(D_METHOD("disconnect_points", "id", "to_id"), &AStar::disconnect_points); ClassDB::bind_method(D_METHOD("are_points_connected", "id", "to_id"), &AStar::are_points_connected); @@ -491,3 +490,135 @@ AStar::~AStar() { pass = 1; clear(); } + +///////////////////////////////////////////////////////////// + +int AStar2D::get_available_point_id() const { + return astar.get_available_point_id(); +} + +void AStar2D::add_point(int p_id, const Vector2 &p_pos, real_t p_weight_scale) { + astar.add_point(p_id, Vector3(p_pos.x, p_pos.y, 0), p_weight_scale); +} + +Vector2 AStar2D::get_point_position(int p_id) const { + Vector3 p = astar.get_point_position(p_id); + return Vector2(p.x, p.y); +} + +void AStar2D::set_point_position(int p_id, const Vector2 &p_pos) { + astar.set_point_position(p_id, Vector3(p_pos.x, p_pos.y, 0)); +} + +real_t AStar2D::get_point_weight_scale(int p_id) const { + return astar.get_point_weight_scale(p_id); +} + +void AStar2D::set_point_weight_scale(int p_id, real_t p_weight_scale) { + astar.set_point_weight_scale(p_id, p_weight_scale); +} + +void AStar2D::remove_point(int p_id) { + astar.remove_point(p_id); +} + +bool AStar2D::has_point(int p_id) const { + return astar.has_point(p_id); +} + +PoolVector<int> AStar2D::get_point_connections(int p_id) { + return astar.get_point_connections(p_id); +} + +Array AStar2D::get_points() { + return astar.get_points(); +} + +void AStar2D::set_point_disabled(int p_id, bool p_disabled) { + astar.set_point_disabled(p_id, p_disabled); +} + +bool AStar2D::is_point_disabled(int p_id) const { + return astar.is_point_disabled(p_id); +} + +void AStar2D::connect_points(int p_id, int p_with_id, bool p_bidirectional) { + astar.connect_points(p_id, p_with_id, p_bidirectional); +} + +void AStar2D::disconnect_points(int p_id, int p_with_id) { + astar.disconnect_points(p_id, p_with_id); +} + +bool AStar2D::are_points_connected(int p_id, int p_with_id) const { + return astar.are_points_connected(p_id, p_with_id); +} + +void AStar2D::clear() { + astar.clear(); +} + +int AStar2D::get_closest_point(const Vector2 &p_point) const { + return astar.get_closest_point(Vector3(p_point.x, p_point.y, 0)); +} + +Vector2 AStar2D::get_closest_position_in_segment(const Vector2 &p_point) const { + Vector3 p = astar.get_closest_position_in_segment(Vector3(p_point.x, p_point.y, 0)); + return Vector2(p.x, p.y); +} + +PoolVector<Vector2> AStar2D::get_point_path(int p_from_id, int p_to_id) { + + PoolVector3Array pv = astar.get_point_path(p_from_id, p_to_id); + int size = pv.size(); + PoolVector2Array path; + path.resize(size); + { + PoolVector<Vector3>::Read r = pv.read(); + PoolVector<Vector2>::Write w = path.write(); + for (int i = 0; i < size; i++) { + Vector3 p = r[i]; + w[i] = Vector2(p.x, p.y); + } + } + return path; +} + +PoolVector<int> AStar2D::get_id_path(int p_from_id, int p_to_id) { + return astar.get_id_path(p_from_id, p_to_id); +} + +void AStar2D::_bind_methods() { + + ClassDB::bind_method(D_METHOD("get_available_point_id"), &AStar2D::get_available_point_id); + ClassDB::bind_method(D_METHOD("add_point", "id", "position", "weight_scale"), &AStar2D::add_point, DEFVAL(1.0)); + ClassDB::bind_method(D_METHOD("get_point_position", "id"), &AStar2D::get_point_position); + ClassDB::bind_method(D_METHOD("set_point_position", "id", "position"), &AStar2D::set_point_position); + ClassDB::bind_method(D_METHOD("get_point_weight_scale", "id"), &AStar2D::get_point_weight_scale); + ClassDB::bind_method(D_METHOD("set_point_weight_scale", "id", "weight_scale"), &AStar2D::set_point_weight_scale); + ClassDB::bind_method(D_METHOD("remove_point", "id"), &AStar2D::remove_point); + ClassDB::bind_method(D_METHOD("has_point", "id"), &AStar2D::has_point); + ClassDB::bind_method(D_METHOD("get_point_connections", "id"), &AStar2D::get_point_connections); + ClassDB::bind_method(D_METHOD("get_points"), &AStar2D::get_points); + + ClassDB::bind_method(D_METHOD("set_point_disabled", "id", "disabled"), &AStar2D::set_point_disabled, DEFVAL(true)); + ClassDB::bind_method(D_METHOD("is_point_disabled", "id"), &AStar2D::is_point_disabled); + + ClassDB::bind_method(D_METHOD("connect_points", "id", "to_id", "bidirectional"), &AStar2D::connect_points, DEFVAL(true)); + ClassDB::bind_method(D_METHOD("disconnect_points", "id", "to_id"), &AStar2D::disconnect_points); + ClassDB::bind_method(D_METHOD("are_points_connected", "id", "to_id"), &AStar2D::are_points_connected); + + ClassDB::bind_method(D_METHOD("clear"), &AStar2D::clear); + + ClassDB::bind_method(D_METHOD("get_closest_point", "to_position"), &AStar2D::get_closest_point); + ClassDB::bind_method(D_METHOD("get_closest_position_in_segment", "to_position"), &AStar2D::get_closest_position_in_segment); + + ClassDB::bind_method(D_METHOD("get_point_path", "from_id", "to_id"), &AStar2D::get_point_path); + ClassDB::bind_method(D_METHOD("get_id_path", "from_id", "to_id"), &AStar2D::get_id_path); +} + +AStar2D::AStar2D() { +} + +AStar2D::~AStar2D() { +} diff --git a/core/math/a_star.h b/core/math/a_star.h index ba35d929b3..e2a0356c7c 100644 --- a/core/math/a_star.h +++ b/core/math/a_star.h @@ -143,4 +143,43 @@ public: ~AStar(); }; +class AStar2D : public Reference { + GDCLASS(AStar2D, Reference); + AStar astar; + +protected: + static void _bind_methods(); + +public: + int get_available_point_id() const; + + void add_point(int p_id, const Vector2 &p_pos, real_t p_weight_scale = 1); + Vector2 get_point_position(int p_id) const; + void set_point_position(int p_id, const Vector2 &p_pos); + real_t get_point_weight_scale(int p_id) const; + void set_point_weight_scale(int p_id, real_t p_weight_scale); + void remove_point(int p_id); + bool has_point(int p_id) const; + PoolVector<int> get_point_connections(int p_id); + Array get_points(); + + void set_point_disabled(int p_id, bool p_disabled = true); + bool is_point_disabled(int p_id) const; + + void connect_points(int p_id, int p_with_id, bool p_bidirectional = true); + void disconnect_points(int p_id, int p_with_id); + bool are_points_connected(int p_id, int p_with_id) const; + + void clear(); + + int get_closest_point(const Vector2 &p_point) const; + Vector2 get_closest_position_in_segment(const Vector2 &p_point) const; + + PoolVector<Vector2> get_point_path(int p_from_id, int p_to_id); + PoolVector<int> get_id_path(int p_from_id, int p_to_id); + + AStar2D(); + ~AStar2D(); +}; + #endif // ASTAR_H diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index 97c96b4018..135df4e5bd 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -184,6 +184,7 @@ void register_core_types() { ClassDB::register_class<PackedDataContainer>(); ClassDB::register_virtual_class<PackedDataContainerRef>(); ClassDB::register_class<AStar>(); + ClassDB::register_class<AStar2D>(); ClassDB::register_class<EncodedObjectAsID>(); ClassDB::register_class<RandomNumberGenerator>(); diff --git a/doc/classes/AStar.xml b/doc/classes/AStar.xml index 16ceb293ad..81722535c2 100644 --- a/doc/classes/AStar.xml +++ b/doc/classes/AStar.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="AStar" inherits="Reference" category="Core" version="3.2"> <brief_description> - AStar class representation that uses vectors as edges. + AStar class representation that uses 3d-vectors as edges. </brief_description> <description> A* (A star) is a computer algorithm that is widely used in pathfinding and graph traversal, the process of plotting an efficiently directed path between multiple points. It enjoys widespread use due to its performance and accuracy. Godot's A* implementation make use of vectors as points. diff --git a/doc/classes/AStar2D.xml b/doc/classes/AStar2D.xml new file mode 100644 index 0000000000..b86e53d4d4 --- /dev/null +++ b/doc/classes/AStar2D.xml @@ -0,0 +1,258 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="AStar2D" inherits="Reference" category="Core" version="3.2"> + <brief_description> + AStar class representation that uses 2d-vectors as edges. + </brief_description> + <description> + This is a wrapper for the [AStar] class which uses 2D vectors instead of 3D vectors. + </description> + <tutorials> + </tutorials> + <methods> + <method name="add_point"> + <return type="void"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <argument index="1" name="position" type="Vector2"> + </argument> + <argument index="2" name="weight_scale" type="float" default="1.0"> + </argument> + <description> + Adds a new point at the given position with the given identifier. The algorithm prefers points with lower [code]weight_scale[/code] to form a path. The [code]id[/code] must be 0 or larger, and the [code]weight_scale[/code] must be 1 or larger. + [codeblock] + var as = AStar2D.new() + as.add_point(1, Vector2(1, 0), 4) # Adds the point (1, 0) with weight_scale 4 and id 1 + [/codeblock] + If there already exists a point for the given id, its position and weight scale are updated to the given values. + </description> + </method> + <method name="are_points_connected" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <argument index="1" name="to_id" type="int"> + </argument> + <description> + Returns whether there is a connection/segment between the given points. + </description> + </method> + <method name="clear"> + <return type="void"> + </return> + <description> + Clears all the points and segments. + </description> + </method> + <method name="connect_points"> + <return type="void"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <argument index="1" name="to_id" type="int"> + </argument> + <argument index="2" name="bidirectional" type="bool" default="true"> + </argument> + <description> + Creates a segment between the given points. If [code]bidirectional[/code] is [code]false[/code], only movement from [code]id[/code] to [code]to_id[/code] is allowed, not the reverse direction. + [codeblock] + var as = AStar2D.new() + as.add_point(1, Vector2(1, 1)) + as.add_point(2, Vector2(0, 5)) + as.connect_points(1, 2, false) + [/codeblock] + </description> + </method> + <method name="disconnect_points"> + <return type="void"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <argument index="1" name="to_id" type="int"> + </argument> + <description> + Deletes the segment between the given points. + </description> + </method> + <method name="get_available_point_id" qualifiers="const"> + <return type="int"> + </return> + <description> + Returns the next available point id with no point associated to it. + </description> + </method> + <method name="get_closest_point" qualifiers="const"> + <return type="int"> + </return> + <argument index="0" name="to_position" type="Vector2"> + </argument> + <description> + Returns the id of the closest point to [code]to_position[/code]. Returns -1 if there are no points in the points pool. + </description> + </method> + <method name="get_closest_position_in_segment" qualifiers="const"> + <return type="Vector2"> + </return> + <argument index="0" name="to_position" type="Vector2"> + </argument> + <description> + Returns the closest position to [code]to_position[/code] that resides inside a segment between two connected points. + [codeblock] + var as = AStar2D.new() + as.add_point(1, Vector2(0, 0)) + as.add_point(2, Vector2(0, 5)) + as.connect_points(1, 2) + var res = as.get_closest_position_in_segment(Vector2(3, 3)) # returns (0, 3) + [/codeblock] + The result is in the segment that goes from [code]y = 0[/code] to [code]y = 5[/code]. It's the closest position in the segment to the given point. + </description> + </method> + <method name="get_id_path"> + <return type="PoolIntArray"> + </return> + <argument index="0" name="from_id" type="int"> + </argument> + <argument index="1" name="to_id" type="int"> + </argument> + <description> + Returns an array with the ids of the points that form the path found by AStar2D between the given points. The array is ordered from the starting point to the ending point of the path. + [codeblock] + var as = AStar2D.new() + as.add_point(1, Vector2(0, 0)) + as.add_point(2, Vector2(0, 1), 1) # default weight is 1 + as.add_point(3, Vector2(1, 1)) + as.add_point(4, Vector2(2, 0)) + + as.connect_points(1, 2, false) + as.connect_points(2, 3, false) + as.connect_points(4, 3, false) + as.connect_points(1, 4, false) + as.connect_points(5, 4, false) + + var res = as.get_id_path(1, 3) # returns [1, 2, 3] + [/codeblock] + If you change the 2nd point's weight to 3, then the result will be [code][1, 4, 3][/code] instead, because now even though the distance is longer, it's "easier" to get through point 4 than through point 2. + </description> + </method> + <method name="get_point_connections"> + <return type="PoolIntArray"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <description> + Returns an array with the ids of the points that form the connect with the given point. + [codeblock] + var as = AStar2D.new() + as.add_point(1, Vector2(0, 0)) + as.add_point(2, Vector2(0, 1)) + as.add_point(3, Vector2(1, 1)) + as.add_point(4, Vector2(2, 0)) + + as.connect_points(1, 2, true) + as.connect_points(1, 3, true) + + var neighbors = as.get_point_connections(1) # returns [2, 3] + [/codeblock] + </description> + </method> + <method name="get_point_path"> + <return type="PoolVector2Array"> + </return> + <argument index="0" name="from_id" type="int"> + </argument> + <argument index="1" name="to_id" type="int"> + </argument> + <description> + Returns an array with the points that are in the path found by AStar2D between the given points. The array is ordered from the starting point to the ending point of the path. + </description> + </method> + <method name="get_point_position" qualifiers="const"> + <return type="Vector2"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <description> + Returns the position of the point associated with the given id. + </description> + </method> + <method name="get_point_weight_scale" qualifiers="const"> + <return type="float"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <description> + Returns the weight scale of the point associated with the given id. + </description> + </method> + <method name="get_points"> + <return type="Array"> + </return> + <description> + Returns an array of all points. + </description> + </method> + <method name="has_point" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <description> + Returns whether a point associated with the given id exists. + </description> + </method> + <method name="is_point_disabled" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <description> + Returns whether a point is disabled or not for pathfinding. By default, all points are enabled. + </description> + </method> + <method name="remove_point"> + <return type="void"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <description> + Removes the point associated with the given id from the points pool. + </description> + </method> + <method name="set_point_disabled"> + <return type="void"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <argument index="1" name="disabled" type="bool" default="true"> + </argument> + <description> + Disables or enables the specified point for pathfinding. Useful for making a temporary obstacle. + </description> + </method> + <method name="set_point_position"> + <return type="void"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <argument index="1" name="position" type="Vector2"> + </argument> + <description> + Sets the position for the point with the given id. + </description> + </method> + <method name="set_point_weight_scale"> + <return type="void"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <argument index="1" name="weight_scale" type="float"> + </argument> + <description> + Sets the [code]weight_scale[/code] for the point with the given id. + </description> + </method> + </methods> + <constants> + </constants> +</class> diff --git a/doc/classes/AcceptDialog.xml b/doc/classes/AcceptDialog.xml index db35b2f352..3ea280cba3 100644 --- a/doc/classes/AcceptDialog.xml +++ b/doc/classes/AcceptDialog.xml @@ -57,12 +57,15 @@ </method> </methods> <members> + <member name="dialog_autowrap" type="bool" setter="set_autowrap" getter="has_autowrap"> + Sets autowrapping for the text in the dialog. + </member> <member name="dialog_hide_on_ok" type="bool" setter="set_hide_on_ok" getter="get_hide_on_ok"> If [code]true[/code], the dialog is hidden when the OK button is pressed. You can set it to [code]false[/code] if you want to do e.g. input validation when receiving the [signal confirmed] signal, and handle hiding the dialog in your own logic. Default value: [code]true[/code]. Note: Some nodes derived from this class can have a different default value, and potentially their own built-in logic overriding this setting. For example [FileDialog] defaults to [code]false[/code], and has its own input validation code that is called when you press OK, which eventually hides the dialog if the input is valid. As such this property can't be used in [FileDialog] to disable hiding the dialog when pressing OK. </member> <member name="dialog_text" type="String" setter="set_text" getter="get_text"> - The text displayed by this dialog. + The text displayed by the dialog. </member> </members> <signals> diff --git a/doc/classes/CameraFeed.xml b/doc/classes/CameraFeed.xml index 7f353f7a05..4611b9c507 100644 --- a/doc/classes/CameraFeed.xml +++ b/doc/classes/CameraFeed.xml @@ -45,10 +45,10 @@ <constant name="FEED_RGB" value="1" enum="FeedDataType"> Feed supplies RGB images. </constant> - <constant name="FEED_YCbCr" value="2" enum="FeedDataType"> + <constant name="FEED_YCBCR" value="2" enum="FeedDataType"> Feed supplies YCbCr images that need to be converted to RGB. </constant> - <constant name="FEED_YCbCr_Sep" value="3" enum="FeedDataType"> + <constant name="FEED_YCBCR_SEP" value="3" enum="FeedDataType"> Feed supplies separate Y and CbCr images that need to be combined and converted to RGB. </constant> <constant name="FEED_UNSPECIFIED" value="0" enum="FeedPosition"> diff --git a/doc/classes/CameraServer.xml b/doc/classes/CameraServer.xml index f492bda74f..ee41f08ec6 100644 --- a/doc/classes/CameraServer.xml +++ b/doc/classes/CameraServer.xml @@ -70,13 +70,13 @@ <constant name="FEED_RGBA_IMAGE" value="0" enum="FeedImage"> The RGBA camera image. </constant> - <constant name="FEED_YCbCr_IMAGE" value="0" enum="FeedImage"> + <constant name="FEED_YCBCR_IMAGE" value="0" enum="FeedImage"> The YCbCr camera image. </constant> <constant name="FEED_Y_IMAGE" value="0" enum="FeedImage"> The Y component camera image. </constant> - <constant name="FEED_CbCr_IMAGE" value="1" enum="FeedImage"> + <constant name="FEED_CBCR_IMAGE" value="1" enum="FeedImage"> The CbCr component camera image. </constant> </constants> diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp index a07c6832dc..ea29af7d9e 100644 --- a/drivers/gles2/rasterizer_scene_gles2.cpp +++ b/drivers/gles2/rasterizer_scene_gles2.cpp @@ -2920,16 +2920,16 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const VS::get_singleton()->texture_bind(camera_RGBA, 0); - } else if (feed->get_datatype() == CameraFeed::FEED_YCbCr) { - RID camera_YCbCr = feed->get_texture(CameraServer::FEED_YCbCr_IMAGE); + } else if (feed->get_datatype() == CameraFeed::FEED_YCBCR) { + RID camera_YCbCr = feed->get_texture(CameraServer::FEED_YCBCR_IMAGE); VS::get_singleton()->texture_bind(camera_YCbCr, 0); storage->shaders.copy.set_conditional(CopyShaderGLES2::YCBCR_TO_RGB, true); - } else if (feed->get_datatype() == CameraFeed::FEED_YCbCr_Sep) { + } else if (feed->get_datatype() == CameraFeed::FEED_YCBCR_SEP) { RID camera_Y = feed->get_texture(CameraServer::FEED_Y_IMAGE); - RID camera_CbCr = feed->get_texture(CameraServer::FEED_CbCr_IMAGE); + RID camera_CbCr = feed->get_texture(CameraServer::FEED_CBCR_IMAGE); VS::get_singleton()->texture_bind(camera_Y, 0); VS::get_singleton()->texture_bind(camera_CbCr, 1); diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 7acb8a22bc..c7ef5cded4 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -4454,16 +4454,16 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const RID camera_RGBA = feed->get_texture(CameraServer::FEED_RGBA_IMAGE); VS::get_singleton()->texture_bind(camera_RGBA, 0); - } else if (feed->get_datatype() == CameraFeed::FEED_YCbCr) { - RID camera_YCbCr = feed->get_texture(CameraServer::FEED_YCbCr_IMAGE); + } else if (feed->get_datatype() == CameraFeed::FEED_YCBCR) { + RID camera_YCbCr = feed->get_texture(CameraServer::FEED_YCBCR_IMAGE); VS::get_singleton()->texture_bind(camera_YCbCr, 0); storage->shaders.copy.set_conditional(CopyShaderGLES3::YCBCR_TO_SRGB, true); - } else if (feed->get_datatype() == CameraFeed::FEED_YCbCr_Sep) { + } else if (feed->get_datatype() == CameraFeed::FEED_YCBCR_SEP) { RID camera_Y = feed->get_texture(CameraServer::FEED_Y_IMAGE); - RID camera_CbCr = feed->get_texture(CameraServer::FEED_CbCr_IMAGE); + RID camera_CbCr = feed->get_texture(CameraServer::FEED_CBCR_IMAGE); VS::get_singleton()->texture_bind(camera_Y, 0); VS::get_singleton()->texture_bind(camera_CbCr, 1); diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 3295753bda..6e47fadb20 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -2083,8 +2083,6 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { moving_selection_from_ofs = (mb->get_position().x - timeline->get_name_limit()) / timeline->get_zoom_scale(); } accept_event(); - } else { - emit_signal("clear_selection"); } } @@ -2326,7 +2324,7 @@ void AnimationTrackEdit::set_in_group(bool p_enable) { update(); } -void AnimationTrackEdit::append_to_selection(const Rect2 &p_box) { +void AnimationTrackEdit::append_to_selection(const Rect2 &p_box, bool p_deselection) { Rect2 select_rect(timeline->get_name_limit(), 0, get_size().width - timeline->get_name_limit() - timeline->get_buttons_width(), get_size().height); select_rect = select_rect.clip(p_box); @@ -2339,7 +2337,10 @@ void AnimationTrackEdit::append_to_selection(const Rect2 &p_box) { rect.position.x += offset; if (select_rect.intersects(rect)) { - emit_signal("select_key", i, false); + if (p_deselection) + emit_signal("deselect_key", i); + else + emit_signal("select_key", i, false); } } } @@ -4342,7 +4343,7 @@ void AnimationTrackEditor::_scroll_input(const Ref<InputEvent> &p_event) { Rect2 local_rect = box_select_rect; local_rect.position -= track_edits[i]->get_global_position(); - track_edits[i]->append_to_selection(local_rect); + track_edits[i]->append_to_selection(local_rect, mb->get_command()); } if (_get_track_selected() == -1 && track_edits.size() > 0) { //minimal hack to make shortcuts work @@ -4374,8 +4375,8 @@ void AnimationTrackEditor::_scroll_input(const Ref<InputEvent> &p_event) { } if (!box_selection->is_visible_in_tree()) { - if (!mm->get_shift()) { - _clear_selection(); //only append if shift is pressed + if (!mm->get_command() && !mm->get_shift()) { + _clear_selection(); } box_selection->show(); } @@ -4568,7 +4569,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { it->set_metadata(0, md); } - track_copy_dialog->popup_centered_minsize(Size2(300, 500) * EDSCALE); + track_copy_dialog->popup_centered_minsize(Size2(350, 500) * EDSCALE); } break; case EDIT_COPY_TRACKS_CONFIRM: { @@ -4962,6 +4963,19 @@ void AnimationTrackEditor::_show_imported_anim_warning() const { TTR("Warning: Editing imported animation")); } +void AnimationTrackEditor::_select_all_tracks_for_copy() { + TreeItem *track = track_copy_select->get_root()->get_children(); + while (track) { + track->set_checked(0, selected_all_tracks); + track = track->get_next(); + } + selected_all_tracks = !selected_all_tracks; + if (selected_all_tracks) + select_all_button->set_text(TTR("Select All")); + else + select_all_button->set_text(TTR("Select None")); +} + void AnimationTrackEditor::_bind_methods() { ClassDB::bind_method("_animation_changed", &AnimationTrackEditor::_animation_changed); @@ -5002,6 +5016,7 @@ void AnimationTrackEditor::_bind_methods() { ClassDB::bind_method("_selection_changed", &AnimationTrackEditor::_selection_changed); ClassDB::bind_method("_snap_mode_changed", &AnimationTrackEditor::_snap_mode_changed); ClassDB::bind_method("_show_imported_anim_warning", &AnimationTrackEditor::_show_imported_anim_warning); + ClassDB::bind_method("_select_all_tracks_for_copy", &AnimationTrackEditor::_select_all_tracks_for_copy); ADD_SIGNAL(MethodInfo("timeline_changed", PropertyInfo(Variant::REAL, "position"), PropertyInfo(Variant::BOOL, "drag"))); ADD_SIGNAL(MethodInfo("keying_changed")); @@ -5284,9 +5299,22 @@ AnimationTrackEditor::AnimationTrackEditor() { track_copy_dialog->set_title(TTR("Select tracks to copy:")); track_copy_dialog->get_ok()->set_text(TTR("Copy")); + VBoxContainer *track_vbox = memnew(VBoxContainer); + track_copy_dialog->add_child(track_vbox); + + selected_all_tracks = true; + track_copy_select = memnew(Tree); + track_copy_select->set_h_size_flags(SIZE_EXPAND_FILL); + track_copy_select->set_v_size_flags(SIZE_EXPAND_FILL); track_copy_select->set_hide_root(true); - track_copy_dialog->add_child(track_copy_select); + track_vbox->add_child(track_copy_select); + track_copy_options = memnew(HBoxContainer); + track_vbox->add_child(track_copy_options); + select_all_button = memnew(Button); + select_all_button->set_text(TTR("Select All")); + select_all_button->connect("pressed", this, "_select_all_tracks_for_copy"); + track_copy_options->add_child(select_all_button); track_copy_dialog->connect("confirmed", this, "_edit_menu_pressed", varray(EDIT_COPY_TRACKS_CONFIRM)); animation_changing_awaiting_update = false; } diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h index c64f663b3b..0f1363b34f 100644 --- a/editor/animation_track_editor.h +++ b/editor/animation_track_editor.h @@ -231,7 +231,7 @@ public: void cancel_drop(); void set_in_group(bool p_enable); - void append_to_selection(const Rect2 &p_box); + void append_to_selection(const Rect2 &p_box, bool p_deselection); AnimationTrackEdit(); }; @@ -445,6 +445,8 @@ class AnimationTrackEditor : public VBoxContainer { ConfirmationDialog *scale_dialog; SpinBox *scale; + void _select_all_tracks_for_copy(); + void _edit_menu_pressed(int p_option); int last_menu_track_opt; @@ -458,8 +460,12 @@ class AnimationTrackEditor : public VBoxContainer { void _selection_changed(); + bool selected_all_tracks; ConfirmationDialog *track_copy_dialog; Tree *track_copy_select; + HBoxContainer *track_copy_options; + Button *select_all_button; + struct TrackClipboard { NodePath full_path; NodePath base_path; diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index f3a1e657cc..ebaa930eb0 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -178,6 +178,12 @@ public: GIZMO_GRID_LAYER = 25 }; + enum NavigationScheme { + NAVIGATION_GODOT, + NAVIGATION_MAYA, + NAVIGATION_MODO, + }; + private: int index; String name; @@ -260,12 +266,6 @@ private: PopupMenu *selection_menu; - enum NavigationScheme { - NAVIGATION_GODOT, - NAVIGATION_MAYA, - NAVIGATION_MODO, - }; - enum NavigationZoomStyle { NAVIGATION_ZOOM_VERTICAL, NAVIGATION_ZOOM_HORIZONTAL diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index e8f5139cd5..a15ae2efda 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -269,7 +269,7 @@ void SceneTreeDock::_replace_with_branch_scene(const String &p_file, Node *base) bool SceneTreeDock::_cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node) { int childCount = p_desired_node->get_child_count(); - if (p_desired_node->get_filename() == p_target_scene_path) { + if (_track_inherit(p_target_scene_path, p_desired_node)) { return true; } @@ -284,6 +284,33 @@ bool SceneTreeDock::_cyclical_dependency_exists(const String &p_target_scene_pat return false; } +bool SceneTreeDock::_track_inherit(const String &p_target_scene_path, Node *p_desired_node) { + Node *p = p_desired_node; + bool result = false; + Vector<Node *> instances; + while (true) { + if (p->get_filename() == p_target_scene_path) { + result = true; + break; + } + Ref<SceneState> ss = p->get_scene_inherited_state(); + if (ss.is_valid()) { + String path = ss->get_path(); + Ref<PackedScene> data = ResourceLoader::load(path); + if (data.is_valid()) { + p = data->instance(PackedScene::GEN_EDIT_STATE_INSTANCE); + instances.push_back(p); + } else + break; + } else + break; + } + for (int i = 0; i < instances.size(); i++) { + memdelete(instances[i]); + } + return result; +} + void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { current_option = p_tool; diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index 9f9e93f2df..b645c22295 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -165,6 +165,7 @@ class SceneTreeDock : public VBoxContainer { void _script_open_request(const Ref<Script> &p_script); bool _cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node); + bool _track_inherit(const String &p_target_scene_path, Node *p_desired_node); void _node_selected(); void _node_renamed(); diff --git a/main/tests/test_string.cpp b/main/tests/test_string.cpp index 531887a452..a107fd738f 100644 --- a/main/tests/test_string.cpp +++ b/main/tests/test_string.cpp @@ -1017,8 +1017,8 @@ bool test_32() { STRIP_TEST(String("abca").lstrip("a") == "bca"); STRIP_TEST(String("abc").rstrip("a") == "abc"); STRIP_TEST(String("abca").rstrip("a") == "abc"); - // in utf-8 "¿" has the same first byte as "µ" - // and the same second as "ÿ" + // in utf-8 "¿" (\u00bf) has the same first byte as "µ" (\u00b5) + // and the same second as "ÿ" (\u00ff) STRIP_TEST(String::utf8("¿").lstrip(String::utf8("µÿ")) == String::utf8("¿")); STRIP_TEST(String::utf8("¿").rstrip(String::utf8("µÿ")) == String::utf8("¿")); STRIP_TEST(String::utf8("µ¿ÿ").lstrip(String::utf8("µÿ")) == String::utf8("¿ÿ")); @@ -1046,8 +1046,8 @@ bool test_32() { STRIP_TEST(String("abca").lstrip("qwajkl") == "bca"); STRIP_TEST(String("abc").rstrip("qwajkl") == "abc"); STRIP_TEST(String("abca").rstrip("qwajkl") == "abc"); - // in utf-8 "¿" has the same first byte as "µ" - // and the same second as "ÿ" + // in utf-8 "¿" (\u00bf) has the same first byte as "µ" (\u00b5) + // and the same second as "ÿ" (\u00ff) STRIP_TEST(String::utf8("¿").lstrip(String::utf8("qwaµÿjkl")) == String::utf8("¿")); STRIP_TEST(String::utf8("¿").rstrip(String::utf8("qwaµÿjkl")) == String::utf8("¿")); STRIP_TEST(String::utf8("µ¿ÿ").lstrip(String::utf8("qwaµÿjkl")) == String::utf8("¿ÿ")); @@ -1068,8 +1068,8 @@ bool test_33() { bool test_34() { OS::get_singleton()->print("\n\nTest 34: Cyrillic to_lower()\n"); - String upper = L"АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ"; - String lower = L"абвгдеёжзийклмнопрстуфхцчшщъыьэюя"; + String upper = String::utf8("АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ"); + String lower = String::utf8("абвгдеёжзийклмнопрстуфхцчшщъыьэюя"); String test = upper.to_lower(); diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index 890bd730f7..6b9a97efb4 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -664,8 +664,10 @@ bool GridMapEditor::forward_spatial_input_event(Camera *p_camera, const Ref<Inpu } if (mb->is_pressed()) { - - if (mb->get_button_index() == BUTTON_LEFT) { + SpatialEditorViewport::NavigationScheme nav_scheme = (SpatialEditorViewport::NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int(); + if ((nav_scheme == SpatialEditorViewport::NAVIGATION_MAYA || nav_scheme == SpatialEditorViewport::NAVIGATION_MODO) && mb->get_alt()) { + input_action = INPUT_NONE; + } else if (mb->get_button_index() == BUTTON_LEFT) { if (input_action == INPUT_PASTE) { _do_paste(); diff --git a/scene/3d/area.cpp b/scene/3d/area.cpp index 3557f0425c..4247266e3d 100644 --- a/scene/3d/area.cpp +++ b/scene/3d/area.cpp @@ -752,7 +752,7 @@ Area::Area() : gravity_is_point = false; gravity_distance_scale = 0; linear_damp = 0.1; - angular_damp = 1; + angular_damp = 0.1; priority = 0; monitoring = false; monitorable = false; diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index 89f3d509d0..4da11b671e 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -406,12 +406,20 @@ void AcceptDialog::set_hide_on_ok(bool p_hide) { hide_on_ok = p_hide; } - bool AcceptDialog::get_hide_on_ok() const { return hide_on_ok; } +void AcceptDialog::set_autowrap(bool p_autowrap) { + + label->set_autowrap(p_autowrap); +} +bool AcceptDialog::has_autowrap() { + + return label->has_autowrap(); +} + void AcceptDialog::register_text_enter(Node *p_line_edit) { ERR_FAIL_NULL(p_line_edit); @@ -530,6 +538,8 @@ void AcceptDialog::_bind_methods() { ClassDB::bind_method(D_METHOD("_custom_action"), &AcceptDialog::_custom_action); ClassDB::bind_method(D_METHOD("set_text", "text"), &AcceptDialog::set_text); ClassDB::bind_method(D_METHOD("get_text"), &AcceptDialog::get_text); + ClassDB::bind_method(D_METHOD("set_autowrap", "autowrap"), &AcceptDialog::set_autowrap); + ClassDB::bind_method(D_METHOD("has_autowrap"), &AcceptDialog::has_autowrap); ADD_SIGNAL(MethodInfo("confirmed")); ADD_SIGNAL(MethodInfo("custom_action", PropertyInfo(Variant::STRING, "action"))); @@ -537,6 +547,7 @@ void AcceptDialog::_bind_methods() { ADD_GROUP("Dialog", "dialog"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "dialog_text", PROPERTY_HINT_MULTILINE_TEXT, "", PROPERTY_USAGE_DEFAULT_INTL), "set_text", "get_text"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "dialog_hide_on_ok"), "set_hide_on_ok", "get_hide_on_ok"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "dialog_autowrap"), "set_autowrap", "has_autowrap"); } bool AcceptDialog::swap_ok_cancel = false; @@ -555,7 +566,6 @@ AcceptDialog::AcceptDialog() { label->set_anchor(MARGIN_BOTTOM, ANCHOR_END); label->set_begin(Point2(margin, margin)); label->set_end(Point2(-margin, -button_margin - 10)); - //label->set_autowrap(true); add_child(label); hbc = memnew(HBoxContainer); diff --git a/scene/gui/dialogs.h b/scene/gui/dialogs.h index 4b89ac54c5..c1a7f26a85 100644 --- a/scene/gui/dialogs.h +++ b/scene/gui/dialogs.h @@ -145,6 +145,9 @@ public: void set_text(String p_text); String get_text() const; + void set_autowrap(bool p_autowrap); + bool has_autowrap(); + AcceptDialog(); ~AcceptDialog(); }; diff --git a/servers/camera/camera_feed.cpp b/servers/camera/camera_feed.cpp index 31b8b2874f..094c83cd7c 100644 --- a/servers/camera/camera_feed.cpp +++ b/servers/camera/camera_feed.cpp @@ -60,8 +60,8 @@ void CameraFeed::_bind_methods() { BIND_ENUM_CONSTANT(FEED_NOIMAGE); BIND_ENUM_CONSTANT(FEED_RGB); - BIND_ENUM_CONSTANT(FEED_YCbCr); - BIND_ENUM_CONSTANT(FEED_YCbCr_Sep); + BIND_ENUM_CONSTANT(FEED_YCBCR); + BIND_ENUM_CONSTANT(FEED_YCBCR_SEP); BIND_ENUM_CONSTANT(FEED_UNSPECIFIED); BIND_ENUM_CONSTANT(FEED_FRONT); @@ -145,7 +145,7 @@ CameraFeed::CameraFeed() { // create a texture object VisualServer *vs = VisualServer::get_singleton(); texture[CameraServer::FEED_Y_IMAGE] = vs->texture_create(); // also used for RGBA - texture[CameraServer::FEED_CbCr_IMAGE] = vs->texture_create(); + texture[CameraServer::FEED_CBCR_IMAGE] = vs->texture_create(); } CameraFeed::CameraFeed(String p_name, FeedPosition p_position) { @@ -162,14 +162,14 @@ CameraFeed::CameraFeed(String p_name, FeedPosition p_position) { // create a texture object VisualServer *vs = VisualServer::get_singleton(); texture[CameraServer::FEED_Y_IMAGE] = vs->texture_create(); // also used for RGBA - texture[CameraServer::FEED_CbCr_IMAGE] = vs->texture_create(); + texture[CameraServer::FEED_CBCR_IMAGE] = vs->texture_create(); } CameraFeed::~CameraFeed() { // Free our textures VisualServer *vs = VisualServer::get_singleton(); vs->free(texture[CameraServer::FEED_Y_IMAGE]); - vs->free(texture[CameraServer::FEED_CbCr_IMAGE]); + vs->free(texture[CameraServer::FEED_CBCR_IMAGE]); } void CameraFeed::set_RGB_img(Ref<Image> p_rgb_img) { @@ -208,7 +208,7 @@ void CameraFeed::set_YCbCr_img(Ref<Image> p_ycbcr_img) { } vs->texture_set_data(texture[CameraServer::FEED_RGBA_IMAGE], p_ycbcr_img); - datatype = CameraFeed::FEED_YCbCr; + datatype = CameraFeed::FEED_YCBCR; } } @@ -233,12 +233,12 @@ void CameraFeed::set_YCbCr_imgs(Ref<Image> p_y_img, Ref<Image> p_cbcr_img) { vs->texture_allocate(texture[CameraServer::FEED_Y_IMAGE], new_y_width, new_y_height, 0, Image::FORMAT_R8, VS::TEXTURE_TYPE_2D, VS::TEXTURE_FLAG_USED_FOR_STREAMING); ///@TODO GLES2 doesn't support FORMAT_RG8, need to do some form of conversion - vs->texture_allocate(texture[CameraServer::FEED_CbCr_IMAGE], new_cbcr_width, new_cbcr_height, 0, Image::FORMAT_RG8, VS::TEXTURE_TYPE_2D, VS::TEXTURE_FLAG_USED_FOR_STREAMING); + vs->texture_allocate(texture[CameraServer::FEED_CBCR_IMAGE], new_cbcr_width, new_cbcr_height, 0, Image::FORMAT_RG8, VS::TEXTURE_TYPE_2D, VS::TEXTURE_FLAG_USED_FOR_STREAMING); } vs->texture_set_data(texture[CameraServer::FEED_Y_IMAGE], p_y_img); - vs->texture_set_data(texture[CameraServer::FEED_CbCr_IMAGE], p_cbcr_img); - datatype = CameraFeed::FEED_YCbCr_Sep; + vs->texture_set_data(texture[CameraServer::FEED_CBCR_IMAGE], p_cbcr_img); + datatype = CameraFeed::FEED_YCBCR_SEP; } } diff --git a/servers/camera/camera_feed.h b/servers/camera/camera_feed.h index 90c076071c..0c53ff9309 100644 --- a/servers/camera/camera_feed.h +++ b/servers/camera/camera_feed.h @@ -50,8 +50,8 @@ public: enum FeedDataType { FEED_NOIMAGE, // we don't have an image yet FEED_RGB, // our texture will contain a normal RGB texture that can be used directly - FEED_YCbCr, // our texture will contain a YCbCr texture that needs to be converted to RGB before output - FEED_YCbCr_Sep // our camera is split into two textures, first plane contains Y data, second plane contains CbCr data + FEED_YCBCR, // our texture will contain a YCbCr texture that needs to be converted to RGB before output + FEED_YCBCR_SEP // our camera is split into two textures, first plane contains Y data, second plane contains CbCr data }; enum FeedPosition { diff --git a/servers/camera_server.cpp b/servers/camera_server.cpp index 8d2ae37001..0f93221072 100644 --- a/servers/camera_server.cpp +++ b/servers/camera_server.cpp @@ -47,9 +47,9 @@ void CameraServer::_bind_methods() { ADD_SIGNAL(MethodInfo("camera_feed_removed", PropertyInfo(Variant::INT, "id"))); BIND_ENUM_CONSTANT(FEED_RGBA_IMAGE); - BIND_ENUM_CONSTANT(FEED_YCbCr_IMAGE); + BIND_ENUM_CONSTANT(FEED_YCBCR_IMAGE); BIND_ENUM_CONSTANT(FEED_Y_IMAGE); - BIND_ENUM_CONSTANT(FEED_CbCr_IMAGE); + BIND_ENUM_CONSTANT(FEED_CBCR_IMAGE); }; CameraServer *CameraServer::singleton = NULL; diff --git a/servers/camera_server.h b/servers/camera_server.h index d204142c7d..5a62af3d60 100644 --- a/servers/camera_server.h +++ b/servers/camera_server.h @@ -53,9 +53,9 @@ class CameraServer : public Object { public: enum FeedImage { FEED_RGBA_IMAGE = 0, - FEED_YCbCr_IMAGE = 0, + FEED_YCBCR_IMAGE = 0, FEED_Y_IMAGE = 0, - FEED_CbCr_IMAGE = 1, + FEED_CBCR_IMAGE = 1, FEED_IMAGES = 2 }; diff --git a/servers/physics/area_sw.cpp b/servers/physics/area_sw.cpp index 9d68869bc2..ad3e40916d 100644 --- a/servers/physics/area_sw.cpp +++ b/servers/physics/area_sw.cpp @@ -250,7 +250,7 @@ AreaSW::AreaSW() : gravity_is_point = false; gravity_distance_scale = 0; point_attenuation = 1; - angular_damp = 1.0; + angular_damp = 0.1; linear_damp = 0.1; priority = 0; set_ray_pickable(false); |