summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/camera_2d.cpp8
-rw-r--r--scene/2d/collision_polygon_2d.cpp5
-rw-r--r--scene/2d/joints_2d.cpp12
-rw-r--r--scene/2d/light_occluder_2d.cpp5
-rw-r--r--scene/2d/line_2d.cpp3
-rw-r--r--scene/2d/navigation_agent_2d.cpp3
-rw-r--r--scene/2d/navigation_region_2d.cpp5
-rw-r--r--scene/2d/path_2d.cpp9
-rw-r--r--scene/2d/path_2d.h2
-rw-r--r--scene/2d/polygon_2d.cpp8
-rw-r--r--scene/3d/baked_lightmap.cpp2
-rw-r--r--scene/3d/collision_polygon_3d.cpp3
-rw-r--r--scene/3d/light_3d.cpp2
-rw-r--r--scene/3d/navigation_agent_3d.cpp2
-rw-r--r--scene/3d/path_3d.cpp6
-rw-r--r--scene/3d/path_3d.h2
-rw-r--r--scene/3d/skeleton_3d.cpp42
-rw-r--r--scene/3d/skeleton_3d.h1
-rw-r--r--scene/3d/voxelizer.cpp10
-rw-r--r--scene/animation/animation_blend_space_2d.cpp10
-rw-r--r--scene/animation/animation_player.cpp2
-rw-r--r--scene/debugger/scene_debugger.cpp9
-rw-r--r--scene/gui/color_picker.cpp2
-rw-r--r--scene/gui/container.cpp4
-rw-r--r--scene/gui/control.cpp5
-rw-r--r--scene/gui/file_dialog.cpp5
-rw-r--r--scene/gui/line_edit.cpp4
-rw-r--r--scene/gui/rich_text_label.cpp321
-rw-r--r--scene/gui/rich_text_label.h5
-rw-r--r--scene/gui/scroll_bar.cpp21
-rw-r--r--scene/gui/scroll_bar.h22
-rw-r--r--scene/gui/tab_container.cpp49
-rw-r--r--scene/gui/tab_container.h1
-rw-r--r--scene/gui/tree.cpp21
-rw-r--r--scene/main/canvas_item.cpp4
-rw-r--r--scene/main/node.cpp61
-rw-r--r--scene/register_scene_types.cpp1
-rw-r--r--scene/resources/animation.cpp6
-rw-r--r--scene/resources/capsule_shape_2d.cpp3
-rw-r--r--scene/resources/concave_polygon_shape_2d.cpp3
-rw-r--r--scene/resources/convex_polygon_shape_2d.cpp8
-rw-r--r--scene/resources/convex_polygon_shape_3d.cpp2
-rw-r--r--scene/resources/default_theme/default_theme.cpp4
-rw-r--r--scene/resources/default_theme/icon_file.pngbin0 -> 183 bytes
-rw-r--r--scene/resources/default_theme/theme_data.h4
-rw-r--r--scene/resources/dynamic_font.cpp2
-rw-r--r--scene/resources/font.cpp3
-rw-r--r--scene/resources/line_shape_2d.cpp3
-rw-r--r--scene/resources/packed_scene.cpp3
-rw-r--r--scene/resources/polygon_path_finder.cpp20
-rw-r--r--scene/resources/primitive_meshes.cpp2
-rw-r--r--scene/resources/ray_shape_2d.cpp105
-rw-r--r--scene/resources/ray_shape_2d.h61
-rw-r--r--scene/resources/segment_shape_2d.cpp77
-rw-r--r--scene/resources/segment_shape_2d.h25
-rw-r--r--scene/resources/shader.cpp2
-rw-r--r--scene/resources/tile_set.cpp4
-rw-r--r--scene/scene_string_names.cpp2
-rw-r--r--scene/scene_string_names.h2
59 files changed, 585 insertions, 433 deletions
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp
index 8f69676da4..68e99445d8 100644
--- a/scene/2d/camera_2d.cpp
+++ b/scene/2d/camera_2d.cpp
@@ -343,7 +343,9 @@ void Camera2D::_notification(int p_what) {
void Camera2D::set_offset(const Vector2 &p_offset) {
offset = p_offset;
+ Point2 old_smoothed_camera_pos = smoothed_camera_pos;
_update_scroll();
+ smoothed_camera_pos = old_smoothed_camera_pos;
}
Vector2 Camera2D::get_offset() const {
@@ -361,7 +363,9 @@ Camera2D::AnchorMode Camera2D::get_anchor_mode() const {
void Camera2D::set_rotating(bool p_rotating) {
rotating = p_rotating;
+ Point2 old_smoothed_camera_pos = smoothed_camera_pos;
_update_scroll();
+ smoothed_camera_pos = old_smoothed_camera_pos;
}
bool Camera2D::is_rotating() const {
@@ -522,7 +526,9 @@ bool Camera2D::is_v_drag_enabled() const {
void Camera2D::set_v_offset(float p_offset) {
v_ofs = p_offset;
v_offset_changed = true;
+ Point2 old_smoothed_camera_pos = smoothed_camera_pos;
_update_scroll();
+ smoothed_camera_pos = old_smoothed_camera_pos;
}
float Camera2D::get_v_offset() const {
@@ -532,7 +538,9 @@ float Camera2D::get_v_offset() const {
void Camera2D::set_h_offset(float p_offset) {
h_ofs = p_offset;
h_offset_changed = true;
+ Point2 old_smoothed_camera_pos = smoothed_camera_pos;
_update_scroll();
+ smoothed_camera_pos = old_smoothed_camera_pos;
}
float Camera2D::get_h_offset() const {
diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp
index 4919ef8304..d23398713a 100644
--- a/scene/2d/collision_polygon_2d.cpp
+++ b/scene/2d/collision_polygon_2d.cpp
@@ -32,6 +32,7 @@
#include "collision_object_2d.h"
#include "core/engine.h"
+#include "core/math/geometry_2d.h"
#include "scene/resources/concave_polygon_shape_2d.h"
#include "scene/resources/convex_polygon_shape_2d.h"
@@ -75,7 +76,7 @@ void CollisionPolygon2D::_build_polygon() {
}
Vector<Vector<Vector2>> CollisionPolygon2D::_decompose_in_convex() {
- Vector<Vector<Vector2>> decomp = Geometry::decompose_polygon_in_convex(polygon);
+ Vector<Vector<Vector2>> decomp = Geometry2D::decompose_polygon_in_convex(polygon);
return decomp;
}
@@ -224,7 +225,7 @@ bool CollisionPolygon2D::_edit_use_rect() const {
}
bool CollisionPolygon2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
- return Geometry::is_point_in_polygon(p_point, Variant(polygon));
+ return Geometry2D::is_point_in_polygon(p_point, Variant(polygon));
}
#endif
diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp
index 0d126b949d..8df72d7aac 100644
--- a/scene/2d/joints_2d.cpp
+++ b/scene/2d/joints_2d.cpp
@@ -309,10 +309,10 @@ RID DampedSpringJoint2D::_configure_joint(PhysicsBody2D *body_a, PhysicsBody2D *
RID dsj = PhysicsServer2D::get_singleton()->damped_spring_joint_create(anchor_A, anchor_B, body_a->get_rid(), body_b->get_rid());
if (rest_length) {
- PhysicsServer2D::get_singleton()->damped_string_joint_set_param(dsj, PhysicsServer2D::DAMPED_STRING_REST_LENGTH, rest_length);
+ PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(dsj, PhysicsServer2D::DAMPED_SPRING_REST_LENGTH, rest_length);
}
- PhysicsServer2D::get_singleton()->damped_string_joint_set_param(dsj, PhysicsServer2D::DAMPED_STRING_STIFFNESS, stiffness);
- PhysicsServer2D::get_singleton()->damped_string_joint_set_param(dsj, PhysicsServer2D::DAMPED_STRING_DAMPING, damping);
+ PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(dsj, PhysicsServer2D::DAMPED_SPRING_STIFFNESS, stiffness);
+ PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(dsj, PhysicsServer2D::DAMPED_SPRING_DAMPING, damping);
return dsj;
}
@@ -330,7 +330,7 @@ void DampedSpringJoint2D::set_rest_length(real_t p_rest_length) {
rest_length = p_rest_length;
update();
if (get_joint().is_valid()) {
- PhysicsServer2D::get_singleton()->damped_string_joint_set_param(get_joint(), PhysicsServer2D::DAMPED_STRING_REST_LENGTH, p_rest_length ? p_rest_length : length);
+ PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(get_joint(), PhysicsServer2D::DAMPED_SPRING_REST_LENGTH, p_rest_length ? p_rest_length : length);
}
}
@@ -342,7 +342,7 @@ void DampedSpringJoint2D::set_stiffness(real_t p_stiffness) {
stiffness = p_stiffness;
update();
if (get_joint().is_valid()) {
- PhysicsServer2D::get_singleton()->damped_string_joint_set_param(get_joint(), PhysicsServer2D::DAMPED_STRING_STIFFNESS, p_stiffness);
+ PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(get_joint(), PhysicsServer2D::DAMPED_SPRING_STIFFNESS, p_stiffness);
}
}
@@ -354,7 +354,7 @@ void DampedSpringJoint2D::set_damping(real_t p_damping) {
damping = p_damping;
update();
if (get_joint().is_valid()) {
- PhysicsServer2D::get_singleton()->damped_string_joint_set_param(get_joint(), PhysicsServer2D::DAMPED_STRING_DAMPING, p_damping);
+ PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(get_joint(), PhysicsServer2D::DAMPED_SPRING_DAMPING, p_damping);
}
}
diff --git a/scene/2d/light_occluder_2d.cpp b/scene/2d/light_occluder_2d.cpp
index 0f4880f69a..023cfa6d03 100644
--- a/scene/2d/light_occluder_2d.cpp
+++ b/scene/2d/light_occluder_2d.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "light_occluder_2d.h"
+#include "core/math/geometry_2d.h"
#include "core/engine.h"
@@ -68,12 +69,12 @@ Rect2 OccluderPolygon2D::_edit_get_rect() const {
bool OccluderPolygon2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
if (closed) {
- return Geometry::is_point_in_polygon(p_point, Variant(polygon));
+ return Geometry2D::is_point_in_polygon(p_point, Variant(polygon));
} else {
const real_t d = LINE_GRAB_WIDTH / 2 + p_tolerance;
const Vector2 *points = polygon.ptr();
for (int i = 0; i < polygon.size() - 1; i++) {
- Vector2 p = Geometry::get_closest_point_to_segment_2d(p_point, &points[i]);
+ Vector2 p = Geometry2D::get_closest_point_to_segment(p_point, &points[i]);
if (p.distance_to(p_point) <= d) {
return true;
}
diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp
index 28183403f2..b120b115b0 100644
--- a/scene/2d/line_2d.cpp
+++ b/scene/2d/line_2d.cpp
@@ -31,6 +31,7 @@
#include "line_2d.h"
#include "core/core_string_names.h"
+#include "core/math/geometry_2d.h"
#include "line_builder.h"
// Needed so we can bind functions
@@ -72,7 +73,7 @@ bool Line2D::_edit_is_selected_on_click(const Point2 &p_point, double p_toleranc
const real_t d = _width / 2 + p_tolerance;
const Vector2 *points = _points.ptr();
for (int i = 0; i < _points.size() - 1; i++) {
- Vector2 p = Geometry::get_closest_point_to_segment_2d(p_point, &points[i]);
+ Vector2 p = Geometry2D::get_closest_point_to_segment(p_point, &points[i]);
if (p.distance_to(p_point) <= d) {
return true;
}
diff --git a/scene/2d/navigation_agent_2d.cpp b/scene/2d/navigation_agent_2d.cpp
index cb2dbba0fe..e5cdade4a4 100644
--- a/scene/2d/navigation_agent_2d.cpp
+++ b/scene/2d/navigation_agent_2d.cpp
@@ -31,6 +31,7 @@
#include "navigation_agent_2d.h"
#include "core/engine.h"
+#include "core/math/geometry_2d.h"
#include "scene/2d/navigation_2d.h"
#include "servers/navigation_server_2d.h"
@@ -304,7 +305,7 @@ void NavigationAgent2D::update_navigation() {
Vector2 segment[2];
segment[0] = navigation_path[nav_path_index - 1];
segment[1] = navigation_path[nav_path_index];
- Vector2 p = Geometry::get_closest_point_to_segment_2d(o, segment);
+ Vector2 p = Geometry2D::get_closest_point_to_segment(o, segment);
if (o.distance_to(p) >= path_max_distance) {
// To faraway, reload path
reload_path = true;
diff --git a/scene/2d/navigation_region_2d.cpp b/scene/2d/navigation_region_2d.cpp
index 72bde17428..671bda558d 100644
--- a/scene/2d/navigation_region_2d.cpp
+++ b/scene/2d/navigation_region_2d.cpp
@@ -32,6 +32,7 @@
#include "core/core_string_names.h"
#include "core/engine.h"
+#include "core/math/geometry_2d.h"
#include "core/os/mutex.h"
#include "navigation_2d.h"
#include "servers/navigation_server_2d.h"
@@ -73,7 +74,7 @@ bool NavigationPolygon::_edit_is_selected_on_click(const Point2 &p_point, double
if (outline_size < 3) {
continue;
}
- if (Geometry::is_point_in_polygon(p_point, Variant(outline))) {
+ if (Geometry2D::is_point_in_polygon(p_point, Variant(outline))) {
return true;
}
}
@@ -269,7 +270,7 @@ void NavigationPolygon::make_polygons_from_outlines() {
const Vector2 *r2 = ol2.ptr();
for (int l = 0; l < olsize2; l++) {
- if (Geometry::segment_intersects_segment_2d(r[0], outside_point, r2[l], r2[(l + 1) % olsize2], nullptr)) {
+ if (Geometry2D::segment_intersects_segment(r[0], outside_point, r2[l], r2[(l + 1) % olsize2], nullptr)) {
interscount++;
}
}
diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp
index 046e4dbd41..f2f549e851 100644
--- a/scene/2d/path_2d.cpp
+++ b/scene/2d/path_2d.cpp
@@ -31,6 +31,7 @@
#include "path_2d.h"
#include "core/engine.h"
+#include "core/math/geometry_2d.h"
#include "scene/scene_string_names.h"
#ifdef TOOLS_ENABLED
@@ -73,7 +74,7 @@ bool Path2D::_edit_is_selected_on_click(const Point2 &p_point, double p_toleranc
real_t frac = j / 8.0;
s[1] = curve->interpolate(i, frac);
- Vector2 p = Geometry::get_closest_point_to_segment_2d(p_point, s);
+ Vector2 p = Geometry2D::get_closest_point_to_segment(p_point, s);
if (p.distance_to(p_point) <= p_tolerance) {
return true;
}
@@ -148,11 +149,7 @@ void Path2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_curve", "curve"), &Path2D::set_curve);
ClassDB::bind_method(D_METHOD("get_curve"), &Path2D::get_curve);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve2D"), "set_curve", "get_curve");
-}
-
-Path2D::Path2D() {
- set_curve(Ref<Curve2D>(memnew(Curve2D))); //create one by default
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve2D", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT), "set_curve", "get_curve");
}
/////////////////////////////////////////////////////////////////////////////////
diff --git a/scene/2d/path_2d.h b/scene/2d/path_2d.h
index 288ef698e7..38fcca0323 100644
--- a/scene/2d/path_2d.h
+++ b/scene/2d/path_2d.h
@@ -55,7 +55,7 @@ public:
void set_curve(const Ref<Curve2D> &p_curve);
Ref<Curve2D> get_curve() const;
- Path2D();
+ Path2D() {}
};
class PathFollow2D : public Node2D {
diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp
index 62c66dbb29..13b62816a4 100644
--- a/scene/2d/polygon_2d.cpp
+++ b/scene/2d/polygon_2d.cpp
@@ -30,7 +30,7 @@
#include "polygon_2d.h"
-#include "core/math/geometry.h"
+#include "core/math/geometry_2d.h"
#include "skeleton_2d.h"
#ifdef TOOLS_ENABLED
@@ -86,7 +86,7 @@ bool Polygon2D::_edit_is_selected_on_click(const Point2 &p_point, double p_toler
if (internal_vertices > 0) {
polygon2d.resize(polygon2d.size() - internal_vertices);
}
- return Geometry::is_point_in_polygon(p_point - get_offset(), polygon2d);
+ return Geometry2D::is_point_in_polygon(p_point - get_offset(), polygon2d);
}
#endif
@@ -300,7 +300,7 @@ void Polygon2D::_notification(int p_what) {
}
if (invert || polygons.size() == 0) {
- Vector<int> indices = Geometry::triangulate_polygon(points);
+ Vector<int> indices = Geometry2D::triangulate_polygon(points);
if (indices.size()) {
RS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, points, colors, uvs, bones, weights, texture.is_valid() ? texture->get_rid() : RID(), -1, normal_map.is_valid() ? normal_map->get_rid() : RID(), specular_map.is_valid() ? specular_map->get_rid() : RID(), Color(specular_color.r, specular_color.g, specular_color.b, shininess));
}
@@ -323,7 +323,7 @@ void Polygon2D::_notification(int p_what) {
ERR_CONTINUE(idx < 0 || idx >= points.size());
tmp_points.write[j] = points[r[j]];
}
- Vector<int> indices = Geometry::triangulate_polygon(tmp_points);
+ Vector<int> indices = Geometry2D::triangulate_polygon(tmp_points);
int ic2 = indices.size();
const int *r2 = indices.ptr();
diff --git a/scene/3d/baked_lightmap.cpp b/scene/3d/baked_lightmap.cpp
index e2f1b3807d..a41eaf9da0 100644
--- a/scene/3d/baked_lightmap.cpp
+++ b/scene/3d/baked_lightmap.cpp
@@ -559,7 +559,7 @@ void BakedLightmap::_plot_triangle_into_octree(GenProbesOctree *p_cell, float p_
subcell.position = Vector3(pos) * p_cell_size;
subcell.size = Vector3(half_size, half_size, half_size) * p_cell_size;
- if (!Geometry::triangle_box_overlap(subcell.position + subcell.size * 0.5, subcell.size * 0.5, p_triangle)) {
+ if (!Geometry3D::triangle_box_overlap(subcell.position + subcell.size * 0.5, subcell.size * 0.5, p_triangle)) {
continue;
}
diff --git a/scene/3d/collision_polygon_3d.cpp b/scene/3d/collision_polygon_3d.cpp
index bad4a1fddd..e2d11c740a 100644
--- a/scene/3d/collision_polygon_3d.cpp
+++ b/scene/3d/collision_polygon_3d.cpp
@@ -31,6 +31,7 @@
#include "collision_polygon_3d.h"
#include "collision_object_3d.h"
+#include "core/math/geometry_2d.h"
#include "scene/resources/concave_polygon_shape_3d.h"
#include "scene/resources/convex_polygon_shape_3d.h"
@@ -45,7 +46,7 @@ void CollisionPolygon3D::_build_polygon() {
return;
}
- Vector<Vector<Vector2>> decomp = Geometry::decompose_polygon_in_convex(polygon);
+ Vector<Vector<Vector2>> decomp = Geometry2D::decompose_polygon_in_convex(polygon);
if (decomp.size() == 0) {
return;
}
diff --git a/scene/3d/light_3d.cpp b/scene/3d/light_3d.cpp
index 814e911372..ef24676d69 100644
--- a/scene/3d/light_3d.cpp
+++ b/scene/3d/light_3d.cpp
@@ -402,7 +402,7 @@ void DirectionalLight3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_blend_splits_enabled"), &DirectionalLight3D::is_blend_splits_enabled);
ADD_GROUP("Directional Shadow", "directional_shadow_");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "directional_shadow_mode", PROPERTY_HINT_ENUM, "Orthogonal,PSSM 2 Splits,PSSM 4 Splits"), "set_shadow_mode", "get_shadow_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "directional_shadow_mode", PROPERTY_HINT_ENUM, "Orthogonal (Fast),PSSM 2 Splits (Average),PSSM 4 Splits (Slow)"), "set_shadow_mode", "get_shadow_mode");
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "directional_shadow_split_1", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_param", "get_param", PARAM_SHADOW_SPLIT_1_OFFSET);
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "directional_shadow_split_2", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_param", "get_param", PARAM_SHADOW_SPLIT_2_OFFSET);
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "directional_shadow_split_3", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_param", "get_param", PARAM_SHADOW_SPLIT_3_OFFSET);
diff --git a/scene/3d/navigation_agent_3d.cpp b/scene/3d/navigation_agent_3d.cpp
index f8d44506b6..e179261002 100644
--- a/scene/3d/navigation_agent_3d.cpp
+++ b/scene/3d/navigation_agent_3d.cpp
@@ -323,7 +323,7 @@ void NavigationAgent3D::update_navigation() {
segment[1] = navigation_path[nav_path_index];
segment[0].y -= navigation_height_offset;
segment[1].y -= navigation_height_offset;
- Vector3 p = Geometry::get_closest_point_to_segment(o, segment);
+ Vector3 p = Geometry3D::get_closest_point_to_segment(o, segment);
if (o.distance_to(p) >= path_max_distance) {
// To faraway, reload path
reload_path = true;
diff --git a/scene/3d/path_3d.cpp b/scene/3d/path_3d.cpp
index dcfdf8efcf..40d988ff9f 100644
--- a/scene/3d/path_3d.cpp
+++ b/scene/3d/path_3d.cpp
@@ -77,15 +77,11 @@ void Path3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_curve", "curve"), &Path3D::set_curve);
ClassDB::bind_method(D_METHOD("get_curve"), &Path3D::get_curve);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve3D"), "set_curve", "get_curve");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve3D", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT), "set_curve", "get_curve");
ADD_SIGNAL(MethodInfo("curve_changed"));
}
-Path3D::Path3D() {
- set_curve(Ref<Curve3D>(memnew(Curve3D))); //create one by default
-}
-
//////////////
void PathFollow3D::_update_transform() {
diff --git a/scene/3d/path_3d.h b/scene/3d/path_3d.h
index 5a33016bc6..7f227a8a6f 100644
--- a/scene/3d/path_3d.h
+++ b/scene/3d/path_3d.h
@@ -49,7 +49,7 @@ public:
void set_curve(const Ref<Curve3D> &p_curve);
Ref<Curve3D> get_curve() const;
- Path3D();
+ Path3D() {}
};
class PathFollow3D : public Node3D {
diff --git a/scene/3d/skeleton_3d.cpp b/scene/3d/skeleton_3d.cpp
index 7516cf95b0..a09424fa17 100644
--- a/scene/3d/skeleton_3d.cpp
+++ b/scene/3d/skeleton_3d.cpp
@@ -36,6 +36,7 @@
#include "core/type_info.h"
#include "scene/3d/physics_body_3d.h"
#include "scene/resources/surface_tool.h"
+#include "scene/scene_string_names.h"
void SkinReference::_skin_changed() {
if (skeleton_node) {
@@ -157,12 +158,12 @@ bool Skeleton3D::_get(const StringName &p_path, Variant &r_ret) const {
void Skeleton3D::_get_property_list(List<PropertyInfo> *p_list) const {
for (int i = 0; i < bones.size(); i++) {
String prep = "bones/" + itos(i) + "/";
- p_list->push_back(PropertyInfo(Variant::STRING, prep + "name"));
- p_list->push_back(PropertyInfo(Variant::INT, prep + "parent", PROPERTY_HINT_RANGE, "-1," + itos(bones.size() - 1) + ",1"));
- p_list->push_back(PropertyInfo(Variant::TRANSFORM, prep + "rest"));
- p_list->push_back(PropertyInfo(Variant::BOOL, prep + "enabled"));
- p_list->push_back(PropertyInfo(Variant::TRANSFORM, prep + "pose", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR));
- p_list->push_back(PropertyInfo(Variant::ARRAY, prep + "bound_children"));
+ p_list->push_back(PropertyInfo(Variant::STRING, prep + "name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
+ p_list->push_back(PropertyInfo(Variant::INT, prep + "parent", PROPERTY_HINT_RANGE, "-1," + itos(bones.size() - 1) + ",1", PROPERTY_USAGE_NOEDITOR));
+ p_list->push_back(PropertyInfo(Variant::TRANSFORM, prep + "rest", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
+ p_list->push_back(PropertyInfo(Variant::BOOL, prep + "enabled", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
+ p_list->push_back(PropertyInfo(Variant::TRANSFORM, prep + "pose", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
+ p_list->push_back(PropertyInfo(Variant::ARRAY, prep + "bound_children", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
}
}
@@ -214,7 +215,7 @@ void Skeleton3D::_update_process_order() {
}
if (pass_count == len * len) {
- ERR_PRINT("Skeleton parenthood graph is cyclic");
+ ERR_PRINT("Skeleton3D parenthood graph is cyclic");
}
process_order_dirty = false;
@@ -223,7 +224,7 @@ void Skeleton3D::_update_process_order() {
void Skeleton3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_UPDATE_SKELETON: {
- RenderingServer *vs = RenderingServer::get_singleton();
+ RenderingServer *rs = RenderingServer::get_singleton();
Bone *bonesptr = bones.ptrw();
int len = bones.size();
@@ -288,9 +289,9 @@ void Skeleton3D::_notification(int p_what) {
for (List<ObjectID>::Element *E = b.nodes_bound.front(); E; E = E->next()) {
Object *obj = ObjectDB::get_instance(E->get());
ERR_CONTINUE(!obj);
- Node3D *sp = Object::cast_to<Node3D>(obj);
- ERR_CONTINUE(!sp);
- sp->set_transform(b.pose_global);
+ Node3D *node_3d = Object::cast_to<Node3D>(obj);
+ ERR_CONTINUE(!node_3d);
+ node_3d->set_transform(b.pose_global);
}
}
@@ -323,7 +324,7 @@ void Skeleton3D::_notification(int p_what) {
}
if (!found) {
- ERR_PRINT("Skin bind #" + itos(i) + " contains named bind '" + String(bind_name) + "' but Skeleton has no bone by that name.");
+ ERR_PRINT("Skin bind #" + itos(i) + " contains named bind '" + String(bind_name) + "' but Skeleton3D has no bone by that name.");
E->get()->skin_bone_indices_ptrs[i] = 0;
}
} else if (skin->get_bind_bone(i) >= 0) {
@@ -346,11 +347,16 @@ void Skeleton3D::_notification(int p_what) {
for (uint32_t i = 0; i < bind_count; i++) {
uint32_t bone_index = E->get()->skin_bone_indices_ptrs[i];
ERR_CONTINUE(bone_index >= (uint32_t)len);
- vs->skeleton_bone_set_transform(skeleton, i, bonesptr[bone_index].pose_global * skin->get_bind_pose(i));
+ rs->skeleton_bone_set_transform(skeleton, i, bonesptr[bone_index].pose_global * skin->get_bind_pose(i));
}
}
dirty = false;
+
+#ifdef TOOLS_ENABLED
+ emit_signal(SceneStringNames::get_singleton()->pose_updated);
+#endif // TOOLS_ENABLED
+
} break;
#ifndef _3D_DISABLED
@@ -603,6 +609,11 @@ int Skeleton3D::get_process_order(int p_idx) {
return process_order[p_idx];
}
+Vector<int> Skeleton3D::get_bone_process_orders() {
+ _update_process_order();
+ return process_order;
+}
+
void Skeleton3D::localize_rests() {
_update_process_order();
@@ -843,6 +854,7 @@ Ref<SkinReference> Skeleton3D::register_skin(const Ref<Skin> &p_skin) {
}
void Skeleton3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("get_bone_process_orders"), &Skeleton3D::get_bone_process_orders);
ClassDB::bind_method(D_METHOD("add_bone", "name"), &Skeleton3D::add_bone);
ClassDB::bind_method(D_METHOD("find_bone", "name"), &Skeleton3D::find_bone);
ClassDB::bind_method(D_METHOD("get_bone_name", "bone_idx"), &Skeleton3D::get_bone_name);
@@ -893,6 +905,10 @@ void Skeleton3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "animate_physical_bones"), "set_animate_physical_bones", "get_animate_physical_bones");
#endif // _3D_DISABLED
+#ifdef TOOLS_ENABLED
+ ADD_SIGNAL(MethodInfo("pose_updated"));
+#endif // TOOLS_ENABLED
+
BIND_CONSTANT(NOTIFICATION_UPDATE_SKELETON);
}
diff --git a/scene/3d/skeleton_3d.h b/scene/3d/skeleton_3d.h
index 1e864c1c48..66706a9450 100644
--- a/scene/3d/skeleton_3d.h
+++ b/scene/3d/skeleton_3d.h
@@ -196,6 +196,7 @@ public:
void localize_rests(); // used for loaders and tools
int get_process_order(int p_idx);
+ Vector<int> get_bone_process_orders();
Ref<SkinReference> register_skin(const Ref<Skin> &p_skin);
diff --git a/scene/3d/voxelizer.cpp b/scene/3d/voxelizer.cpp
index 9fc3feb49a..de5496ee35 100644
--- a/scene/3d/voxelizer.cpp
+++ b/scene/3d/voxelizer.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "voxelizer.h"
-#include "core/math/geometry.h"
+#include "core/math/geometry_3d.h"
#include "core/os/os.h"
#include "core/os/threaded_array_processor.h"
@@ -124,7 +124,7 @@ void Voxelizer::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, co
Vector3 half = (to - from) * 0.5;
//is in this cell?
- if (!Geometry::triangle_box_overlap(from + half, half, p_vtx)) {
+ if (!Geometry3D::triangle_box_overlap(from + half, half, p_vtx)) {
continue; //face does not span this cell
}
@@ -267,7 +267,7 @@ void Voxelizer::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, co
//test_aabb.grow_by(test_aabb.get_longest_axis_size()*0.05); //grow a bit to avoid numerical error in real-time
Vector3 qsize = test_aabb.size * 0.5; //quarter size, for fast aabb test
- if (!Geometry::triangle_box_overlap(test_aabb.position + qsize, qsize, p_vtx)) {
+ if (!Geometry3D::triangle_box_overlap(test_aabb.position + qsize, qsize, p_vtx)) {
//if (!Face3(p_vtx[0],p_vtx[1],p_vtx[2]).intersects_aabb2(aabb)) {
//does not fit in child, go on
continue;
@@ -439,7 +439,7 @@ void Voxelizer::plot_mesh(const Transform &p_xform, Ref<Mesh> &p_mesh, const Vec
}
//test against original bounds
- if (!Geometry::triangle_box_overlap(original_bounds.position + original_bounds.size * 0.5, original_bounds.size * 0.5, vtxs)) {
+ if (!Geometry3D::triangle_box_overlap(original_bounds.position + original_bounds.size * 0.5, original_bounds.size * 0.5, vtxs)) {
continue;
}
//plot
@@ -471,7 +471,7 @@ void Voxelizer::plot_mesh(const Transform &p_xform, Ref<Mesh> &p_mesh, const Vec
}
//test against original bounds
- if (!Geometry::triangle_box_overlap(original_bounds.position + original_bounds.size * 0.5, original_bounds.size * 0.5, vtxs)) {
+ if (!Geometry3D::triangle_box_overlap(original_bounds.position + original_bounds.size * 0.5, original_bounds.size * 0.5, vtxs)) {
continue;
}
//plot face
diff --git a/scene/animation/animation_blend_space_2d.cpp b/scene/animation/animation_blend_space_2d.cpp
index 003a4fad90..5a42e2af7a 100644
--- a/scene/animation/animation_blend_space_2d.cpp
+++ b/scene/animation/animation_blend_space_2d.cpp
@@ -30,7 +30,7 @@
#include "animation_blend_space_2d.h"
-#include "core/math/delaunay_2d.h"
+#include "core/math/geometry_2d.h"
void AnimationNodeBlendSpace2D::get_parameter_list(List<PropertyInfo> *r_list) const {
r_list->push_back(PropertyInfo(Variant::VECTOR2, blend_position));
@@ -366,7 +366,7 @@ Vector2 AnimationNodeBlendSpace2D::get_closest_point(const Vector2 &p_point) {
points[j] = get_blend_point_position(get_triangle_point(i, j));
}
- if (Geometry::is_point_in_triangle(p_point, points[0], points[1], points[2])) {
+ if (Geometry2D::is_point_in_triangle(p_point, points[0], points[1], points[2])) {
return p_point;
}
@@ -375,7 +375,7 @@ Vector2 AnimationNodeBlendSpace2D::get_closest_point(const Vector2 &p_point) {
points[j],
points[(j + 1) % 3]
};
- Vector2 closest = Geometry::get_closest_point_to_segment_2d(p_point, s);
+ Vector2 closest = Geometry2D::get_closest_point_to_segment(p_point, s);
if (first || closest.distance_to(p_point) < best_point.distance_to(p_point)) {
best_point = closest;
first = false;
@@ -455,7 +455,7 @@ float AnimationNodeBlendSpace2D::process(float p_time, bool p_seek) {
points[j] = get_blend_point_position(get_triangle_point(i, j));
}
- if (Geometry::is_point_in_triangle(blend_pos, points[0], points[1], points[2])) {
+ if (Geometry2D::is_point_in_triangle(blend_pos, points[0], points[1], points[2])) {
blend_triangle = i;
_blend_triangle(blend_pos, points, blend_weights);
break;
@@ -466,7 +466,7 @@ float AnimationNodeBlendSpace2D::process(float p_time, bool p_seek) {
points[j],
points[(j + 1) % 3]
};
- Vector2 closest2 = Geometry::get_closest_point_to_segment_2d(blend_pos, s);
+ Vector2 closest2 = Geometry2D::get_closest_point_to_segment(blend_pos, s);
if (first || closest2.distance_to(blend_pos) < best_point.distance_to(blend_pos)) {
best_point = closest2;
blend_triangle = i;
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index 4e56f1acf0..319d0171b3 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -396,7 +396,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float
Animation::UpdateMode update_mode = a->value_track_get_update_mode(i);
if (update_mode == Animation::UPDATE_CAPTURE) {
- if (p_started) {
+ if (p_started || pa->capture == Variant()) {
pa->capture = pa->object->get_indexed(pa->subpath);
}
diff --git a/scene/debugger/scene_debugger.cpp b/scene/debugger/scene_debugger.cpp
index 0222585948..f57c8e58db 100644
--- a/scene/debugger/scene_debugger.cpp
+++ b/scene/debugger/scene_debugger.cpp
@@ -361,15 +361,6 @@ void SceneDebuggerObject::serialize(Array &r_arr, int p_max_size) {
RES res = var;
- if (var.get_type() == Variant::OBJECT && var.is_ref()) {
- REF r = var;
- if (r.is_valid()) {
- res = *r;
- } else {
- res = RES();
- }
- }
-
Array prop;
prop.push_back(pi.name);
prop.push_back(pi.type);
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 88710289c7..84170a65d1 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -66,7 +66,7 @@ void ColorPicker::_notification(int p_what) {
} break;
case NOTIFICATION_PARENTED: {
for (int i = 0; i < 4; i++) {
- set_margin((Margin)i, get_theme_constant("margin"));
+ set_margin((Margin)i, get_margin((Margin)i) + get_theme_constant("margin"));
}
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
diff --git a/scene/gui/container.cpp b/scene/gui/container.cpp
index 18a84ce348..a89eef6209 100644
--- a/scene/gui/container.cpp
+++ b/scene/gui/container.cpp
@@ -140,7 +140,7 @@ void Container::queue_sort() {
return;
}
- MessageQueue::get_singleton()->push_call(this, "_sort_children");
+ MessageQueue::get_singleton()->push_callable(callable_mp(this, &Container::_sort_children));
pending_sort = true;
}
@@ -177,8 +177,6 @@ String Container::get_configuration_warning() const {
}
void Container::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_sort_children"), &Container::_sort_children);
-
ClassDB::bind_method(D_METHOD("queue_sort"), &Container::queue_sort);
ClassDB::bind_method(D_METHOD("fit_child_in_rect", "child", "rect"), &Container::fit_child_in_rect);
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 96aaec6ae9..97daeceda9 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -30,6 +30,7 @@
#include "control.h"
+#include "core/math/geometry_2d.h"
#include "core/message_queue.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
@@ -2293,8 +2294,8 @@ void Control::_window_find_focus_neighbour(const Vector2 &p_dir, Node *p_at, con
Vector2 fb = points[(j + 1) % 4];
Vector2 pa, pb;
- float d = Geometry::get_closest_points_between_segments(la, lb, fa, fb, pa, pb);
- //float d = Geometry::get_closest_distance_between_segments(Vector3(la.x,la.y,0),Vector3(lb.x,lb.y,0),Vector3(fa.x,fa.y,0),Vector3(fb.x,fb.y,0));
+ float d = Geometry2D::get_closest_points_between_segments(la, lb, fa, fb, pa, pb);
+ //float d = Geometry2D::get_closest_distance_between_segments(Vector3(la.x,la.y,0),Vector3(lb.x,lb.y,0),Vector3(fa.x,fa.y,0),Vector3(fb.x,fb.y,0));
if (d < r_closest_dist) {
r_closest_dist = d;
*r_closest = c;
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index be6b542ae1..630f3c8ff6 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -402,7 +402,9 @@ void FileDialog::update_file_list() {
TreeItem *root = tree->create_item();
Ref<Texture2D> folder = vbox->get_theme_icon("folder", "FileDialog");
+ Ref<Texture2D> file_icon = vbox->get_theme_icon("file", "FileDialog");
const Color folder_color = vbox->get_theme_color("folder_icon_modulate", "FileDialog");
+ const Color file_color = vbox->get_theme_color("file_icon_modulate", "FileDialog");
List<String> files;
List<String> dirs;
@@ -491,7 +493,10 @@ void FileDialog::update_file_list() {
if (get_icon_func) {
Ref<Texture2D> icon = get_icon_func(base_dir.plus_file(files.front()->get()));
ti->set_icon(0, icon);
+ } else {
+ ti->set_icon(0, file_icon);
}
+ ti->set_icon_modulate(0, file_color);
if (mode == FILE_MODE_OPEN_DIR) {
ti->set_custom_color(0, vbox->get_theme_color("files_disabled", "FileDialog"));
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index fbacb3ed9e..ee6783167a 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -1211,6 +1211,8 @@ void LineEdit::delete_char() {
}
void LineEdit::delete_text(int p_from_column, int p_to_column) {
+ ERR_FAIL_COND_MSG(p_from_column < 0 || p_from_column > p_to_column || p_to_column > text.length(),
+ vformat("Positional parameters (from: %d, to: %d) are inverted or outside the text length (%d).", p_from_column, p_to_column, text.length()));
if (text.size() > 0) {
Ref<Font> font = get_theme_font("font");
if (font != nullptr) {
@@ -1783,6 +1785,8 @@ void LineEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_max_length", "chars"), &LineEdit::set_max_length);
ClassDB::bind_method(D_METHOD("get_max_length"), &LineEdit::get_max_length);
ClassDB::bind_method(D_METHOD("append_at_cursor", "text"), &LineEdit::append_at_cursor);
+ ClassDB::bind_method(D_METHOD("delete_char_at_cursor"), &LineEdit::delete_char);
+ ClassDB::bind_method(D_METHOD("delete_text", "from_column", "to_column"), &LineEdit::delete_text);
ClassDB::bind_method(D_METHOD("set_editable", "enabled"), &LineEdit::set_editable);
ClassDB::bind_method(D_METHOD("is_editable"), &LineEdit::is_editable);
ClassDB::bind_method(D_METHOD("set_secret", "enabled"), &LineEdit::set_secret);
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index a57408b83b..92508f7fd2 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -256,6 +256,11 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
lh = line < l.height_caches.size() ? l.height_caches[line] : 1; \
line_ascent = line < l.ascent_caches.size() ? l.ascent_caches[line] : 1; \
line_descent = line < l.descent_caches.size() ? l.descent_caches[line] : 1; \
+ if (p_mode == PROCESS_DRAW) { \
+ if (line < l.offset_caches.size()) { \
+ wofs = l.offset_caches[line]; \
+ } \
+ } \
} \
if (p_mode == PROCESS_POINTER && r_click_item && p_click_pos.y >= p_ofs.y + y && p_click_pos.y <= p_ofs.y + y + lh && p_click_pos.x < p_ofs.x + wofs) { \
if (r_outside) \
@@ -646,7 +651,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
}
if (p_mode == PROCESS_DRAW && visible) {
- img->image->draw_rect(ci, Rect2(p_ofs + Point2(align_ofs + wofs, y + lh - font->get_descent() - img->size.height), img->size));
+ img->image->draw_rect(ci, Rect2(p_ofs + Point2(align_ofs + wofs, y + lh - font->get_descent() - img->size.height), img->size), false, img->color);
}
p_char_count++;
@@ -873,7 +878,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
}
void RichTextLabel::_scroll_changed(double) {
- if (updating_scroll || !scroll_active) {
+ if (updating_scroll) {
return;
}
@@ -1443,6 +1448,46 @@ void RichTextLabel::_fetch_item_fx_stack(Item *p_item, Vector<ItemFX *> &r_stack
}
}
+Color RichTextLabel::_get_color_from_string(const String &p_color_str, const Color &p_default_color) {
+ if (p_color_str.begins_with("#")) {
+ return Color::html(p_color_str);
+ } else if (p_color_str == "aqua") {
+ return Color(0, 1, 1);
+ } else if (p_color_str == "black") {
+ return Color(0, 0, 0);
+ } else if (p_color_str == "blue") {
+ return Color(0, 0, 1);
+ } else if (p_color_str == "fuchsia") {
+ return Color(1, 0, 1);
+ } else if (p_color_str == "gray" || p_color_str == "grey") {
+ return Color(0.5, 0.5, 0.5);
+ } else if (p_color_str == "green") {
+ return Color(0, 0.5, 0);
+ } else if (p_color_str == "lime") {
+ return Color(0, 1, 0);
+ } else if (p_color_str == "maroon") {
+ return Color(0.5, 0, 0);
+ } else if (p_color_str == "navy") {
+ return Color(0, 0, 0.5);
+ } else if (p_color_str == "olive") {
+ return Color(0.5, 0.5, 0);
+ } else if (p_color_str == "purple") {
+ return Color(0.5, 0, 0.5);
+ } else if (p_color_str == "red") {
+ return Color(1, 0, 0);
+ } else if (p_color_str == "silver") {
+ return Color(0.75, 0.75, 0.75);
+ } else if (p_color_str == "teal") {
+ return Color(0, 0.5, 0.5);
+ } else if (p_color_str == "white") {
+ return Color(1, 1, 1);
+ } else if (p_color_str == "yellow") {
+ return Color(1, 1, 0);
+ } else {
+ return p_default_color;
+ }
+}
+
bool RichTextLabel::_find_meta(Item *p_item, Variant *r_meta, ItemMeta **r_item) {
Item *item = p_item;
@@ -1636,7 +1681,7 @@ void RichTextLabel::_remove_item(Item *p_item, const int p_line, const int p_sub
}
}
-void RichTextLabel::add_image(const Ref<Texture2D> &p_image, const int p_width, const int p_height) {
+void RichTextLabel::add_image(const Ref<Texture2D> &p_image, const int p_width, const int p_height, const Color &p_color) {
if (current->type == ITEM_TABLE) {
return;
}
@@ -1645,6 +1690,7 @@ void RichTextLabel::add_image(const Ref<Texture2D> &p_image, const int p_width,
ItemImage *item = memnew(ItemImage);
item->image = p_image;
+ item->color = p_color;
if (p_width > 0) {
// custom width
@@ -1924,6 +1970,9 @@ void RichTextLabel::clear() {
selection.click = nullptr;
selection.active = false;
current_idx = 1;
+ if (scroll_follow) {
+ scroll_following = true;
+ }
if (fixed_width != -1) {
minimum_size_changed();
@@ -1967,6 +2016,7 @@ void RichTextLabel::set_scroll_active(bool p_active) {
}
scroll_active = p_active;
+ vscroll->set_drag_node_enabled(p_active);
update();
}
@@ -2034,7 +2084,32 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
String tag = p_bbcode.substr(brk_pos + 1, brk_end - brk_pos - 1);
Vector<String> split_tag_block = tag.split(" ", false);
- String bbcode = !split_tag_block.empty() ? split_tag_block[0] : "";
+
+ // Find optional parameters.
+ String bbcode_name;
+ typedef Map<String, String> OptionMap;
+ OptionMap bbcode_options;
+ if (!split_tag_block.empty()) {
+ bbcode_name = split_tag_block[0];
+ for (int i = 1; i < split_tag_block.size(); i++) {
+ const String &expr = split_tag_block[i];
+ int value_pos = expr.find("=");
+ if (value_pos > -1) {
+ bbcode_options[expr.substr(0, value_pos)] = expr.substr(value_pos + 1);
+ }
+ }
+ } else {
+ bbcode_name = tag;
+ }
+
+ // Find main parameter.
+ String bbcode_value;
+ int main_value_pos = bbcode_name.find("=");
+ if (main_value_pos > -1) {
+ bbcode_value = bbcode_name.substr(main_value_pos + 1);
+ bbcode_name = bbcode_name.substr(0, main_value_pos);
+ }
+
if (tag.begins_with("/") && tag_stack.size()) {
bool tag_ok = tag_stack.size() && tag_stack.front()->get() == tag.substr(1, tag.length());
@@ -2160,7 +2235,7 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
push_meta(url);
pos = brk_end + 1;
tag_stack.push_front("url");
- } else if (tag == "img") {
+ } else if (bbcode_name == "img") {
int end = p_bbcode.find("[", brk_end);
if (end == -1) {
end = p_bbcode.length();
@@ -2170,80 +2245,42 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
Ref<Texture2D> texture = ResourceLoader::load(image, "Texture2D");
if (texture.is_valid()) {
- add_image(texture);
- }
-
- pos = end;
- tag_stack.push_front(tag);
- } else if (tag.begins_with("img=")) {
- int width = 0;
- int height = 0;
-
- String params = tag.substr(4, tag.length());
- int sep = params.find("x");
- if (sep == -1) {
- width = params.to_int();
- } else {
- width = params.substr(0, sep).to_int();
- height = params.substr(sep + 1, params.length()).to_int();
- }
+ Color color = Color(1.0, 1.0, 1.0);
+ OptionMap::Element *color_option = bbcode_options.find("color");
+ if (color_option) {
+ color = _get_color_from_string(color_option->value(), color);
+ }
- int end = p_bbcode.find("[", brk_end);
- if (end == -1) {
- end = p_bbcode.length();
- }
+ int width = 0;
+ int height = 0;
+ if (!bbcode_value.empty()) {
+ int sep = bbcode_value.find("x");
+ if (sep == -1) {
+ width = bbcode_value.to_int();
+ } else {
+ width = bbcode_value.substr(0, sep).to_int();
+ height = bbcode_value.substr(sep + 1).to_int();
+ }
+ } else {
+ OptionMap::Element *width_option = bbcode_options.find("width");
+ if (width_option) {
+ width = width_option->value().to_int();
+ }
- String image = p_bbcode.substr(brk_end + 1, end - brk_end - 1);
+ OptionMap::Element *height_option = bbcode_options.find("height");
+ if (height_option) {
+ height = height_option->value().to_int();
+ }
+ }
- Ref<Texture2D> texture = ResourceLoader::load(image, "Texture");
- if (texture.is_valid()) {
- add_image(texture, width, height);
+ add_image(texture, width, height, color);
}
pos = end;
- tag_stack.push_front("img");
+ tag_stack.push_front(bbcode_name);
} else if (tag.begins_with("color=")) {
- String col = tag.substr(6, tag.length());
- Color color;
-
- if (col.begins_with("#")) {
- color = Color::html(col);
- } else if (col == "aqua") {
- color = Color(0, 1, 1);
- } else if (col == "black") {
- color = Color(0, 0, 0);
- } else if (col == "blue") {
- color = Color(0, 0, 1);
- } else if (col == "fuchsia") {
- color = Color(1, 0, 1);
- } else if (col == "gray" || col == "grey") {
- color = Color(0.5, 0.5, 0.5);
- } else if (col == "green") {
- color = Color(0, 0.5, 0);
- } else if (col == "lime") {
- color = Color(0, 1, 0);
- } else if (col == "maroon") {
- color = Color(0.5, 0, 0);
- } else if (col == "navy") {
- color = Color(0, 0, 0.5);
- } else if (col == "olive") {
- color = Color(0.5, 0.5, 0);
- } else if (col == "purple") {
- color = Color(0.5, 0, 0.5);
- } else if (col == "red") {
- color = Color(1, 0, 0);
- } else if (col == "silver") {
- color = Color(0.75, 0.75, 0.75);
- } else if (col == "teal") {
- color = Color(0, 0.5, 0.5);
- } else if (col == "white") {
- color = Color(1, 1, 1);
- } else if (col == "yellow") {
- color = Color(1, 1, 0);
- } else {
- color = base_color;
- }
-
+ String color_str = tag.substr(6, tag.length());
+ Color color = _get_color_from_string(color_str, base_color);
push_color(color);
pos = brk_end + 1;
tag_stack.push_front("color");
@@ -2261,113 +2298,90 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
pos = brk_end + 1;
tag_stack.push_front("font");
- } else if (bbcode == "fade") {
- int startIndex = 0;
- int length = 10;
+ } else if (bbcode_name == "fade") {
+ int start_index = 0;
+ OptionMap::Element *start_option = bbcode_options.find("start");
+ if (start_option) {
+ start_index = start_option->value().to_int();
+ }
- if (split_tag_block.size() > 1) {
- split_tag_block.remove(0);
- for (int i = 0; i < split_tag_block.size(); i++) {
- String expr = split_tag_block[i];
- if (expr.begins_with("start=")) {
- String start_str = expr.substr(6, expr.length());
- startIndex = start_str.to_int();
- } else if (expr.begins_with("length=")) {
- String end_str = expr.substr(7, expr.length());
- length = end_str.to_int();
- }
- }
+ int length = 10;
+ OptionMap::Element *length_option = bbcode_options.find("length");
+ if (length_option) {
+ length = length_option->value().to_int();
}
- push_fade(startIndex, length);
+ push_fade(start_index, length);
pos = brk_end + 1;
tag_stack.push_front("fade");
- } else if (bbcode == "shake") {
+ } else if (bbcode_name == "shake") {
int strength = 5;
- float rate = 20.0f;
+ OptionMap::Element *strength_option = bbcode_options.find("level");
+ if (strength_option) {
+ strength = strength_option->value().to_int();
+ }
- if (split_tag_block.size() > 1) {
- split_tag_block.remove(0);
- for (int i = 0; i < split_tag_block.size(); i++) {
- String expr = split_tag_block[i];
- if (expr.begins_with("level=")) {
- String str_str = expr.substr(6, expr.length());
- strength = str_str.to_int();
- } else if (expr.begins_with("rate=")) {
- String rate_str = expr.substr(5, expr.length());
- rate = rate_str.to_float();
- }
- }
+ float rate = 20.0f;
+ OptionMap::Element *rate_option = bbcode_options.find("rate");
+ if (rate_option) {
+ rate = rate_option->value().to_float();
}
push_shake(strength, rate);
pos = brk_end + 1;
tag_stack.push_front("shake");
set_process_internal(true);
- } else if (bbcode == "wave") {
+ } else if (bbcode_name == "wave") {
float amplitude = 20.0f;
- float period = 5.0f;
+ OptionMap::Element *amplitude_option = bbcode_options.find("amp");
+ if (amplitude_option) {
+ amplitude = amplitude_option->value().to_float();
+ }
- if (split_tag_block.size() > 1) {
- split_tag_block.remove(0);
- for (int i = 0; i < split_tag_block.size(); i++) {
- String expr = split_tag_block[i];
- if (expr.begins_with("amp=")) {
- String amp_str = expr.substr(4, expr.length());
- amplitude = amp_str.to_float();
- } else if (expr.begins_with("freq=")) {
- String period_str = expr.substr(5, expr.length());
- period = period_str.to_float();
- }
- }
+ float period = 5.0f;
+ OptionMap::Element *period_option = bbcode_options.find("freq");
+ if (period_option) {
+ period = period_option->value().to_float();
}
push_wave(period, amplitude);
pos = brk_end + 1;
tag_stack.push_front("wave");
set_process_internal(true);
- } else if (bbcode == "tornado") {
+ } else if (bbcode_name == "tornado") {
float radius = 10.0f;
- float frequency = 1.0f;
+ OptionMap::Element *radius_option = bbcode_options.find("radius");
+ if (radius_option) {
+ radius = radius_option->value().to_float();
+ }
- if (split_tag_block.size() > 1) {
- split_tag_block.remove(0);
- for (int i = 0; i < split_tag_block.size(); i++) {
- String expr = split_tag_block[i];
- if (expr.begins_with("radius=")) {
- String amp_str = expr.substr(7, expr.length());
- radius = amp_str.to_float();
- } else if (expr.begins_with("freq=")) {
- String period_str = expr.substr(5, expr.length());
- frequency = period_str.to_float();
- }
- }
+ float frequency = 1.0f;
+ OptionMap::Element *frequency_option = bbcode_options.find("freq");
+ if (frequency_option) {
+ frequency = frequency_option->value().to_float();
}
push_tornado(frequency, radius);
pos = brk_end + 1;
tag_stack.push_front("tornado");
set_process_internal(true);
- } else if (bbcode == "rainbow") {
+ } else if (bbcode_name == "rainbow") {
float saturation = 0.8f;
+ OptionMap::Element *saturation_option = bbcode_options.find("sat");
+ if (saturation_option) {
+ saturation = saturation_option->value().to_float();
+ }
+
float value = 0.8f;
- float frequency = 1.0f;
+ OptionMap::Element *value_option = bbcode_options.find("val");
+ if (value_option) {
+ value = value_option->value().to_float();
+ }
- if (split_tag_block.size() > 1) {
- split_tag_block.remove(0);
- for (int i = 0; i < split_tag_block.size(); i++) {
- String expr = split_tag_block[i];
- if (expr.begins_with("sat=")) {
- String sat_str = expr.substr(4, expr.length());
- saturation = sat_str.to_float();
- } else if (expr.begins_with("val=")) {
- String val_str = expr.substr(4, expr.length());
- value = val_str.to_float();
- } else if (expr.begins_with("freq=")) {
- String freq_str = expr.substr(5, expr.length());
- frequency = freq_str.to_float();
- }
- }
+ float frequency = 1.0f;
+ OptionMap::Element *frequency_option = bbcode_options.find("freq");
+ if (frequency_option) {
+ frequency = frequency_option->value().to_float();
}
push_rainbow(saturation, value, frequency);
@@ -2398,6 +2412,17 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
}
}
+ Vector<ItemFX *> fx_items;
+ for (List<Item *>::Element *E = main->subitems.front(); E; E = E->next()) {
+ Item *subitem = static_cast<Item *>(E->get());
+ _fetch_item_fx_stack(subitem, fx_items);
+
+ if (fx_items.size()) {
+ set_process_internal(true);
+ break;
+ }
+ }
+
return OK;
}
@@ -2634,7 +2659,7 @@ void RichTextLabel::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_text"), &RichTextLabel::get_text);
ClassDB::bind_method(D_METHOD("add_text", "text"), &RichTextLabel::add_text);
ClassDB::bind_method(D_METHOD("set_text", "text"), &RichTextLabel::set_text);
- ClassDB::bind_method(D_METHOD("add_image", "image", "width", "height"), &RichTextLabel::add_image, DEFVAL(0), DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("add_image", "image", "width", "height", "color"), &RichTextLabel::add_image, DEFVAL(0), DEFVAL(0), DEFVAL(Color(1.0, 1.0, 1.0)));
ClassDB::bind_method(D_METHOD("newline"), &RichTextLabel::add_newline);
ClassDB::bind_method(D_METHOD("remove_line", "line"), &RichTextLabel::remove_line);
ClassDB::bind_method(D_METHOD("push_font", "font"), &RichTextLabel::push_font);
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index 019edf5d45..4cec435568 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -149,6 +149,7 @@ private:
struct ItemImage : public Item {
Ref<Texture2D> image;
Size2 size;
+ Color color;
ItemImage() { type = ITEM_IMAGE; }
};
@@ -381,6 +382,8 @@ private:
bool _find_by_type(Item *p_item, ItemType p_type);
void _fetch_item_fx_stack(Item *p_item, Vector<ItemFX *> &r_stack);
+ static Color _get_color_from_string(const String &p_color_str, const Color &p_default_color);
+
void _update_scroll();
void _update_fx(ItemFrame *p_frame, float p_delta_time);
void _scroll_changed(double);
@@ -406,7 +409,7 @@ protected:
public:
String get_text();
void add_text(const String &p_text);
- void add_image(const Ref<Texture2D> &p_image, const int p_width = 0, const int p_height = 0);
+ void add_image(const Ref<Texture2D> &p_image, const int p_width = 0, const int p_height = 0, const Color &p_color = Color(1.0, 1.0, 1.0));
void add_newline();
bool remove_line(const int p_line);
void push_font(const Ref<Font> &p_font);
diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp
index e7950bec98..4db6ca2949 100644
--- a/scene/gui/scroll_bar.cpp
+++ b/scene/gui/scroll_bar.cpp
@@ -506,6 +506,10 @@ void ScrollBar::_drag_node_exit() {
}
void ScrollBar::_drag_node_input(const Ref<InputEvent> &p_input) {
+ if (!drag_node_enabled) {
+ return;
+ }
+
Ref<InputEventMouseButton> mb = p_input;
if (mb.is_valid()) {
@@ -590,6 +594,10 @@ NodePath ScrollBar::get_drag_node() const {
return drag_node_path;
}
+void ScrollBar::set_drag_node_enabled(bool p_enable) {
+ drag_node_enabled = p_enable;
+}
+
void ScrollBar::set_smooth_scroll_enabled(bool p_enable) {
smooth_scroll_enabled = p_enable;
}
@@ -610,19 +618,6 @@ void ScrollBar::_bind_methods() {
ScrollBar::ScrollBar(Orientation p_orientation) {
orientation = p_orientation;
- highlight = HIGHLIGHT_NONE;
- custom_step = -1;
- drag_node = nullptr;
-
- drag.active = false;
-
- drag_node_speed = Vector2();
- drag_node_touching = false;
- drag_node_touching_deaccel = false;
-
- scrolling = false;
- target_scroll = 0;
- smooth_scroll_enabled = false;
if (focus_by_default) {
set_focus_mode(FOCUS_ALL);
diff --git a/scene/gui/scroll_bar.h b/scene/gui/scroll_bar.h
index d2641b14f3..23ee61d9e1 100644
--- a/scene/gui/scroll_bar.h
+++ b/scene/gui/scroll_bar.h
@@ -47,12 +47,12 @@ class ScrollBar : public Range {
Orientation orientation;
Size2 size;
- float custom_step;
+ float custom_step = -1;
- HighlightStatus highlight;
+ HighlightStatus highlight = HIGHLIGHT_NONE;
struct Drag {
- bool active;
+ bool active = false;
float pos_at_click;
float value_at_click;
} drag;
@@ -66,22 +66,23 @@ class ScrollBar : public Range {
static void set_can_focus_by_default(bool p_can_focus);
- Node *drag_node;
+ Node *drag_node = nullptr;
NodePath drag_node_path;
+ bool drag_node_enabled = true;
- Vector2 drag_node_speed;
+ Vector2 drag_node_speed = Vector2();
Vector2 drag_node_accum;
Vector2 drag_node_from;
Vector2 last_drag_node_accum;
float last_drag_node_time;
float time_since_motion;
- bool drag_node_touching;
- bool drag_node_touching_deaccel;
+ bool drag_node_touching = false;
+ bool drag_node_touching_deaccel = false;
bool click_handled;
- bool scrolling;
- double target_scroll;
- bool smooth_scroll_enabled;
+ bool scrolling = false;
+ double target_scroll = 0;
+ bool smooth_scroll_enabled = false;
void _drag_node_exit();
void _drag_node_input(const Ref<InputEvent> &p_input);
@@ -99,6 +100,7 @@ public:
void set_drag_node(const NodePath &p_path);
NodePath get_drag_node() const;
+ void set_drag_node_enabled(bool p_enable);
void set_smooth_scroll_enabled(bool p_enable);
bool is_smooth_scroll_enabled() const;
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index 97b8362214..0d48fde642 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -278,7 +278,7 @@ void TabContainer::_notification(int p_what) {
Color font_color_bg = get_theme_color("font_color_bg");
Color font_color_disabled = get_theme_color("font_color_disabled");
int side_margin = get_theme_constant("side_margin");
- int icon_text_distance = get_theme_constant("hseparation");
+ int icon_text_distance = get_theme_constant("icon_separation");
// Find out start and width of the header area.
int header_x = side_margin;
@@ -435,7 +435,30 @@ void TabContainer::_notification(int p_what) {
void TabContainer::_on_theme_changed() {
if (get_tab_count() > 0) {
- set_current_tab(get_current_tab());
+ _repaint();
+ update();
+ }
+}
+
+void TabContainer::_repaint() {
+ Ref<StyleBox> sb = get_theme_stylebox("panel");
+ Vector<Control *> tabs = _get_tabs();
+ for (int i = 0; i < tabs.size(); i++) {
+ Control *c = tabs[i];
+ if (i == current) {
+ c->show();
+ c->set_anchors_and_margins_preset(Control::PRESET_WIDE);
+ if (tabs_visible) {
+ c->set_margin(MARGIN_TOP, _get_top_margin());
+ }
+ c->set_margin(Margin(MARGIN_TOP), c->get_margin(Margin(MARGIN_TOP)) + sb->get_margin(Margin(MARGIN_TOP)));
+ c->set_margin(Margin(MARGIN_LEFT), c->get_margin(Margin(MARGIN_LEFT)) + sb->get_margin(Margin(MARGIN_LEFT)));
+ c->set_margin(Margin(MARGIN_RIGHT), c->get_margin(Margin(MARGIN_RIGHT)) - sb->get_margin(Margin(MARGIN_RIGHT)));
+ c->set_margin(Margin(MARGIN_BOTTOM), c->get_margin(Margin(MARGIN_BOTTOM)) - sb->get_margin(Margin(MARGIN_BOTTOM)));
+
+ } else {
+ c->hide();
+ }
}
}
@@ -465,7 +488,7 @@ int TabContainer::_get_tab_width(int p_index) const {
if (icon.is_valid()) {
width += icon->get_width();
if (text != "") {
- width += get_theme_constant("hseparation");
+ width += get_theme_constant("icon_separation");
}
}
}
@@ -551,25 +574,7 @@ void TabContainer::set_current_tab(int p_current) {
int pending_previous = current;
current = p_current;
- Ref<StyleBox> sb = get_theme_stylebox("panel");
- Vector<Control *> tabs = _get_tabs();
- for (int i = 0; i < tabs.size(); i++) {
- Control *c = tabs[i];
- if (i == current) {
- c->show();
- c->set_anchors_and_margins_preset(Control::PRESET_WIDE);
- if (tabs_visible) {
- c->set_margin(MARGIN_TOP, _get_top_margin());
- }
- c->set_margin(Margin(MARGIN_TOP), c->get_margin(Margin(MARGIN_TOP)) + sb->get_margin(Margin(MARGIN_TOP)));
- c->set_margin(Margin(MARGIN_LEFT), c->get_margin(Margin(MARGIN_LEFT)) + sb->get_margin(Margin(MARGIN_LEFT)));
- c->set_margin(Margin(MARGIN_RIGHT), c->get_margin(Margin(MARGIN_RIGHT)) - sb->get_margin(Margin(MARGIN_RIGHT)));
- c->set_margin(Margin(MARGIN_BOTTOM), c->get_margin(Margin(MARGIN_BOTTOM)) - sb->get_margin(Margin(MARGIN_BOTTOM)));
-
- } else {
- c->hide();
- }
- }
+ _repaint();
_change_notify("current_tab");
diff --git a/scene/gui/tab_container.h b/scene/gui/tab_container.h
index e8cde74c83..55a5d35b30 100644
--- a/scene/gui/tab_container.h
+++ b/scene/gui/tab_container.h
@@ -65,6 +65,7 @@ private:
Vector<Control *> _get_tabs() const;
int _get_tab_width(int p_index) const;
void _on_theme_changed();
+ void _repaint();
void _on_mouse_exited();
void _update_current_tab();
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 45fcb448f8..7b9db7c081 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -2364,7 +2364,6 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
if (pos.x < len) {
cache.hover_type = Cache::CLICK_TITLE;
cache.hover_index = i;
- update();
break;
}
}
@@ -2383,6 +2382,9 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
mpos.y += v_scroll->get_value();
}
+ TreeItem *old_it = cache.hover_item;
+ int old_col = cache.hover_cell;
+
int col, h, section;
TreeItem *it = _find_item_at_pos(root, mpos, col, h, section);
@@ -2397,18 +2399,21 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
}
}
- if (it != cache.hover_item) {
- cache.hover_item = it;
- update();
- }
+ cache.hover_item = it;
+ cache.hover_cell = col;
- if (it && col != cache.hover_cell) {
- cache.hover_cell = col;
- update();
+ if (it != old_it || col != old_col) {
+ // Only need to update if mouse enters/exits a button
+ bool was_over_button = old_it && old_it->cells[old_col].custom_button;
+ bool is_over_button = it && it->cells[col].custom_button;
+ if (was_over_button || is_over_button) {
+ update();
+ }
}
}
}
+ // Update if mouse enters/exits columns
if (cache.hover_type != old_hover || cache.hover_index != old_index) {
update();
}
diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp
index 524ff346d1..721f573f39 100644
--- a/scene/main/canvas_item.cpp
+++ b/scene/main/canvas_item.cpp
@@ -1222,8 +1222,8 @@ void CanvasItem::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "light_mask", PROPERTY_HINT_LAYERS_2D_RENDER), "set_light_mask", "get_light_mask");
ADD_GROUP("Texture", "texture_");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_filter", PROPERTY_HINT_ENUM, "ParentNode,Nearest,Linear,MipmapNearest,MipmapLinear,MipmapNearestAniso,MipmapLinearAniso"), "set_texture_filter", "get_texture_filter");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_repeat", PROPERTY_HINT_ENUM, "ParentNode,Disabled,Enabled,Mirror"), "set_texture_repeat", "get_texture_repeat");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_filter", PROPERTY_HINT_ENUM, "Inherit,Nearest,Linear,MipmapNearest,MipmapLinear,MipmapNearestAniso,MipmapLinearAniso"), "set_texture_filter", "get_texture_filter");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_repeat", PROPERTY_HINT_ENUM, "Inherit,Disabled,Enabled,Mirror"), "set_texture_repeat", "get_texture_repeat");
ADD_GROUP("Material", "");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,CanvasItemMaterial"), "set_material", "get_material");
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index c9d430c656..1bf828a03b 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -2238,46 +2238,53 @@ void Node::_duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p
// because re-targeting of connections from some descendant to another is not possible
// if the emitter node comes later in tree order than the receiver
void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const {
- if (this != p_original && (get_owner() != p_original && get_owner() != p_original->get_owner())) {
+ if ((this != p_original) && !(p_original->is_a_parent_of(this))) {
return;
}
- List<Connection> conns;
- get_all_signal_connections(&conns);
+ List<const Node *> process_list;
+ process_list.push_back(this);
+ while (!process_list.empty()) {
+ const Node *n = process_list.front()->get();
+ process_list.pop_front();
- for (List<Connection>::Element *E = conns.front(); E; E = E->next()) {
- if (E->get().flags & CONNECT_PERSIST) {
- //user connected
- NodePath p = p_original->get_path_to(this);
- Node *copy = p_copy->get_node(p);
+ List<Connection> conns;
+ n->get_all_signal_connections(&conns);
- Node *target = Object::cast_to<Node>(E->get().callable.get_object());
- if (!target) {
- continue;
- }
- NodePath ptarget = p_original->get_path_to(target);
+ for (List<Connection>::Element *E = conns.front(); E; E = E->next()) {
+ if (E->get().flags & CONNECT_PERSIST) {
+ //user connected
+ NodePath p = p_original->get_path_to(n);
+ Node *copy = p_copy->get_node(p);
- Node *copytarget = target;
+ Node *target = Object::cast_to<Node>(E->get().callable.get_object());
+ if (!target) {
+ continue;
+ }
+ NodePath ptarget = p_original->get_path_to(target);
- // Attempt to find a path to the duplicate target, if it seems it's not part
- // of the duplicated and not yet parented hierarchy then at least try to connect
- // to the same target as the original
+ Node *copytarget = target;
- if (p_copy->has_node(ptarget)) {
- copytarget = p_copy->get_node(ptarget);
- }
+ // Attempt to find a path to the duplicate target, if it seems it's not part
+ // of the duplicated and not yet parented hierarchy then at least try to connect
+ // to the same target as the original
- if (copy && copytarget) {
- const Callable copy_callable = Callable(copytarget, E->get().callable.get_method());
- if (!copy->is_connected(E->get().signal.get_name(), copy_callable)) {
- copy->connect(E->get().signal.get_name(), copy_callable, E->get().binds, E->get().flags);
+ if (p_copy->has_node(ptarget)) {
+ copytarget = p_copy->get_node(ptarget);
+ }
+
+ if (copy && copytarget) {
+ const Callable copy_callable = Callable(copytarget, E->get().callable.get_method());
+ if (!copy->is_connected(E->get().signal.get_name(), copy_callable)) {
+ copy->connect(E->get().signal.get_name(), copy_callable, E->get().binds, E->get().flags);
+ }
}
}
}
- }
- for (int i = 0; i < get_child_count(); i++) {
- get_child(i)->_duplicate_signals(p_original, p_copy);
+ for (int i = 0; i < n->get_child_count(); i++) {
+ process_list.push_back(n->get_child(i));
+ }
}
}
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index 5588d1bd97..2d0e2daf41 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -154,6 +154,7 @@
#include "scene/resources/physics_material.h"
#include "scene/resources/polygon_path_finder.h"
#include "scene/resources/primitive_meshes.h"
+#include "scene/resources/ray_shape_2d.h"
#include "scene/resources/ray_shape_3d.h"
#include "scene/resources/rectangle_shape_2d.h"
#include "scene/resources/resource_format_text.h"
diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp
index c9fc68233d..014b773298 100644
--- a/scene/resources/animation.cpp
+++ b/scene/resources/animation.cpp
@@ -31,7 +31,7 @@
#include "animation.h"
#include "scene/scene_string_names.h"
-#include "core/math/geometry.h"
+#include "core/math/geometry_3d.h"
#define ANIM_MIN_LENGTH 0.001
@@ -2730,7 +2730,7 @@ bool Animation::_transform_track_optimize_key(const TKey<TransformKey> &t0, cons
}
Vector3 s[2] = { v0, v2 };
- real_t d = Geometry::get_closest_point_to_segment(v1, s).distance_to(v1);
+ real_t d = Geometry3D::get_closest_point_to_segment(v1, s).distance_to(v1);
if (d > pd.length() * p_alowed_linear_err) {
return false; //beyond allowed error for colinearity
@@ -2820,7 +2820,7 @@ bool Animation::_transform_track_optimize_key(const TKey<TransformKey> &t0, cons
}
Vector3 s[2] = { v0, v2 };
- real_t d = Geometry::get_closest_point_to_segment(v1, s).distance_to(v1);
+ real_t d = Geometry3D::get_closest_point_to_segment(v1, s).distance_to(v1);
if (d > pd.length() * p_alowed_linear_err) {
return false; //beyond allowed error for colinearity
diff --git a/scene/resources/capsule_shape_2d.cpp b/scene/resources/capsule_shape_2d.cpp
index 0e784e04ff..e519970f38 100644
--- a/scene/resources/capsule_shape_2d.cpp
+++ b/scene/resources/capsule_shape_2d.cpp
@@ -30,6 +30,7 @@
#include "capsule_shape_2d.h"
+#include "core/math/geometry_2d.h"
#include "servers/physics_server_2d.h"
#include "servers/rendering_server.h"
@@ -48,7 +49,7 @@ Vector<Vector2> CapsuleShape2D::_get_points() const {
}
bool CapsuleShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
- return Geometry::is_point_in_polygon(p_point, _get_points());
+ return Geometry2D::is_point_in_polygon(p_point, _get_points());
}
void CapsuleShape2D::_update_shape() {
diff --git a/scene/resources/concave_polygon_shape_2d.cpp b/scene/resources/concave_polygon_shape_2d.cpp
index 2154633111..eecf8afa8f 100644
--- a/scene/resources/concave_polygon_shape_2d.cpp
+++ b/scene/resources/concave_polygon_shape_2d.cpp
@@ -30,6 +30,7 @@
#include "concave_polygon_shape_2d.h"
+#include "core/math/geometry_2d.h"
#include "servers/physics_server_2d.h"
#include "servers/rendering_server.h"
@@ -42,7 +43,7 @@ bool ConcavePolygonShape2D::_edit_is_selected_on_click(const Point2 &p_point, do
const Vector2 *r = s.ptr();
for (int i = 0; i < len; i += 2) {
- Vector2 closest = Geometry::get_closest_point_to_segment_2d(p_point, &r[i]);
+ Vector2 closest = Geometry2D::get_closest_point_to_segment(p_point, &r[i]);
if (p_point.distance_to(closest) < p_tolerance) {
return true;
}
diff --git a/scene/resources/convex_polygon_shape_2d.cpp b/scene/resources/convex_polygon_shape_2d.cpp
index 7df7c3ac72..2b7531c630 100644
--- a/scene/resources/convex_polygon_shape_2d.cpp
+++ b/scene/resources/convex_polygon_shape_2d.cpp
@@ -30,17 +30,17 @@
#include "convex_polygon_shape_2d.h"
-#include "core/math/geometry.h"
+#include "core/math/geometry_2d.h"
#include "servers/physics_server_2d.h"
#include "servers/rendering_server.h"
bool ConvexPolygonShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
- return Geometry::is_point_in_polygon(p_point, points);
+ return Geometry2D::is_point_in_polygon(p_point, points);
}
void ConvexPolygonShape2D::_update_shape() {
Vector<Vector2> final_points = points;
- if (Geometry::is_polygon_clockwise(final_points)) { //needs to be counter clockwise
+ if (Geometry2D::is_polygon_clockwise(final_points)) { //needs to be counter clockwise
final_points.invert();
}
PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), final_points);
@@ -48,7 +48,7 @@ void ConvexPolygonShape2D::_update_shape() {
}
void ConvexPolygonShape2D::set_point_cloud(const Vector<Vector2> &p_points) {
- Vector<Point2> hull = Geometry::convex_hull_2d(p_points);
+ Vector<Point2> hull = Geometry2D::convex_hull(p_points);
ERR_FAIL_COND(hull.size() < 3);
set_points(hull);
}
diff --git a/scene/resources/convex_polygon_shape_3d.cpp b/scene/resources/convex_polygon_shape_3d.cpp
index e52df73663..affeb05a8f 100644
--- a/scene/resources/convex_polygon_shape_3d.cpp
+++ b/scene/resources/convex_polygon_shape_3d.cpp
@@ -37,7 +37,7 @@ Vector<Vector3> ConvexPolygonShape3D::get_debug_mesh_lines() {
if (points.size() > 3) {
Vector<Vector3> varr = Variant(points);
- Geometry::MeshData md;
+ Geometry3D::MeshData md;
Error err = QuickHull::build(varr, md);
if (err == OK) {
Vector<Vector3> lines;
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index f5b987e8df..fd5c861eb5 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -681,7 +681,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_color("font_color_disabled", "TabContainer", control_font_color_disabled);
theme->set_constant("side_margin", "TabContainer", 8 * scale);
- theme->set_constant("hseparation", "TabContainer", 4 * scale);
+ theme->set_constant("icon_separation", "TabContainer", 4 * scale);
// Tabs
@@ -726,7 +726,9 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
// FileDialog
theme->set_icon("folder", "FileDialog", make_icon(icon_folder_png));
+ theme->set_icon("file", "FileDialog", make_icon(icon_file_png));
theme->set_color("folder_icon_modulate", "FileDialog", Color(1, 1, 1));
+ theme->set_color("file_icon_modulate", "FileDialog", Color(1, 1, 1));
theme->set_color("files_disabled", "FileDialog", Color(0, 0, 0, 0.7));
// ColorPicker
diff --git a/scene/resources/default_theme/icon_file.png b/scene/resources/default_theme/icon_file.png
new file mode 100644
index 0000000000..bb4c361a8d
--- /dev/null
+++ b/scene/resources/default_theme/icon_file.png
Binary files differ
diff --git a/scene/resources/default_theme/theme_data.h b/scene/resources/default_theme/theme_data.h
index 0a4e557451..edcdb90db9 100644
--- a/scene/resources/default_theme/theme_data.h
+++ b/scene/resources/default_theme/theme_data.h
@@ -150,6 +150,10 @@ static const unsigned char icon_color_pick_png[] = {
0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xfa, 0x37, 0xea, 0x0, 0x0, 0x0, 0xaa, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0x9d, 0x8e, 0x35, 0x82, 0x2, 0x41, 0x10, 0x45, 0x3b, 0xda, 0x3d, 0xca, 0xba, 0x44, 0x2b, 0x70, 0x9, 0xdc, 0xe1, 0x20, 0xe8, 0x91, 0x90, 0x78, 0x6e, 0x40, 0x4c, 0x82, 0x74, 0xff, 0xc2, 0x9d, 0x18, 0xa7, 0x6, 0x77, 0x7b, 0x23, 0x2d, 0xaf, 0x4c, 0xdc, 0xc, 0xbd, 0x65, 0x1e, 0x84, 0x80, 0x19, 0x55, 0x34, 0x60, 0x3e, 0xd0, 0xea, 0x17, 0x3d, 0x4a, 0xc8, 0x80, 0x1a, 0x60, 0xc2, 0x4f, 0xfd, 0x30, 0xe0, 0x1b, 0x2d, 0x16, 0xab, 0xa7, 0x2c, 0xe, 0x41, 0x68, 0xa5, 0xb9, 0xca, 0x91, 0x16, 0x2e, 0x54, 0xe0, 0x59, 0x54, 0x91, 0xfe, 0xa3, 0x3a, 0xff, 0xce, 0xab, 0x5b, 0xf, 0xa0, 0x4, 0x8f, 0x7b, 0x4c, 0xd3, 0x1b, 0xca, 0x32, 0xcc, 0x55, 0x7a, 0xf4, 0x76, 0x42, 0x2b, 0x97, 0x3e, 0xae, 0xfa, 0xdd, 0xd2, 0xd2, 0x8e, 0x72, 0xe1, 0x83, 0xaf, 0x9f, 0xa9, 0x28, 0x7d, 0x5b, 0xe2, 0x2a, 0xd, 0xc3, 0xa2, 0x78, 0xfe, 0x7d, 0x51, 0xfc, 0x0, 0x8a, 0x41, 0xcb, 0x3d, 0xb2, 0xae, 0x1c, 0xd3, 0xc, 0xa5, 0x30, 0x81, 0xc6, 0xda, 0x29, 0x8e, 0x83, 0x34, 0x25, 0x29, 0x4a, 0x46, 0x71, 0x1f, 0x33, 0xbe, 0x51, 0x89, 0xaf, 0x78, 0xe3, 0x97, 0x7e, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
+static const unsigned char icon_file_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x2, 0x3, 0x0, 0x0, 0x0, 0x62, 0x9d, 0x17, 0xf2, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xe, 0xc3, 0x0, 0x0, 0xe, 0xc3, 0x1, 0xc7, 0x6f, 0xa8, 0x64, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65, 0x0, 0x77, 0x77, 0x77, 0x2e, 0x69, 0x6e, 0x6b, 0x73, 0x63, 0x61, 0x70, 0x65, 0x2e, 0x6f, 0x72, 0x67, 0x9b, 0xee, 0x3c, 0x1a, 0x0, 0x0, 0x0, 0x9, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0xdf, 0xdf, 0xdf, 0xe0, 0xe0, 0xe0, 0x42, 0xf, 0xc7, 0x49, 0x0, 0x0, 0x0, 0x2, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x88, 0x95, 0xf0, 0xc6, 0x2a, 0x0, 0x0, 0x0, 0x21, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0x0, 0x1, 0xae, 0x55, 0x2d, 0x20, 0xa2, 0x13, 0x44, 0x74, 0x39, 0x80, 0x88, 0x9, 0x40, 0xa2, 0x1, 0xc4, 0x5d, 0xb5, 0x80, 0x68, 0x2, 0x4, 0x0, 0x95, 0x34, 0x18, 0xe4, 0x5e, 0x46, 0xf7, 0x27, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
+};
+
static const unsigned char icon_folder_png[] = {
0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xfa, 0x37, 0xea, 0x0, 0x0, 0x0, 0x2e, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0x63, 0xa0, 0x6, 0x78, 0x70, 0xf4, 0xc1, 0x7f, 0x24, 0x78, 0x18, 0x53, 0xc1, 0x7f, 0x54, 0x48, 0x50, 0xc1, 0x43, 0x1b, 0xbc, 0xa, 0x50, 0xad, 0x23, 0xa4, 0xe0, 0xff, 0x70, 0x52, 0x70, 0x18, 0x97, 0xf4, 0xfd, 0x43, 0xd4, 0x88, 0x4a, 0x0, 0x5a, 0xcb, 0x18, 0xab, 0x5e, 0xd9, 0x1a, 0x53, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp
index 3b4e4b73f8..3d99556a10 100644
--- a/scene/resources/dynamic_font.cpp
+++ b/scene/resources/dynamic_font.cpp
@@ -567,7 +567,7 @@ DynamicFontAtSize::Character DynamicFontAtSize::_make_outline_char(CharType p_ch
if (FT_Glyph_Stroke(&glyph, stroker, 1) != 0) {
goto cleanup_glyph;
}
- if (FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, nullptr, 1) != 0) {
+ if (FT_Glyph_To_Bitmap(&glyph, font->antialiased ? FT_RENDER_MODE_NORMAL : FT_RENDER_MODE_MONO, nullptr, 1) != 0) {
goto cleanup_glyph;
}
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index 1878b174e8..ccab88a153 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -93,6 +93,7 @@ void Font::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_descent"), &Font::get_descent);
ClassDB::bind_method(D_METHOD("get_height"), &Font::get_height);
ClassDB::bind_method(D_METHOD("is_distance_field_hint"), &Font::is_distance_field_hint);
+ ClassDB::bind_method(D_METHOD("get_char_size", "char", "next"), &Font::get_char_size, DEFVAL(0));
ClassDB::bind_method(D_METHOD("get_string_size", "string"), &Font::get_string_size);
ClassDB::bind_method(D_METHOD("get_wordwrap_string_size", "string", "width"), &Font::get_wordwrap_string_size);
ClassDB::bind_method(D_METHOD("has_outline"), &Font::has_outline);
@@ -596,8 +597,6 @@ void BitmapFont::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_texture_count"), &BitmapFont::get_texture_count);
ClassDB::bind_method(D_METHOD("get_texture", "idx"), &BitmapFont::get_texture);
- ClassDB::bind_method(D_METHOD("get_char_size", "char", "next"), &BitmapFont::get_char_size, DEFVAL(0));
-
ClassDB::bind_method(D_METHOD("set_distance_field_hint", "enable"), &BitmapFont::set_distance_field_hint);
ClassDB::bind_method(D_METHOD("clear"), &BitmapFont::clear);
diff --git a/scene/resources/line_shape_2d.cpp b/scene/resources/line_shape_2d.cpp
index 802ccaaee6..58653c5f4a 100644
--- a/scene/resources/line_shape_2d.cpp
+++ b/scene/resources/line_shape_2d.cpp
@@ -30,6 +30,7 @@
#include "line_shape_2d.h"
+#include "core/math/geometry_2d.h"
#include "servers/physics_server_2d.h"
#include "servers/rendering_server.h"
@@ -38,7 +39,7 @@ bool LineShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tol
Vector2 l[2][2] = { { point - get_normal().tangent() * 100, point + get_normal().tangent() * 100 }, { point, point + get_normal() * 30 } };
for (int i = 0; i < 2; i++) {
- Vector2 closest = Geometry::get_closest_point_to_segment_2d(p_point, l[i]);
+ Vector2 closest = Geometry2D::get_closest_point_to_segment(p_point, l[i]);
if (p_point.distance_to(closest) < p_tolerance) {
return true;
}
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index 058e89cf2e..cb201bc539 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -98,6 +98,9 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
}
#endif
parent = nparent;
+ } else {
+ // i == 0 is root node. Confirm that it doesn't have a parent defined.
+ ERR_FAIL_COND_V_MSG(n.parent != -1, nullptr, vformat("Invalid scene: root node %s cannot specify a parent node.", snames[n.name]));
}
Node *node = nullptr;
diff --git a/scene/resources/polygon_path_finder.cpp b/scene/resources/polygon_path_finder.cpp
index 0546c92948..df98d4cfd4 100644
--- a/scene/resources/polygon_path_finder.cpp
+++ b/scene/resources/polygon_path_finder.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "polygon_path_finder.h"
-#include "core/math/geometry.h"
+#include "core/math/geometry_2d.h"
bool PolygonPathFinder::_is_point_inside(const Vector2 &p_point) const {
int crosses = 0;
@@ -40,7 +40,7 @@ bool PolygonPathFinder::_is_point_inside(const Vector2 &p_point) const {
Vector2 a = points[e.points[0]].pos;
Vector2 b = points[e.points[1]].pos;
- if (Geometry::segment_intersects_segment_2d(a, b, p_point, outside_point, nullptr)) {
+ if (Geometry2D::segment_intersects_segment(a, b, p_point, outside_point, nullptr)) {
crosses++;
}
}
@@ -114,7 +114,7 @@ void PolygonPathFinder::setup(const Vector<Vector2> &p_points, const Vector<int>
Vector2 a = points[e.points[0]].pos;
Vector2 b = points[e.points[1]].pos;
- if (Geometry::segment_intersects_segment_2d(a, b, from, to, nullptr)) {
+ if (Geometry2D::segment_intersects_segment(a, b, from, to, nullptr)) {
valid = false;
break;
}
@@ -147,7 +147,7 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
points[e.points[1]].pos
};
- Vector2 closest = Geometry::get_closest_point_to_segment_2d(from, seg);
+ Vector2 closest = Geometry2D::get_closest_point_to_segment(from, seg);
float d = from.distance_squared_to(closest);
if (d < closest_dist) {
@@ -171,7 +171,7 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
points[e.points[1]].pos
};
- Vector2 closest = Geometry::get_closest_point_to_segment_2d(to, seg);
+ Vector2 closest = Geometry2D::get_closest_point_to_segment(to, seg);
float d = to.distance_squared_to(closest);
if (d < closest_dist) {
@@ -200,7 +200,7 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
Vector2 a = points[e.points[0]].pos;
Vector2 b = points[e.points[1]].pos;
- if (Geometry::segment_intersects_segment_2d(a, b, from, to, nullptr)) {
+ if (Geometry2D::segment_intersects_segment(a, b, from, to, nullptr)) {
can_see_eachother = false;
break;
}
@@ -255,7 +255,7 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
e.points[1] != ignore_from_edge.points[1] &&
e.points[0] != ignore_from_edge.points[0] &&
e.points[1] != ignore_from_edge.points[0]) {
- if (Geometry::segment_intersects_segment_2d(a, b, from, points[i].pos, nullptr)) {
+ if (Geometry2D::segment_intersects_segment(a, b, from, points[i].pos, nullptr)) {
valid_a = false;
}
}
@@ -266,7 +266,7 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
e.points[1] != ignore_to_edge.points[1] &&
e.points[0] != ignore_to_edge.points[0] &&
e.points[1] != ignore_to_edge.points[0]) {
- if (Geometry::segment_intersects_segment_2d(a, b, to, points[i].pos, nullptr)) {
+ if (Geometry2D::segment_intersects_segment(a, b, to, points[i].pos, nullptr)) {
valid_b = false;
}
}
@@ -499,7 +499,7 @@ Vector2 PolygonPathFinder::get_closest_point(const Vector2 &p_point) const {
points[e.points[1]].pos
};
- Vector2 closest = Geometry::get_closest_point_to_segment_2d(p_point, seg);
+ Vector2 closest = Geometry2D::get_closest_point_to_segment(p_point, seg);
float d = p_point.distance_squared_to(closest);
if (d < closest_dist) {
@@ -521,7 +521,7 @@ Vector<Vector2> PolygonPathFinder::get_intersections(const Vector2 &p_from, cons
Vector2 b = points[E->get().points[1]].pos;
Vector2 res;
- if (Geometry::segment_intersects_segment_2d(a, b, p_from, p_to, &res)) {
+ if (Geometry2D::segment_intersects_segment(a, b, p_from, p_to, &res)) {
inters.push_back(res);
}
}
diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp
index 99edf26dc1..8d9c5f07b2 100644
--- a/scene/resources/primitive_meshes.cpp
+++ b/scene/resources/primitive_meshes.cpp
@@ -204,7 +204,7 @@ void PrimitiveMesh::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_flip_faces", "flip_faces"), &PrimitiveMesh::set_flip_faces);
ClassDB::bind_method(D_METHOD("get_flip_faces"), &PrimitiveMesh::get_flip_faces);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,StandardMaterial3D"), "set_material", "get_material");
ADD_PROPERTY(PropertyInfo(Variant::AABB, "custom_aabb", PROPERTY_HINT_NONE, ""), "set_custom_aabb", "get_custom_aabb");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flip_faces"), "set_flip_faces", "get_flip_faces");
}
diff --git a/scene/resources/ray_shape_2d.cpp b/scene/resources/ray_shape_2d.cpp
new file mode 100644
index 0000000000..67c4f84749
--- /dev/null
+++ b/scene/resources/ray_shape_2d.cpp
@@ -0,0 +1,105 @@
+/*************************************************************************/
+/* ray_shape_2d.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "ray_shape_2d.h"
+
+#include "servers/physics_server_2d.h"
+#include "servers/rendering_server.h"
+
+void RayShape2D::_update_shape() {
+ Dictionary d;
+ d["length"] = length;
+ d["slips_on_slope"] = slips_on_slope;
+ PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), d);
+ emit_changed();
+}
+
+void RayShape2D::draw(const RID &p_to_rid, const Color &p_color) {
+ Vector2 tip = Vector2(0, get_length());
+ RS::get_singleton()->canvas_item_add_line(p_to_rid, Vector2(), tip, p_color, 3);
+ Vector<Vector2> pts;
+ float tsize = 4;
+ pts.push_back(tip + Vector2(0, tsize));
+ pts.push_back(tip + Vector2(Math_SQRT12 * tsize, 0));
+ pts.push_back(tip + Vector2(-Math_SQRT12 * tsize, 0));
+ Vector<Color> cols;
+ for (int i = 0; i < 3; i++) {
+ cols.push_back(p_color);
+ }
+ RS::get_singleton()->canvas_item_add_primitive(p_to_rid, pts, cols, Vector<Point2>(), RID());
+}
+
+Rect2 RayShape2D::get_rect() const {
+ Rect2 rect;
+ rect.position = Vector2();
+ rect.expand_to(Vector2(0, length));
+ rect = rect.grow(Math_SQRT12 * 4);
+ return rect;
+}
+
+real_t RayShape2D::get_enclosing_radius() const {
+ return length;
+}
+
+void RayShape2D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_length", "length"), &RayShape2D::set_length);
+ ClassDB::bind_method(D_METHOD("get_length"), &RayShape2D::get_length);
+
+ ClassDB::bind_method(D_METHOD("set_slips_on_slope", "active"), &RayShape2D::set_slips_on_slope);
+ ClassDB::bind_method(D_METHOD("get_slips_on_slope"), &RayShape2D::get_slips_on_slope);
+
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "length"), "set_length", "get_length");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "slips_on_slope"), "set_slips_on_slope", "get_slips_on_slope");
+}
+
+void RayShape2D::set_length(real_t p_length) {
+ length = p_length;
+ _update_shape();
+}
+
+real_t RayShape2D::get_length() const {
+ return length;
+}
+
+void RayShape2D::set_slips_on_slope(bool p_active) {
+ slips_on_slope = p_active;
+ _update_shape();
+}
+
+bool RayShape2D::get_slips_on_slope() const {
+ return slips_on_slope;
+}
+
+RayShape2D::RayShape2D() :
+ Shape2D(PhysicsServer2D::get_singleton()->ray_shape_create()) {
+ length = 20;
+ slips_on_slope = false;
+ _update_shape();
+}
diff --git a/scene/resources/ray_shape_2d.h b/scene/resources/ray_shape_2d.h
new file mode 100644
index 0000000000..9a209d2907
--- /dev/null
+++ b/scene/resources/ray_shape_2d.h
@@ -0,0 +1,61 @@
+/*************************************************************************/
+/* ray_shape_2d.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef RAY_SHAPE_2D_H
+#define RAY_SHAPE_2D_H
+
+#include "scene/resources/shape_2d.h"
+
+class RayShape2D : public Shape2D {
+ GDCLASS(RayShape2D, Shape2D);
+
+ real_t length;
+ bool slips_on_slope;
+
+ void _update_shape();
+
+protected:
+ static void _bind_methods();
+
+public:
+ void set_length(real_t p_length);
+ real_t get_length() const;
+
+ void set_slips_on_slope(bool p_active);
+ bool get_slips_on_slope() const;
+
+ virtual void draw(const RID &p_to_rid, const Color &p_color);
+ virtual Rect2 get_rect() const;
+ virtual real_t get_enclosing_radius() const;
+
+ RayShape2D();
+};
+
+#endif // RAY_SHAPE_2D_H
diff --git a/scene/resources/segment_shape_2d.cpp b/scene/resources/segment_shape_2d.cpp
index 7b409eebbb..b1001203a1 100644
--- a/scene/resources/segment_shape_2d.cpp
+++ b/scene/resources/segment_shape_2d.cpp
@@ -30,12 +30,13 @@
#include "segment_shape_2d.h"
+#include "core/math/geometry_2d.h"
#include "servers/physics_server_2d.h"
#include "servers/rendering_server.h"
bool SegmentShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
Vector2 l[2] = { a, b };
- Vector2 closest = Geometry::get_closest_point_to_segment_2d(p_point, l);
+ Vector2 closest = Geometry2D::get_closest_point_to_segment(p_point, l);
return p_point.distance_to(closest) < p_tolerance;
}
@@ -97,77 +98,3 @@ SegmentShape2D::SegmentShape2D() :
b = Vector2(0, 10);
_update_shape();
}
-
-////////////////////////////////////////////////////////////
-
-void RayShape2D::_update_shape() {
- Dictionary d;
- d["length"] = length;
- d["slips_on_slope"] = slips_on_slope;
- PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), d);
- emit_changed();
-}
-
-void RayShape2D::draw(const RID &p_to_rid, const Color &p_color) {
- Vector2 tip = Vector2(0, get_length());
- RS::get_singleton()->canvas_item_add_line(p_to_rid, Vector2(), tip, p_color, 3);
- Vector<Vector2> pts;
- float tsize = 4;
- pts.push_back(tip + Vector2(0, tsize));
- pts.push_back(tip + Vector2(Math_SQRT12 * tsize, 0));
- pts.push_back(tip + Vector2(-Math_SQRT12 * tsize, 0));
- Vector<Color> cols;
- for (int i = 0; i < 3; i++) {
- cols.push_back(p_color);
- }
-
- RS::get_singleton()->canvas_item_add_primitive(p_to_rid, pts, cols, Vector<Point2>(), RID());
-}
-
-Rect2 RayShape2D::get_rect() const {
- Rect2 rect;
- rect.position = Vector2();
- rect.expand_to(Vector2(0, length));
- rect = rect.grow(Math_SQRT12 * 4);
- return rect;
-}
-
-real_t RayShape2D::get_enclosing_radius() const {
- return length;
-}
-
-void RayShape2D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_length", "length"), &RayShape2D::set_length);
- ClassDB::bind_method(D_METHOD("get_length"), &RayShape2D::get_length);
-
- ClassDB::bind_method(D_METHOD("set_slips_on_slope", "active"), &RayShape2D::set_slips_on_slope);
- ClassDB::bind_method(D_METHOD("get_slips_on_slope"), &RayShape2D::get_slips_on_slope);
-
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "length"), "set_length", "get_length");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "slips_on_slope"), "set_slips_on_slope", "get_slips_on_slope");
-}
-
-void RayShape2D::set_length(real_t p_length) {
- length = p_length;
- _update_shape();
-}
-
-real_t RayShape2D::get_length() const {
- return length;
-}
-
-void RayShape2D::set_slips_on_slope(bool p_active) {
- slips_on_slope = p_active;
- _update_shape();
-}
-
-bool RayShape2D::get_slips_on_slope() const {
- return slips_on_slope;
-}
-
-RayShape2D::RayShape2D() :
- Shape2D(PhysicsServer2D::get_singleton()->ray_shape_create()) {
- length = 20;
- slips_on_slope = false;
- _update_shape();
-}
diff --git a/scene/resources/segment_shape_2d.h b/scene/resources/segment_shape_2d.h
index ca10c24f07..39c297b040 100644
--- a/scene/resources/segment_shape_2d.h
+++ b/scene/resources/segment_shape_2d.h
@@ -60,29 +60,4 @@ public:
SegmentShape2D();
};
-class RayShape2D : public Shape2D {
- GDCLASS(RayShape2D, Shape2D);
-
- real_t length;
- bool slips_on_slope;
-
- void _update_shape();
-
-protected:
- static void _bind_methods();
-
-public:
- void set_length(real_t p_length);
- real_t get_length() const;
-
- void set_slips_on_slope(bool p_active);
- bool get_slips_on_slope() const;
-
- virtual void draw(const RID &p_to_rid, const Color &p_color);
- virtual Rect2 get_rect() const;
- virtual real_t get_enclosing_radius() const;
-
- RayShape2D();
-};
-
#endif // SEGMENT_SHAPE_2D_H
diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp
index 4ca8032d65..4249542567 100644
--- a/scene/resources/shader.cpp
+++ b/scene/resources/shader.cpp
@@ -125,7 +125,7 @@ bool Shader::is_text_shader() const {
}
bool Shader::has_param(const StringName &p_param) const {
- return params_cache.has(p_param);
+ return params_cache.has("shader_param/" + p_param);
}
void Shader::_update_shader() const {
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp
index c17b6f8817..6992360df7 100644
--- a/scene/resources/tile_set.cpp
+++ b/scene/resources/tile_set.cpp
@@ -29,8 +29,10 @@
/*************************************************************************/
#include "tile_set.h"
+
#include "core/array.h"
#include "core/engine.h"
+#include "core/math/geometry_2d.h"
bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
String n = p_name;
@@ -1033,7 +1035,7 @@ void TileSet::_decompose_convex_shape(Ref<Shape2D> p_shape) {
if (!convex.is_valid()) {
return;
}
- Vector<Vector<Vector2>> decomp = Geometry::decompose_polygon_in_convex(convex->get_points());
+ Vector<Vector<Vector2>> decomp = Geometry2D::decompose_polygon_in_convex(convex->get_points());
if (decomp.size() > 1) {
Array sub_shapes;
for (int i = 0; i < decomp.size(); i++) {
diff --git a/scene/scene_string_names.cpp b/scene/scene_string_names.cpp
index 7f87da3724..7cf9a4fedd 100644
--- a/scene/scene_string_names.cpp
+++ b/scene/scene_string_names.cpp
@@ -62,6 +62,8 @@ SceneStringNames::SceneStringNames() {
animation_changed = StaticCString::create("animation_changed");
animation_started = StaticCString::create("animation_started");
+ pose_updated = StaticCString::create("pose_updated");
+
mouse_entered = StaticCString::create("mouse_entered");
mouse_exited = StaticCString::create("mouse_exited");
diff --git a/scene/scene_string_names.h b/scene/scene_string_names.h
index 1a6ffbd5dd..1ae244492e 100644
--- a/scene/scene_string_names.h
+++ b/scene/scene_string_names.h
@@ -95,6 +95,8 @@ public:
StringName animation_changed;
StringName animation_started;
+ StringName pose_updated;
+
StringName body_shape_entered;
StringName body_entered;
StringName body_shape_exited;