summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/canvas_item.cpp17
-rw-r--r--scene/2d/canvas_item.h2
-rw-r--r--scene/2d/cpu_particles_2d.cpp6
-rw-r--r--scene/2d/navigation_polygon.cpp10
-rw-r--r--scene/2d/path_2d.cpp2
-rw-r--r--scene/2d/physics_body_2d.cpp18
-rw-r--r--scene/2d/tile_map.cpp4
-rw-r--r--scene/3d/cpu_particles.cpp10
-rw-r--r--scene/3d/listener.h2
-rw-r--r--scene/3d/path.cpp4
-rw-r--r--scene/3d/remote_transform.cpp36
-rw-r--r--scene/3d/sprite_3d.cpp4
-rw-r--r--scene/animation/animation_player.cpp2
-rw-r--r--scene/animation/animation_tree_player.cpp10
-rw-r--r--scene/animation/animation_tree_player.h2
-rw-r--r--scene/gui/base_button.cpp11
-rw-r--r--scene/gui/base_button.h1
-rw-r--r--scene/gui/color_picker.cpp59
-rw-r--r--scene/gui/color_picker.h3
-rw-r--r--scene/gui/control.cpp18
-rw-r--r--scene/gui/file_dialog.cpp3
-rw-r--r--scene/gui/graph_edit.cpp4
-rw-r--r--scene/gui/line_edit.cpp16
-rw-r--r--scene/gui/line_edit.h1
-rw-r--r--scene/gui/menu_button.cpp19
-rw-r--r--scene/gui/menu_button.h3
-rw-r--r--scene/gui/rich_text_label.cpp39
-rw-r--r--scene/gui/rich_text_label.h1
-rw-r--r--scene/gui/spin_box.cpp34
-rw-r--r--scene/gui/spin_box.h4
-rw-r--r--scene/gui/split_container.cpp15
-rw-r--r--scene/gui/text_edit.cpp23
-rw-r--r--scene/gui/text_edit.h3
-rw-r--r--scene/gui/tree.cpp17
-rw-r--r--scene/gui/tree.h2
-rw-r--r--scene/main/scene_tree.cpp1
-rw-r--r--scene/main/viewport.cpp22
-rw-r--r--scene/main/viewport.h1
-rw-r--r--scene/resources/audio_stream_sample.cpp7
-rw-r--r--scene/resources/audio_stream_sample.h3
-rw-r--r--scene/resources/default_theme/default_theme.cpp4
-rw-r--r--scene/resources/material.cpp61
-rw-r--r--scene/resources/material.h2
-rw-r--r--scene/resources/particles_material.cpp15
-rw-r--r--scene/resources/particles_material.h2
-rw-r--r--scene/resources/primitive_meshes.cpp44
-rw-r--r--scene/resources/surface_tool.cpp104
-rw-r--r--scene/resources/surface_tool.h1
-rw-r--r--scene/resources/tile_set.cpp47
-rw-r--r--scene/resources/tile_set.h4
50 files changed, 481 insertions, 242 deletions
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index 0ea2e85dfa..2534f676ca 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -42,7 +42,7 @@
#include "servers/visual_server.h"
Mutex *CanvasItemMaterial::material_mutex = NULL;
-SelfList<CanvasItemMaterial>::List CanvasItemMaterial::dirty_materials;
+SelfList<CanvasItemMaterial>::List *CanvasItemMaterial::dirty_materials = NULL;
Map<CanvasItemMaterial::MaterialKey, CanvasItemMaterial::ShaderData> CanvasItemMaterial::shader_map;
CanvasItemMaterial::ShaderNames *CanvasItemMaterial::shader_names = NULL;
@@ -52,6 +52,8 @@ void CanvasItemMaterial::init_shaders() {
material_mutex = Mutex::create();
#endif
+ dirty_materials = memnew(SelfList<CanvasItemMaterial>::List);
+
shader_names = memnew(ShaderNames);
shader_names->particles_anim_h_frames = "particles_anim_h_frames";
@@ -61,6 +63,9 @@ void CanvasItemMaterial::init_shaders() {
void CanvasItemMaterial::finish_shaders() {
+ memdelete(dirty_materials);
+ dirty_materials = NULL;
+
#ifndef NO_THREADS
memdelete(material_mutex);
#endif
@@ -68,7 +73,7 @@ void CanvasItemMaterial::finish_shaders() {
void CanvasItemMaterial::_update_shader() {
- dirty_materials.remove(&element);
+ dirty_materials->remove(&element);
MaterialKey mk = _compute_key();
if (mk.key == current_key.key)
@@ -157,9 +162,9 @@ void CanvasItemMaterial::flush_changes() {
if (material_mutex)
material_mutex->lock();
- while (dirty_materials.first()) {
+ while (dirty_materials->first()) {
- dirty_materials.first()->self()->_update_shader();
+ dirty_materials->first()->self()->_update_shader();
}
if (material_mutex)
@@ -172,7 +177,7 @@ void CanvasItemMaterial::_queue_shader_change() {
material_mutex->lock();
if (!element.in_list()) {
- dirty_materials.add(&element);
+ dirty_materials->add(&element);
}
if (material_mutex)
@@ -1160,7 +1165,7 @@ void CanvasItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("draw_string", "font", "position", "text", "modulate", "clip_w"), &CanvasItem::draw_string, DEFVAL(Color(1, 1, 1)), DEFVAL(-1));
ClassDB::bind_method(D_METHOD("draw_char", "font", "position", "char", "next", "modulate"), &CanvasItem::draw_char, DEFVAL(Color(1, 1, 1)));
ClassDB::bind_method(D_METHOD("draw_mesh", "mesh", "texture", "normal_map"), &CanvasItem::draw_mesh, DEFVAL(Ref<Texture>()));
- ClassDB::bind_method(D_METHOD("draw_multimesh", "mesh", "texture", "normal_map"), &CanvasItem::draw_mesh, DEFVAL(Ref<Texture>()));
+ ClassDB::bind_method(D_METHOD("draw_multimesh", "multimesh", "texture", "normal_map"), &CanvasItem::draw_multimesh, DEFVAL(Ref<Texture>()));
ClassDB::bind_method(D_METHOD("draw_set_transform", "position", "rotation", "scale"), &CanvasItem::draw_set_transform);
ClassDB::bind_method(D_METHOD("draw_set_transform_matrix", "xform"), &CanvasItem::draw_set_transform_matrix);
diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h
index 9fe7cb1e00..1a6016e6e1 100644
--- a/scene/2d/canvas_item.h
+++ b/scene/2d/canvas_item.h
@@ -109,7 +109,7 @@ private:
}
static Mutex *material_mutex;
- static SelfList<CanvasItemMaterial>::List dirty_materials;
+ static SelfList<CanvasItemMaterial>::List *dirty_materials;
SelfList<CanvasItemMaterial> element;
void _update_shader();
diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp
index 613387bf07..93ad99272c 100644
--- a/scene/2d/cpu_particles_2d.cpp
+++ b/scene/2d/cpu_particles_2d.cpp
@@ -1305,9 +1305,9 @@ void CPUParticles2D::_bind_methods() {
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angle_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_ANGLE);
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "angle_curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_param_curve", "get_param_curve", PARAM_ANGLE);
ADD_GROUP("Scale", "");
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "scale", PROPERTY_HINT_RANGE, "0,1000,0.01,or_greater"), "set_param", "get_param", PARAM_SCALE);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "scale_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_SCALE);
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "scale_curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_param_curve", "get_param_curve", PARAM_SCALE);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "scale_amount", PROPERTY_HINT_RANGE, "0,1000,0.01,or_greater"), "set_param", "get_param", PARAM_SCALE);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "scale_amount_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_SCALE);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "scale_amount_curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_param_curve", "get_param_curve", PARAM_SCALE);
ADD_GROUP("Color", "");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "color_ramp", PROPERTY_HINT_RESOURCE_TYPE, "Gradient"), "set_color_ramp", "get_color_ramp");
diff --git a/scene/2d/navigation_polygon.cpp b/scene/2d/navigation_polygon.cpp
index b36924e521..9154929e0b 100644
--- a/scene/2d/navigation_polygon.cpp
+++ b/scene/2d/navigation_polygon.cpp
@@ -349,8 +349,6 @@ void NavigationPolygonInstance::set_enabled(bool p_enabled) {
if (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_navigation_hint())
update();
-
- //update_gizmo();
}
bool NavigationPolygonInstance::is_enabled() const {
@@ -461,26 +459,28 @@ void NavigationPolygonInstance::_notification(int p_what) {
void NavigationPolygonInstance::set_navigation_polygon(const Ref<NavigationPolygon> &p_navpoly) {
- if (p_navpoly == navpoly)
+ if (p_navpoly == navpoly) {
return;
+ }
if (navigation && nav_id != -1) {
navigation->navpoly_remove(nav_id);
nav_id = -1;
}
+
if (navpoly.is_valid()) {
navpoly->disconnect(CoreStringNames::get_singleton()->changed, this, "_navpoly_changed");
}
navpoly = p_navpoly;
-
if (navpoly.is_valid()) {
navpoly->connect(CoreStringNames::get_singleton()->changed, this, "_navpoly_changed");
}
+ _navpoly_changed();
if (navigation && navpoly.is_valid() && enabled) {
nav_id = navigation->navpoly_add(navpoly, get_relative_transform_to_parent(navigation), this);
}
- //update_gizmo();
+
_change_notify("navpoly");
update_configuration_warning();
}
diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp
index 4276918f53..5eae43b2d5 100644
--- a/scene/2d/path_2d.cpp
+++ b/scene/2d/path_2d.cpp
@@ -303,7 +303,7 @@ void PathFollow2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_lookahead", "lookahead"), &PathFollow2D::set_lookahead);
ClassDB::bind_method(D_METHOD("get_lookahead"), &PathFollow2D::get_lookahead);
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "offset", PROPERTY_HINT_EXP_RANGE, "0,10000,0.01,or_greater"), "set_offset", "get_offset");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "offset", PROPERTY_HINT_RANGE, "0,10000,0.01,or_greater"), "set_offset", "get_offset");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "unit_offset", PROPERTY_HINT_RANGE, "0,1,0.0001", PROPERTY_USAGE_EDITOR), "set_unit_offset", "get_unit_offset");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "h_offset"), "set_h_offset", "get_h_offset");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "v_offset"), "set_v_offset", "get_v_offset");
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index 3dde228bfa..c440512c84 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -1279,7 +1279,6 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const
colliders.push_back(collision);
motion = collision.remainder;
- bool is_on_slope = false;
if (p_floor_direction == Vector2()) {
//all is a wall
on_wall = true;
@@ -1291,16 +1290,14 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const
floor_velocity = collision.collider_vel;
if (p_stop_on_slope) {
- if (Vector2() == lv_n + p_floor_direction) {
+ if (Vector2() == lv_n + p_floor_direction && collision.travel.length() < 1) {
Transform2D gt = get_global_transform();
- gt.elements[2] -= collision.travel;
+ gt.elements[2] -= collision.travel.project(p_floor_direction.tangent());
set_global_transform(gt);
return Vector2();
}
}
- is_on_slope = true;
-
} else if (collision.normal.dot(-p_floor_direction) >= Math::cos(p_floor_max_angle + FLOOR_ANGLE_THRESHOLD)) { //ceiling
on_ceiling = true;
} else {
@@ -1308,14 +1305,9 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const
}
}
- if (p_stop_on_slope && is_on_slope) {
- motion = motion.slide(p_floor_direction);
- lv = lv.slide(p_floor_direction);
- } else {
- Vector2 n = collision.normal;
- motion = motion.slide(n);
- lv = lv.slide(n);
- }
+ Vector2 n = collision.normal;
+ motion = motion.slide(n);
+ lv = lv.slide(n);
}
if (p_stop_on_slope)
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 8fe65f53a9..641cb161ca 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -327,6 +327,10 @@ void TileMap::update_dirty_quadrants() {
Ref<ShaderMaterial> mat = tile_set->tile_get_material(c.id);
int z_index = tile_set->tile_get_z_index(c.id);
+ if (tile_set->tile_get_tile_mode(c.id) == TileSet::AUTO_TILE) {
+ z_index += tile_set->autotile_get_z_index(c.id, Vector2(c.autotile_coord_x, c.autotile_coord_y));
+ }
+
RID canvas_item;
RID debug_canvas_item;
diff --git a/scene/3d/cpu_particles.cpp b/scene/3d/cpu_particles.cpp
index 1269cef7c2..b07848e02e 100644
--- a/scene/3d/cpu_particles.cpp
+++ b/scene/3d/cpu_particles.cpp
@@ -217,7 +217,7 @@ String CPUParticles::get_configuration_warning() const {
if (!mesh_found) {
if (warnings != String())
warnings += "\n";
- warnings += "- " + TTR("Nothing is visible because no mesh has not been assigned.");
+ warnings += "- " + TTR("Nothing is visible because no mesh has been assigned.");
}
if (!anim_material_found && (get_param(PARAM_ANIM_SPEED) != 0.0 || get_param(PARAM_ANIM_OFFSET) != 0.0 ||
@@ -523,7 +523,7 @@ void CPUParticles::_particles_process(float p_delta) {
Basis velocity_xform;
if (!local_coords) {
emission_xform = get_global_transform();
- velocity_xform = emission_xform.basis.inverse().transposed();
+ velocity_xform = emission_xform.basis;
}
for (int i = 0; i < pcount; i++) {
@@ -1361,9 +1361,9 @@ void CPUParticles::_bind_methods() {
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angle_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_ANGLE);
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "angle_curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_param_curve", "get_param_curve", PARAM_ANGLE);
ADD_GROUP("Scale", "");
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "scale", PROPERTY_HINT_RANGE, "0,1000,0.01,or_greater"), "set_param", "get_param", PARAM_SCALE);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "scale_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_SCALE);
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "scale_curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_param_curve", "get_param_curve", PARAM_SCALE);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "scale_amount", PROPERTY_HINT_RANGE, "0,1000,0.01,or_greater"), "set_param", "get_param", PARAM_SCALE);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "scale_amount_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_SCALE);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "scale_amount_curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_param_curve", "get_param_curve", PARAM_SCALE);
ADD_GROUP("Color", "");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "color_ramp", PROPERTY_HINT_RESOURCE_TYPE, "Gradient"), "set_color_ramp", "get_color_ramp");
diff --git a/scene/3d/listener.h b/scene/3d/listener.h
index 8047971ebd..9901f7635c 100644
--- a/scene/3d/listener.h
+++ b/scene/3d/listener.h
@@ -71,8 +71,6 @@ public:
void set_visible_layers(uint32_t p_layers);
uint32_t get_visible_layers() const;
- Vector<Plane> get_frustum() const;
-
Listener();
~Listener();
};
diff --git a/scene/3d/path.cpp b/scene/3d/path.cpp
index 339a434a6e..b732c3b8b7 100644
--- a/scene/3d/path.cpp
+++ b/scene/3d/path.cpp
@@ -252,7 +252,7 @@ void PathFollow::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_loop", "loop"), &PathFollow::set_loop);
ClassDB::bind_method(D_METHOD("has_loop"), &PathFollow::has_loop);
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "offset", PROPERTY_HINT_EXP_RANGE, "0,10000,0.01,or_greater"), "set_offset", "get_offset");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "offset", PROPERTY_HINT_RANGE, "0,10000,0.01,or_greater"), "set_offset", "get_offset");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "unit_offset", PROPERTY_HINT_RANGE, "0,1,0.0001", PROPERTY_USAGE_EDITOR), "set_unit_offset", "get_unit_offset");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "h_offset"), "set_h_offset", "get_h_offset");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "v_offset"), "set_v_offset", "get_v_offset");
@@ -476,7 +476,7 @@ String OrientedPathFollow::get_configuration_warning() const {
} else {
Path *path = Object::cast_to<Path>(get_parent());
if (path->get_curve().is_valid() && !path->get_curve()->is_up_vector_enabled()) {
- return TTR("OrientedPathFollow requires up vectors enabled in its parent Path.");
+ return TTR("OrientedPathFollow requires \"Up Vector\" enabled in its parent Path's Curve resource.");
}
}
diff --git a/scene/3d/remote_transform.cpp b/scene/3d/remote_transform.cpp
index c12e49fb47..490fcf24fd 100644
--- a/scene/3d/remote_transform.cpp
+++ b/scene/3d/remote_transform.cpp
@@ -63,38 +63,40 @@ void RemoteTransform::_update_remote() {
if (update_remote_position && update_remote_rotation && update_remote_scale) {
n->set_global_transform(get_global_transform());
} else {
- Transform n_trans = n->get_global_transform();
Transform our_trans = get_global_transform();
- if (!update_remote_position)
- our_trans.set_origin(n_trans.get_origin());
+ if (update_remote_rotation)
+ n->set_rotation(our_trans.basis.get_rotation());
- n->set_global_transform(our_trans);
+ if (update_remote_scale)
+ n->set_scale(our_trans.basis.get_scale());
- if (!update_remote_rotation)
- n->set_rotation(n_trans.basis.get_rotation());
+ if (update_remote_position) {
+ Transform n_trans = n->get_global_transform();
- if (!update_remote_scale)
- n->set_scale(n_trans.basis.get_scale());
+ n_trans.set_origin(our_trans.get_origin());
+ n->set_global_transform(n_trans);
+ }
}
} else {
if (update_remote_position && update_remote_rotation && update_remote_scale) {
- n->set_global_transform(get_global_transform());
+ n->set_transform(get_transform());
} else {
- Transform n_trans = n->get_transform();
Transform our_trans = get_transform();
- if (!update_remote_position)
- our_trans.set_origin(n_trans.get_origin());
+ if (update_remote_rotation)
+ n->set_rotation(our_trans.basis.get_rotation());
- n->set_transform(our_trans);
+ if (update_remote_scale)
+ n->set_scale(our_trans.basis.get_scale());
- if (!update_remote_rotation)
- n->set_rotation(n_trans.basis.get_rotation());
+ if (update_remote_position) {
+ Transform n_trans = n->get_transform();
- if (!update_remote_scale)
- n->set_scale(n_trans.basis.get_scale());
+ n_trans.set_origin(our_trans.get_origin());
+ n->set_transform(n_trans);
+ }
}
}
}
diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp
index 5bde224ce3..7b4c7de029 100644
--- a/scene/3d/sprite_3d.cpp
+++ b/scene/3d/sprite_3d.cpp
@@ -463,9 +463,9 @@ void Sprite3D::_draw() {
Plane tangent;
if (axis == Vector3::AXIS_X) {
- tangent = Plane(0, 0, -1, -1);
+ tangent = Plane(0, 0, -1, 1);
} else {
- tangent = Plane(1, 0, 0, -1);
+ tangent = Plane(1, 0, 0, 1);
}
RID mat = SpatialMaterial::get_material_rid_for_2d(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS);
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index 7f9953ab43..cfc3b2f4ce 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -1427,6 +1427,8 @@ StringName AnimationPlayer::find_animation(const Ref<Animation> &p_animation) co
}
void AnimationPlayer::set_autoplay(const String &p_name) {
+ if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint())
+ WARN_PRINT("Setting autoplay after the node has been added to the scene has no effect.");
autoplay = p_name;
}
diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp
index 524784df53..6adfb94695 100644
--- a/scene/animation/animation_tree_player.cpp
+++ b/scene/animation/animation_tree_player.cpp
@@ -401,6 +401,9 @@ void AnimationTreePlayer::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
+ ERR_EXPLAIN("AnimationTreePlayer has been deprecated. Use AnimationTree instead.");
+ WARN_DEPRECATED
+
if (!processing) {
//make sure that a previous process state was not saved
//only process if "processing" is set
@@ -409,12 +412,14 @@ void AnimationTreePlayer::_notification(int p_what) {
}
} break;
case NOTIFICATION_READY: {
+
dirty_caches = true;
if (master != NodePath()) {
_update_sources();
}
} break;
case NOTIFICATION_INTERNAL_PROCESS: {
+
if (animation_process_mode == ANIMATION_PROCESS_PHYSICS)
break;
@@ -1715,6 +1720,11 @@ Error AnimationTreePlayer::node_rename(const StringName &p_node, const StringNam
return OK;
}
+String AnimationTreePlayer::get_configuration_warning() const {
+
+ return TTR("This node has been deprecated. Use AnimationTree instead.");
+}
+
void AnimationTreePlayer::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_node", "type", "id"), &AnimationTreePlayer::add_node);
diff --git a/scene/animation/animation_tree_player.h b/scene/animation/animation_tree_player.h
index d2d7b1c9ec..4e4c876e87 100644
--- a/scene/animation/animation_tree_player.h
+++ b/scene/animation/animation_tree_player.h
@@ -343,6 +343,8 @@ public:
int node_get_input_count(const StringName &p_node) const;
StringName node_get_input_source(const StringName &p_node, int p_input) const;
+ String get_configuration_warning() const;
+
/* ANIMATION NODE */
void animation_node_set_animation(const StringName &p_node, const Ref<Animation> &p_animation);
Ref<Animation> animation_node_get_animation(const StringName &p_node) const;
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index 1ac19774f7..dc85c8e641 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -595,6 +595,16 @@ void ButtonGroup::get_buttons(List<BaseButton *> *r_buttons) {
}
}
+Array ButtonGroup::_get_buttons() {
+
+ Array btns;
+ for (Set<BaseButton *>::Element *E = buttons.front(); E; E = E->next()) {
+ btns.push_back(E->get());
+ }
+
+ return btns;
+}
+
BaseButton *ButtonGroup::get_pressed_button() {
for (Set<BaseButton *>::Element *E = buttons.front(); E; E = E->next()) {
@@ -608,6 +618,7 @@ BaseButton *ButtonGroup::get_pressed_button() {
void ButtonGroup::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_pressed_button"), &ButtonGroup::get_pressed_button);
+ ClassDB::bind_method(D_METHOD("get_buttons"), &ButtonGroup::_get_buttons);
}
ButtonGroup::ButtonGroup() {
diff --git a/scene/gui/base_button.h b/scene/gui/base_button.h
index a131e719ad..272c07f68a 100644
--- a/scene/gui/base_button.h
+++ b/scene/gui/base_button.h
@@ -143,6 +143,7 @@ protected:
public:
BaseButton *get_pressed_button();
void get_buttons(List<BaseButton *> *r_buttons);
+ Array _get_buttons();
ButtonGroup();
};
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index c5d3def4c1..523e07087b 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -204,22 +204,9 @@ void ColorPicker::_update_presets() {
preset->draw_texture_rect(get_icon("preset_bg", "ColorPicker"), Rect2(Point2(), preset_size), true);
-#ifdef TOOLS_ENABLED
- if (Engine::get_singleton()->is_editor_hint()) {
- PoolColorArray arr_to_save = PoolColorArray();
-
- for (int i = 0; i < presets.size(); i++) {
- preset->draw_rect(Rect2(Point2(size.width * i, 0), size), presets[i]);
- arr_to_save.insert(i, presets[i]);
- }
-
- EditorSettings::get_singleton()->set_project_metadata("color_picker", "presets", arr_to_save);
- }
-#else
for (int i = 0; i < presets.size(); i++) {
preset->draw_rect(Rect2(Point2(size.width * i, 0), size), presets[i]);
}
-#endif
}
void ColorPicker::_text_type_toggled() {
@@ -251,6 +238,38 @@ void ColorPicker::add_preset(const Color &p_color) {
preset->update();
if (presets.size() == 10)
bt_add_preset->hide();
+
+#ifdef TOOLS_ENABLED
+ if (Engine::get_singleton()->is_editor_hint()) {
+ PoolColorArray arr_to_save = get_presets();
+ EditorSettings::get_singleton()->set_project_metadata("color_picker", "presets", arr_to_save);
+ }
+#endif
+}
+
+void ColorPicker::erase_preset(const Color &p_color) {
+
+ if (presets.find(p_color)) {
+ presets.erase(presets.find(p_color));
+ preset->update();
+
+#ifdef TOOLS_ENABLED
+ if (Engine::get_singleton()->is_editor_hint()) {
+ PoolColorArray arr_to_save = get_presets();
+ EditorSettings::get_singleton()->set_project_metadata("color_picker", "presets", arr_to_save);
+ }
+#endif
+ }
+}
+
+PoolColorArray ColorPicker::get_presets() const {
+
+ PoolColorArray arr;
+ arr.resize(presets.size());
+ for (int i = 0; i < presets.size(); i++) {
+ arr.set(i, presets[i]);
+ }
+ return arr;
}
void ColorPicker::set_raw_mode(bool p_enabled) {
@@ -444,14 +463,15 @@ void ColorPicker::_preset_input(const Ref<InputEvent> &p_event) {
if (bev->is_pressed() && bev->get_button_index() == BUTTON_LEFT) {
int index = bev->get_position().x / (preset->get_size().x / presets.size());
set_pick_color(presets[index]);
+ _update_color();
+ emit_signal("color_changed", color);
} else if (bev->is_pressed() && bev->get_button_index() == BUTTON_RIGHT) {
int index = bev->get_position().x / (preset->get_size().x / presets.size());
- presets.erase(presets[index]);
- preset->update();
+ Color clicked_preset = presets[index];
+ erase_preset(clicked_preset);
+ emit_signal("preset_removed", clicked_preset);
bt_add_preset->show();
}
- _update_color();
- emit_signal("color_changed", color);
}
Ref<InputEventMouseMotion> mev = p_event;
@@ -501,6 +521,7 @@ void ColorPicker::_screen_input(const Ref<InputEvent> &p_event) {
void ColorPicker::_add_preset_pressed() {
add_preset(color);
+ emit_signal("preset_added", color);
}
void ColorPicker::_screen_pick_pressed() {
@@ -553,6 +574,8 @@ void ColorPicker::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_edit_alpha", "show"), &ColorPicker::set_edit_alpha);
ClassDB::bind_method(D_METHOD("is_editing_alpha"), &ColorPicker::is_editing_alpha);
ClassDB::bind_method(D_METHOD("add_preset", "color"), &ColorPicker::add_preset);
+ ClassDB::bind_method(D_METHOD("erase_preset", "color"), &ColorPicker::erase_preset);
+ ClassDB::bind_method(D_METHOD("get_presets"), &ColorPicker::get_presets);
ClassDB::bind_method(D_METHOD("_value_changed"), &ColorPicker::_value_changed);
ClassDB::bind_method(D_METHOD("_html_entered"), &ColorPicker::_html_entered);
ClassDB::bind_method(D_METHOD("_text_type_toggled"), &ColorPicker::_text_type_toggled);
@@ -575,6 +598,8 @@ void ColorPicker::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "deferred_mode"), "set_deferred_mode", "is_deferred_mode");
ADD_SIGNAL(MethodInfo("color_changed", PropertyInfo(Variant::COLOR, "color")));
+ ADD_SIGNAL(MethodInfo("preset_added", PropertyInfo(Variant::COLOR, "color")));
+ ADD_SIGNAL(MethodInfo("preset_removed", PropertyInfo(Variant::COLOR, "color")));
}
ColorPicker::ColorPicker() :
diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h
index 0166da7118..e32c830434 100644
--- a/scene/gui/color_picker.h
+++ b/scene/gui/color_picker.h
@@ -105,6 +105,9 @@ public:
Color get_pick_color() const;
void add_preset(const Color &p_color);
+ void erase_preset(const Color &p_color);
+ PoolColorArray get_presets() const;
+
void set_raw_mode(bool p_enabled);
bool is_raw_mode() const;
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 79e1d35b94..a580d89439 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -451,6 +451,11 @@ void Control::_update_canvas_item_transform() {
Transform2D xform = _get_internal_transform();
xform[2] += get_position();
+ // We use a little workaround to avoid flickering when moving the pivot with _edit_set_pivot()
+ if (is_inside_tree() && Math::abs(Math::sin(data.rotation * 4.0f)) < 0.00001f && get_viewport()->is_snap_controls_to_pixels_enabled()) {
+ xform[2] = xform[2].round();
+ }
+
VisualServer::get_singleton()->canvas_item_set_transform(get_canvas_item(), xform);
}
@@ -1336,11 +1341,6 @@ void Control::_size_changed() {
new_size_cache.height = minimum_size.height;
}
- // We use a little workaround to avoid flickering when moving the pivot with _edit_set_pivot()
- if (is_inside_tree() && Math::abs(Math::sin(data.rotation * 4.0f)) < 0.00001f && get_viewport()->is_snap_controls_to_pixels_enabled()) {
- new_size_cache = new_size_cache.round();
- new_pos_cache = new_pos_cache.round();
- }
bool pos_changed = new_pos_cache != data.pos_cache;
bool size_changed = new_size_cache != data.size_cache;
@@ -1740,10 +1740,10 @@ Rect2 Control::_compute_child_rect(const float p_anchors[4], const float p_margi
void Control::_compute_margins(Rect2 p_rect, const float p_anchors[4], float (&r_margins)[4]) {
Size2 parent_rect_size = get_parent_anchorable_rect().size;
- r_margins[0] = Math::floor(p_rect.position.x - (p_anchors[0] * parent_rect_size.x));
- r_margins[1] = Math::floor(p_rect.position.y - (p_anchors[1] * parent_rect_size.y));
- r_margins[2] = Math::floor(p_rect.position.x + p_rect.size.x - (p_anchors[2] * parent_rect_size.x));
- r_margins[3] = Math::floor(p_rect.position.y + p_rect.size.y - (p_anchors[3] * parent_rect_size.y));
+ r_margins[0] = p_rect.position.x - (p_anchors[0] * parent_rect_size.x);
+ r_margins[1] = p_rect.position.y - (p_anchors[1] * parent_rect_size.y);
+ r_margins[2] = p_rect.position.x + p_rect.size.x - (p_anchors[2] * parent_rect_size.x);
+ r_margins[3] = p_rect.position.y + p_rect.size.y - (p_anchors[3] * parent_rect_size.y);
}
void Control::set_position(const Size2 &p_point) {
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index 1e9f4df4a3..a869f7cfcd 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "file_dialog.h"
+
#include "core/os/keyboard.h"
#include "core/print_string.h"
#include "scene/gui/label.h"
@@ -596,7 +597,7 @@ void FileDialog::set_current_file(const String &p_file) {
int lp = p_file.find_last(".");
if (lp != -1) {
file->select(0, lp);
- if (file->is_inside_tree())
+ if (file->is_inside_tree() && !get_tree()->is_node_being_edited(file))
file->grab_focus();
}
}
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index b3bebc88ec..eee3213fe7 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -1339,21 +1339,25 @@ GraphEdit::GraphEdit() {
zoom_minus = memnew(ToolButton);
zoom_hb->add_child(zoom_minus);
+ zoom_minus->set_tooltip(RTR("Zoom Out"));
zoom_minus->connect("pressed", this, "_zoom_minus");
zoom_minus->set_focus_mode(FOCUS_NONE);
zoom_reset = memnew(ToolButton);
zoom_hb->add_child(zoom_reset);
+ zoom_reset->set_tooltip(RTR("Zoom Reset"));
zoom_reset->connect("pressed", this, "_zoom_reset");
zoom_reset->set_focus_mode(FOCUS_NONE);
zoom_plus = memnew(ToolButton);
zoom_hb->add_child(zoom_plus);
+ zoom_plus->set_tooltip(RTR("Zoom In"));
zoom_plus->connect("pressed", this, "_zoom_plus");
zoom_plus->set_focus_mode(FOCUS_NONE);
snap_button = memnew(ToolButton);
snap_button->set_toggle_mode(true);
+ snap_button->set_tooltip(RTR("Enable snap and show grid."));
snap_button->connect("pressed", this, "_snap_toggled");
snap_button->set_pressed(true);
snap_button->set_focus_mode(FOCUS_NONE);
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 299c304c5f..42d7f1b080 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -831,7 +831,6 @@ void LineEdit::_notification(int p_what) {
OS::get_singleton()->set_ime_active(true);
OS::get_singleton()->set_ime_position(get_global_position() + Point2(using_placeholder ? 0 : x_ofs, y_ofs + caret_height));
- OS::get_singleton()->set_ime_intermediate_text_callback(_ime_text_callback, this);
}
} break;
case NOTIFICATION_FOCUS_ENTER: {
@@ -843,7 +842,6 @@ void LineEdit::_notification(int p_what) {
OS::get_singleton()->set_ime_active(true);
Point2 cursor_pos = Point2(get_cursor_position(), 1) * get_minimum_size().height;
OS::get_singleton()->set_ime_position(get_global_position() + cursor_pos);
- OS::get_singleton()->set_ime_intermediate_text_callback(_ime_text_callback, this);
if (OS::get_singleton()->has_virtual_keyboard())
OS::get_singleton()->show_virtual_keyboard(text, get_global_rect());
@@ -852,7 +850,6 @@ void LineEdit::_notification(int p_what) {
case NOTIFICATION_FOCUS_EXIT: {
OS::get_singleton()->set_ime_position(Point2());
- OS::get_singleton()->set_ime_intermediate_text_callback(NULL, NULL);
OS::get_singleton()->set_ime_active(false);
ime_text = "";
ime_selection = Point2();
@@ -861,6 +858,12 @@ void LineEdit::_notification(int p_what) {
OS::get_singleton()->hide_virtual_keyboard();
} break;
+ case MainLoop::NOTIFICATION_OS_IME_UPDATE: {
+
+ ime_text = OS::get_singleton()->get_ime_text();
+ ime_selection = OS::get_singleton()->get_ime_selection();
+ update();
+ } break;
}
}
@@ -1461,13 +1464,6 @@ void LineEdit::set_right_icon(const Ref<Texture> &p_icon) {
update();
}
-void LineEdit::_ime_text_callback(void *p_self, String p_text, Point2 p_selection) {
- LineEdit *self = (LineEdit *)p_self;
- self->ime_text = p_text;
- self->ime_selection = p_selection;
- self->update();
-}
-
void LineEdit::_text_changed() {
if (expand_to_text_length)
diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h
index 5294d99da0..ddcdeda8c0 100644
--- a/scene/gui/line_edit.h
+++ b/scene/gui/line_edit.h
@@ -122,7 +122,6 @@ private:
Timer *caret_blink_timer;
- static void _ime_text_callback(void *p_self, String p_text, Point2 p_selection);
void _text_changed();
void _emit_text_change();
bool expand_to_text_length;
diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp
index 95ec618c3b..b4cb297900 100644
--- a/scene/gui/menu_button.cpp
+++ b/scene/gui/menu_button.cpp
@@ -71,13 +71,24 @@ PopupMenu *MenuButton::get_popup() const {
return popup;
}
+void MenuButton::_set_items(const Array &p_items) {
+
+ popup->set("items", p_items);
+}
+
Array MenuButton::_get_items() const {
return popup->get("items");
}
-void MenuButton::_set_items(const Array &p_items) {
- popup->set("items", p_items);
+void MenuButton::set_switch_on_hover(bool p_enabled) {
+
+ switch_on_hover = p_enabled;
+}
+
+bool MenuButton::is_switch_on_hover() {
+
+ return switch_on_hover;
}
void MenuButton::_bind_methods() {
@@ -86,9 +97,12 @@ void MenuButton::_bind_methods() {
ClassDB::bind_method(D_METHOD("_unhandled_key_input"), &MenuButton::_unhandled_key_input);
ClassDB::bind_method(D_METHOD("_set_items"), &MenuButton::_set_items);
ClassDB::bind_method(D_METHOD("_get_items"), &MenuButton::_get_items);
+ ClassDB::bind_method(D_METHOD("set_switch_on_hover", "enable"), &MenuButton::set_switch_on_hover);
+ ClassDB::bind_method(D_METHOD("is_switch_on_hover"), &MenuButton::is_switch_on_hover);
ClassDB::bind_method(D_METHOD("set_disable_shortcuts", "disabled"), &MenuButton::set_disable_shortcuts);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "items", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_items", "_get_items");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "switch_on_hover"), "set_switch_on_hover", "is_switch_on_hover");
ADD_SIGNAL(MethodInfo("about_to_show"));
}
@@ -100,6 +114,7 @@ void MenuButton::set_disable_shortcuts(bool p_disabled) {
MenuButton::MenuButton() {
+ switch_on_hover = false;
set_flat(true);
set_disable_shortcuts(false);
set_enabled_focus_mode(FOCUS_NONE);
diff --git a/scene/gui/menu_button.h b/scene/gui/menu_button.h
index 0636accfee..abc49f4988 100644
--- a/scene/gui/menu_button.h
+++ b/scene/gui/menu_button.h
@@ -41,6 +41,7 @@ class MenuButton : public Button {
GDCLASS(MenuButton, Button);
bool clicked;
+ bool switch_on_hover;
bool disable_shortcuts;
PopupMenu *popup;
@@ -57,6 +58,8 @@ public:
virtual void pressed();
PopupMenu *get_popup() const;
+ void set_switch_on_hover(bool p_enabled);
+ bool is_switch_on_hover();
void set_disable_shortcuts(bool p_disabled);
MenuButton();
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 17de346f51..db890bf1c8 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -765,20 +765,19 @@ void RichTextLabel::_update_scroll() {
if (exceeds) {
scroll_visible = true;
- main->first_invalid_line = 0;
scroll_w = vscroll->get_combined_minimum_size().width;
vscroll->show();
vscroll->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, -scroll_w);
- _validate_line_caches(main);
-
} else {
-
scroll_visible = false;
- vscroll->hide();
scroll_w = 0;
- _validate_line_caches(main);
+ vscroll->hide();
}
+
+ main->first_invalid_line = 0; //invalidate ALL
+ _validate_line_caches(main);
}
+ scroll_updated = true;
}
void RichTextLabel::_notification(int p_what) {
@@ -931,6 +930,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
if (true) {
if (b->is_pressed() && !b->is_doubleclick()) {
+ scroll_updated = false;
int line = 0;
Item *item = NULL;
@@ -939,12 +939,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
if (item) {
- Variant meta;
- if (!outside && _find_meta(item, &meta)) {
- //meta clicked
-
- emit_signal("meta_clicked", meta);
- } else if (selection.enabled) {
+ if (selection.enabled) {
selection.click = item;
selection.click_char = line;
@@ -993,6 +988,24 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
} else if (!b->is_pressed()) {
selection.click = NULL;
+
+ if (!b->is_doubleclick() && !scroll_updated) {
+ int line = 0;
+ Item *item = NULL;
+
+ bool outside;
+ _find_click(main, b->get_position(), &item, &line, &outside);
+
+ if (item) {
+
+ Variant meta;
+ if (!outside && _find_meta(item, &meta)) {
+ //meta clicked
+
+ emit_signal("meta_clicked", meta);
+ }
+ }
+ }
}
}
}
@@ -1616,7 +1629,6 @@ void RichTextLabel::clear() {
main->lines.clear();
main->lines.resize(1);
main->first_invalid_line = 0;
- scroll_w = 0;
update();
selection.click = NULL;
selection.active = false;
@@ -2327,6 +2339,7 @@ RichTextLabel::RichTextLabel() {
updating_scroll = false;
scroll_active = true;
scroll_w = 0;
+ scroll_updated = false;
vscroll = memnew(VScrollBar);
add_child(vscroll);
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index c2e5712b9d..7c30738e2d 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -225,6 +225,7 @@ private:
bool scroll_following;
bool scroll_active;
int scroll_w;
+ bool scroll_updated;
bool updating_scroll;
int current_idx;
int visible_line_count;
diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp
index ace22dddff..4f43bb0581 100644
--- a/scene/gui/spin_box.cpp
+++ b/scene/gui/spin_box.cpp
@@ -110,6 +110,9 @@ void SpinBox::_gui_input(const Ref<InputEvent> &p_event) {
range_click_timer->start();
line_edit->grab_focus();
+
+ drag.allowed = true;
+ drag.capture_pos = mb->get_position();
} break;
case BUTTON_RIGHT: {
@@ -133,14 +136,7 @@ void SpinBox::_gui_input(const Ref<InputEvent> &p_event) {
}
}
- if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == 1) {
-
- //set_default_cursor_shape(CURSOR_VSIZE);
- Vector2 cpos = Vector2(mb->get_position().x, mb->get_position().y);
- drag.mouse_pos = cpos;
- }
-
- if (mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == 1) {
+ if (mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
//set_default_cursor_shape(CURSOR_ARROW);
range_click_timer->stop();
@@ -150,32 +146,24 @@ void SpinBox::_gui_input(const Ref<InputEvent> &p_event) {
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
warp_mouse(drag.capture_pos);
}
+ drag.allowed = false;
}
Ref<InputEventMouseMotion> mm = p_event;
- if (mm.is_valid() && mm->get_button_mask() & 1) {
-
- Vector2 cpos = mm->get_position();
+ if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_LEFT) {
if (drag.enabled) {
- float diff_y = drag.mouse_pos.y - cpos.y;
- diff_y = Math::pow(ABS(diff_y), 1.8f) * SGN(diff_y);
- diff_y *= 0.1;
-
- drag.mouse_pos = cpos;
- drag.base_val = CLAMP(drag.base_val + get_step() * diff_y, get_min(), get_max());
-
- set_value(drag.base_val);
-
- } else if (drag.mouse_pos.distance_to(cpos) > 2) {
+ drag.diff_y += mm->get_relative().y;
+ float diff_y = -0.01 * Math::pow(ABS(drag.diff_y), 1.8f) * SGN(drag.diff_y);
+ set_value(CLAMP(drag.base_val + get_step() * diff_y, get_min(), get_max()));
+ } else if (drag.allowed && drag.capture_pos.distance_to(mm->get_position()) > 2) {
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_CAPTURED);
drag.enabled = true;
drag.base_val = get_value();
- drag.mouse_pos = cpos;
- drag.capture_pos = cpos;
+ drag.diff_y = 0;
}
}
}
diff --git a/scene/gui/spin_box.h b/scene/gui/spin_box.h
index f1ee26d9f3..6425af7158 100644
--- a/scene/gui/spin_box.h
+++ b/scene/gui/spin_box.h
@@ -54,10 +54,10 @@ class SpinBox : public Range {
struct Drag {
float base_val;
+ bool allowed;
bool enabled;
- Vector2 from;
- Vector2 mouse_pos;
Vector2 capture_pos;
+ float diff_y;
} drag;
void _line_edit_focus_exit();
diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp
index 3554f04cc0..c3265d3ed5 100644
--- a/scene/gui/split_container.cpp
+++ b/scene/gui/split_container.cpp
@@ -94,12 +94,15 @@ void SplitContainer::_resort() {
}
// Compute the final middle separation
- int clamped_split_offset = CLAMP(split_offset, ms_first[axis] - no_offset_middle_sep, (get_size()[axis] - ms_second[axis] - sep) - no_offset_middle_sep);
- middle_sep = no_offset_middle_sep + clamped_split_offset;
- if (!collapsed && should_clamp_split_offset) {
- split_offset = clamped_split_offset;
- _change_notify("split_offset");
- should_clamp_split_offset = false;
+ middle_sep = no_offset_middle_sep;
+ if (!collapsed) {
+ int clamped_split_offset = CLAMP(split_offset, ms_first[axis] - no_offset_middle_sep, (get_size()[axis] - ms_second[axis] - sep) - no_offset_middle_sep);
+ middle_sep += clamped_split_offset;
+ if (should_clamp_split_offset) {
+ split_offset = clamped_split_offset;
+ _change_notify("split_offset");
+ should_clamp_split_offset = false;
+ }
}
if (vertical) {
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 51d707c28f..fef29b7e6c 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1412,7 +1412,6 @@ void TextEdit::_notification(int p_what) {
if (has_focus()) {
OS::get_singleton()->set_ime_active(true);
OS::get_singleton()->set_ime_position(get_global_position() + cursor_pos + Point2(0, get_row_height()));
- OS::get_singleton()->set_ime_intermediate_text_callback(_ime_text_callback, this);
}
} break;
@@ -1425,7 +1424,6 @@ void TextEdit::_notification(int p_what) {
OS::get_singleton()->set_ime_active(true);
Point2 cursor_pos = Point2(cursor_get_column(), cursor_get_line()) * get_row_height();
OS::get_singleton()->set_ime_position(get_global_position() + cursor_pos);
- OS::get_singleton()->set_ime_intermediate_text_callback(_ime_text_callback, this);
if (OS::get_singleton()->has_virtual_keyboard())
OS::get_singleton()->show_virtual_keyboard(get_text(), get_global_rect());
@@ -1433,7 +1431,6 @@ void TextEdit::_notification(int p_what) {
case NOTIFICATION_FOCUS_EXIT: {
OS::get_singleton()->set_ime_position(Point2());
- OS::get_singleton()->set_ime_intermediate_text_callback(NULL, NULL);
OS::get_singleton()->set_ime_active(false);
ime_text = "";
ime_selection = Point2();
@@ -1441,14 +1438,13 @@ void TextEdit::_notification(int p_what) {
if (OS::get_singleton()->has_virtual_keyboard())
OS::get_singleton()->hide_virtual_keyboard();
} break;
- }
-}
+ case MainLoop::NOTIFICATION_OS_IME_UPDATE: {
-void TextEdit::_ime_text_callback(void *p_self, String p_text, Point2 p_selection) {
- TextEdit *self = (TextEdit *)p_self;
- self->ime_text = p_text;
- self->ime_selection = p_selection;
- self->update();
+ ime_text = OS::get_singleton()->get_ime_text();
+ ime_selection = OS::get_singleton()->get_ime_selection();
+ update();
+ } break;
+ }
}
void TextEdit::_consume_pair_symbol(CharType ch) {
@@ -6045,7 +6041,10 @@ void TextEdit::menu_option(int p_option) {
case MENU_UNDO: {
undo();
} break;
- };
+ case MENU_REDO: {
+ redo();
+ }
+ }
}
void TextEdit::set_select_identifiers_on_hover(bool p_enable) {
@@ -6221,6 +6220,7 @@ void TextEdit::_bind_methods() {
BIND_ENUM_CONSTANT(MENU_CLEAR);
BIND_ENUM_CONSTANT(MENU_SELECT_ALL);
BIND_ENUM_CONSTANT(MENU_UNDO);
+ BIND_ENUM_CONSTANT(MENU_REDO);
BIND_ENUM_CONSTANT(MENU_MAX);
GLOBAL_DEF("gui/timers/text_edit_idle_detect_sec", 3);
@@ -6349,6 +6349,7 @@ TextEdit::TextEdit() {
menu->add_item(RTR("Clear"), MENU_CLEAR);
menu->add_separator();
menu->add_item(RTR("Undo"), MENU_UNDO, KEY_MASK_CMD | KEY_Z);
+ menu->add_item(RTR("Redo"), MENU_REDO, KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_Z);
menu->connect("id_pressed", this, "menu_option");
}
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 8a508a8738..f069ffc167 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -380,8 +380,6 @@ private:
void _scroll_lines_up();
void _scroll_lines_down();
- static void _ime_text_callback(void *p_self, String p_text, Point2 p_selection);
-
//void mouse_motion(const Point& p_pos, const Point& p_rel, int p_button_mask);
Size2 get_minimum_size() const;
@@ -444,6 +442,7 @@ public:
MENU_CLEAR,
MENU_SELECT_ALL,
MENU_UNDO,
+ MENU_REDO,
MENU_MAX
};
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index f441364c44..479b035f86 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -2701,6 +2701,7 @@ bool Tree::edit_selected() {
Vector2 ofs(0, (text_editor->get_size().height - rect.size.height) / 2);
Point2i textedpos = get_global_position() + rect.position - ofs;
+ cache.text_editor_position = textedpos;
text_editor->set_position(textedpos);
text_editor->set_size(rect.size);
text_editor->clear();
@@ -2956,6 +2957,21 @@ void Tree::_notification(int p_what) {
if (p_what == NOTIFICATION_THEME_CHANGED) {
update_cache();
}
+
+ if (p_what == NOTIFICATION_RESIZED || p_what == NOTIFICATION_TRANSFORM_CHANGED) {
+
+ if (popup_edited_item != NULL) {
+ Rect2 rect = popup_edited_item->get_meta("__focus_rect");
+ Vector2 ofs(0, (text_editor->get_size().height - rect.size.height) / 2);
+ Point2i textedpos = get_global_position() + rect.position - ofs;
+
+ if (cache.text_editor_position != textedpos) {
+ cache.text_editor_position = textedpos;
+ text_editor->set_position(textedpos);
+ value_editor->set_position(textedpos + Point2i(0, text_editor->get_size().height));
+ }
+ }
+ }
}
Size2 Tree::get_minimum_size() const {
@@ -3884,6 +3900,7 @@ Tree::Tree() {
value_editor->set_as_toplevel(true);
text_editor->set_as_toplevel(true);
+ set_notify_transform(true);
updating_value_editor = false;
pressed_button = -1;
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 886ce66e2c..8622184bf8 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -457,6 +457,8 @@ private:
TreeItem *hover_item;
int hover_cell;
+ Point2i text_editor_position;
+
} cache;
int _get_title_button_height() const;
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index 3f664bab10..be4878588e 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -639,6 +639,7 @@ void SceneTree::_notification(int p_notification) {
}
} break;
case NOTIFICATION_OS_MEMORY_WARNING:
+ case NOTIFICATION_OS_IME_UPDATE:
case NOTIFICATION_WM_MOUSE_ENTER:
case NOTIFICATION_WM_MOUSE_EXIT:
case NOTIFICATION_WM_FOCUS_IN:
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 9ceac0d7b0..b220df6ce1 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -1727,6 +1727,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
gui.mouse_focus = _gui_find_control(pos);
gui.mouse_focus_mask = 1 << (mb->get_button_index() - 1);
+ gui.last_mouse_focus = gui.mouse_focus;
if (!gui.mouse_focus) {
return;
@@ -1747,7 +1748,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
mb->set_position(pos);
#ifdef DEBUG_ENABLED
- if (ScriptDebugger::get_singleton()) {
+ if (ScriptDebugger::get_singleton() && gui.mouse_focus) {
Array arr;
arr.push_back(gui.mouse_focus->get_path());
@@ -1780,7 +1781,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
}
}
- if (gui.mouse_focus->can_process()) {
+ if (gui.mouse_focus && gui.mouse_focus->can_process()) {
_gui_call_input(gui.mouse_focus, mb);
}
@@ -1850,7 +1851,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
gui.mouse_focus = NULL;
}
- if (mouse_focus->can_process()) {
+ if (mouse_focus && mouse_focus->can_process()) {
_gui_call_input(mouse_focus, mb);
}
@@ -1955,10 +1956,9 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
// If the mouse is over a menu button, this menu will open automatically
// if there is already a pop-up menu open at the same hierarchical level.
- if (popup_menu_parent && menu_button &&
- popup_menu_parent->get_icon().is_null() &&
- menu_button->get_icon().is_null() &&
- (popup_menu->get_parent()->get_parent()->is_a_parent_of(menu_button) ||
+ if (popup_menu_parent && menu_button && popup_menu_parent->is_switch_on_hover() &&
+ !menu_button->is_disabled() && menu_button->is_switch_on_hover() &&
+ (popup_menu_parent->get_parent()->is_a_parent_of(menu_button) ||
menu_button->get_parent()->is_a_parent_of(popup_menu))) {
popup_menu->notification(Control::NOTIFICATION_MODAL_CLOSE);
@@ -2065,7 +2065,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
OS::get_singleton()->set_cursor_shape((OS::CursorShape)cursor_shape);
- if (over->can_process()) {
+ if (over && over->can_process()) {
_gui_call_input(over, mm);
}
@@ -2115,14 +2115,14 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
set_input_as_handled();
return;
}
- } else if (gui.mouse_focus) {
+ } else if (touch_event->get_index() == 0 && gui.last_mouse_focus) {
- if (gui.mouse_focus->can_process()) {
+ if (gui.last_mouse_focus->can_process()) {
touch_event = touch_event->xformed_by(Transform2D()); //make a copy
touch_event->set_position(gui.focus_inv_xform.xform(pos));
- _gui_call_input(gui.mouse_focus, touch_event);
+ _gui_call_input(gui.last_mouse_focus, touch_event);
}
set_input_as_handled();
return;
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index 278350b1c9..6b6ca3b7db 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -271,6 +271,7 @@ private:
bool key_event_accepted;
Control *mouse_focus;
+ Control *last_mouse_focus;
Control *mouse_click_grabber;
int mouse_focus_mask;
Control *key_focus;
diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp
index 9ee85b64b6..35132c1195 100644
--- a/scene/resources/audio_stream_sample.cpp
+++ b/scene/resources/audio_stream_sample.cpp
@@ -249,6 +249,10 @@ void AudioStreamPlaybackSample::mix(AudioFrame *p_buffer, float p_rate_scale, in
int32_t todo = p_frames;
+ if (base->loop_mode == AudioStreamSample::LOOP_BACKWARD) {
+ sign = -1;
+ }
+
float base_rate = AudioServer::get_singleton()->get_mix_rate();
float srate = base->mix_rate;
srate *= p_rate_scale;
@@ -621,7 +625,7 @@ void AudioStreamSample::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::POOL_BYTE_ARRAY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_data", "get_data");
ADD_PROPERTY(PropertyInfo(Variant::INT, "format", PROPERTY_HINT_ENUM, "8-Bit,16-Bit,IMA-ADPCM"), "set_format", "get_format");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "loop_mode", PROPERTY_HINT_ENUM, "Disabled,Forward,Ping-Pong"), "set_loop_mode", "get_loop_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "loop_mode", PROPERTY_HINT_ENUM, "Disabled,Forward,Ping-Pong,Backward"), "set_loop_mode", "get_loop_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "loop_begin"), "set_loop_begin", "get_loop_begin");
ADD_PROPERTY(PropertyInfo(Variant::INT, "loop_end"), "set_loop_end", "get_loop_end");
ADD_PROPERTY(PropertyInfo(Variant::INT, "mix_rate"), "set_mix_rate", "get_mix_rate");
@@ -634,6 +638,7 @@ void AudioStreamSample::_bind_methods() {
BIND_ENUM_CONSTANT(LOOP_DISABLED);
BIND_ENUM_CONSTANT(LOOP_FORWARD);
BIND_ENUM_CONSTANT(LOOP_PING_PONG);
+ BIND_ENUM_CONSTANT(LOOP_BACKWARD);
}
AudioStreamSample::AudioStreamSample() {
diff --git a/scene/resources/audio_stream_sample.h b/scene/resources/audio_stream_sample.h
index a27acc92b7..2c39e0a11e 100644
--- a/scene/resources/audio_stream_sample.h
+++ b/scene/resources/audio_stream_sample.h
@@ -94,7 +94,8 @@ public:
enum LoopMode {
LOOP_DISABLED,
LOOP_FORWARD,
- LOOP_PING_PONG
+ LOOP_PING_PONG,
+ LOOP_BACKWARD
};
private:
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index fff136cdc3..b0c1dcde9a 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -307,10 +307,6 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_constant("hseparation", "MenuButton", 3 * scale);
- // ButtonGroup
-
- theme->set_stylebox("panel", "ButtonGroup", memnew(StyleBoxEmpty));
-
// CheckBox
Ref<StyleBox> cbx_empty = memnew(StyleBoxEmpty);
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 5327ed318f..f6dc60900f 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -258,7 +258,7 @@ ShaderMaterial::~ShaderMaterial() {
/////////////////////////////////
Mutex *SpatialMaterial::material_mutex = NULL;
-SelfList<SpatialMaterial>::List SpatialMaterial::dirty_materials;
+SelfList<SpatialMaterial>::List *SpatialMaterial::dirty_materials = NULL;
Map<SpatialMaterial::MaterialKey, SpatialMaterial::ShaderData> SpatialMaterial::shader_map;
SpatialMaterial::ShaderNames *SpatialMaterial::shader_names = NULL;
@@ -268,6 +268,8 @@ void SpatialMaterial::init_shaders() {
material_mutex = Mutex::create();
#endif
+ dirty_materials = memnew(SelfList<SpatialMaterial>::List);
+
shader_names = memnew(ShaderNames);
shader_names->albedo = "albedo";
@@ -348,12 +350,15 @@ void SpatialMaterial::finish_shaders() {
memdelete(material_mutex);
#endif
+ memdelete(dirty_materials);
+ dirty_materials = NULL;
+
memdelete(shader_names);
}
void SpatialMaterial::_update_shader() {
- dirty_materials.remove(&element);
+ dirty_materials->remove(&element);
MaterialKey mk = _compute_key();
if (mk.key == current_key.key)
@@ -699,7 +704,7 @@ void SpatialMaterial::_update_shader() {
if (features[FEATURE_DEPTH_MAPPING] && !flags[FLAG_UV1_USE_TRIPLANAR]) { //depthmap not supported with triplanar
code += "\t{\n";
- code += "\t\tvec3 view_dir = normalize(normalize(-VERTEX)*mat3(TANGENT*depth_flip.x,BINORMAL*depth_flip.y,NORMAL));\n"; // binormal is negative due to mikktspace
+ code += "\t\tvec3 view_dir = normalize(normalize(-VERTEX)*mat3(TANGENT*depth_flip.x,-BINORMAL*depth_flip.y,NORMAL));\n"; // binormal is negative due to mikktspace, flip 'unflips' it ;-)
if (deep_parallax) {
code += "\t\tfloat num_layers = mix(float(depth_max_layers),float(depth_min_layers), abs(dot(vec3(0.0, 0.0, 1.0), view_dir)));\n";
@@ -1002,9 +1007,9 @@ void SpatialMaterial::flush_changes() {
if (material_mutex)
material_mutex->lock();
- while (dirty_materials.first()) {
+ while (dirty_materials->first()) {
- dirty_materials.first()->self()->_update_shader();
+ dirty_materials->first()->self()->_update_shader();
}
if (material_mutex)
@@ -1017,7 +1022,7 @@ void SpatialMaterial::_queue_shader_change() {
material_mutex->lock();
if (!element.in_list()) {
- dirty_materials.add(&element);
+ dirty_materials->add(&element);
}
if (material_mutex)
@@ -1315,7 +1320,7 @@ void SpatialMaterial::set_flag(Flags p_flag, bool p_enabled) {
return;
flags[p_flag] = p_enabled;
- if (p_flag == FLAG_USE_ALPHA_SCISSOR) {
+ if (p_flag == FLAG_USE_ALPHA_SCISSOR || p_flag == FLAG_UNSHADED) {
_change_notify();
}
_queue_shader_change();
@@ -1421,6 +1426,48 @@ void SpatialMaterial::_validate_property(PropertyInfo &property) const {
if ((property.name == "depth_min_layers" || property.name == "depth_max_layers") && !deep_parallax) {
property.usage = 0;
}
+
+ if (flags[FLAG_UNSHADED]) {
+ if (property.name.begins_with("anisotropy")) {
+ property.usage = 0;
+ }
+
+ if (property.name.begins_with("ao")) {
+ property.usage = 0;
+ }
+
+ if (property.name.begins_with("clearcoat")) {
+ property.usage = 0;
+ }
+
+ if (property.name.begins_with("emission")) {
+ property.usage = 0;
+ }
+
+ if (property.name.begins_with("metallic")) {
+ property.usage = 0;
+ }
+
+ if (property.name.begins_with("normal")) {
+ property.usage = 0;
+ }
+
+ if (property.name.begins_with("rim")) {
+ property.usage = 0;
+ }
+
+ if (property.name.begins_with("roughness")) {
+ property.usage = 0;
+ }
+
+ if (property.name.begins_with("subsurf_scatter")) {
+ property.usage = 0;
+ }
+
+ if (property.name.begins_with("transmission")) {
+ property.usage = 0;
+ }
+ }
}
void SpatialMaterial::set_line_width(float p_line_width) {
diff --git a/scene/resources/material.h b/scene/resources/material.h
index 54fceaddc1..921f3baeaa 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -360,7 +360,7 @@ private:
};
static Mutex *material_mutex;
- static SelfList<SpatialMaterial>::List dirty_materials;
+ static SelfList<SpatialMaterial>::List *dirty_materials;
static ShaderNames *shader_names;
SelfList<SpatialMaterial> element;
diff --git a/scene/resources/particles_material.cpp b/scene/resources/particles_material.cpp
index dae01e8d96..92c185712a 100644
--- a/scene/resources/particles_material.cpp
+++ b/scene/resources/particles_material.cpp
@@ -31,7 +31,7 @@
#include "particles_material.h"
Mutex *ParticlesMaterial::material_mutex = NULL;
-SelfList<ParticlesMaterial>::List ParticlesMaterial::dirty_materials;
+SelfList<ParticlesMaterial>::List *ParticlesMaterial::dirty_materials = NULL;
Map<ParticlesMaterial::MaterialKey, ParticlesMaterial::ShaderData> ParticlesMaterial::shader_map;
ParticlesMaterial::ShaderNames *ParticlesMaterial::shader_names = NULL;
@@ -41,6 +41,8 @@ void ParticlesMaterial::init_shaders() {
material_mutex = Mutex::create();
#endif
+ dirty_materials = memnew(SelfList<ParticlesMaterial>::List);
+
shader_names = memnew(ShaderNames);
shader_names->spread = "spread";
@@ -106,12 +108,15 @@ void ParticlesMaterial::finish_shaders() {
memdelete(material_mutex);
#endif
+ memdelete(dirty_materials);
+ dirty_materials = NULL;
+
memdelete(shader_names);
}
void ParticlesMaterial::_update_shader() {
- dirty_materials.remove(&element);
+ dirty_materials->remove(&element);
MaterialKey mk = _compute_key();
if (mk.key == current_key.key)
@@ -584,9 +589,9 @@ void ParticlesMaterial::flush_changes() {
if (material_mutex)
material_mutex->lock();
- while (dirty_materials.first()) {
+ while (dirty_materials->first()) {
- dirty_materials.first()->self()->_update_shader();
+ dirty_materials->first()->self()->_update_shader();
}
if (material_mutex)
@@ -599,7 +604,7 @@ void ParticlesMaterial::_queue_shader_change() {
material_mutex->lock();
if (!element.in_list()) {
- dirty_materials.add(&element);
+ dirty_materials->add(&element);
}
if (material_mutex)
diff --git a/scene/resources/particles_material.h b/scene/resources/particles_material.h
index 06ebb3c4dc..20b505532e 100644
--- a/scene/resources/particles_material.h
+++ b/scene/resources/particles_material.h
@@ -126,7 +126,7 @@ private:
}
static Mutex *material_mutex;
- static SelfList<ParticlesMaterial>::List dirty_materials;
+ static SelfList<ParticlesMaterial>::List *dirty_materials;
struct ShaderNames {
StringName spread;
diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp
index dafdddd990..6dedb74fad 100644
--- a/scene/resources/primitive_meshes.cpp
+++ b/scene/resources/primitive_meshes.cpp
@@ -306,7 +306,7 @@ void CapsuleMesh::_create_mesh_array(Array &p_arr) const {
Vector3 p = Vector3(x * radius * w, y * radius * w, z);
points.push_back(p + Vector3(0.0, 0.0, 0.5 * mid_height));
normals.push_back(p.normalized());
- ADD_TANGENT(-y, x, 0.0, -1.0)
+ ADD_TANGENT(-y, x, 0.0, 1.0)
uvs.push_back(Vector2(u, v * onethird));
point++;
@@ -345,7 +345,7 @@ void CapsuleMesh::_create_mesh_array(Array &p_arr) const {
Vector3 p = Vector3(x * radius, y * radius, z);
points.push_back(p);
normals.push_back(Vector3(x, y, 0.0));
- ADD_TANGENT(-y, x, 0.0, -1.0)
+ ADD_TANGENT(-y, x, 0.0, 1.0)
uvs.push_back(Vector2(u, onethird + (v * onethird)));
point++;
@@ -385,7 +385,7 @@ void CapsuleMesh::_create_mesh_array(Array &p_arr) const {
Vector3 p = Vector3(x * radius * w, y * radius * w, z);
points.push_back(p + Vector3(0.0, 0.0, -0.5 * mid_height));
normals.push_back(p.normalized());
- ADD_TANGENT(-y, x, 0.0, -1.0)
+ ADD_TANGENT(-y, x, 0.0, 1.0)
uvs.push_back(Vector2(u, twothirds + ((v - 1.0) * onethird)));
point++;
@@ -514,14 +514,14 @@ void CubeMesh::_create_mesh_array(Array &p_arr) const {
// front
points.push_back(Vector3(x, -y, -start_pos.z)); // double negative on the Z!
normals.push_back(Vector3(0.0, 0.0, 1.0));
- ADD_TANGENT(1.0, 0.0, 0.0, -1.0);
+ ADD_TANGENT(1.0, 0.0, 0.0, 1.0);
uvs.push_back(Vector2(u, v));
point++;
// back
points.push_back(Vector3(-x, -y, start_pos.z));
normals.push_back(Vector3(0.0, 0.0, -1.0));
- ADD_TANGENT(-1.0, 0.0, 0.0, -1.0);
+ ADD_TANGENT(-1.0, 0.0, 0.0, 1.0);
uvs.push_back(Vector2(twothirds + u, v));
point++;
@@ -568,14 +568,14 @@ void CubeMesh::_create_mesh_array(Array &p_arr) const {
// right
points.push_back(Vector3(-start_pos.x, -y, -z));
normals.push_back(Vector3(1.0, 0.0, 0.0));
- ADD_TANGENT(0.0, 0.0, -1.0, -1.0);
+ ADD_TANGENT(0.0, 0.0, -1.0, 1.0);
uvs.push_back(Vector2(onethird + u, v));
point++;
// left
points.push_back(Vector3(start_pos.x, -y, z));
normals.push_back(Vector3(-1.0, 0.0, 0.0));
- ADD_TANGENT(0.0, 0.0, 1.0, -1.0);
+ ADD_TANGENT(0.0, 0.0, 1.0, 1.0);
uvs.push_back(Vector2(u, 0.5 + v));
point++;
@@ -622,14 +622,14 @@ void CubeMesh::_create_mesh_array(Array &p_arr) const {
// top
points.push_back(Vector3(-x, -start_pos.y, -z));
normals.push_back(Vector3(0.0, 1.0, 0.0));
- ADD_TANGENT(-1.0, 0.0, 0.0, -1.0);
+ ADD_TANGENT(-1.0, 0.0, 0.0, 1.0);
uvs.push_back(Vector2(onethird + u, 0.5 + v));
point++;
// bottom
points.push_back(Vector3(x, start_pos.y, -z));
normals.push_back(Vector3(0.0, -1.0, 0.0));
- ADD_TANGENT(1.0, 0.0, 0.0, -1.0);
+ ADD_TANGENT(1.0, 0.0, 0.0, 1.0);
uvs.push_back(Vector2(twothirds + u, 0.5 + v));
point++;
@@ -773,7 +773,7 @@ void CylinderMesh::_create_mesh_array(Array &p_arr) const {
Vector3 p = Vector3(x * radius, y, z * radius);
points.push_back(p);
normals.push_back(Vector3(x, 0.0, z));
- ADD_TANGENT(z, 0.0, -x, -1.0)
+ ADD_TANGENT(z, 0.0, -x, 1.0)
uvs.push_back(Vector2(u, v * 0.5));
point++;
@@ -799,7 +799,7 @@ void CylinderMesh::_create_mesh_array(Array &p_arr) const {
thisrow = point;
points.push_back(Vector3(0.0, y, 0.0));
normals.push_back(Vector3(0.0, 1.0, 0.0));
- ADD_TANGENT(1.0, 0.0, 0.0, -1.0)
+ ADD_TANGENT(1.0, 0.0, 0.0, 1.0)
uvs.push_back(Vector2(0.25, 0.75));
point++;
@@ -816,7 +816,7 @@ void CylinderMesh::_create_mesh_array(Array &p_arr) const {
Vector3 p = Vector3(x * top_radius, y, z * top_radius);
points.push_back(p);
normals.push_back(Vector3(0.0, 1.0, 0.0));
- ADD_TANGENT(1.0, 0.0, 0.0, -1.0)
+ ADD_TANGENT(1.0, 0.0, 0.0, 1.0)
uvs.push_back(Vector2(u, v));
point++;
@@ -835,7 +835,7 @@ void CylinderMesh::_create_mesh_array(Array &p_arr) const {
thisrow = point;
points.push_back(Vector3(0.0, y, 0.0));
normals.push_back(Vector3(0.0, -1.0, 0.0));
- ADD_TANGENT(1.0, 0.0, 0.0, -1.0)
+ ADD_TANGENT(1.0, 0.0, 0.0, 1.0)
uvs.push_back(Vector2(0.75, 0.75));
point++;
@@ -852,7 +852,7 @@ void CylinderMesh::_create_mesh_array(Array &p_arr) const {
Vector3 p = Vector3(x * bottom_radius, y, z * bottom_radius);
points.push_back(p);
normals.push_back(Vector3(0.0, -1.0, 0.0));
- ADD_TANGENT(1.0, 0.0, 0.0, -1.0)
+ ADD_TANGENT(1.0, 0.0, 0.0, 1.0)
uvs.push_back(Vector2(u, v));
point++;
@@ -982,7 +982,7 @@ void PlaneMesh::_create_mesh_array(Array &p_arr) const {
points.push_back(Vector3(-x, 0.0, -z));
normals.push_back(Vector3(0.0, 1.0, 0.0));
- ADD_TANGENT(1.0, 0.0, 0.0, -1.0);
+ ADD_TANGENT(1.0, 0.0, 0.0, 1.0);
uvs.push_back(Vector2(1.0 - u, 1.0 - v)); /* 1.0 - uv to match orientation with Quad */
point++;
@@ -1108,14 +1108,14 @@ void PrismMesh::_create_mesh_array(Array &p_arr) const {
/* front */
points.push_back(Vector3(start_x + x, -y, -start_pos.z)); // double negative on the Z!
normals.push_back(Vector3(0.0, 0.0, 1.0));
- ADD_TANGENT(1.0, 0.0, 0.0, -1.0);
+ ADD_TANGENT(1.0, 0.0, 0.0, 1.0);
uvs.push_back(Vector2(offset_front + u, v));
point++;
/* back */
points.push_back(Vector3(start_x + scaled_size_x - x, -y, start_pos.z));
normals.push_back(Vector3(0.0, 0.0, -1.0));
- ADD_TANGENT(-1.0, 0.0, 0.0, -1.0);
+ ADD_TANGENT(-1.0, 0.0, 0.0, 1.0);
uvs.push_back(Vector2(twothirds + offset_back + u, v));
point++;
@@ -1187,14 +1187,14 @@ void PrismMesh::_create_mesh_array(Array &p_arr) const {
/* right */
points.push_back(Vector3(right, -y, -z));
normals.push_back(normal_right);
- ADD_TANGENT(0.0, 0.0, -1.0, -1.0);
+ ADD_TANGENT(0.0, 0.0, -1.0, 1.0);
uvs.push_back(Vector2(onethird + u, v));
point++;
/* left */
points.push_back(Vector3(left, -y, z));
normals.push_back(normal_left);
- ADD_TANGENT(0.0, 0.0, 1.0, -1.0);
+ ADD_TANGENT(0.0, 0.0, 1.0, 1.0);
uvs.push_back(Vector2(u, 0.5 + v));
point++;
@@ -1241,7 +1241,7 @@ void PrismMesh::_create_mesh_array(Array &p_arr) const {
/* bottom */
points.push_back(Vector3(x, start_pos.y, -z));
normals.push_back(Vector3(0.0, -1.0, 0.0));
- ADD_TANGENT(1.0, 0.0, 0.0, -1.0);
+ ADD_TANGENT(1.0, 0.0, 0.0, 1.0);
uvs.push_back(Vector2(twothirds + u, 0.5 + v));
point++;
@@ -1382,7 +1382,7 @@ void QuadMesh::_create_mesh_array(Array &p_arr) const {
tangents.set(i * 4 + 0, 1.0);
tangents.set(i * 4 + 1, 0.0);
tangents.set(i * 4 + 2, 0.0);
- tangents.set(i * 4 + 3, -1.0);
+ tangents.set(i * 4 + 3, 1.0);
static const Vector2 quad_uv[4] = {
Vector2(0, 1),
@@ -1468,7 +1468,7 @@ void SphereMesh::_create_mesh_array(Array &p_arr) const {
points.push_back(p);
normals.push_back(p.normalized());
};
- ADD_TANGENT(z, 0.0, -x, -1.0)
+ ADD_TANGENT(z, 0.0, -x, 1.0)
uvs.push_back(Vector2(u, v));
point++;
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp
index 5d4c7861e3..842252d5d9 100644
--- a/scene/resources/surface_tool.cpp
+++ b/scene/resources/surface_tool.cpp
@@ -764,10 +764,22 @@ void SurfaceTool::append_from(const Ref<Mesh> &p_existing, int p_surface, const
}
//mikktspace callbacks
+namespace {
+struct TangentGenerationContextUserData {
+ Vector<List<SurfaceTool::Vertex>::Element *> vertices;
+ Vector<List<int>::Element *> indices;
+};
+} // namespace
+
int SurfaceTool::mikktGetNumFaces(const SMikkTSpaceContext *pContext) {
- Vector<List<Vertex>::Element *> &varr = *((Vector<List<Vertex>::Element *> *)pContext->m_pUserData);
- return varr.size() / 3;
+ TangentGenerationContextUserData &triangle_data = *reinterpret_cast<TangentGenerationContextUserData *>(pContext->m_pUserData);
+
+ if (triangle_data.indices.size() > 0) {
+ return triangle_data.indices.size() / 3;
+ } else {
+ return triangle_data.vertices.size() / 3;
+ }
}
int SurfaceTool::mikktGetNumVerticesOfFace(const SMikkTSpaceContext *pContext, const int iFace) {
@@ -775,8 +787,17 @@ int SurfaceTool::mikktGetNumVerticesOfFace(const SMikkTSpaceContext *pContext, c
}
void SurfaceTool::mikktGetPosition(const SMikkTSpaceContext *pContext, float fvPosOut[], const int iFace, const int iVert) {
- Vector<List<Vertex>::Element *> &varr = *((Vector<List<Vertex>::Element *> *)pContext->m_pUserData);
- Vector3 v = varr[iFace * 3 + iVert]->get().vertex;
+ TangentGenerationContextUserData &triangle_data = *reinterpret_cast<TangentGenerationContextUserData *>(pContext->m_pUserData);
+ Vector3 v;
+ if (triangle_data.indices.size() > 0) {
+ int index = triangle_data.indices[iFace * 3 + iVert]->get();
+ if (index < triangle_data.vertices.size()) {
+ v = triangle_data.vertices[index]->get().vertex;
+ }
+ } else {
+ v = triangle_data.vertices[iFace * 3 + iVert]->get().vertex;
+ }
+
fvPosOut[0] = v.x;
fvPosOut[1] = v.y;
fvPosOut[2] = v.z;
@@ -784,38 +805,56 @@ void SurfaceTool::mikktGetPosition(const SMikkTSpaceContext *pContext, float fvP
void SurfaceTool::mikktGetNormal(const SMikkTSpaceContext *pContext, float fvNormOut[], const int iFace, const int iVert) {
- Vector<List<Vertex>::Element *> &varr = *((Vector<List<Vertex>::Element *> *)pContext->m_pUserData);
- Vector3 v = varr[iFace * 3 + iVert]->get().normal;
+ TangentGenerationContextUserData &triangle_data = *reinterpret_cast<TangentGenerationContextUserData *>(pContext->m_pUserData);
+ Vector3 v;
+ if (triangle_data.indices.size() > 0) {
+ int index = triangle_data.indices[iFace * 3 + iVert]->get();
+ if (index < triangle_data.vertices.size()) {
+ v = triangle_data.vertices[index]->get().normal;
+ }
+ } else {
+ v = triangle_data.vertices[iFace * 3 + iVert]->get().normal;
+ }
+
fvNormOut[0] = v.x;
fvNormOut[1] = v.y;
fvNormOut[2] = v.z;
}
void SurfaceTool::mikktGetTexCoord(const SMikkTSpaceContext *pContext, float fvTexcOut[], const int iFace, const int iVert) {
- Vector<List<Vertex>::Element *> &varr = *((Vector<List<Vertex>::Element *> *)pContext->m_pUserData);
- Vector2 v = varr[iFace * 3 + iVert]->get().uv;
+ TangentGenerationContextUserData &triangle_data = *reinterpret_cast<TangentGenerationContextUserData *>(pContext->m_pUserData);
+ Vector2 v;
+ if (triangle_data.indices.size() > 0) {
+ int index = triangle_data.indices[iFace * 3 + iVert]->get();
+ if (index < triangle_data.vertices.size()) {
+ v = triangle_data.vertices[index]->get().uv;
+ }
+ } else {
+ v = triangle_data.vertices[iFace * 3 + iVert]->get().uv;
+ }
+
fvTexcOut[0] = v.x;
fvTexcOut[1] = v.y;
- //fvTexcOut[1]=1.0-v.y;
}
void SurfaceTool::mikktSetTSpaceDefault(const SMikkTSpaceContext *pContext, const float fvTangent[], const float fvBiTangent[], const float fMagS, const float fMagT,
const tbool bIsOrientationPreserving, const int iFace, const int iVert) {
- Vector<List<Vertex>::Element *> &varr = *((Vector<List<Vertex>::Element *> *)pContext->m_pUserData);
- Vertex *vtx = &varr[iFace * 3 + iVert]->get();
-
- vtx->tangent = Vector3(fvTangent[0], fvTangent[1], fvTangent[2]);
- vtx->binormal = Vector3(fvBiTangent[0], fvBiTangent[1], fvBiTangent[2]);
-}
-
-void SurfaceTool::mikktSetTSpaceBasic(const SMikkTSpaceContext *pContext, const float fvTangent[], const float fSign, const int iFace, const int iVert) {
-
- Vector<List<Vertex>::Element *> &varr = *((Vector<List<Vertex>::Element *> *)pContext->m_pUserData);
- Vertex &vtx = varr[iFace * 3 + iVert]->get();
+ TangentGenerationContextUserData &triangle_data = *reinterpret_cast<TangentGenerationContextUserData *>(pContext->m_pUserData);
+ Vertex *vtx = NULL;
+ if (triangle_data.indices.size() > 0) {
+ int index = triangle_data.indices[iFace * 3 + iVert]->get();
+ if (index < triangle_data.vertices.size()) {
+ vtx = &triangle_data.vertices[index]->get();
+ }
+ } else {
+ vtx = &triangle_data.vertices[iFace * 3 + iVert]->get();
+ }
- vtx.tangent = Vector3(fvTangent[0], fvTangent[1], fvTangent[2]);
- vtx.binormal = vtx.normal.cross(vtx.tangent) * fSign;
+ if (vtx != NULL) {
+ vtx->tangent = Vector3(fvTangent[0], fvTangent[1], fvTangent[2]);
+ vtx->binormal = Vector3(-fvBiTangent[0], -fvBiTangent[1], -fvBiTangent[2]); // for some reason these are reversed, something with the coordinate system in Godot
+ }
}
void SurfaceTool::generate_tangents() {
@@ -823,10 +862,6 @@ void SurfaceTool::generate_tangents() {
ERR_FAIL_COND(!(format & Mesh::ARRAY_FORMAT_TEX_UV));
ERR_FAIL_COND(!(format & Mesh::ARRAY_FORMAT_NORMAL));
- bool indexed = index_array.size() > 0;
- if (indexed)
- deindex();
-
SMikkTSpaceInterface mkif;
mkif.m_getNormal = mikktGetNormal;
mkif.m_getNumFaces = mikktGetNumFaces;
@@ -839,24 +874,25 @@ void SurfaceTool::generate_tangents() {
SMikkTSpaceContext msc;
msc.m_pInterface = &mkif;
- Vector<List<Vertex>::Element *> vtx;
- vtx.resize(vertex_array.size());
+ TangentGenerationContextUserData triangle_data;
+ triangle_data.vertices.resize(vertex_array.size());
int idx = 0;
for (List<Vertex>::Element *E = vertex_array.front(); E; E = E->next()) {
- vtx.write[idx++] = E;
+ triangle_data.vertices.write[idx++] = E;
E->get().binormal = Vector3();
E->get().tangent = Vector3();
}
- msc.m_pUserData = &vtx;
+ triangle_data.indices.resize(index_array.size());
+ idx = 0;
+ for (List<int>::Element *E = index_array.front(); E; E = E->next()) {
+ triangle_data.indices.write[idx++] = E;
+ }
+ msc.m_pUserData = &triangle_data;
bool res = genTangSpaceDefault(&msc);
ERR_FAIL_COND(!res);
format |= Mesh::ARRAY_FORMAT_TANGENT;
-
- if (indexed) {
- index();
- }
}
void SurfaceTool::generate_normals(bool p_flip) {
diff --git a/scene/resources/surface_tool.h b/scene/resources/surface_tool.h
index 459d399380..cc8599e90a 100644
--- a/scene/resources/surface_tool.h
+++ b/scene/resources/surface_tool.h
@@ -90,7 +90,6 @@ private:
static void mikktGetPosition(const SMikkTSpaceContext *pContext, float fvPosOut[], const int iFace, const int iVert);
static void mikktGetNormal(const SMikkTSpaceContext *pContext, float fvNormOut[], const int iFace, const int iVert);
static void mikktGetTexCoord(const SMikkTSpaceContext *pContext, float fvTexcOut[], const int iFace, const int iVert);
- static void mikktSetTSpaceBasic(const SMikkTSpaceContext *pContext, const float fvTangent[], const float fSign, const int iFace, const int iVert);
static void mikktSetTSpaceDefault(const SMikkTSpaceContext *pContext, const float fvTangent[], const float fvBiTangent[], const float fMagS, const float fMagT,
const tbool bIsOrientationPreserving, const int iFace, const int iVert);
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp
index f852ecd7eb..c2c2c0ff32 100644
--- a/scene/resources/tile_set.cpp
+++ b/scene/resources/tile_set.cpp
@@ -129,6 +129,22 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
}
p.pop_front();
}
+ } else if (what == "z_index_map") {
+ tile_map[id].autotile_data.z_index_map.clear();
+ Array p = p_value;
+ Vector3 val;
+ Vector2 v;
+ int z_index;
+ while (p.size() > 0) {
+ val = p[0];
+ if (val.z != 0) {
+ v.x = val.x;
+ v.y = val.y;
+ z_index = (int)val.z;
+ tile_map[id].autotile_data.z_index_map[v] = z_index;
+ }
+ p.pop_front();
+ }
}
} else if (what == "shape")
tile_set_shape(id, 0, p_value);
@@ -228,6 +244,19 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const {
}
}
r_ret = p;
+ } else if (what == "z_index_map") {
+ Array p;
+ Vector3 v;
+ for (Map<Vector2, int>::Element *E = tile_map[id].autotile_data.z_index_map.front(); E; E = E->next()) {
+ if (E->value() != 0) {
+ //Don't save default value
+ v.x = E->key().x;
+ v.y = E->key().y;
+ v.z = E->value();
+ p.push_back(v);
+ }
+ }
+ r_ret = p;
}
} else if (what == "shape")
r_ret = tile_get_shape(id, 0);
@@ -278,6 +307,7 @@ void TileSet::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::ARRAY, pre + "autotile/occluder_map", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
p_list->push_back(PropertyInfo(Variant::ARRAY, pre + "autotile/navpoly_map", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
p_list->push_back(PropertyInfo(Variant::ARRAY, pre + "autotile/priority_map", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
+ p_list->push_back(PropertyInfo(Variant::ARRAY, pre + "autotile/z_index_map", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
} else if (tile_get_tile_mode(id) == ATLAS_TILE) {
p_list->push_back(PropertyInfo(Variant::VECTOR2, pre + "autotile/icon_coordinate", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
p_list->push_back(PropertyInfo(Variant::VECTOR2, pre + "autotile/tile_size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
@@ -476,6 +506,23 @@ int TileSet::autotile_get_subtile_priority(int p_id, const Vector2 &p_coord) {
return 1;
}
+void TileSet::autotile_set_z_index(int p_id, const Vector2 &p_coord, int p_z_index) {
+
+ ERR_FAIL_COND(!tile_map.has(p_id));
+ tile_map[p_id].autotile_data.z_index_map[p_coord] = p_z_index;
+ emit_changed();
+}
+
+int TileSet::autotile_get_z_index(int p_id, const Vector2 &p_coord) {
+
+ ERR_FAIL_COND_V(!tile_map.has(p_id), 1);
+ if (tile_map[p_id].autotile_data.z_index_map.has(p_coord)) {
+ return tile_map[p_id].autotile_data.z_index_map[p_coord];
+ }
+ //When not custom z index set return the default value
+ return 0;
+}
+
const Map<Vector2, int> &TileSet::autotile_get_priority_map(int p_id) const {
static Map<Vector2, int> dummy;
diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h
index 1802bf12b6..2ab771b1b0 100644
--- a/scene/resources/tile_set.h
+++ b/scene/resources/tile_set.h
@@ -87,6 +87,7 @@ public:
Map<Vector2, Ref<OccluderPolygon2D> > occluder_map;
Map<Vector2, Ref<NavigationPolygon> > navpoly_map;
Map<Vector2, int> priority_map;
+ Map<Vector2, int> z_index_map;
// Default size to prevent invalid value
explicit AutotileData() :
@@ -172,6 +173,9 @@ public:
int autotile_get_subtile_priority(int p_id, const Vector2 &p_coord);
const Map<Vector2, int> &autotile_get_priority_map(int p_id) const;
+ void autotile_set_z_index(int p_id, const Vector2 &p_coord, int p_z_index);
+ int autotile_get_z_index(int p_id, const Vector2 &p_coord);
+
void autotile_set_bitmask(int p_id, Vector2 p_coord, uint16_t p_flag);
uint16_t autotile_get_bitmask(int p_id, Vector2 p_coord);
const Map<Vector2, uint16_t> &autotile_get_bitmask_map(int p_id);