diff options
-rw-r--r-- | core/math/geometry_3d.cpp | 2 | ||||
-rw-r--r-- | core/math/plane.h | 2 | ||||
-rw-r--r-- | core/variant/variant_call.cpp | 2 | ||||
-rw-r--r-- | doc/classes/Plane.xml | 17 | ||||
-rw-r--r-- | doc/classes/Transform3D.xml | 1 | ||||
-rw-r--r-- | doc/classes/Tree.xml | 4 | ||||
-rw-r--r-- | doc/classes/TreeItem.xml | 42 | ||||
-rw-r--r-- | editor/plugins/tiles/tile_set_atlas_source_editor.cpp | 100 | ||||
-rw-r--r-- | editor/plugins/tiles/tile_set_atlas_source_editor.h | 2 | ||||
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs | 56 | ||||
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs | 48 | ||||
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs | 84 | ||||
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs | 51 | ||||
-rw-r--r-- | modules/raycast/SCsub | 2 | ||||
-rw-r--r-- | scene/gui/tree.cpp | 98 | ||||
-rw-r--r-- | scene/gui/tree.h | 22 | ||||
-rw-r--r-- | scene/main/scene_tree.cpp | 1 | ||||
-rw-r--r-- | servers/rendering/renderer_scene_render.cpp | 2 | ||||
-rw-r--r-- | tests/core/math/test_plane.h | 4 |
19 files changed, 302 insertions, 238 deletions
diff --git a/core/math/geometry_3d.cpp b/core/math/geometry_3d.cpp index 3ac78e0709..c04fe7320d 100644 --- a/core/math/geometry_3d.cpp +++ b/core/math/geometry_3d.cpp @@ -748,7 +748,7 @@ Geometry3D::MeshData Geometry3D::build_convex_mesh(const Vector<Plane> &p_planes Vector3 right = p.normal.cross(ref).normalized(); Vector3 up = p.normal.cross(right).normalized(); - Vector3 center = p.center(); + Vector3 center = p.get_center(); // make a quad clockwise LocalVector<Vector3> vertices = { diff --git a/core/math/plane.h b/core/math/plane.h index 3bc7c54b9d..8159f25342 100644 --- a/core/math/plane.h +++ b/core/math/plane.h @@ -47,7 +47,7 @@ struct _NO_DISCARD_ Plane { /* Plane-Point operations */ - _FORCE_INLINE_ Vector3 center() const { return normal * d; } + _FORCE_INLINE_ Vector3 get_center() const { return normal * d; } Vector3 get_any_perpendicular_normal() const; _FORCE_INLINE_ bool is_point_over(const Vector3 &p_point) const; ///< Point is over plane diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index 05fb62ff12..2cc0b3a8d7 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -1923,7 +1923,7 @@ static void _register_variant_builtin_methods() { /* Plane */ bind_method(Plane, normalized, sarray(), varray()); - bind_method(Plane, center, sarray(), varray()); + bind_method(Plane, get_center, sarray(), varray()); bind_method(Plane, is_equal_approx, sarray("to_plane"), varray()); bind_method(Plane, is_finite, sarray(), varray()); bind_method(Plane, is_point_over, sarray("point"), varray()); diff --git a/doc/classes/Plane.xml b/doc/classes/Plane.xml index fbe8afa8d1..aa09081e3e 100644 --- a/doc/classes/Plane.xml +++ b/doc/classes/Plane.xml @@ -38,6 +38,7 @@ <param index="0" name="normal" type="Vector3" /> <description> Creates a plane from the normal vector. The plane will intersect the origin. + The [param normal] of the plane must be a unit vector. </description> </constructor> <constructor name="Plane"> @@ -46,6 +47,7 @@ <param index="1" name="d" type="float" /> <description> Creates a plane from the normal vector and the plane's distance from the origin. + The [param normal] of the plane must be a unit vector. </description> </constructor> <constructor name="Plane"> @@ -54,6 +56,7 @@ <param index="1" name="point" type="Vector3" /> <description> Creates a plane from the normal vector and a point on the plane. + The [param normal] of the plane must be a unit vector. </description> </constructor> <constructor name="Plane"> @@ -67,12 +70,6 @@ </constructor> </constructors> <methods> - <method name="center" qualifiers="const"> - <return type="Vector3" /> - <description> - Returns the center of the plane. - </description> - </method> <method name="distance_to" qualifiers="const"> <return type="float" /> <param index="0" name="point" type="Vector3" /> @@ -80,6 +77,12 @@ Returns the shortest distance from the plane to the position [param point]. If the point is above the plane, the distance will be positive. If below, the distance will be negative. </description> </method> + <method name="get_center" qualifiers="const"> + <return type="Vector3" /> + <description> + Returns the center of the plane. + </description> + </method> <method name="has_point" qualifiers="const"> <return type="bool" /> <param index="0" name="point" type="Vector3" /> @@ -152,7 +155,7 @@ In the scalar equation of the plane [code]ax + by + cz = d[/code], this is [code]d[/code], while the [code](a, b, c)[/code] coordinates are represented by the [member normal] property. </member> <member name="normal" type="Vector3" setter="" getter="" default="Vector3(0, 0, 0)"> - The normal of the plane, which must be normalized. + The normal of the plane, which must be a unit vector. In the scalar equation of the plane [code]ax + by + cz = d[/code], this is the vector [code](a, b, c)[/code], where [code]d[/code] is the [member d] property. </member> <member name="x" type="float" setter="" getter="" default="0.0"> diff --git a/doc/classes/Transform3D.xml b/doc/classes/Transform3D.xml index b3145ea022..90c10e3664 100644 --- a/doc/classes/Transform3D.xml +++ b/doc/classes/Transform3D.xml @@ -41,6 +41,7 @@ <return type="Transform3D" /> <param index="0" name="from" type="Projection" /> <description> + Constructs a Transform3D from a [Projection] by trimming the last row of the projection matrix ([code]from.x.w[/code], [code]from.y.w[/code], [code]from.z.w[/code], and [code]from.w.w[/code] are not copied over). </description> </constructor> <constructor name="Transform3D"> diff --git a/doc/classes/Tree.xml b/doc/classes/Tree.xml index bfabd2d97d..ff5a665bfd 100644 --- a/doc/classes/Tree.xml +++ b/doc/classes/Tree.xml @@ -45,11 +45,11 @@ <method name="create_item"> <return type="TreeItem" /> <param index="0" name="parent" type="TreeItem" default="null" /> - <param index="1" name="idx" type="int" default="-1" /> + <param index="1" name="index" type="int" default="-1" /> <description> Creates an item in the tree and adds it as a child of [param parent], which can be either a valid [TreeItem] or [code]null[/code]. If [param parent] is [code]null[/code], the root item will be the parent, or the new item will be the root itself if the tree is empty. - The new item will be the [param idx]th child of parent, or it will be the last child if there are not enough siblings. + The new item will be the [param index]-th child of parent, or it will be the last child if there are not enough siblings. </description> </method> <method name="deselect_all"> diff --git a/doc/classes/TreeItem.xml b/doc/classes/TreeItem.xml index ec6b166e57..91248092d9 100644 --- a/doc/classes/TreeItem.xml +++ b/doc/classes/TreeItem.xml @@ -18,7 +18,7 @@ <param index="3" name="disabled" type="bool" default="false" /> <param index="4" name="tooltip_text" type="String" default="""" /> <description> - Adds a button with [Texture2D] [param button] at column [param column]. The [param id] is used to identify the button. If not specified, the next available index is used, which may be retrieved by calling [method get_button_count] immediately before this method. Optionally, the button can be [param disabled] and have a [param tooltip_text]. + Adds a button with [Texture2D] [param button] at column [param column]. The [param id] is used to identify the button in the according [signal Tree.button_clicked] signal and can be different from the buttons index. If not specified, the next available index is used, which may be retrieved by calling [method get_button_count] immediately before this method. Optionally, the button can be [param disabled] and have a [param tooltip_text]. </description> </method> <method name="call_recursive" qualifiers="vararg"> @@ -44,10 +44,10 @@ </method> <method name="create_child"> <return type="TreeItem" /> - <param index="0" name="idx" type="int" default="-1" /> + <param index="0" name="index" type="int" default="-1" /> <description> Creates an item and adds it as a child. - The new item will be inserted as position [param idx] (the default value [code]-1[/code] means the last position), or it will be the last child if [param idx] is higher than the child count. + The new item will be inserted as position [param index] (the default value [code]-1[/code] means the last position), or it will be the last child if [param index] is higher than the child count. </description> </method> <method name="deselect"> @@ -60,17 +60,17 @@ <method name="erase_button"> <return type="void" /> <param index="0" name="column" type="int" /> - <param index="1" name="button_idx" type="int" /> + <param index="1" name="button_index" type="int" /> <description> - Removes the button at index [param button_idx] in column [param column]. + Removes the button at index [param button_index] in column [param column]. </description> </method> <method name="get_button" qualifiers="const"> <return type="Texture2D" /> <param index="0" name="column" type="int" /> - <param index="1" name="button_idx" type="int" /> + <param index="1" name="button_index" type="int" /> <description> - Returns the [Texture2D] of the button at index [param button_idx] in column [param column]. + Returns the [Texture2D] of the button at index [param button_index] in column [param column]. </description> </method> <method name="get_button_by_id" qualifiers="const"> @@ -91,17 +91,17 @@ <method name="get_button_id" qualifiers="const"> <return type="int" /> <param index="0" name="column" type="int" /> - <param index="1" name="button_idx" type="int" /> + <param index="1" name="button_index" type="int" /> <description> - Returns the ID for the button at index [param button_idx] in column [param column]. + Returns the ID for the button at index [param button_index] in column [param column]. </description> </method> <method name="get_button_tooltip_text" qualifiers="const"> <return type="String" /> <param index="0" name="column" type="int" /> - <param index="1" name="button_idx" type="int" /> + <param index="1" name="button_index" type="int" /> <description> - Returns the tooltip text for the button at index [param button_idx] in column [param column]. + Returns the tooltip text for the button at index [param button_index] in column [param column]. </description> </method> <method name="get_cell_mode" qualifiers="const"> @@ -113,9 +113,9 @@ </method> <method name="get_child"> <return type="TreeItem" /> - <param index="0" name="idx" type="int" /> + <param index="0" name="index" type="int" /> <description> - Returns a child item by its index (see [method get_child_count]). This method is often used for iterating all children of an item. + Returns a child item by its [param index] (see [method get_child_count]). This method is often used for iterating all children of an item. Negative indices access the children from the last one. </description> </method> @@ -332,9 +332,9 @@ <method name="is_button_disabled" qualifiers="const"> <return type="bool" /> <param index="0" name="column" type="int" /> - <param index="1" name="button_idx" type="int" /> + <param index="1" name="button_index" type="int" /> <description> - Returns [code]true[/code] if the button at index [param button_idx] for the given [param column] is disabled. + Returns [code]true[/code] if the button at index [param button_index] for the given [param column] is disabled. </description> </method> <method name="is_checked" qualifiers="const"> @@ -419,28 +419,28 @@ <method name="set_button"> <return type="void" /> <param index="0" name="column" type="int" /> - <param index="1" name="button_idx" type="int" /> + <param index="1" name="button_index" type="int" /> <param index="2" name="button" type="Texture2D" /> <description> - Sets the given column's button [Texture2D] at index [param button_idx] to [param button]. + Sets the given column's button [Texture2D] at index [param button_index] to [param button]. </description> </method> <method name="set_button_color"> <return type="void" /> <param index="0" name="column" type="int" /> - <param index="1" name="button_idx" type="int" /> + <param index="1" name="button_index" type="int" /> <param index="2" name="color" type="Color" /> <description> - Sets the given column's button color at index [param button_idx] to [param color]. + Sets the given column's button color at index [param button_index] to [param color]. </description> </method> <method name="set_button_disabled"> <return type="void" /> <param index="0" name="column" type="int" /> - <param index="1" name="button_idx" type="int" /> + <param index="1" name="button_index" type="int" /> <param index="2" name="disabled" type="bool" /> <description> - If [code]true[/code], disables the button at index [param button_idx] in the given [param column]. + If [code]true[/code], disables the button at index [param button_index] in the given [param column]. </description> </method> <method name="set_cell_mode"> diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp index 146a53f3dd..d59ef6056c 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp @@ -1021,38 +1021,7 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<InputEven Vector2i grid_size = tile_set_atlas_source->get_atlas_grid_size(); - if (drag_type == DRAG_TYPE_NONE) { - if (selection.size() == 1) { - // Change the cursor depending on the hovered thing. - TileSelection selected = selection.front()->get(); - if (selected.tile != TileSetSource::INVALID_ATLAS_COORDS && selected.alternative == 0) { - Vector2 mouse_local_pos = tile_atlas_control->get_local_mouse_position(); - Vector2i size_in_atlas = tile_set_atlas_source->get_tile_size_in_atlas(selected.tile); - Rect2 region = tile_set_atlas_source->get_tile_texture_region(selected.tile); - Size2 zoomed_size = resize_handle->get_size() / tile_atlas_view->get_zoom(); - Rect2 rect = region.grow_individual(zoomed_size.x, zoomed_size.y, 0, 0); - const Vector2i coords[] = { Vector2i(0, 0), Vector2i(1, 0), Vector2i(1, 1), Vector2i(0, 1) }; - const Vector2i directions[] = { Vector2i(0, -1), Vector2i(1, 0), Vector2i(0, 1), Vector2i(-1, 0) }; - CursorShape cursor_shape = CURSOR_ARROW; - bool can_grow[4]; - for (int i = 0; i < 4; i++) { - can_grow[i] = tile_set_atlas_source->has_room_for_tile(selected.tile + directions[i], tile_set_atlas_source->get_tile_size_in_atlas(selected.tile), tile_set_atlas_source->get_tile_animation_columns(selected.tile), tile_set_atlas_source->get_tile_animation_separation(selected.tile), tile_set_atlas_source->get_tile_animation_frames_count(selected.tile), selected.tile); - can_grow[i] |= (i % 2 == 0) ? size_in_atlas.y > 1 : size_in_atlas.x > 1; - } - for (int i = 0; i < 4; i++) { - Vector2 pos = rect.position + rect.size * coords[i]; - if (can_grow[i] && can_grow[(i + 3) % 4] && Rect2(pos, zoomed_size).has_point(mouse_local_pos)) { - cursor_shape = (i % 2) ? CURSOR_BDIAGSIZE : CURSOR_FDIAGSIZE; - } - Vector2 next_pos = rect.position + rect.size * coords[(i + 1) % 4]; - if (can_grow[i] && Rect2((pos + next_pos) / 2.0, zoomed_size).has_point(mouse_local_pos)) { - cursor_shape = (i % 2) ? CURSOR_HSIZE : CURSOR_VSIZE; - } - } - tile_atlas_control->set_default_cursor_shape(cursor_shape); - } - } - } else if (drag_type == DRAG_TYPE_CREATE_BIG_TILE) { + if (drag_type == DRAG_TYPE_CREATE_BIG_TILE) { // Create big tile. new_base_tiles_coords = new_base_tiles_coords.max(Vector2i(0, 0)).min(grid_size - Vector2i(1, 1)); @@ -1243,7 +1212,6 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<InputEven Rect2 rect = region.grow_individual(zoomed_size.x, zoomed_size.y, 0, 0); const Vector2i coords[] = { Vector2i(0, 0), Vector2i(1, 0), Vector2i(1, 1), Vector2i(0, 1) }; const Vector2i directions[] = { Vector2i(0, -1), Vector2i(1, 0), Vector2i(0, 1), Vector2i(-1, 0) }; - CursorShape cursor_shape = CURSOR_ARROW; bool can_grow[4]; for (int i = 0; i < 4; i++) { can_grow[i] = tile_set_atlas_source->has_room_for_tile(selected.tile + directions[i], tile_set_atlas_source->get_tile_size_in_atlas(selected.tile), tile_set_atlas_source->get_tile_animation_columns(selected.tile), tile_set_atlas_source->get_tile_animation_separation(selected.tile), tile_set_atlas_source->get_tile_animation_frames_count(selected.tile), selected.tile); @@ -1257,7 +1225,6 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<InputEven drag_last_mouse_pos = drag_start_mouse_pos; drag_current_tile = selected.tile; drag_start_tile_shape = Rect2i(selected.tile, tile_set_atlas_source->get_tile_size_in_atlas(selected.tile)); - cursor_shape = (i % 2) ? CURSOR_BDIAGSIZE : CURSOR_FDIAGSIZE; } Vector2 next_pos = rect.position + rect.size * coords[(i + 1) % 4]; if (can_grow[i] && Rect2((pos + next_pos) / 2.0, zoomed_size).has_point(mouse_local_pos)) { @@ -1266,10 +1233,8 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<InputEven drag_last_mouse_pos = drag_start_mouse_pos; drag_current_tile = selected.tile; drag_start_tile_shape = Rect2i(selected.tile, tile_set_atlas_source->get_tile_size_in_atlas(selected.tile)); - cursor_shape = (i % 2) ? CURSOR_HSIZE : CURSOR_VSIZE; } } - tile_atlas_control->set_default_cursor_shape(cursor_shape); } } @@ -1292,7 +1257,6 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<InputEven drag_last_mouse_pos = drag_start_mouse_pos; drag_current_tile = selected.tile; drag_start_tile_shape = Rect2i(selected.tile, tile_set_atlas_source->get_tile_size_in_atlas(selected.tile)); - tile_atlas_control->set_default_cursor_shape(CURSOR_MOVE); } else { // Start selection dragging. drag_type = DRAG_TYPE_RECT_SELECT; @@ -1543,7 +1507,67 @@ void TileSetAtlasSourceEditor::_end_dragging() { drag_modified_tiles.clear(); drag_type = DRAG_TYPE_NONE; - tile_atlas_control->set_default_cursor_shape(CURSOR_ARROW); + // Change mouse accordingly. +} + +Control::CursorShape TileSetAtlasSourceEditor::get_cursor_shape(const Point2 &p_pos) const { + Control::CursorShape cursor_shape = get_default_cursor_shape(); + if (drag_type == DRAG_TYPE_NONE) { + if (selection.size() == 1) { + // Change the cursor depending on the hovered thing. + TileSelection selected = selection.front()->get(); + if (selected.tile != TileSetSource::INVALID_ATLAS_COORDS && selected.alternative == 0) { + Transform2D xform = tile_atlas_control->get_global_transform().affine_inverse() * get_global_transform(); + Vector2 mouse_local_pos = xform.xform(p_pos); + Vector2i size_in_atlas = tile_set_atlas_source->get_tile_size_in_atlas(selected.tile); + Rect2 region = tile_set_atlas_source->get_tile_texture_region(selected.tile); + Size2 zoomed_size = resize_handle->get_size() / tile_atlas_view->get_zoom(); + Rect2 rect = region.grow_individual(zoomed_size.x, zoomed_size.y, 0, 0); + const Vector2i coords[] = { Vector2i(0, 0), Vector2i(1, 0), Vector2i(1, 1), Vector2i(0, 1) }; + const Vector2i directions[] = { Vector2i(0, -1), Vector2i(1, 0), Vector2i(0, 1), Vector2i(-1, 0) }; + bool can_grow[4]; + for (int i = 0; i < 4; i++) { + can_grow[i] = tile_set_atlas_source->has_room_for_tile(selected.tile + directions[i], tile_set_atlas_source->get_tile_size_in_atlas(selected.tile), tile_set_atlas_source->get_tile_animation_columns(selected.tile), tile_set_atlas_source->get_tile_animation_separation(selected.tile), tile_set_atlas_source->get_tile_animation_frames_count(selected.tile), selected.tile); + can_grow[i] |= (i % 2 == 0) ? size_in_atlas.y > 1 : size_in_atlas.x > 1; + } + for (int i = 0; i < 4; i++) { + Vector2 pos = rect.position + rect.size * coords[i]; + if (can_grow[i] && can_grow[(i + 3) % 4] && Rect2(pos, zoomed_size).has_point(mouse_local_pos)) { + cursor_shape = (i % 2) ? CURSOR_BDIAGSIZE : CURSOR_FDIAGSIZE; + } + Vector2 next_pos = rect.position + rect.size * coords[(i + 1) % 4]; + if (can_grow[i] && Rect2((pos + next_pos) / 2.0, zoomed_size).has_point(mouse_local_pos)) { + cursor_shape = (i % 2) ? CURSOR_HSIZE : CURSOR_VSIZE; + } + } + } + } + } else { + switch (drag_type) { + case DRAG_TYPE_RESIZE_TOP_LEFT: + case DRAG_TYPE_RESIZE_BOTTOM_RIGHT: + cursor_shape = CURSOR_FDIAGSIZE; + break; + case DRAG_TYPE_RESIZE_TOP: + case DRAG_TYPE_RESIZE_BOTTOM: + cursor_shape = CURSOR_VSIZE; + break; + case DRAG_TYPE_RESIZE_TOP_RIGHT: + case DRAG_TYPE_RESIZE_BOTTOM_LEFT: + cursor_shape = CURSOR_BDIAGSIZE; + break; + case DRAG_TYPE_RESIZE_LEFT: + case DRAG_TYPE_RESIZE_RIGHT: + cursor_shape = CURSOR_HSIZE; + break; + case DRAG_TYPE_MOVE_TILE: + cursor_shape = CURSOR_MOVE; + break; + default: + break; + } + } + return cursor_shape; } HashMap<Vector2i, List<const PropertyInfo *>> TileSetAtlasSourceEditor::_group_properties_per_tiles(const List<PropertyInfo> &r_list, const TileSetAtlasSource *p_atlas) { diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.h b/editor/plugins/tiles/tile_set_atlas_source_editor.h index 85f780ea26..bcab1296ad 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.h +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.h @@ -277,6 +277,8 @@ public: void edit(Ref<TileSet> p_tile_set, TileSetAtlasSource *p_tile_set_source, int p_source_id); void init_source(); + virtual CursorShape get_cursor_shape(const Point2 &p_pos) const override; + TileSetAtlasSourceEditor(); ~TileSetAtlasSourceEditor(); }; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs index c7cdc18b21..19f7c54847 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs @@ -120,31 +120,6 @@ namespace Godot } /// <summary> - /// The scale of this basis. - /// </summary> - /// <value>Equivalent to the lengths of each column vector, but negative if the determinant is negative.</value> - public Vector3 Scale - { - readonly get - { - real_t detSign = Mathf.Sign(Determinant()); - return detSign * new Vector3 - ( - Column0.Length(), - Column1.Length(), - Column2.Length() - ); - } - set - { - value /= Scale; // Value becomes what's called "delta_scale" in core. - Column0 *= value.x; - Column1 *= value.y; - Column2 *= value.z; - } - } - - /// <summary> /// Access whole columns in the form of <see cref="Vector3"/>. /// </summary> /// <param name="column">Which column vector.</param> @@ -567,6 +542,21 @@ namespace Godot } /// <summary> + /// Assuming that the matrix is the combination of a rotation and scaling, + /// return the absolute value of scaling factors along each axis. + /// </summary> + public readonly Vector3 GetScale() + { + real_t detSign = Mathf.Sign(Determinant()); + return detSign * new Vector3 + ( + Column0.Length(), + Column1.Length(), + Column2.Length() + ); + } + + /// <summary> /// Returns the inverse of the matrix. /// </summary> /// <returns>The inverse matrix.</returns> @@ -868,8 +858,20 @@ namespace Godot // We need to assign the struct fields here first so we can't do it that way... } - // Arguments are named such that xy is equal to calling x.y - internal Basis(real_t xx, real_t yx, real_t zx, real_t xy, real_t yy, real_t zy, real_t xz, real_t yz, real_t zz) + /// <summary> + /// Constructs a transformation matrix from the given components. + /// Arguments are named such that xy is equal to calling <c>x.y</c>. + /// </summary> + /// <param name="xx">The X component of the X column vector, accessed via <c>b.x.x</c> or <c>[0][0]</c>.</param> + /// <param name="yx">The X component of the Y column vector, accessed via <c>b.y.x</c> or <c>[1][0]</c>.</param> + /// <param name="zx">The X component of the Z column vector, accessed via <c>b.z.x</c> or <c>[2][0]</c>.</param> + /// <param name="xy">The Y component of the X column vector, accessed via <c>b.x.y</c> or <c>[0][1]</c>.</param> + /// <param name="yy">The Y component of the Y column vector, accessed via <c>b.y.y</c> or <c>[1][1]</c>.</param> + /// <param name="zy">The Y component of the Z column vector, accessed via <c>b.y.y</c> or <c>[2][1]</c>.</param> + /// <param name="xz">The Z component of the X column vector, accessed via <c>b.x.y</c> or <c>[0][2]</c>.</param> + /// <param name="yz">The Z component of the Y column vector, accessed via <c>b.y.y</c> or <c>[1][2]</c>.</param> + /// <param name="zz">The Z component of the Z column vector, accessed via <c>b.y.y</c> or <c>[2][2]</c>.</param> + public Basis(real_t xx, real_t yx, real_t zx, real_t xy, real_t yy, real_t zy, real_t xz, real_t yz, real_t zz) { Row0 = new Vector3(xx, yx, zx); Row1 = new Vector3(xy, yy, zy); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs index 9e5f7c4f9e..8a125e3c73 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs @@ -15,7 +15,7 @@ namespace Godot private Vector3 _normal; /// <summary> - /// The normal of the plane, which must be normalized. + /// The normal of the plane, which must be a unit vector. /// In the scalar equation of the plane <c>ax + by + cz = d</c>, this is /// the vector <c>(a, b, c)</c>, where <c>d</c> is the <see cref="D"/> property. /// </summary> @@ -85,23 +85,6 @@ namespace Godot public real_t D { get; set; } /// <summary> - /// The center of the plane, the point where the normal line intersects the plane. - /// </summary> - /// <value>Equivalent to <see cref="Normal"/> multiplied by <see cref="D"/>.</value> - public Vector3 Center - { - readonly get - { - return _normal * D; - } - set - { - _normal = value.Normalized(); - D = value.Length(); - } - } - - /// <summary> /// Returns the shortest distance from this plane to the position <paramref name="point"/>. /// </summary> /// <param name="point">The position to use for the calculation.</param> @@ -112,6 +95,16 @@ namespace Godot } /// <summary> + /// Returns the center of the plane, the point on the plane closest to the origin. + /// The point where the normal line going through the origin intersects the plane. + /// </summary> + /// <value>Equivalent to <see cref="Normal"/> multiplied by <see cref="D"/>.</value> + public readonly Vector3 GetCenter() + { + return _normal * D; + } + + /// <summary> /// Returns <see langword="true"/> if point is inside the plane. /// Comparison uses a custom minimum tolerance threshold. /// </summary> @@ -155,7 +148,7 @@ namespace Godot /// <param name="from">The start of the ray.</param> /// <param name="dir">The direction of the ray, normalized.</param> /// <returns>The intersection, or <see langword="null"/> if none is found.</returns> - public readonly Vector3? IntersectRay(Vector3 from, Vector3 dir) + public readonly Vector3? IntersectsRay(Vector3 from, Vector3 dir) { real_t den = _normal.Dot(dir); @@ -183,7 +176,7 @@ namespace Godot /// <param name="begin">The start of the line segment.</param> /// <param name="end">The end of the line segment.</param> /// <returns>The intersection, or <see langword="null"/> if none is found.</returns> - public readonly Vector3? IntersectSegment(Vector3 begin, Vector3 end) + public readonly Vector3? IntersectsSegment(Vector3 begin, Vector3 end) { Vector3 segment = begin - end; real_t den = _normal.Dot(segment); @@ -290,10 +283,21 @@ namespace Godot } /// <summary> + /// Constructs a <see cref="Plane"/> from a <paramref name="normal"/> vector. + /// The plane will intersect the origin. + /// </summary> + /// <param name="normal">The normal of the plane, must be a unit vector.</param> + public Plane(Vector3 normal) + { + _normal = normal; + D = 0; + } + + /// <summary> /// Constructs a <see cref="Plane"/> from a <paramref name="normal"/> vector and /// the plane's distance to the origin <paramref name="d"/>. /// </summary> - /// <param name="normal">The normal of the plane, must be normalized.</param> + /// <param name="normal">The normal of the plane, must be a unit vector.</param> /// <param name="d">The plane's distance from the origin. This value is typically non-negative.</param> public Plane(Vector3 normal, real_t d) { @@ -305,7 +309,7 @@ namespace Godot /// Constructs a <see cref="Plane"/> from a <paramref name="normal"/> vector and /// a <paramref name="point"/> on the plane. /// </summary> - /// <param name="normal">The normal of the plane, must be normalized.</param> + /// <param name="normal">The normal of the plane, must be a unit vector.</param> /// <param name="point">The point on the plane.</param> public Plane(Vector3 normal, Vector3 point) { diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs index c99d91bff1..6dda150c2b 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs @@ -32,45 +32,6 @@ namespace Godot public Vector2 origin; /// <summary> - /// The rotation of this transformation matrix. - /// </summary> - /// <value>Getting is equivalent to calling <see cref="Mathf.Atan2(real_t, real_t)"/> with the values of <see cref="x"/>.</value> - public real_t Rotation - { - readonly get - { - return Mathf.Atan2(x.y, x.x); - } - set - { - Vector2 scale = Scale; - x.x = y.y = Mathf.Cos(value); - x.y = y.x = Mathf.Sin(value); - y.x *= -1; - Scale = scale; - } - } - - /// <summary> - /// The scale of this transformation matrix. - /// </summary> - /// <value>Equivalent to the lengths of each column vector, but Y is negative if the determinant is negative.</value> - public Vector2 Scale - { - readonly get - { - real_t detSign = Mathf.Sign(BasisDeterminant()); - return new Vector2(x.Length(), detSign * y.Length()); - } - set - { - value /= Scale; // Value becomes what's called "delta_scale" in core. - x *= value.x; - y *= value.y; - } - } - - /// <summary> /// Access whole columns in the form of <see cref="Vector2"/>. /// The third column is the <see cref="origin"/> vector. /// </summary> @@ -203,6 +164,23 @@ namespace Godot } /// <summary> + /// Returns the transform's rotation (in radians). + /// </summary> + public readonly real_t GetRotation() + { + return Mathf.Atan2(x.y, x.x); + } + + /// <summary> + /// Returns the scale. + /// </summary> + public readonly Vector2 GetScale() + { + real_t detSign = Mathf.Sign(BasisDeterminant()); + return new Vector2(x.Length(), detSign * y.Length()); + } + + /// <summary> /// Interpolates this transform to the other <paramref name="transform"/> by <paramref name="weight"/>. /// </summary> /// <param name="transform">The other transform.</param> @@ -210,11 +188,11 @@ namespace Godot /// <returns>The interpolated transform.</returns> public readonly Transform2D InterpolateWith(Transform2D transform, real_t weight) { - real_t r1 = Rotation; - real_t r2 = transform.Rotation; + real_t r1 = GetRotation(); + real_t r2 = transform.GetRotation(); - Vector2 s1 = Scale; - Vector2 s2 = transform.Scale; + Vector2 s1 = GetScale(); + Vector2 s2 = transform.GetScale(); // Slerp rotation var v1 = new Vector2(Mathf.Cos(r1), Mathf.Sin(r1)); @@ -433,7 +411,7 @@ namespace Godot /// <summary> /// Constructs a transformation matrix from the given components. - /// Arguments are named such that xy is equal to calling x.y + /// Arguments are named such that xy is equal to calling <c>x.y</c>. /// </summary> /// <param name="xx">The X component of the X column vector, accessed via <c>t.x.x</c> or <c>[0][0]</c>.</param> /// <param name="xy">The Y component of the X column vector, accessed via <c>t.x.y</c> or <c>[0][1]</c>.</param> @@ -463,6 +441,24 @@ namespace Godot } /// <summary> + /// Constructs a transformation matrix from a <paramref name="rotation"/> value, + /// <paramref name="scale"/> vector, <paramref name="skew"/> value, and + /// <paramref name="origin"/> vector. + /// </summary> + /// <param name="rotation">The rotation of the new transform, in radians.</param> + /// <param name="scale">The scale of the new transform.</param> + /// <param name="skew">The skew of the new transform, in radians.</param> + /// <param name="origin">The origin vector, or column index 2.</param> + public Transform2D(real_t rotation, Vector2 scale, real_t skew, Vector2 origin) + { + x.x = Mathf.Cos(rotation) * scale.x; + y.y = Mathf.Cos(rotation + skew) * scale.y; + y.x = -Mathf.Sin(rotation + skew) * scale.y; + x.y = Mathf.Sin(rotation) * scale.x; + this.origin = origin; + } + + /// <summary> /// Composes these two transformation matrices by multiplying them /// together. This has the effect of transforming the second transform /// (the child) by the first transform (the parent). diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs index 23f6d9ca04..6b2475fc59 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs @@ -124,11 +124,11 @@ namespace Godot /// <returns>The interpolated transform.</returns> public readonly Transform3D InterpolateWith(Transform3D transform, real_t weight) { - Vector3 sourceScale = basis.Scale; + Vector3 sourceScale = basis.GetScale(); Quaternion sourceRotation = basis.GetRotationQuaternion(); Vector3 sourceLocation = origin; - Vector3 destinationScale = transform.basis.Scale; + Vector3 destinationScale = transform.basis.GetScale(); Quaternion destinationRotation = transform.basis.GetRotationQuaternion(); Vector3 destinationLocation = transform.origin; @@ -342,15 +342,25 @@ namespace Godot } /// <summary> - /// Constructs a transformation matrix from the given <paramref name="quaternion"/> - /// and <paramref name="origin"/> vector. + /// Constructs a transformation matrix from the given components. + /// Arguments are named such that xy is equal to calling <c>basis.x.y</c>. /// </summary> - /// <param name="quaternion">The <see cref="Quaternion"/> to create the basis from.</param> - /// <param name="origin">The origin vector, or column index 3.</param> - public Transform3D(Quaternion quaternion, Vector3 origin) + /// <param name="xx">The X component of the X column vector, accessed via <c>t.basis.x.x</c> or <c>[0][0]</c>.</param> + /// <param name="yx">The X component of the Y column vector, accessed via <c>t.basis.y.x</c> or <c>[1][0]</c>.</param> + /// <param name="zx">The X component of the Z column vector, accessed via <c>t.basis.z.x</c> or <c>[2][0]</c>.</param> + /// <param name="xy">The Y component of the X column vector, accessed via <c>t.basis.x.y</c> or <c>[0][1]</c>.</param> + /// <param name="yy">The Y component of the Y column vector, accessed via <c>t.basis.y.y</c> or <c>[1][1]</c>.</param> + /// <param name="zy">The Y component of the Z column vector, accessed via <c>t.basis.y.y</c> or <c>[2][1]</c>.</param> + /// <param name="xz">The Z component of the X column vector, accessed via <c>t.basis.x.y</c> or <c>[0][2]</c>.</param> + /// <param name="yz">The Z component of the Y column vector, accessed via <c>t.basis.y.y</c> or <c>[1][2]</c>.</param> + /// <param name="zz">The Z component of the Z column vector, accessed via <c>t.basis.y.y</c> or <c>[2][2]</c>.</param> + /// <param name="ox">The X component of the origin vector, accessed via <c>t.origin.x</c> or <c>[2][0]</c>.</param> + /// <param name="oy">The Y component of the origin vector, accessed via <c>t.origin.y</c> or <c>[2][1]</c>.</param> + /// <param name="oz">The Z component of the origin vector, accessed via <c>t.origin.z</c> or <c>[2][2]</c>.</param> + public Transform3D(real_t xx, real_t yx, real_t zx, real_t xy, real_t yy, real_t zy, real_t xz, real_t yz, real_t zz, real_t ox, real_t oy, real_t oz) { - basis = new Basis(quaternion); - this.origin = origin; + basis = new Basis(xx, yx, zx, xy, yy, zy, xz, yz, zz); + origin = new Vector3(ox, oy, oz); } /// <summary> @@ -366,6 +376,29 @@ namespace Godot } /// <summary> + /// Constructs a transformation matrix from the given <paramref name="projection"/> + /// by trimming the last row of the projection matrix (<c>projection.x.w</c>, + /// <c>projection.y.w</c>, <c>projection.z.w</c>, and <c>projection.w.w</c> + /// are not copied over). + /// </summary> + /// <param name="projection">The <see cref="Projection"/> to create the transform from.</param> + public Transform3D(Projection projection) + { + basis = new Basis + ( + projection.x.x, projection.y.x, projection.z.x, + projection.x.y, projection.y.y, projection.z.y, + projection.x.z, projection.y.z, projection.z.z + ); + origin = new Vector3 + ( + projection.w.x, + projection.w.y, + projection.w.z + ); + } + + /// <summary> /// Composes these two transformation matrices by multiplying them /// together. This has the effect of transforming the second transform /// (the child) by the first transform (the parent). diff --git a/modules/raycast/SCsub b/modules/raycast/SCsub index 37c8a95905..209ebab388 100644 --- a/modules/raycast/SCsub +++ b/modules/raycast/SCsub @@ -96,7 +96,7 @@ if env["builtin_embree"]: if not env.msvc: # Flags synced with upstream gnu.cmake. - if env["arch"] == "arm64" and env["platform"] == "linuxbsd": + if env["arch"] == "arm64" and env["platform"] == "linuxbsd" and not env["use_llvm"]: env_thirdparty.Append(CXXFLAGS=["-flax-vector-conversions"]) env_thirdparty.Append( diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 3458b87b8d..2138f10ad0 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -657,7 +657,7 @@ int TreeItem::get_custom_minimum_height() const { /* Item manipulation */ -TreeItem *TreeItem::create_child(int p_idx) { +TreeItem *TreeItem::create_child(int p_index) { TreeItem *ti = memnew(TreeItem(tree)); if (tree) { ti->cells.resize(tree->columns.size()); @@ -669,7 +669,7 @@ TreeItem *TreeItem::create_child(int p_idx) { int idx = 0; while (c) { - if (idx++ == p_idx) { + if (idx++ == p_index) { c->prev = ti; ti->next = c; break; @@ -683,7 +683,7 @@ TreeItem *TreeItem::create_child(int p_idx) { ti->prev = l_prev; if (!children_cache.is_empty()) { if (ti->next) { - children_cache.insert(p_idx, ti); + children_cache.insert(p_index, ti); } else { children_cache.append(ti); } @@ -826,15 +826,15 @@ TreeItem *TreeItem::get_next_visible(bool p_wrap) { return next_item; } -TreeItem *TreeItem::get_child(int p_idx) { +TreeItem *TreeItem::get_child(int p_index) { _create_children_cache(); - if (p_idx < 0) { - p_idx += children_cache.size(); + if (p_index < 0) { + p_index += children_cache.size(); } - ERR_FAIL_INDEX_V(p_idx, children_cache.size(), nullptr); + ERR_FAIL_INDEX_V(p_index, children_cache.size(), nullptr); - return children_cache.get(p_idx); + return children_cache.get(p_index); } int TreeItem::get_visible_child_count() { @@ -1058,28 +1058,28 @@ int TreeItem::get_button_count(int p_column) const { return cells[p_column].buttons.size(); } -Ref<Texture2D> TreeItem::get_button(int p_column, int p_idx) const { +Ref<Texture2D> TreeItem::get_button(int p_column, int p_index) const { ERR_FAIL_INDEX_V(p_column, cells.size(), Ref<Texture2D>()); - ERR_FAIL_INDEX_V(p_idx, cells[p_column].buttons.size(), Ref<Texture2D>()); - return cells[p_column].buttons[p_idx].texture; + ERR_FAIL_INDEX_V(p_index, cells[p_column].buttons.size(), Ref<Texture2D>()); + return cells[p_column].buttons[p_index].texture; } -String TreeItem::get_button_tooltip_text(int p_column, int p_idx) const { +String TreeItem::get_button_tooltip_text(int p_column, int p_index) const { ERR_FAIL_INDEX_V(p_column, cells.size(), String()); - ERR_FAIL_INDEX_V(p_idx, cells[p_column].buttons.size(), String()); - return cells[p_column].buttons[p_idx].tooltip; + ERR_FAIL_INDEX_V(p_index, cells[p_column].buttons.size(), String()); + return cells[p_column].buttons[p_index].tooltip; } -int TreeItem::get_button_id(int p_column, int p_idx) const { +int TreeItem::get_button_id(int p_column, int p_index) const { ERR_FAIL_INDEX_V(p_column, cells.size(), -1); - ERR_FAIL_INDEX_V(p_idx, cells[p_column].buttons.size(), -1); - return cells[p_column].buttons[p_idx].id; + ERR_FAIL_INDEX_V(p_index, cells[p_column].buttons.size(), -1); + return cells[p_column].buttons[p_index].id; } -void TreeItem::erase_button(int p_column, int p_idx) { +void TreeItem::erase_button(int p_column, int p_index) { ERR_FAIL_INDEX(p_column, cells.size()); - ERR_FAIL_INDEX(p_idx, cells[p_column].buttons.size()); - cells.write[p_column].buttons.remove_at(p_idx); + ERR_FAIL_INDEX(p_index, cells[p_column].buttons.size()); + cells.write[p_column].buttons.remove_at(p_index); _changed_notify(p_column); } @@ -1094,52 +1094,52 @@ int TreeItem::get_button_by_id(int p_column, int p_id) const { return -1; } -void TreeItem::set_button(int p_column, int p_idx, const Ref<Texture2D> &p_button) { +void TreeItem::set_button(int p_column, int p_index, const Ref<Texture2D> &p_button) { ERR_FAIL_COND(p_button.is_null()); ERR_FAIL_INDEX(p_column, cells.size()); - ERR_FAIL_INDEX(p_idx, cells[p_column].buttons.size()); + ERR_FAIL_INDEX(p_index, cells[p_column].buttons.size()); - if (cells[p_column].buttons[p_idx].texture == p_button) { + if (cells[p_column].buttons[p_index].texture == p_button) { return; } - cells.write[p_column].buttons.write[p_idx].texture = p_button; + cells.write[p_column].buttons.write[p_index].texture = p_button; cells.write[p_column].cached_minimum_size_dirty = true; _changed_notify(p_column); } -void TreeItem::set_button_color(int p_column, int p_idx, const Color &p_color) { +void TreeItem::set_button_color(int p_column, int p_index, const Color &p_color) { ERR_FAIL_INDEX(p_column, cells.size()); - ERR_FAIL_INDEX(p_idx, cells[p_column].buttons.size()); + ERR_FAIL_INDEX(p_index, cells[p_column].buttons.size()); - if (cells[p_column].buttons[p_idx].color == p_color) { + if (cells[p_column].buttons[p_index].color == p_color) { return; } - cells.write[p_column].buttons.write[p_idx].color = p_color; + cells.write[p_column].buttons.write[p_index].color = p_color; _changed_notify(p_column); } -void TreeItem::set_button_disabled(int p_column, int p_idx, bool p_disabled) { +void TreeItem::set_button_disabled(int p_column, int p_index, bool p_disabled) { ERR_FAIL_INDEX(p_column, cells.size()); - ERR_FAIL_INDEX(p_idx, cells[p_column].buttons.size()); + ERR_FAIL_INDEX(p_index, cells[p_column].buttons.size()); - if (cells[p_column].buttons[p_idx].disabled == p_disabled) { + if (cells[p_column].buttons[p_index].disabled == p_disabled) { return; } - cells.write[p_column].buttons.write[p_idx].disabled = p_disabled; + cells.write[p_column].buttons.write[p_index].disabled = p_disabled; cells.write[p_column].cached_minimum_size_dirty = true; _changed_notify(p_column); } -bool TreeItem::is_button_disabled(int p_column, int p_idx) const { +bool TreeItem::is_button_disabled(int p_column, int p_index) const { ERR_FAIL_INDEX_V(p_column, cells.size(), false); - ERR_FAIL_INDEX_V(p_idx, cells[p_column].buttons.size(), false); + ERR_FAIL_INDEX_V(p_index, cells[p_column].buttons.size(), false); - return cells[p_column].buttons[p_idx].disabled; + return cells[p_column].buttons[p_index].disabled; } void TreeItem::set_editable(int p_column, bool p_editable) { @@ -1497,15 +1497,15 @@ void TreeItem::_bind_methods() { ClassDB::bind_method(D_METHOD("add_button", "column", "button", "id", "disabled", "tooltip_text"), &TreeItem::add_button, DEFVAL(-1), DEFVAL(false), DEFVAL("")); ClassDB::bind_method(D_METHOD("get_button_count", "column"), &TreeItem::get_button_count); - ClassDB::bind_method(D_METHOD("get_button_tooltip_text", "column", "button_idx"), &TreeItem::get_button_tooltip_text); - ClassDB::bind_method(D_METHOD("get_button_id", "column", "button_idx"), &TreeItem::get_button_id); + ClassDB::bind_method(D_METHOD("get_button_tooltip_text", "column", "button_index"), &TreeItem::get_button_tooltip_text); + ClassDB::bind_method(D_METHOD("get_button_id", "column", "button_index"), &TreeItem::get_button_id); ClassDB::bind_method(D_METHOD("get_button_by_id", "column", "id"), &TreeItem::get_button_by_id); - ClassDB::bind_method(D_METHOD("get_button", "column", "button_idx"), &TreeItem::get_button); - ClassDB::bind_method(D_METHOD("set_button", "column", "button_idx", "button"), &TreeItem::set_button); - ClassDB::bind_method(D_METHOD("erase_button", "column", "button_idx"), &TreeItem::erase_button); - ClassDB::bind_method(D_METHOD("set_button_disabled", "column", "button_idx", "disabled"), &TreeItem::set_button_disabled); - ClassDB::bind_method(D_METHOD("set_button_color", "column", "button_idx", "color"), &TreeItem::set_button_color); - ClassDB::bind_method(D_METHOD("is_button_disabled", "column", "button_idx"), &TreeItem::is_button_disabled); + ClassDB::bind_method(D_METHOD("get_button", "column", "button_index"), &TreeItem::get_button); + ClassDB::bind_method(D_METHOD("set_button", "column", "button_index", "button"), &TreeItem::set_button); + ClassDB::bind_method(D_METHOD("erase_button", "column", "button_index"), &TreeItem::erase_button); + ClassDB::bind_method(D_METHOD("set_button_disabled", "column", "button_index", "disabled"), &TreeItem::set_button_disabled); + ClassDB::bind_method(D_METHOD("set_button_color", "column", "button_index", "color"), &TreeItem::set_button_color); + ClassDB::bind_method(D_METHOD("is_button_disabled", "column", "button_index"), &TreeItem::is_button_disabled); ClassDB::bind_method(D_METHOD("set_tooltip_text", "column", "tooltip"), &TreeItem::set_tooltip_text); ClassDB::bind_method(D_METHOD("get_tooltip_text", "column"), &TreeItem::get_tooltip_text); @@ -1518,7 +1518,7 @@ void TreeItem::_bind_methods() { ClassDB::bind_method(D_METHOD("set_disable_folding", "disable"), &TreeItem::set_disable_folding); ClassDB::bind_method(D_METHOD("is_folding_disabled"), &TreeItem::is_folding_disabled); - ClassDB::bind_method(D_METHOD("create_child", "idx"), &TreeItem::create_child, DEFVAL(-1)); + ClassDB::bind_method(D_METHOD("create_child", "index"), &TreeItem::create_child, DEFVAL(-1)); ClassDB::bind_method(D_METHOD("get_tree"), &TreeItem::get_tree); ClassDB::bind_method(D_METHOD("get_next"), &TreeItem::get_next); @@ -1529,7 +1529,7 @@ void TreeItem::_bind_methods() { ClassDB::bind_method(D_METHOD("get_next_visible", "wrap"), &TreeItem::get_next_visible, DEFVAL(false)); ClassDB::bind_method(D_METHOD("get_prev_visible", "wrap"), &TreeItem::get_prev_visible, DEFVAL(false)); - ClassDB::bind_method(D_METHOD("get_child", "idx"), &TreeItem::get_child); + ClassDB::bind_method(D_METHOD("get_child", "index"), &TreeItem::get_child); ClassDB::bind_method(D_METHOD("get_child_count"), &TreeItem::get_child_count); ClassDB::bind_method(D_METHOD("get_children"), &TreeItem::get_children); ClassDB::bind_method(D_METHOD("get_index"), &TreeItem::get_index); @@ -4108,14 +4108,14 @@ Size2 Tree::get_minimum_size() const { } } -TreeItem *Tree::create_item(TreeItem *p_parent, int p_idx) { +TreeItem *Tree::create_item(TreeItem *p_parent, int p_index) { ERR_FAIL_COND_V(blocked > 0, nullptr); TreeItem *ti = nullptr; if (p_parent) { ERR_FAIL_COND_V_MSG(p_parent->tree != this, nullptr, "A different tree owns the given parent"); - ti = p_parent->create_child(p_idx); + ti = p_parent->create_child(p_index); } else { if (!root) { // No root exists, make the given item the new root. @@ -4126,7 +4126,7 @@ TreeItem *Tree::create_item(TreeItem *p_parent, int p_idx) { root = ti; } else { // Root exists, append or insert to root. - ti = create_item(root, p_idx); + ti = create_item(root, p_index); } } @@ -5162,7 +5162,7 @@ bool Tree::get_allow_reselect() const { void Tree::_bind_methods() { ClassDB::bind_method(D_METHOD("clear"), &Tree::clear); - ClassDB::bind_method(D_METHOD("create_item", "parent", "idx"), &Tree::create_item, DEFVAL(Variant()), DEFVAL(-1)); + ClassDB::bind_method(D_METHOD("create_item", "parent", "index"), &Tree::create_item, DEFVAL(Variant()), DEFVAL(-1)); ClassDB::bind_method(D_METHOD("get_root"), &Tree::get_root); ClassDB::bind_method(D_METHOD("set_column_custom_minimum_width", "column", "min_width"), &Tree::set_column_custom_minimum_width); diff --git a/scene/gui/tree.h b/scene/gui/tree.h index e0ed5fdfb5..ec639ce439 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -247,15 +247,15 @@ public: void add_button(int p_column, const Ref<Texture2D> &p_button, int p_id = -1, bool p_disabled = false, const String &p_tooltip = ""); int get_button_count(int p_column) const; - String get_button_tooltip_text(int p_column, int p_idx) const; - Ref<Texture2D> get_button(int p_column, int p_idx) const; - int get_button_id(int p_column, int p_idx) const; - void erase_button(int p_column, int p_idx); + String get_button_tooltip_text(int p_column, int p_index) const; + Ref<Texture2D> get_button(int p_column, int p_index) const; + int get_button_id(int p_column, int p_index) const; + void erase_button(int p_column, int p_index); int get_button_by_id(int p_column, int p_id) const; - void set_button(int p_column, int p_idx, const Ref<Texture2D> &p_button); - void set_button_color(int p_column, int p_idx, const Color &p_color); - void set_button_disabled(int p_column, int p_idx, bool p_disabled); - bool is_button_disabled(int p_column, int p_idx) const; + void set_button(int p_column, int p_index, const Ref<Texture2D> &p_button); + void set_button_color(int p_column, int p_index, const Color &p_color); + void set_button_disabled(int p_column, int p_index, bool p_disabled); + bool is_button_disabled(int p_column, int p_index) const; /* range works for mode number or mode combo */ @@ -329,7 +329,7 @@ public: /* Item manipulation */ - TreeItem *create_child(int p_idx = -1); + TreeItem *create_child(int p_index = -1); Tree *get_tree() const; @@ -341,7 +341,7 @@ public: TreeItem *get_prev_visible(bool p_wrap = false); TreeItem *get_next_visible(bool p_wrap = false); - TreeItem *get_child(int p_idx); + TreeItem *get_child(int p_index); int get_visible_child_count(); int get_child_count(); TypedArray<TreeItem> get_children(); @@ -647,7 +647,7 @@ public: void clear(); - TreeItem *create_item(TreeItem *p_parent = nullptr, int p_idx = -1); + TreeItem *create_item(TreeItem *p_parent = nullptr, int p_index = -1); TreeItem *get_root() const; TreeItem *get_last_item() const; diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index b5c587c0aa..fbe11c94d1 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -1134,7 +1134,6 @@ Error SceneTree::change_scene_to_packed(const Ref<PackedScene> &p_scene) { ERR_FAIL_COND_V_MSG(p_scene.is_null(), ERR_INVALID_PARAMETER, "Can't change to a null scene. Use unload_current_scene() if you wish to unload it."); Node *new_scene = p_scene->instantiate(); - new_scene = p_scene->instantiate(); ERR_FAIL_COND_V(!new_scene, ERR_CANT_CREATE); call_deferred(SNAME("_change_scene"), new_scene); diff --git a/servers/rendering/renderer_scene_render.cpp b/servers/rendering/renderer_scene_render.cpp index e2e6ea5aa2..a389e3e767 100644 --- a/servers/rendering/renderer_scene_render.cpp +++ b/servers/rendering/renderer_scene_render.cpp @@ -84,7 +84,7 @@ void RendererSceneRender::CameraData::set_multiview_camera(uint32_t p_view_count Transform3D main_transform_inv = main_transform.inverse(); // 5. figure out far plane, this could use some improvement, we may have our far plane too close like this, not sure if this matters - Vector3 far_center = (planes[0][Projection::PLANE_FAR].center() + planes[1][Projection::PLANE_FAR].center()) * 0.5; + Vector3 far_center = (planes[0][Projection::PLANE_FAR].get_center() + planes[1][Projection::PLANE_FAR].get_center()) * 0.5; Plane far(-z, far_center); ///////////////////////////////////////////////////////////////////////////// diff --git a/tests/core/math/test_plane.h b/tests/core/math/test_plane.h index b2b857ca69..f784a29a17 100644 --- a/tests/core/math/test_plane.h +++ b/tests/core/math/test_plane.h @@ -87,8 +87,8 @@ TEST_CASE("[Plane] Plane-point operations") { const Plane y_facing_plane = Plane(0, 1, 0, 4); CHECK_MESSAGE( - plane.center().is_equal_approx(Vector3(32 * 3, 22 * 3, 16 * 3)), - "center() should return a vector pointing to the center of the plane."); + plane.get_center().is_equal_approx(Vector3(32 * 3, 22 * 3, 16 * 3)), + "get_center() should return a vector pointing to the center of the plane."); CHECK_MESSAGE( y_facing_plane.is_point_over(Vector3(0, 5, 0)), |