summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/animated_sprite.cpp5
-rw-r--r--scene/2d/area_2d.cpp8
-rw-r--r--scene/2d/audio_stream_player_2d.cpp4
-rw-r--r--scene/2d/canvas_item.h2
-rw-r--r--scene/2d/collision_object_2d.cpp7
-rw-r--r--scene/2d/cpu_particles_2d.cpp3
-rw-r--r--scene/2d/cpu_particles_2d.h2
-rw-r--r--scene/2d/line_2d.cpp3
-rw-r--r--scene/2d/particles_2d.cpp26
-rw-r--r--scene/2d/physics_body_2d.cpp2
-rw-r--r--scene/2d/physics_body_2d.h4
-rw-r--r--scene/2d/sprite.cpp5
-rw-r--r--scene/2d/tile_map.cpp215
-rw-r--r--scene/2d/tile_map.h15
-rw-r--r--scene/3d/arvr_nodes.cpp1
-rw-r--r--scene/3d/audio_stream_player_3d.cpp6
-rw-r--r--scene/3d/camera.h2
-rw-r--r--scene/3d/cpu_particles.cpp3
-rw-r--r--scene/3d/cpu_particles.h2
-rw-r--r--scene/3d/particles.cpp28
-rw-r--r--scene/3d/physics_body.cpp2
-rw-r--r--scene/3d/soft_body.cpp1
-rw-r--r--scene/3d/sprite_3d.cpp1
-rw-r--r--scene/3d/vehicle_body.cpp7
-rw-r--r--scene/3d/visual_instance.cpp1
-rw-r--r--scene/3d/voxel_light_baker.cpp4
-rw-r--r--scene/animation/animation_node_state_machine.cpp114
-rw-r--r--scene/animation/root_motion_view.h2
-rw-r--r--scene/animation/skeleton_ik.cpp1
-rw-r--r--scene/animation/skeleton_ik.h4
-rw-r--r--scene/animation/tween.cpp4
-rw-r--r--scene/audio/audio_stream_player.cpp2
-rw-r--r--scene/gui/box_container.cpp1
-rw-r--r--scene/gui/color_picker.cpp10
-rw-r--r--scene/gui/control.cpp35
-rw-r--r--scene/gui/control.h4
-rw-r--r--scene/gui/file_dialog.cpp7
-rw-r--r--scene/gui/graph_edit.cpp12
-rw-r--r--scene/gui/label.cpp9
-rw-r--r--scene/gui/line_edit.cpp44
-rw-r--r--scene/gui/line_edit.h3
-rw-r--r--scene/gui/popup.cpp17
-rw-r--r--scene/gui/popup.h3
-rw-r--r--scene/gui/rich_text_label.cpp140
-rw-r--r--scene/gui/rich_text_label.h1
-rw-r--r--scene/gui/scroll_container.cpp22
-rw-r--r--scene/gui/text_edit.cpp30
-rw-r--r--scene/gui/text_edit.h1
-rw-r--r--scene/gui/tree.cpp4
-rw-r--r--scene/main/node.cpp17
-rw-r--r--scene/main/scene_tree.cpp11
-rw-r--r--scene/main/viewport.cpp2
-rw-r--r--scene/resources/concave_polygon_shape_2d.cpp2
-rw-r--r--scene/resources/default_theme/default_theme.cpp2
-rw-r--r--scene/resources/multimesh.cpp8
-rw-r--r--scene/resources/particles_material.cpp3
-rw-r--r--scene/resources/primitive_meshes.cpp2
-rw-r--r--scene/resources/resource_format_text.cpp4
-rw-r--r--scene/resources/texture.cpp1
-rw-r--r--scene/resources/visual_shader.cpp10
-rw-r--r--scene/resources/visual_shader.h1
-rw-r--r--scene/resources/visual_shader_nodes.h8
62 files changed, 554 insertions, 346 deletions
diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp
index 5bf70e12b7..b7ace804ef 100644
--- a/scene/2d/animated_sprite.cpp
+++ b/scene/2d/animated_sprite.cpp
@@ -69,10 +69,7 @@ bool AnimatedSprite::_edit_use_rect() const {
Ref<Texture> t;
if (animation)
t = frames->get_frame(animation, frame);
- if (t.is_null())
- return false;
-
- return true;
+ return t.is_valid();
}
Rect2 AnimatedSprite::get_anchorable_rect() const {
diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp
index b322cfe8f1..b701e84a9c 100644
--- a/scene/2d/area_2d.cpp
+++ b/scene/2d/area_2d.cpp
@@ -657,10 +657,10 @@ void Area2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("_body_inout"), &Area2D::_body_inout);
ClassDB::bind_method(D_METHOD("_area_inout"), &Area2D::_area_inout);
- ADD_SIGNAL(MethodInfo("body_shape_entered", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsBody2D"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "area_shape")));
- ADD_SIGNAL(MethodInfo("body_shape_exited", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsBody2D"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "area_shape")));
- ADD_SIGNAL(MethodInfo("body_entered", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsBody2D")));
- ADD_SIGNAL(MethodInfo("body_exited", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsBody2D")));
+ ADD_SIGNAL(MethodInfo("body_shape_entered", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "area_shape")));
+ ADD_SIGNAL(MethodInfo("body_shape_exited", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "area_shape")));
+ ADD_SIGNAL(MethodInfo("body_entered", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
+ ADD_SIGNAL(MethodInfo("body_exited", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
ADD_SIGNAL(MethodInfo("area_shape_entered", PropertyInfo(Variant::INT, "area_id"), PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area2D"), PropertyInfo(Variant::INT, "area_shape"), PropertyInfo(Variant::INT, "self_shape")));
ADD_SIGNAL(MethodInfo("area_shape_exited", PropertyInfo(Variant::INT, "area_id"), PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area2D"), PropertyInfo(Variant::INT, "area_shape"), PropertyInfo(Variant::INT, "self_shape")));
diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp
index 73f583111b..932af469d0 100644
--- a/scene/2d/audio_stream_player_2d.cpp
+++ b/scene/2d/audio_stream_player_2d.cpp
@@ -457,8 +457,8 @@ void AudioStreamPlayer2D::set_stream_paused(bool p_pause) {
if (p_pause != stream_paused) {
stream_paused = p_pause;
- stream_paused_fade_in = p_pause ? false : true;
- stream_paused_fade_out = p_pause ? true : false;
+ stream_paused_fade_in = !p_pause;
+ stream_paused_fade_out = p_pause;
}
}
diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h
index 1f585d84ce..2604eb04e4 100644
--- a/scene/2d/canvas_item.h
+++ b/scene/2d/canvas_item.h
@@ -143,7 +143,7 @@ public:
void set_particles_anim_v_frames(int p_frames);
int get_particles_anim_v_frames() const;
- void set_particles_anim_loop(bool p_frames);
+ void set_particles_anim_loop(bool p_loop);
bool get_particles_anim_loop() const;
static void init_shaders();
diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp
index 375375285d..36c88e395a 100644
--- a/scene/2d/collision_object_2d.cpp
+++ b/scene/2d/collision_object_2d.cpp
@@ -218,12 +218,13 @@ void CollisionObject2D::shape_owner_set_transform(uint32_t p_owner, const Transf
ERR_FAIL_COND(!shapes.has(p_owner));
ShapeData &sd = shapes[p_owner];
+
sd.xform = p_transform;
for (int i = 0; i < sd.shapes.size(); i++) {
if (area) {
- Physics2DServer::get_singleton()->area_set_shape_transform(rid, sd.shapes[i].index, p_transform);
+ Physics2DServer::get_singleton()->area_set_shape_transform(rid, sd.shapes[i].index, sd.xform);
} else {
- Physics2DServer::get_singleton()->body_set_shape_transform(rid, sd.shapes[i].index, p_transform);
+ Physics2DServer::get_singleton()->body_set_shape_transform(rid, sd.shapes[i].index, sd.xform);
}
}
}
@@ -387,7 +388,7 @@ String CollisionObject2D::get_configuration_warning() const {
String warning = Node2D::get_configuration_warning();
if (shapes.empty()) {
- if (warning == String()) {
+ if (!warning.empty()) {
warning += "\n";
}
warning += TTR("This node has no shape, so it can't collide or interact with other objects.\nConsider adding a CollisionShape2D or CollisionPolygon2D as a child to define its shape.");
diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp
index fba1c26d1c..faa0a08d10 100644
--- a/scene/2d/cpu_particles_2d.cpp
+++ b/scene/2d/cpu_particles_2d.cpp
@@ -532,7 +532,8 @@ void CPUParticles2D::_particles_process(float p_delta) {
time = Math::fmod(time, lifetime);
cycle++;
if (one_shot && cycle > 0) {
- emitting = false;
+ set_emitting(false);
+ _change_notify();
}
}
diff --git a/scene/2d/cpu_particles_2d.h b/scene/2d/cpu_particles_2d.h
index 6c83abb311..813f5ddc6e 100644
--- a/scene/2d/cpu_particles_2d.h
+++ b/scene/2d/cpu_particles_2d.h
@@ -252,7 +252,7 @@ public:
void set_color(const Color &p_color);
Color get_color() const;
- void set_color_ramp(const Ref<Gradient> &p_texture);
+ void set_color_ramp(const Ref<Gradient> &p_ramp);
Ref<Gradient> get_color_ramp() const;
void set_particle_flag(Flags p_flag, bool p_enable);
diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp
index 5ba184b324..4488dc501c 100644
--- a/scene/2d/line_2d.cpp
+++ b/scene/2d/line_2d.cpp
@@ -38,8 +38,7 @@ VARIANT_ENUM_CAST(Line2D::LineJointMode)
VARIANT_ENUM_CAST(Line2D::LineCapMode)
VARIANT_ENUM_CAST(Line2D::LineTextureMode)
-Line2D::Line2D() :
- Node2D() {
+Line2D::Line2D() {
_joint_mode = LINE_JOINT_SHARP;
_begin_cap_mode = LINE_CAP_NONE;
_end_cap_mode = LINE_CAP_NONE;
diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp
index 823794c3ba..7759897420 100644
--- a/scene/2d/particles_2d.cpp
+++ b/scene/2d/particles_2d.cpp
@@ -41,6 +41,12 @@
void Particles2D::set_emitting(bool p_emitting) {
VS::get_singleton()->particles_set_emitting(particles, p_emitting);
+
+ if (p_emitting && one_shot) {
+ set_process_internal(true);
+ } else if (!p_emitting) {
+ set_process_internal(false);
+ }
}
void Particles2D::set_amount(int p_amount) {
@@ -60,8 +66,16 @@ void Particles2D::set_one_shot(bool p_enable) {
one_shot = p_enable;
VS::get_singleton()->particles_set_one_shot(particles, one_shot);
- if (!one_shot && is_emitting())
- VisualServer::get_singleton()->particles_restart(particles);
+
+ if (is_emitting()) {
+
+ set_process_internal(true);
+ if (!one_shot)
+ VisualServer::get_singleton()->particles_restart(particles);
+ }
+
+ if (!one_shot)
+ set_process_internal(false);
}
void Particles2D::set_pre_process_time(float p_time) {
@@ -314,6 +328,14 @@ void Particles2D::_notification(int p_what) {
if (p_what == NOTIFICATION_TRANSFORM_CHANGED) {
_update_particle_emission_transform();
}
+
+ if (p_what == NOTIFICATION_INTERNAL_PROCESS) {
+
+ if (one_shot && !is_emitting()) {
+ _change_notify();
+ set_process_internal(false);
+ }
+ }
}
void Particles2D::_bind_methods() {
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index 2bd9e5e2a2..95acf13fad 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -1541,7 +1541,7 @@ Vector2 KinematicCollision2D::get_remainder() const {
return collision.remainder;
}
Object *KinematicCollision2D::get_local_shape() const {
- ERR_FAIL_COND_V(!owner, NULL);
+ if (!owner) return NULL;
uint32_t ownerid = owner->shape_find_owner(collision.local_shape);
return owner->shape_owner_get_owner(ownerid);
}
diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h
index 89dd1e5341..66e5ce250f 100644
--- a/scene/2d/physics_body_2d.h
+++ b/scene/2d/physics_body_2d.h
@@ -157,8 +157,8 @@ private:
bool operator<(const ShapePair &p_sp) const {
if (body_shape == p_sp.body_shape)
return local_shape < p_sp.local_shape;
- else
- return body_shape < p_sp.body_shape;
+
+ return body_shape < p_sp.body_shape;
}
ShapePair() {}
diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp
index a8c7622828..6626fccf1c 100644
--- a/scene/2d/sprite.cpp
+++ b/scene/2d/sprite.cpp
@@ -63,10 +63,7 @@ Rect2 Sprite::_edit_get_rect() const {
}
bool Sprite::_edit_use_rect() const {
- if (texture.is_null())
- return false;
-
- return true;
+ return texture.is_valid();
}
Rect2 Sprite::get_anchorable_rect() const {
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index b3b6f3175d..bf59fa0ba8 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -30,9 +30,11 @@
#include "tile_map.h"
+#include "collision_object_2d.h"
#include "core/io/marshalls.h"
#include "core/method_bind_ext.gen.inc"
#include "core/os/os.h"
+#include "scene/2d/area_2d.h"
#include "servers/physics_2d_server.h"
int TileMap::_get_quadrant_size() const {
@@ -60,14 +62,21 @@ void TileMap::_notification(int p_what) {
c = Object::cast_to<Node2D>(c->get_parent());
}
+ if (use_parent) {
+ _clear_quadrants();
+ collision_parent = Object::cast_to<CollisionObject2D>(get_parent());
+ }
+
pending_update = true;
_recreate_quadrants();
update_dirty_quadrants();
RID space = get_world_2d()->get_space();
_update_quadrant_transform();
_update_quadrant_space(space);
+ update_configuration_warning();
} break;
+
case NOTIFICATION_EXIT_TREE: {
_update_quadrant_space(RID());
@@ -82,30 +91,46 @@ void TileMap::_notification(int p_what) {
q.navpoly_ids.clear();
}
+ if (collision_parent) {
+ collision_parent->remove_shape_owner(q.shape_owner_id);
+ q.shape_owner_id = -1;
+ }
+
for (Map<PosKey, Quadrant::Occluder>::Element *F = q.occluder_instances.front(); F; F = F->next()) {
VS::get_singleton()->free(F->get().id);
}
q.occluder_instances.clear();
}
+ collision_parent = NULL;
navigation = NULL;
} break;
+
case NOTIFICATION_TRANSFORM_CHANGED: {
//move stuff
_update_quadrant_transform();
} break;
+ case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
+
+ if (use_parent) {
+ _recreate_quadrants();
+ }
+
+ } break;
}
}
void TileMap::_update_quadrant_space(const RID &p_space) {
- for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
+ if (!use_parent) {
+ for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
- Quadrant &q = E->get();
- Physics2DServer::get_singleton()->body_set_space(q.body, p_space);
+ Quadrant &q = E->get();
+ Physics2DServer::get_singleton()->body_set_space(q.body, p_space);
+ }
}
}
@@ -116,6 +141,10 @@ void TileMap::_update_quadrant_transform() {
Transform2D global_transform = get_global_transform();
+ Transform2D local_transform;
+ if (collision_parent)
+ local_transform = get_transform();
+
Transform2D nav_rel;
if (navigation)
nav_rel = get_relative_transform_to_parent(navigation);
@@ -125,8 +154,11 @@ void TileMap::_update_quadrant_transform() {
Quadrant &q = E->get();
Transform2D xform;
xform.set_origin(q.pos);
- xform = global_transform * xform;
- Physics2DServer::get_singleton()->body_set_state(q.body, Physics2DServer::BODY_STATE_TRANSFORM, xform);
+
+ if (!use_parent) {
+ xform = global_transform * xform;
+ Physics2DServer::get_singleton()->body_set_state(q.body, Physics2DServer::BODY_STATE_TRANSFORM, xform);
+ }
if (navigation) {
for (Map<PosKey, Quadrant::NavPoly>::Element *F = q.navpoly_ids.front(); F; F = F->next()) {
@@ -225,6 +257,34 @@ void TileMap::_fix_cell_transform(Transform2D &xform, const Cell &p_cell, const
xform.elements[2] += offset;
}
+void TileMap::_add_shape(int &shape_idx, const Quadrant &p_q, const Ref<Shape2D> &p_shape, const TileSet::ShapeData &p_shape_data, const Transform2D &p_xform, const Vector2 &p_metadata) {
+ Physics2DServer *ps = Physics2DServer::get_singleton();
+
+ if (!use_parent) {
+ ps->body_add_shape(p_q.body, p_shape->get_rid(), p_xform);
+ ps->body_set_shape_metadata(p_q.body, shape_idx, p_metadata);
+ ps->body_set_shape_as_one_way_collision(p_q.body, shape_idx, p_shape_data.one_way_collision, p_shape_data.one_way_collision_margin);
+
+ } else if (collision_parent) {
+ Transform2D xform = p_xform;
+ xform.set_origin(xform.get_origin() + p_q.pos);
+
+ collision_parent->shape_owner_add_shape(p_q.shape_owner_id, p_shape);
+
+ int real_index = collision_parent->shape_owner_get_shape_index(p_q.shape_owner_id, shape_idx);
+ RID rid = collision_parent->get_rid();
+
+ if (Object::cast_to<Area2D>(collision_parent) != NULL) {
+ ps->area_set_shape_transform(rid, real_index, get_transform() * xform);
+ } else {
+ ps->body_set_shape_transform(rid, real_index, get_transform() * xform);
+ ps->body_set_shape_metadata(rid, real_index, p_metadata);
+ ps->body_set_shape_as_one_way_collision(rid, real_index, p_shape_data.one_way_collision, p_shape_data.one_way_collision_margin);
+ }
+ }
+ shape_idx++;
+}
+
void TileMap::update_dirty_quadrants() {
if (!pending_update)
@@ -268,7 +328,11 @@ void TileMap::update_dirty_quadrants() {
q.canvas_items.clear();
- ps->body_clear_shapes(q.body);
+ if (!use_parent) {
+ ps->body_clear_shapes(q.body);
+ } else if (collision_parent) {
+ collision_parent->shape_owner_clear_shapes(q.shape_owner_id);
+ }
int shape_idx = 0;
if (navigation) {
@@ -427,10 +491,7 @@ void TileMap::update_dirty_quadrants() {
for (int k = 0; k < _shapes.size(); k++) {
Ref<ConvexPolygonShape2D> convex = _shapes[k];
if (convex.is_valid()) {
- ps->body_add_shape(q.body, convex->get_rid(), xform);
- ps->body_set_shape_metadata(q.body, shape_idx, Vector2(E->key().x, E->key().y));
- ps->body_set_shape_as_one_way_collision(q.body, shape_idx, shapes[j].one_way_collision, shapes[j].one_way_collision_margin);
- shape_idx++;
+ _add_shape(shape_idx, q, convex, shapes[j], xform, Vector2(E->key().x, E->key().y));
#ifdef DEBUG_ENABLED
} else {
print_error("The TileSet assigned to the TileMap " + get_name() + " has an invalid convex shape.");
@@ -438,10 +499,7 @@ void TileMap::update_dirty_quadrants() {
}
}
} else {
- ps->body_add_shape(q.body, shape->get_rid(), xform);
- ps->body_set_shape_metadata(q.body, shape_idx, Vector2(E->key().x, E->key().y));
- ps->body_set_shape_as_one_way_collision(q.body, shape_idx, shapes[j].one_way_collision, shapes[j].one_way_collision_margin);
- shape_idx++;
+ _add_shape(shape_idx, q, shape, shapes[j], xform, Vector2(E->key().x, E->key().y));
}
}
}
@@ -616,22 +674,29 @@ Map<TileMap::PosKey, TileMap::Quadrant>::Element *TileMap::_create_quadrant(cons
xform.set_origin(q.pos);
//q.canvas_item = VisualServer::get_singleton()->canvas_item_create();
- q.body = Physics2DServer::get_singleton()->body_create();
- Physics2DServer::get_singleton()->body_set_mode(q.body, use_kinematic ? Physics2DServer::BODY_MODE_KINEMATIC : Physics2DServer::BODY_MODE_STATIC);
-
- Physics2DServer::get_singleton()->body_attach_object_instance_id(q.body, get_instance_id());
- Physics2DServer::get_singleton()->body_set_collision_layer(q.body, collision_layer);
- Physics2DServer::get_singleton()->body_set_collision_mask(q.body, collision_mask);
- Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_FRICTION, friction);
- Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_BOUNCE, bounce);
-
- if (is_inside_tree()) {
- xform = get_global_transform() * xform;
- RID space = get_world_2d()->get_space();
- Physics2DServer::get_singleton()->body_set_space(q.body, space);
- }
+ if (!use_parent) {
+ q.body = Physics2DServer::get_singleton()->body_create();
+ Physics2DServer::get_singleton()->body_set_mode(q.body, use_kinematic ? Physics2DServer::BODY_MODE_KINEMATIC : Physics2DServer::BODY_MODE_STATIC);
+
+ Physics2DServer::get_singleton()->body_attach_object_instance_id(q.body, get_instance_id());
+ Physics2DServer::get_singleton()->body_set_collision_layer(q.body, collision_layer);
+ Physics2DServer::get_singleton()->body_set_collision_mask(q.body, collision_mask);
+ Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_FRICTION, friction);
+ Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_BOUNCE, bounce);
- Physics2DServer::get_singleton()->body_set_state(q.body, Physics2DServer::BODY_STATE_TRANSFORM, xform);
+ if (is_inside_tree()) {
+ xform = get_global_transform() * xform;
+ RID space = get_world_2d()->get_space();
+ Physics2DServer::get_singleton()->body_set_space(q.body, space);
+ }
+
+ Physics2DServer::get_singleton()->body_set_state(q.body, Physics2DServer::BODY_STATE_TRANSFORM, xform);
+ } else if (collision_parent) {
+ xform = get_transform() * xform;
+ q.shape_owner_id = collision_parent->create_shape_owner(this);
+ } else {
+ q.shape_owner_id = -1;
+ }
rect_cache_dirty = true;
quadrant_order_dirty = true;
@@ -641,7 +706,12 @@ Map<TileMap::PosKey, TileMap::Quadrant>::Element *TileMap::_create_quadrant(cons
void TileMap::_erase_quadrant(Map<PosKey, Quadrant>::Element *Q) {
Quadrant &q = Q->get();
- Physics2DServer::get_singleton()->free(q.body);
+ if (!use_parent) {
+ Physics2DServer::get_singleton()->free(q.body);
+ } else if (collision_parent) {
+ collision_parent->remove_shape_owner(q.shape_owner_id);
+ }
+
for (List<RID>::Element *E = q.canvas_items.front(); E; E = E->next()) {
VisualServer::get_singleton()->free(E->get());
@@ -1135,20 +1205,24 @@ Rect2 TileMap::_edit_get_rect() const {
void TileMap::set_collision_layer(uint32_t p_layer) {
collision_layer = p_layer;
- for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
+ if (!use_parent) {
+ for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
- Quadrant &q = E->get();
- Physics2DServer::get_singleton()->body_set_collision_layer(q.body, collision_layer);
+ Quadrant &q = E->get();
+ Physics2DServer::get_singleton()->body_set_collision_layer(q.body, collision_layer);
+ }
}
}
void TileMap::set_collision_mask(uint32_t p_mask) {
collision_mask = p_mask;
- for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
+ if (!use_parent) {
+ for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
- Quadrant &q = E->get();
- Physics2DServer::get_singleton()->body_set_collision_mask(q.body, collision_mask);
+ Quadrant &q = E->get();
+ Physics2DServer::get_singleton()->body_set_collision_mask(q.body, collision_mask);
+ }
}
}
@@ -1184,13 +1258,40 @@ void TileMap::set_collision_use_kinematic(bool p_use_kinematic) {
_recreate_quadrants();
}
+bool TileMap::get_collision_use_parent() const {
+
+ return use_parent;
+}
+
+void TileMap::set_collision_use_parent(bool p_use_parent) {
+
+ if (use_parent == p_use_parent) return;
+
+ _clear_quadrants();
+
+ use_parent = p_use_parent;
+ set_notify_local_transform(use_parent);
+
+ if (use_parent && is_inside_tree()) {
+ collision_parent = Object::cast_to<CollisionObject2D>(get_parent());
+ } else {
+ collision_parent = NULL;
+ }
+
+ _recreate_quadrants();
+ _change_notify();
+ update_configuration_warning();
+}
+
void TileMap::set_collision_friction(float p_friction) {
friction = p_friction;
- for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
+ if (!use_parent) {
+ for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
- Quadrant &q = E->get();
- Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_FRICTION, p_friction);
+ Quadrant &q = E->get();
+ Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_FRICTION, p_friction);
+ }
}
}
@@ -1202,10 +1303,12 @@ float TileMap::get_collision_friction() const {
void TileMap::set_collision_bounce(float p_bounce) {
bounce = p_bounce;
- for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
+ if (!use_parent) {
+ for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
- Quadrant &q = E->get();
- Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_BOUNCE, p_bounce);
+ Quadrant &q = E->get();
+ Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_BOUNCE, p_bounce);
+ }
}
}
float TileMap::get_collision_bounce() const {
@@ -1404,6 +1507,12 @@ void TileMap::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(p);
}
+void TileMap::_validate_property(PropertyInfo &property) const {
+ if (use_parent && property.name != "collision_use_parent" && property.name.begins_with("collision_")) {
+ property.usage = PROPERTY_USAGE_NOEDITOR;
+ }
+}
+
Vector2 TileMap::map_to_world(const Vector2 &p_pos, bool p_ignore_ofs) const {
return _map_to_world(p_pos.x, p_pos.y, p_ignore_ofs);
@@ -1552,6 +1661,20 @@ bool TileMap::get_clip_uv() const {
return clip_uv;
}
+String TileMap::get_configuration_warning() const {
+
+ String warning = Node2D::get_configuration_warning();
+
+ if (use_parent && !collision_parent) {
+ if (!warning.empty()) {
+ warning += "\n";
+ }
+ return TTR("TileMap with Use Parent on needs a parent CollisionObject2D to give shapes to. Please use it as a child of Area2D, StaticBody2D, RigidBody2D, KinematicBody2D, etc. to give them a shape.");
+ }
+
+ return warning;
+}
+
void TileMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_tileset", "tileset"), &TileMap::set_tileset);
@@ -1587,6 +1710,9 @@ void TileMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_collision_use_kinematic", "use_kinematic"), &TileMap::set_collision_use_kinematic);
ClassDB::bind_method(D_METHOD("get_collision_use_kinematic"), &TileMap::get_collision_use_kinematic);
+ ClassDB::bind_method(D_METHOD("set_collision_use_parent", "use_parent"), &TileMap::set_collision_use_parent);
+ ClassDB::bind_method(D_METHOD("get_collision_use_parent"), &TileMap::get_collision_use_parent);
+
ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &TileMap::set_collision_layer);
ClassDB::bind_method(D_METHOD("get_collision_layer"), &TileMap::get_collision_layer);
@@ -1652,6 +1778,7 @@ void TileMap::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cell_clip_uv"), "set_clip_uv", "get_clip_uv");
ADD_GROUP("Collision", "collision_");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collision_use_parent", PROPERTY_HINT_NONE, ""), "set_collision_use_parent", "get_collision_use_parent");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collision_use_kinematic", PROPERTY_HINT_NONE, ""), "set_collision_use_kinematic", "get_collision_use_kinematic");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "collision_friction", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_collision_friction", "get_collision_friction");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "collision_bounce", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_collision_bounce", "get_collision_bounce");
@@ -1700,7 +1827,8 @@ TileMap::TileMap() {
bounce = 0;
mode = MODE_SQUARE;
half_offset = HALF_OFFSET_DISABLED;
- use_kinematic = false;
+ use_parent = false;
+ collision_parent = NULL;
navigation = NULL;
y_sort_mode = false;
occluder_light_mask = 1;
@@ -1710,6 +1838,7 @@ TileMap::TileMap() {
fp_adjust = 0.00001;
tile_origin = TILE_ORIGIN_TOP_LEFT;
set_notify_transform(true);
+ set_notify_local_transform(false);
}
TileMap::~TileMap() {
diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h
index 6a1467aa48..1caaefa213 100644
--- a/scene/2d/tile_map.h
+++ b/scene/2d/tile_map.h
@@ -37,6 +37,8 @@
#include "scene/2d/node_2d.h"
#include "scene/resources/tile_set.h"
+class CollisionObject2D;
+
class TileMap : public Node2D {
GDCLASS(TileMap, Node2D);
@@ -74,6 +76,8 @@ private:
Mode mode;
Transform2D custom_transform;
HalfOffset half_offset;
+ bool use_parent;
+ CollisionObject2D *collision_parent;
bool use_kinematic;
Navigation2D *navigation;
@@ -123,6 +127,7 @@ private:
Vector2 pos;
List<RID> canvas_items;
RID body;
+ uint32_t shape_owner_id;
SelfList<Quadrant> dirty_list;
@@ -145,6 +150,7 @@ private:
pos = q.pos;
canvas_items = q.canvas_items;
body = q.body;
+ shape_owner_id = q.shape_owner_id;
cells = q.cells;
navpoly_ids = q.navpoly_ids;
occluder_instances = q.occluder_instances;
@@ -154,6 +160,7 @@ private:
pos = q.pos;
canvas_items = q.canvas_items;
body = q.body;
+ shape_owner_id = q.shape_owner_id;
cells = q.cells;
occluder_instances = q.occluder_instances;
navpoly_ids = q.navpoly_ids;
@@ -188,6 +195,8 @@ private:
void _fix_cell_transform(Transform2D &xform, const Cell &p_cell, const Vector2 &p_offset, const Size2 &p_sc);
+ void _add_shape(int &shape_idx, const Quadrant &p_q, const Ref<Shape2D> &p_shape, const TileSet::ShapeData &p_shape_data, const Transform2D &p_xform, const Vector2 &p_metadata);
+
Map<PosKey, Quadrant>::Element *_create_quadrant(const PosKey &p_qk);
void _erase_quadrant(Map<PosKey, Quadrant>::Element *Q);
void _make_quadrant_dirty(Map<PosKey, Quadrant>::Element *Q, bool update = true);
@@ -218,6 +227,7 @@ protected:
void _notification(int p_what);
static void _bind_methods();
+ virtual void _validate_property(PropertyInfo &property) const;
virtual void _changed_callback(Object *p_changed, const char *p_prop);
public:
@@ -271,6 +281,9 @@ public:
void set_collision_use_kinematic(bool p_use_kinematic);
bool get_collision_use_kinematic() const;
+ void set_collision_use_parent(bool p_use_parent);
+ bool get_collision_use_parent() const;
+
void set_collision_friction(float p_friction);
float get_collision_friction() const;
@@ -314,6 +327,8 @@ public:
void set_clip_uv(bool p_enable);
bool get_clip_uv() const;
+ String get_configuration_warning() const;
+
void fix_invalid_tiles();
void clear();
diff --git a/scene/3d/arvr_nodes.cpp b/scene/3d/arvr_nodes.cpp
index 95eec41fb2..dfa8fce9be 100644
--- a/scene/3d/arvr_nodes.cpp
+++ b/scene/3d/arvr_nodes.cpp
@@ -264,6 +264,7 @@ void ARVRController::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_rumble"), &ARVRController::get_rumble);
ClassDB::bind_method(D_METHOD("set_rumble", "rumble"), &ARVRController::set_rumble);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "rumble", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_rumble", "get_rumble");
+ ADD_PROPERTY_DEFAULT("rumble", 0.0);
ClassDB::bind_method(D_METHOD("get_mesh"), &ARVRController::get_mesh);
diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp
index ff8c218575..ff28f60d4f 100644
--- a/scene/3d/audio_stream_player_3d.cpp
+++ b/scene/3d/audio_stream_player_3d.cpp
@@ -93,7 +93,7 @@ void AudioStreamPlayer3D::_mix_audio() {
}
bool interpolate_filter = !started;
- ;
+
if (!found) {
//create new if was not used before
if (prev_output_count < MAX_OUTPUTS) {
@@ -872,8 +872,8 @@ void AudioStreamPlayer3D::set_stream_paused(bool p_pause) {
if (p_pause != stream_paused) {
stream_paused = p_pause;
- stream_paused_fade_in = stream_paused ? false : true;
- stream_paused_fade_out = stream_paused ? true : false;
+ stream_paused_fade_in = !stream_paused;
+ stream_paused_fade_out = stream_paused;
}
}
diff --git a/scene/3d/camera.h b/scene/3d/camera.h
index c0a4f77435..6460f17e85 100644
--- a/scene/3d/camera.h
+++ b/scene/3d/camera.h
@@ -113,7 +113,7 @@ public:
void set_perspective(float p_fovy_degrees, float p_z_near, float p_z_far);
void set_orthogonal(float p_size, float p_z_near, float p_z_far);
- void set_frustum(float p_size, Vector2 p_offset, float p_near, float p_far);
+ void set_frustum(float p_size, Vector2 p_offset, float p_z_near, float p_z_far);
void set_projection(Camera::Projection p_mode);
void make_current();
diff --git a/scene/3d/cpu_particles.cpp b/scene/3d/cpu_particles.cpp
index ee5d416930..6ede9c10ef 100644
--- a/scene/3d/cpu_particles.cpp
+++ b/scene/3d/cpu_particles.cpp
@@ -505,7 +505,8 @@ void CPUParticles::_particles_process(float p_delta) {
time = Math::fmod(time, lifetime);
cycle++;
if (one_shot && cycle > 0) {
- emitting = false;
+ set_emitting(false);
+ _change_notify();
}
}
diff --git a/scene/3d/cpu_particles.h b/scene/3d/cpu_particles.h
index 6f267102fa..6566792def 100644
--- a/scene/3d/cpu_particles.h
+++ b/scene/3d/cpu_particles.h
@@ -249,7 +249,7 @@ public:
void set_color(const Color &p_color);
Color get_color() const;
- void set_color_ramp(const Ref<Gradient> &p_texture);
+ void set_color_ramp(const Ref<Gradient> &p_ramp);
Ref<Gradient> get_color_ramp() const;
void set_particle_flag(Flags p_flag, bool p_enable);
diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp
index 949de110f5..2bcd0eaa46 100644
--- a/scene/3d/particles.cpp
+++ b/scene/3d/particles.cpp
@@ -47,6 +47,12 @@ PoolVector<Face3> Particles::get_faces(uint32_t p_usage_flags) const {
void Particles::set_emitting(bool p_emitting) {
VS::get_singleton()->particles_set_emitting(particles, p_emitting);
+
+ if (p_emitting && one_shot) {
+ set_process_internal(true);
+ } else if (!p_emitting) {
+ set_process_internal(false);
+ }
}
void Particles::set_amount(int p_amount) {
@@ -66,8 +72,16 @@ void Particles::set_one_shot(bool p_one_shot) {
one_shot = p_one_shot;
VS::get_singleton()->particles_set_one_shot(particles, one_shot);
- if (!one_shot && is_emitting())
- VisualServer::get_singleton()->particles_restart(particles);
+
+ if (is_emitting()) {
+
+ set_process_internal(true);
+ if (!one_shot)
+ VisualServer::get_singleton()->particles_restart(particles);
+ }
+
+ if (!one_shot)
+ set_process_internal(false);
}
void Particles::set_pre_process_time(float p_time) {
@@ -307,6 +321,16 @@ void Particles::_notification(int p_what) {
VS::get_singleton()->particles_set_speed_scale(particles, 0);
}
}
+
+ // Use internal process when emitting and one_shot are on so that when
+ // the shot ends the editor can properly update
+ if (p_what == NOTIFICATION_INTERNAL_PROCESS) {
+
+ if (one_shot && !is_emitting()) {
+ _change_notify();
+ set_process_internal(false);
+ }
+ }
}
void Particles::_bind_methods() {
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index 3624e04434..d3aad7000d 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -1470,7 +1470,7 @@ Vector3 KinematicCollision::get_remainder() const {
return collision.remainder;
}
Object *KinematicCollision::get_local_shape() const {
- ERR_FAIL_COND_V(!owner, NULL);
+ if (!owner) return NULL;
uint32_t ownerid = owner->shape_find_owner(collision.local_shape);
return owner->shape_owner_get_owner(ownerid);
}
diff --git a/scene/3d/soft_body.cpp b/scene/3d/soft_body.cpp
index 909d4fda34..a9d96292a1 100644
--- a/scene/3d/soft_body.cpp
+++ b/scene/3d/soft_body.cpp
@@ -699,7 +699,6 @@ bool SoftBody::is_ray_pickable() const {
}
SoftBody::SoftBody() :
- MeshInstance(),
physics_rid(PhysicsServer::get_singleton()->soft_body_create()),
mesh_owner(false),
collision_mask(1),
diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp
index 6b70eef662..9f73484b6a 100644
--- a/scene/3d/sprite_3d.cpp
+++ b/scene/3d/sprite_3d.cpp
@@ -163,6 +163,7 @@ float SpriteBase3D::get_opacity() const {
void SpriteBase3D::set_axis(Vector3::Axis p_axis) {
+ ERR_FAIL_INDEX(p_axis, 3);
axis = p_axis;
_queue_update();
}
diff --git a/scene/3d/vehicle_body.cpp b/scene/3d/vehicle_body.cpp
index 32b8219ee0..89e96e0227 100644
--- a/scene/3d/vehicle_body.cpp
+++ b/scene/3d/vehicle_body.cpp
@@ -585,7 +585,7 @@ void VehicleBody::_resolve_single_bilateral(PhysicsDirectBodyState *s, const Vec
if (p_rollInfluence > 0.0) {
// !BAS! But seeing we apply this frame by frame, makes more sense to me to make this time based
// keeping in mind our anti roll factor if it is set
- contactDamping = s->get_step() / p_rollInfluence;
+ contactDamping = MIN(contactDamping, s->get_step() / p_rollInfluence);
}
#define ONLY_USE_LINEAR_MASS
@@ -723,7 +723,7 @@ void VehicleBody::_update_friction(PhysicsDirectBodyState *s) {
real_t rollingFriction = 0.f;
if (wheelInfo.m_raycastInfo.m_isInContact) {
- if (engine_force != 0.f && wheelInfo.engine_traction != false) {
+ if (engine_force != 0.f && wheelInfo.engine_traction) {
rollingFriction = -engine_force * s->get_step();
} else {
real_t defaultRollingFrictionImpulse = 0.f;
@@ -928,8 +928,7 @@ void VehicleBody::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "steering", PROPERTY_HINT_RANGE, "-180,180.0,0.01"), "set_steering", "get_steering");
}
-VehicleBody::VehicleBody() :
- RigidBody() {
+VehicleBody::VehicleBody() {
m_pitchControl = 0;
m_currentVehicleSpeedKmHour = real_t(0.);
diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance.cpp
index 99c86f0406..4bb4d18071 100644
--- a/scene/3d/visual_instance.cpp
+++ b/scene/3d/visual_instance.cpp
@@ -326,6 +326,7 @@ void GeometryInstance::_bind_methods() {
BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_SHADOWS_ONLY);
BIND_ENUM_CONSTANT(FLAG_USE_BAKED_LIGHT);
+ BIND_ENUM_CONSTANT(FLAG_DRAW_NEXT_FRAME_IF_VISIBLE);
BIND_ENUM_CONSTANT(FLAG_MAX);
}
diff --git a/scene/3d/voxel_light_baker.cpp b/scene/3d/voxel_light_baker.cpp
index 75b419ca58..5fa8c43f9f 100644
--- a/scene/3d/voxel_light_baker.cpp
+++ b/scene/3d/voxel_light_baker.cpp
@@ -212,9 +212,7 @@ static bool fast_tri_box_overlap(const Vector3 &boxcenter, const Vector3 boxhalf
/* compute plane equation of triangle: normal*x+d=0 */
normal = e0.cross(e1);
d = -normal.dot(v0); /* plane eq: normal.x+d=0 */
- if (!planeBoxOverlap(normal, d, boxhalfsize)) return false;
-
- return true; /* box and triangle overlaps */
+ return planeBoxOverlap(normal, d, boxhalfsize); /* if true, box and triangle overlaps */
}
static _FORCE_INLINE_ void get_uv_and_normal(const Vector3 &p_pos, const Vector3 *p_vtx, const Vector2 *p_uv, const Vector3 *p_normal, Vector2 &r_uv, Vector3 &r_normal) {
diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp
index a2411743d4..f1ce948c43 100644
--- a/scene/animation/animation_node_state_machine.cpp
+++ b/scene/animation/animation_node_state_machine.cpp
@@ -178,11 +178,11 @@ float AnimationNodeStateMachinePlayback::get_current_length() const {
return len_current;
}
-bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *sm, const StringName &p_travel) {
+bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *p_state_machine, const StringName &p_travel) {
ERR_FAIL_COND_V(!playing, false);
- ERR_FAIL_COND_V(!sm->states.has(p_travel), false);
- ERR_FAIL_COND_V(!sm->states.has(current), false);
+ ERR_FAIL_COND_V(!p_state_machine->states.has(p_travel), false);
+ ERR_FAIL_COND_V(!p_state_machine->states.has(current), false);
path.clear(); //a new one will be needed
@@ -191,25 +191,25 @@ bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *sm, c
loops_current = 0; // reset loops, so fade does not happen immediately
- Vector2 current_pos = sm->states[current].position;
- Vector2 target_pos = sm->states[p_travel].position;
+ Vector2 current_pos = p_state_machine->states[current].position;
+ Vector2 target_pos = p_state_machine->states[p_travel].position;
Map<StringName, AStarCost> cost_map;
List<int> open_list;
//build open list
- for (int i = 0; i < sm->transitions.size(); i++) {
- if (sm->transitions[i].from == current) {
+ for (int i = 0; i < p_state_machine->transitions.size(); i++) {
+ if (p_state_machine->transitions[i].from == current) {
open_list.push_back(i);
- float cost = sm->states[sm->transitions[i].to].position.distance_to(current_pos);
- cost *= sm->transitions[i].transition->get_priority();
+ float cost = p_state_machine->states[p_state_machine->transitions[i].to].position.distance_to(current_pos);
+ cost *= p_state_machine->transitions[i].transition->get_priority();
AStarCost ap;
ap.prev = current;
ap.distance = cost;
- cost_map[sm->transitions[i].to] = ap;
+ cost_map[p_state_machine->transitions[i].to] = ap;
- if (sm->transitions[i].to == p_travel) { //prematurely found it! :D
+ if (p_state_machine->transitions[i].to == p_travel) { //prematurely found it! :D
path.push_back(p_travel);
return true;
}
@@ -230,42 +230,42 @@ bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *sm, c
for (List<int>::Element *E = open_list.front(); E; E = E->next()) {
- float cost = cost_map[sm->transitions[E->get()].to].distance;
- cost += sm->states[sm->transitions[E->get()].to].position.distance_to(target_pos);
+ float cost = cost_map[p_state_machine->transitions[E->get()].to].distance;
+ cost += p_state_machine->states[p_state_machine->transitions[E->get()].to].position.distance_to(target_pos);
if (cost < least_cost) {
least_cost_transition = E;
}
}
- StringName transition_prev = sm->transitions[least_cost_transition->get()].from;
- StringName transition = sm->transitions[least_cost_transition->get()].to;
+ StringName transition_prev = p_state_machine->transitions[least_cost_transition->get()].from;
+ StringName transition = p_state_machine->transitions[least_cost_transition->get()].to;
- for (int i = 0; i < sm->transitions.size(); i++) {
- if (sm->transitions[i].from != transition || sm->transitions[i].to == transition_prev) {
+ for (int i = 0; i < p_state_machine->transitions.size(); i++) {
+ if (p_state_machine->transitions[i].from != transition || p_state_machine->transitions[i].to == transition_prev) {
continue; //not interested on those
}
- float distance = sm->states[sm->transitions[i].from].position.distance_to(sm->states[sm->transitions[i].to].position);
- distance *= sm->transitions[i].transition->get_priority();
- distance += cost_map[sm->transitions[i].from].distance;
+ float distance = p_state_machine->states[p_state_machine->transitions[i].from].position.distance_to(p_state_machine->states[p_state_machine->transitions[i].to].position);
+ distance *= p_state_machine->transitions[i].transition->get_priority();
+ distance += cost_map[p_state_machine->transitions[i].from].distance;
- if (cost_map.has(sm->transitions[i].to)) {
+ if (cost_map.has(p_state_machine->transitions[i].to)) {
//oh this was visited already, can we win the cost?
- if (distance < cost_map[sm->transitions[i].to].distance) {
- cost_map[sm->transitions[i].to].distance = distance;
- cost_map[sm->transitions[i].to].prev = sm->transitions[i].from;
+ if (distance < cost_map[p_state_machine->transitions[i].to].distance) {
+ cost_map[p_state_machine->transitions[i].to].distance = distance;
+ cost_map[p_state_machine->transitions[i].to].prev = p_state_machine->transitions[i].from;
}
} else {
//add to open list
AStarCost ac;
- ac.prev = sm->transitions[i].from;
+ ac.prev = p_state_machine->transitions[i].from;
ac.distance = distance;
- cost_map[sm->transitions[i].to] = ac;
+ cost_map[p_state_machine->transitions[i].to] = ac;
open_list.push_back(i);
- if (sm->transitions[i].to == p_travel) {
+ if (p_state_machine->transitions[i].to == p_travel) {
found_route = true;
break;
}
@@ -291,12 +291,12 @@ bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *sm, c
return true;
}
-float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *sm, float p_time, bool p_seek) {
+float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_state_machine, float p_time, bool p_seek) {
//if not playing and it can restart, then restart
if (!playing && start_request == StringName()) {
- if (!stop_request && sm->start_node) {
- start(sm->start_node);
+ if (!stop_request && p_state_machine->start_node) {
+ start(p_state_machine->start_node);
} else {
return 0;
}
@@ -320,7 +320,7 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *sm,
ERR_FAIL_V(0);
}
- if (!_travel(sm, start_request)) {
+ if (!_travel(p_state_machine, start_request)) {
//can't travel, then teleport
path.clear();
current = start_request;
@@ -339,16 +339,16 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *sm,
if (do_start) {
- if (sm->start_node != StringName() && p_seek && p_time == 0) {
- current = sm->start_node;
+ if (p_state_machine->start_node != StringName() && p_seek && p_time == 0) {
+ current = p_state_machine->start_node;
}
- len_current = sm->blend_node(current, sm->states[current].node, 0, true, 1.0, AnimationNode::FILTER_IGNORE, false);
+ len_current = p_state_machine->blend_node(current, p_state_machine->states[current].node, 0, true, 1.0, AnimationNode::FILTER_IGNORE, false);
pos_current = 0;
loops_current = 0;
}
- if (!sm->states.has(current)) {
+ if (!p_state_machine->states.has(current)) {
playing = false; //current does not exist
current = StringName();
return 0;
@@ -357,7 +357,7 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *sm,
if (fading_from != StringName()) {
- if (!sm->states.has(fading_from)) {
+ if (!p_state_machine->states.has(fading_from)) {
fading_from = StringName();
} else {
if (!p_seek) {
@@ -370,11 +370,11 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *sm,
}
}
- float rem = sm->blend_node(current, sm->states[current].node, p_time, p_seek, fade_blend, AnimationNode::FILTER_IGNORE, false);
+ float rem = p_state_machine->blend_node(current, p_state_machine->states[current].node, p_time, p_seek, fade_blend, AnimationNode::FILTER_IGNORE, false);
if (fading_from != StringName()) {
- sm->blend_node(fading_from, sm->states[fading_from].node, p_time, p_seek, 1.0 - fade_blend, AnimationNode::FILTER_IGNORE, false);
+ p_state_machine->blend_node(fading_from, p_state_machine->states[fading_from].node, p_time, p_seek, 1.0 - fade_blend, AnimationNode::FILTER_IGNORE, false);
}
//guess playback position
@@ -399,40 +399,40 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *sm,
if (path.size()) {
- for (int i = 0; i < sm->transitions.size(); i++) {
- if (sm->transitions[i].from == current && sm->transitions[i].to == path[0]) {
- next_xfade = sm->transitions[i].transition->get_xfade_time();
- switch_mode = sm->transitions[i].transition->get_switch_mode();
+ for (int i = 0; i < p_state_machine->transitions.size(); i++) {
+ if (p_state_machine->transitions[i].from == current && p_state_machine->transitions[i].to == path[0]) {
+ next_xfade = p_state_machine->transitions[i].transition->get_xfade_time();
+ switch_mode = p_state_machine->transitions[i].transition->get_switch_mode();
next = path[0];
}
}
} else {
float priority_best = 1e20;
int auto_advance_to = -1;
- for (int i = 0; i < sm->transitions.size(); i++) {
+ for (int i = 0; i < p_state_machine->transitions.size(); i++) {
bool auto_advance = false;
- if (sm->transitions[i].transition->has_auto_advance()) {
+ if (p_state_machine->transitions[i].transition->has_auto_advance()) {
auto_advance = true;
}
- StringName advance_condition_name = sm->transitions[i].transition->get_advance_condition_name();
- if (advance_condition_name != StringName() && bool(sm->get_parameter(advance_condition_name))) {
+ StringName advance_condition_name = p_state_machine->transitions[i].transition->get_advance_condition_name();
+ if (advance_condition_name != StringName() && bool(p_state_machine->get_parameter(advance_condition_name))) {
auto_advance = true;
}
- if (sm->transitions[i].from == current && auto_advance) {
+ if (p_state_machine->transitions[i].from == current && auto_advance) {
- if (sm->transitions[i].transition->get_priority() <= priority_best) {
- priority_best = sm->transitions[i].transition->get_priority();
+ if (p_state_machine->transitions[i].transition->get_priority() <= priority_best) {
+ priority_best = p_state_machine->transitions[i].transition->get_priority();
auto_advance_to = i;
}
}
}
if (auto_advance_to != -1) {
- next = sm->transitions[auto_advance_to].to;
- next_xfade = sm->transitions[auto_advance_to].transition->get_xfade_time();
- switch_mode = sm->transitions[auto_advance_to].transition->get_switch_mode();
+ next = p_state_machine->transitions[auto_advance_to].to;
+ next_xfade = p_state_machine->transitions[auto_advance_to].transition->get_xfade_time();
+ switch_mode = p_state_machine->transitions[auto_advance_to].transition->get_switch_mode();
}
}
@@ -467,12 +467,12 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *sm,
}
current = next;
if (switch_mode == AnimationNodeStateMachineTransition::SWITCH_MODE_SYNC) {
- len_current = sm->blend_node(current, sm->states[current].node, 0, true, 0, AnimationNode::FILTER_IGNORE, false);
+ len_current = p_state_machine->blend_node(current, p_state_machine->states[current].node, 0, true, 0, AnimationNode::FILTER_IGNORE, false);
pos_current = MIN(pos_current, len_current);
- sm->blend_node(current, sm->states[current].node, pos_current, true, 0, AnimationNode::FILTER_IGNORE, false);
+ p_state_machine->blend_node(current, p_state_machine->states[current].node, pos_current, true, 0, AnimationNode::FILTER_IGNORE, false);
} else {
- len_current = sm->blend_node(current, sm->states[current].node, 0, true, 0, AnimationNode::FILTER_IGNORE, false);
+ len_current = p_state_machine->blend_node(current, p_state_machine->states[current].node, 0, true, 0, AnimationNode::FILTER_IGNORE, false);
pos_current = 0;
}
@@ -482,9 +482,9 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *sm,
}
//compute time left for transitions by using the end node
- if (sm->end_node != StringName() && sm->end_node != current) {
+ if (p_state_machine->end_node != StringName() && p_state_machine->end_node != current) {
- rem = sm->blend_node(sm->end_node, sm->states[sm->end_node].node, 0, true, 0, AnimationNode::FILTER_IGNORE, false);
+ rem = p_state_machine->blend_node(p_state_machine->end_node, p_state_machine->states[p_state_machine->end_node].node, 0, true, 0, AnimationNode::FILTER_IGNORE, false);
}
return rem;
diff --git a/scene/animation/root_motion_view.h b/scene/animation/root_motion_view.h
index 07f51165a7..b30b06229e 100644
--- a/scene/animation/root_motion_view.h
+++ b/scene/animation/root_motion_view.h
@@ -56,7 +56,7 @@ public:
void set_animation_path(const NodePath &p_path);
NodePath get_animation_path() const;
- void set_color(const Color &p_path);
+ void set_color(const Color &p_color);
Color get_color() const;
void set_cell_size(float p_size);
diff --git a/scene/animation/skeleton_ik.cpp b/scene/animation/skeleton_ik.cpp
index 06d6806f03..43c4b2aa51 100644
--- a/scene/animation/skeleton_ik.cpp
+++ b/scene/animation/skeleton_ik.cpp
@@ -423,7 +423,6 @@ void SkeletonIK::_notification(int p_what) {
}
SkeletonIK::SkeletonIK() :
- Node(),
interpolation(1),
override_tip_basis(true),
use_magnet(false),
diff --git a/scene/animation/skeleton_ik.h b/scene/animation/skeleton_ik.h
index 5d48b7be33..d2c5f56ace 100644
--- a/scene/animation/skeleton_ik.h
+++ b/scene/animation/skeleton_ik.h
@@ -165,7 +165,7 @@ protected:
_validate_property(PropertyInfo &property) const;
static void _bind_methods();
- virtual void _notification(int p_notification);
+ virtual void _notification(int p_what);
public:
SkeletonIK();
@@ -192,7 +192,7 @@ public:
void set_use_magnet(bool p_use);
bool is_using_magnet() const;
- void set_magnet_position(const Vector3 &p_constraint);
+ void set_magnet_position(const Vector3 &p_local_position);
const Vector3 &get_magnet_position() const;
void set_min_distance(real_t p_min_distance);
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp
index c70e58564f..4dee4e1d12 100644
--- a/scene/animation/tween.cpp
+++ b/scene/animation/tween.cpp
@@ -583,9 +583,7 @@ bool Tween::_apply_tween_value(InterpolateData &p_data, Variant &value) {
}
// Did we get an error from the function call?
- if (error.error == Variant::CallError::CALL_OK)
- return true;
- return false;
+ return error.error == Variant::CallError::CALL_OK;
}
case INTER_CALLBACK:
diff --git a/scene/audio/audio_stream_player.cpp b/scene/audio/audio_stream_player.cpp
index 2def9fe8fc..c053fceb74 100644
--- a/scene/audio/audio_stream_player.cpp
+++ b/scene/audio/audio_stream_player.cpp
@@ -339,7 +339,7 @@ void AudioStreamPlayer::set_stream_paused(bool p_pause) {
if (p_pause != stream_paused) {
stream_paused = p_pause;
- stream_paused_fade = p_pause ? true : false;
+ stream_paused_fade = p_pause;
}
}
diff --git a/scene/gui/box_container.cpp b/scene/gui/box_container.cpp
index cc37d4cf7d..b7d2131ee9 100644
--- a/scene/gui/box_container.cpp
+++ b/scene/gui/box_container.cpp
@@ -91,7 +91,6 @@ void BoxContainer::_resort() {
int stretch_diff = stretch_max - stretch_min;
if (stretch_diff < 0) {
//avoid negative stretch space
- stretch_max = stretch_min;
stretch_diff = 0;
}
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 58a0762469..b197971b61 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -173,7 +173,7 @@ void ColorPicker::_value_changed(double) {
color.set_hsv(scroll[0]->get_value() / 360.0,
scroll[1]->get_value() / 100.0,
scroll[2]->get_value() / 100.0,
- scroll[3]->get_value() / 100.0);
+ scroll[3]->get_value() / 255.0);
} else {
for (int i = 0; i < 4; i++) {
color.components[i] = scroll[i]->get_value() / (raw_mode_enabled ? 1.0 : 255.0);
@@ -209,17 +209,17 @@ void ColorPicker::_update_color(bool p_update_sliders) {
if (hsv_mode_enabled) {
for (int i = 0; i < 4; i++) {
- scroll[i]->set_step(0.1);
+ scroll[i]->set_step(1.0);
}
- scroll[0]->set_max(360);
+ scroll[0]->set_max(359);
scroll[0]->set_value(h * 360.0);
scroll[1]->set_max(100);
scroll[1]->set_value(s * 100.0);
scroll[2]->set_max(100);
scroll[2]->set_value(v * 100.0);
- scroll[3]->set_max(100);
- scroll[3]->set_value(color.components[3] * 100.0);
+ scroll[3]->set_max(255);
+ scroll[3]->set_value(color.components[3] * 255.0);
} else {
for (int i = 0; i < 4; i++) {
if (raw_mode_enabled) {
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 0845b56828..6e0e26312f 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -1042,55 +1042,37 @@ int Control::get_constant(const StringName &p_name, const StringName &p_type) co
bool Control::has_icon_override(const StringName &p_name) const {
const Ref<Texture> *tex = data.icon_override.getptr(p_name);
- if (tex)
- return true;
- else
- return false;
+ return tex != NULL;
}
bool Control::has_shader_override(const StringName &p_name) const {
const Ref<Shader> *sdr = data.shader_override.getptr(p_name);
- if (sdr)
- return true;
- else
- return false;
+ return sdr != NULL;
}
bool Control::has_stylebox_override(const StringName &p_name) const {
const Ref<StyleBox> *style = data.style_override.getptr(p_name);
- if (style)
- return true;
- else
- return false;
+ return style != NULL;
}
bool Control::has_font_override(const StringName &p_name) const {
const Ref<Font> *font = data.font_override.getptr(p_name);
- if (font)
- return true;
- else
- return false;
+ return font != NULL;
}
bool Control::has_color_override(const StringName &p_name) const {
const Color *color = data.color_override.getptr(p_name);
- if (color)
- return true;
- else
- return false;
+ return color != NULL;
}
bool Control::has_constant_override(const StringName &p_name) const {
const int *constant = data.constant_override.getptr(p_name);
- if (constant)
- return true;
- else
- return false;
+ return constant != NULL;
}
bool Control::has_icon(const StringName &p_name, const StringName &p_type) const {
@@ -1997,10 +1979,7 @@ Control *Control::find_next_valid_focus() const {
break;
}
- if (next_child) {
-
- from = next_child;
- } else {
+ if (!next_child) {
next_child = _next_control(from);
if (!next_child) { //nothing else.. go up and find either window or subwindow
diff --git a/scene/gui/control.h b/scene/gui/control.h
index a6f9a442ae..2489a5eda4 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -139,8 +139,8 @@ private:
bool operator()(const Control *p_a, const Control *p_b) const {
if (p_a->get_canvas_layer() == p_b->get_canvas_layer())
return p_b->is_greater_than(p_a);
- else
- return p_a->get_canvas_layer() < p_b->get_canvas_layer();
+
+ return p_a->get_canvas_layer() < p_b->get_canvas_layer();
}
};
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index bc8dcf0e82..ba4d390fc5 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -302,11 +302,8 @@ bool FileDialog::_is_open_should_be_disabled() {
Dictionary d = ti->get_metadata(0);
// Opening a file, but selected a folder? Forbidden.
- if (((mode == MODE_OPEN_FILE || mode == MODE_OPEN_FILES) && d["dir"]) || // Flipped case, also forbidden.
- (mode == MODE_OPEN_DIR && !d["dir"]))
- return true;
-
- return false;
+ return ((mode == MODE_OPEN_FILE || mode == MODE_OPEN_FILES) && d["dir"]) || // Flipped case, also forbidden.
+ (mode == MODE_OPEN_DIR && !d["dir"]);
}
void FileDialog::_go_up() {
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index dabff08fea..f238aeb392 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -479,7 +479,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
connecting_color = gn->get_connection_input_color(j);
connecting_target = false;
connecting_to = pos;
- just_disconnected = true;
+ just_disconnected = false;
return;
}
@@ -550,11 +550,18 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
emit_signal("connection_request", from, from_slot, to, to_slot);
} else if (!just_disconnected) {
+
String from = connecting_from;
int from_slot = connecting_index;
Vector2 ofs = Vector2(mb->get_position().x, mb->get_position().y);
- emit_signal("connection_to_empty", from, from_slot, ofs);
+
+ if (!connecting_out) {
+ emit_signal("connection_from_empty", from, from_slot, ofs);
+ } else {
+ emit_signal("connection_to_empty", from, from_slot, ofs);
+ }
}
+
connecting = false;
top_layer->update();
update();
@@ -1292,6 +1299,7 @@ void GraphEdit::_bind_methods() {
ADD_SIGNAL(MethodInfo("duplicate_nodes_request"));
ADD_SIGNAL(MethodInfo("node_selected", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
ADD_SIGNAL(MethodInfo("connection_to_empty", PropertyInfo(Variant::STRING, "from"), PropertyInfo(Variant::INT, "from_slot"), PropertyInfo(Variant::VECTOR2, "release_position")));
+ ADD_SIGNAL(MethodInfo("connection_from_empty", PropertyInfo(Variant::STRING, "to"), PropertyInfo(Variant::INT, "to_slot"), PropertyInfo(Variant::VECTOR2, "release_position")));
ADD_SIGNAL(MethodInfo("delete_nodes_request"));
ADD_SIGNAL(MethodInfo("_begin_node_move"));
ADD_SIGNAL(MethodInfo("_end_node_move"));
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index e3e9368a12..510f1b18ad 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -247,11 +247,11 @@ void Label::_notification(int p_what) {
n = String::char_uppercase(n);
}
- float move = font->draw_char(ci, Point2(x_ofs_shadow, y_ofs) + shadow_ofs, c, n, font_color_shadow, false);
+ float move = drawer.draw_char(ci, Point2(x_ofs_shadow, y_ofs) + shadow_ofs, c, n, font_color_shadow);
if (use_outline) {
- font->draw_char(ci, Point2(x_ofs_shadow, y_ofs) + Vector2(-shadow_ofs.x, shadow_ofs.y), c, n, font_color_shadow, false);
- font->draw_char(ci, Point2(x_ofs_shadow, y_ofs) + Vector2(shadow_ofs.x, -shadow_ofs.y), c, n, font_color_shadow, false);
- font->draw_char(ci, Point2(x_ofs_shadow, y_ofs) + Vector2(-shadow_ofs.x, -shadow_ofs.y), c, n, font_color_shadow, false);
+ drawer.draw_char(ci, Point2(x_ofs_shadow, y_ofs) + Vector2(-shadow_ofs.x, shadow_ofs.y), c, n, font_color_shadow);
+ drawer.draw_char(ci, Point2(x_ofs_shadow, y_ofs) + Vector2(shadow_ofs.x, -shadow_ofs.y), c, n, font_color_shadow);
+ drawer.draw_char(ci, Point2(x_ofs_shadow, y_ofs) + Vector2(-shadow_ofs.x, -shadow_ofs.y), c, n, font_color_shadow);
}
x_ofs_shadow += move;
chars_total_shadow++;
@@ -470,7 +470,6 @@ void Label::regenerate_word_cache() {
wc->word_len = i - word_pos;
wc->space_count = space_count;
current_word_size = char_width;
- space_count = 0;
word_pos = i;
}
}
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index da6bff8ab8..7a015f77db 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -623,10 +623,7 @@ bool LineEdit::_is_over_clear_button(const Point2 &p_pos) const {
}
Ref<Texture> icon = Control::get_icon("clear");
int x_ofs = get_stylebox("normal")->get_offset().x;
- if (p_pos.x > get_size().width - icon->get_width() - x_ofs) {
- return true;
- }
- return false;
+ return p_pos.x > get_size().width - icon->get_width() - x_ofs;
}
void LineEdit::_notification(int p_what) {
@@ -650,6 +647,11 @@ void LineEdit::_notification(int p_what) {
set_cursor_position(get_cursor_position());
} break;
+ case NOTIFICATION_TRANSLATION_CHANGED: {
+ placeholder_translated = tr(placeholder);
+ update_placeholder_width();
+ update();
+ } break;
case MainLoop::NOTIFICATION_WM_FOCUS_IN: {
window_has_focus = true;
draw_caret = true;
@@ -675,10 +677,8 @@ void LineEdit::_notification(int p_what) {
RID ci = get_canvas_item();
Ref<StyleBox> style = get_stylebox("normal");
- float disabled_alpha = 1.0; // used to set the disabled input text color
if (!is_editable()) {
style = get_stylebox("read_only");
- disabled_alpha = .5;
draw_caret = false;
}
@@ -724,20 +724,19 @@ void LineEdit::_notification(int p_what) {
int font_ascent = font->get_ascent();
Color selection_color = get_color("selection_color");
- Color font_color = get_color("font_color");
+ Color font_color = is_editable() ? get_color("font_color") : get_color("font_color_uneditable");
Color font_color_selected = get_color("font_color_selected");
Color cursor_color = get_color("cursor_color");
- const String &t = using_placeholder ? placeholder : text;
+ const String &t = using_placeholder ? placeholder_translated : text;
// draw placeholder color
if (using_placeholder)
font_color.a *= placeholder_alpha;
- font_color.a *= disabled_alpha;
bool display_clear_icon = !using_placeholder && is_editable() && clear_button_enabled;
if (right_icon.is_valid() || display_clear_icon) {
Ref<Texture> r_icon = display_clear_icon ? Control::get_icon("clear") : right_icon;
- Color color_icon(1, 1, 1, disabled_alpha * .9);
+ Color color_icon(1, 1, 1, !is_editable() ? .5 * .9 : .9);
if (display_clear_icon) {
if (clear_button_status.press_attempt && clear_button_status.pressing_inside) {
color_icon = get_color("clear_button_color_pressed");
@@ -1148,16 +1147,9 @@ String LineEdit::get_text() const {
void LineEdit::set_placeholder(String p_text) {
- placeholder = tr(p_text);
- if ((max_length <= 0) || (placeholder.length() <= max_length)) {
- Ref<Font> font = get_font("font");
- cached_placeholder_width = 0;
- if (font != NULL) {
- for (int i = 0; i < placeholder.length(); i++) {
- cached_placeholder_width += font->get_char_size(placeholder[i]).width;
- }
- }
- }
+ placeholder = p_text;
+ placeholder_translated = tr(placeholder);
+ update_placeholder_width();
update();
}
@@ -1546,6 +1538,18 @@ void LineEdit::_emit_text_change() {
text_changed_dirty = false;
}
+void LineEdit::update_placeholder_width() {
+ if ((max_length <= 0) || (placeholder_translated.length() <= max_length)) {
+ Ref<Font> font = get_font("font");
+ cached_placeholder_width = 0;
+ if (font != NULL) {
+ for (int i = 0; i < placeholder_translated.length(); i++) {
+ cached_placeholder_width += font->get_char_size(placeholder_translated[i]).width;
+ }
+ }
+ }
+}
+
void LineEdit::_clear_redo() {
_create_undo_state();
if (undo_stack_pos == NULL) {
diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h
index 3b29780dc0..3002f6f637 100644
--- a/scene/gui/line_edit.h
+++ b/scene/gui/line_edit.h
@@ -72,6 +72,7 @@ private:
String undo_text;
String text;
String placeholder;
+ String placeholder_translated;
String secret_character;
float placeholder_alpha;
String ime_text;
@@ -126,6 +127,8 @@ private:
void _emit_text_change();
bool expand_to_text_length;
+ void update_placeholder_width();
+
bool caret_blink_enabled;
bool draw_caret;
bool window_has_focus;
diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp
index fdb1b65f77..492e379440 100644
--- a/scene/gui/popup.cpp
+++ b/scene/gui/popup.cpp
@@ -141,7 +141,7 @@ void Popup::popup_centered(const Size2 &p_size) {
rect.size = p_size == Size2() ? get_size() : p_size;
rect.position = ((window_size - rect.size) / 2.0).floor();
- popup(rect);
+ _popup(rect, true);
}
void Popup::popup_centered_ratio(float p_screen_ratio) {
@@ -151,18 +151,29 @@ void Popup::popup_centered_ratio(float p_screen_ratio) {
rect.size = (window_size * p_screen_ratio).floor();
rect.position = ((window_size - rect.size) / 2.0).floor();
- popup(rect);
+ _popup(rect, true);
}
void Popup::popup(const Rect2 &p_bounds) {
+ _popup(p_bounds);
+}
+
+void Popup::_popup(const Rect2 &p_bounds, const bool p_centered) {
+
emit_signal("about_to_show");
show_modal(exclusive);
// Fit the popup into the optionally provided bounds.
if (!p_bounds.has_no_area()) {
- set_position(p_bounds.position);
set_size(p_bounds.size);
+
+ // check if p_bounds.size was using an outdated cached values
+ if (p_centered && p_bounds.size != get_size()) {
+ set_position(p_bounds.position - ((get_size() - p_bounds.size) / 2.0).floor());
+ } else {
+ set_position(p_bounds.position);
+ }
}
_fix_size();
diff --git a/scene/gui/popup.h b/scene/gui/popup.h
index 6615c51ec5..d6d96dfe64 100644
--- a/scene/gui/popup.h
+++ b/scene/gui/popup.h
@@ -43,6 +43,9 @@ class Popup : public Control {
bool exclusive;
bool popped_up;
+private:
+ void _popup(const Rect2 &p_bounds = Rect2(), const bool p_centered = false);
+
protected:
virtual void _post_popup() {}
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 8891f679ee..5b91299de6 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -314,6 +314,18 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
align = align_it->align;
} break;
+ case ITEM_INDENT: {
+
+ if (it != l.from) {
+ ItemIndent *indent_it = static_cast<ItemIndent *>(it);
+
+ int indent = indent_it->level * tab_size * cfont->get_char_size(' ').width;
+ margin += indent;
+ begin += indent;
+ wofs += indent;
+ }
+
+ } break;
case ITEM_TEXT: {
ItemText *text = static_cast<ItemText *>(it);
@@ -447,14 +459,13 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
if (p_font_color_shadow.a > 0) {
float x_ofs_shadow = align_ofs + pofs;
float y_ofs_shadow = y + lh - line_descent;
- float move = font->draw_char(ci, Point2(x_ofs_shadow, y_ofs_shadow) + shadow_ofs, c[i], c[i + 1], p_font_color_shadow);
+ font->draw_char(ci, Point2(x_ofs_shadow, y_ofs_shadow) + shadow_ofs, c[i], c[i + 1], p_font_color_shadow);
if (p_shadow_as_outline) {
font->draw_char(ci, Point2(x_ofs_shadow, y_ofs_shadow) + Vector2(-shadow_ofs.x, shadow_ofs.y), c[i], c[i + 1], p_font_color_shadow);
font->draw_char(ci, Point2(x_ofs_shadow, y_ofs_shadow) + Vector2(shadow_ofs.x, -shadow_ofs.y), c[i], c[i + 1], p_font_color_shadow);
font->draw_char(ci, Point2(x_ofs_shadow, y_ofs_shadow) + Vector2(-shadow_ofs.x, -shadow_ofs.y), c[i], c[i + 1], p_font_color_shadow);
}
- x_ofs_shadow += move;
}
if (selected) {
@@ -935,84 +946,80 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
return;
if (b->get_button_index() == BUTTON_LEFT) {
+ if (b->is_pressed() && !b->is_doubleclick()) {
+ scroll_updated = false;
+ int line = 0;
+ Item *item = NULL;
- if (true) {
+ bool outside;
+ _find_click(main, b->get_position(), &item, &line, &outside);
- if (b->is_pressed() && !b->is_doubleclick()) {
- scroll_updated = false;
- int line = 0;
- Item *item = NULL;
+ if (item) {
- bool outside;
- _find_click(main, b->get_position(), &item, &line, &outside);
-
- if (item) {
+ if (selection.enabled) {
- if (selection.enabled) {
+ selection.click = item;
+ selection.click_char = line;
- selection.click = item;
- selection.click_char = line;
+ // Erase previous selection.
+ if (selection.active) {
+ selection.from = NULL;
+ selection.from_char = '\0';
+ selection.to = NULL;
+ selection.to_char = '\0';
+ selection.active = false;
- // Erase previous selection.
- if (selection.active) {
- selection.from = NULL;
- selection.from_char = '\0';
- selection.to = NULL;
- selection.to_char = '\0';
- selection.active = false;
-
- update();
- }
+ update();
}
}
- } else if (b->is_pressed() && b->is_doubleclick() && selection.enabled) {
+ }
+ } else if (b->is_pressed() && b->is_doubleclick() && selection.enabled) {
- //doubleclick: select word
- int line = 0;
- Item *item = NULL;
- bool outside;
+ //doubleclick: select word
+ int line = 0;
+ Item *item = NULL;
+ bool outside;
- _find_click(main, b->get_position(), &item, &line, &outside);
+ _find_click(main, b->get_position(), &item, &line, &outside);
- while (item && item->type != ITEM_TEXT) {
+ while (item && item->type != ITEM_TEXT) {
- item = _get_next_item(item, true);
- }
+ item = _get_next_item(item, true);
+ }
- if (item && item->type == ITEM_TEXT) {
+ if (item && item->type == ITEM_TEXT) {
- String itext = static_cast<ItemText *>(item)->text;
+ String itext = static_cast<ItemText *>(item)->text;
- int beg, end;
- if (select_word(itext, line, beg, end)) {
+ int beg, end;
+ if (select_word(itext, line, beg, end)) {
- selection.from = item;
- selection.to = item;
- selection.from_char = beg;
- selection.to_char = end - 1;
- selection.active = true;
- update();
- }
+ selection.from = item;
+ selection.to = item;
+ selection.from_char = beg;
+ selection.to_char = end - 1;
+ selection.active = true;
+ update();
}
- } else if (!b->is_pressed()) {
+ }
+ } else if (!b->is_pressed()) {
- selection.click = NULL;
+ selection.click = NULL;
- if (!b->is_doubleclick() && !scroll_updated) {
- int line = 0;
- Item *item = NULL;
+ if (!b->is_doubleclick() && !scroll_updated) {
+ int line = 0;
+ Item *item = NULL;
- bool outside;
- _find_click(main, b->get_position(), &item, &line, &outside);
+ bool outside;
+ _find_click(main, b->get_position(), &item, &line, &outside);
- if (item) {
+ if (item) {
- Variant meta;
- if (!outside && _find_meta(item, &meta)) {
- //meta clicked
+ Variant meta;
+ if (!outside && _find_meta(item, &meta)) {
+ //meta clicked
- emit_signal("meta_clicked", meta);
- }
+ emit_signal("meta_clicked", meta);
}
}
}
@@ -1301,6 +1308,23 @@ bool RichTextLabel::_find_meta(Item *p_item, Variant *r_meta, ItemMeta **r_item)
return false;
}
+bool RichTextLabel::_find_layout_subitem(Item *from, Item *to) {
+
+ if (from && from != to) {
+ if (from->type != ITEM_FONT && from->type != ITEM_COLOR && from->type != ITEM_UNDERLINE && from->type != ITEM_STRIKETHROUGH)
+ return true;
+
+ for (List<Item *>::Element *E = from->subitems.front(); E; E = E->next()) {
+ bool layout = _find_layout_subitem(E->get(), to);
+
+ if (layout)
+ return true;
+ }
+ }
+
+ return false;
+}
+
void RichTextLabel::_validate_line_caches(ItemFrame *p_frame) {
if (p_frame->first_invalid_line == p_frame->lines.size())
@@ -1421,7 +1445,7 @@ void RichTextLabel::_add_item(Item *p_item, bool p_enter, bool p_ensure_newline)
if (p_ensure_newline) {
Item *from = current_frame->lines[current_frame->lines.size() - 1].from;
// only create a new line for Item types that generate content/layout, ignore those that represent formatting/styling
- if (from && from->type != ITEM_FONT && from->type != ITEM_COLOR && from->type != ITEM_UNDERLINE && from->type != ITEM_STRIKETHROUGH) {
+ if (_find_layout_subitem(from, p_item)) {
_invalidate_current_line(current_frame);
current_frame->lines.resize(current_frame->lines.size() + 1);
}
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index 114c6103e2..21d099c37a 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -286,6 +286,7 @@ private:
bool _find_underline(Item *p_item);
bool _find_strikethrough(Item *p_item);
bool _find_meta(Item *p_item, Variant *r_meta, ItemMeta **r_item = NULL);
+ bool _find_layout_subitem(Item *from, Item *to);
void _update_scroll();
void _scroll_changed(double);
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index a1034937b5..d83ae47671 100644
--- a/scene/gui/scroll_container.cpp
+++ b/scene/gui/scroll_container.cpp
@@ -140,19 +140,17 @@ void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) {
_cancel_drag();
}
- if (true) {
- drag_speed = Vector2();
- drag_accum = Vector2();
- last_drag_accum = Vector2();
- drag_from = Vector2(h_scroll->get_value(), v_scroll->get_value());
- drag_touching = OS::get_singleton()->has_touchscreen_ui_hint();
- drag_touching_deaccel = false;
- beyond_deadzone = false;
+ drag_speed = Vector2();
+ drag_accum = Vector2();
+ last_drag_accum = Vector2();
+ drag_from = Vector2(h_scroll->get_value(), v_scroll->get_value());
+ drag_touching = OS::get_singleton()->has_touchscreen_ui_hint();
+ drag_touching_deaccel = false;
+ beyond_deadzone = false;
+ time_since_motion = 0;
+ if (drag_touching) {
+ set_physics_process_internal(true);
time_since_motion = 0;
- if (drag_touching) {
- set_physics_process_internal(true);
- time_since_motion = 0;
- }
}
} else {
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 4e86e4bb1e..fdd21f525b 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -662,10 +662,8 @@ void TextEdit::_notification(int p_what) {
int xmargin_end = size.width - cache.style_normal->get_margin(MARGIN_RIGHT);
//let's do it easy for now:
cache.style_normal->draw(ci, Rect2(Point2(), size));
- float readonly_alpha = 1.0; // used to set the input text color when in read-only mode
if (readonly) {
cache.style_readonly->draw(ci, Rect2(Point2(), size));
- readonly_alpha = .5;
draw_caret = false;
}
if (has_focus())
@@ -675,8 +673,7 @@ void TextEdit::_notification(int p_what) {
int visible_rows = get_visible_rows() + 1;
- Color color = cache.font_color;
- color.a *= readonly_alpha;
+ Color color = readonly ? cache.font_color_readonly : cache.font_color;
if (syntax_coloring) {
if (cache.background_color.a > 0.01) {
@@ -871,10 +868,7 @@ void TextEdit::_notification(int p_what) {
color_map = _get_line_syntax_highlighting(line);
}
// ensure we at least use the font color
- Color current_color = cache.font_color;
- if (readonly) {
- current_color.a *= readonly_alpha;
- }
+ Color current_color = readonly ? cache.font_color_readonly : cache.font_color;
bool underlined = false;
@@ -1061,10 +1055,7 @@ void TextEdit::_notification(int p_what) {
if (syntax_coloring) {
if (color_map.has(last_wrap_column + j)) {
- current_color = color_map[last_wrap_column + j].color;
- if (readonly) {
- current_color.a *= readonly_alpha;
- }
+ current_color = readonly ? cache.font_color_readonly : color_map[last_wrap_column + j].color;
}
color = current_color;
}
@@ -1252,8 +1243,7 @@ void TextEdit::_notification(int p_what) {
if (cursor.column == last_wrap_column + j && cursor.line == line && cursor_wrap_index == line_wrap_index && block_caret && draw_caret && !insert_mode) {
color = cache.caret_background_color;
} else if (!syntax_coloring && block_caret) {
- color = cache.font_color;
- color.a *= readonly_alpha;
+ color = readonly ? cache.font_color_readonly : cache.font_color;
}
if (str[j] >= 32) {
@@ -1603,7 +1593,6 @@ void TextEdit::_consume_pair_symbol(CharType ch) {
insert_text_at_cursor(ch_pair);
cursor_set_column(cursor_position_to_move);
- return;
}
void TextEdit::_consume_backspace_for_pair_symbol(int prev_line, int prev_column) {
@@ -4555,6 +4544,7 @@ void TextEdit::_update_caches() {
cache.safe_line_number_color = get_color("safe_line_number_color");
cache.font_color = get_color("font_color");
cache.font_color_selected = get_color("font_color_selected");
+ cache.font_color_readonly = get_color("font_color_readonly");
cache.keyword_color = get_color("keyword_color");
cache.function_color = get_color("function_color");
cache.member_variable_color = get_color("member_variable_color");
@@ -5404,11 +5394,7 @@ bool TextEdit::is_line_comment(int p_line) const {
for (int i = 0; i < line_length - 1; i++) {
if (_is_symbol(text[p_line][i]) && cri_map.has(i)) {
const Text::ColorRegionInfo &cri = cri_map[i];
- if (color_regions[cri.region].begin_key == "#" || color_regions[cri.region].begin_key == "//") {
- return true;
- } else {
- return false;
- }
+ return color_regions[cri.region].begin_key == "#" || color_regions[cri.region].begin_key == "//";
} else if (_is_whitespace(text[p_line][i])) {
continue;
} else {
@@ -5457,9 +5443,7 @@ bool TextEdit::is_folded(int p_line) const {
ERR_FAIL_INDEX_V(p_line, text.size(), false);
if (p_line + 1 >= text.size())
return false;
- if (!is_line_hidden(p_line) && is_line_hidden(p_line + 1))
- return true;
- return false;
+ return !is_line_hidden(p_line) && is_line_hidden(p_line + 1);
}
Vector<int> TextEdit::get_folded_lines() const {
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index c721cf992e..30956ccb23 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -185,6 +185,7 @@ private:
Color safe_line_number_color;
Color font_color;
Color font_color_selected;
+ Color font_color_readonly;
Color keyword_color;
Color number_color;
Color function_color;
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 54370d02ba..c2493ab321 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -1128,6 +1128,8 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
for (int j = p_item->cells[i].buttons.size() - 1; j >= 0; j--) {
Ref<Texture> b = p_item->cells[i].buttons[j].texture;
Size2 s = b->get_size() + cache.button_pressed->get_minimum_size();
+ if (s.height < label_h)
+ s.height = label_h;
Point2i o = Point2i(ofs + w - s.width, p_pos.y) - cache.offset + p_draw_ofs;
@@ -1929,8 +1931,6 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
edited_col = col;
bool on_arrow = x > col_width - cache.select_arrow->get_width();
- bring_up_editor = false;
-
custom_popup_rect = Rect2i(get_global_position() + Point2i(col_ofs, _get_title_button_height() + y_ofs + item_h - cache.offset.y), Size2(get_column_width(col), item_h));
if (on_arrow || !p_item->cells[col].custom_button) {
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index ee23b24b3c..a580a7f8ac 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -1393,7 +1393,7 @@ Node *Node::get_node(const NodePath &p_path) const {
Node *node = get_node_or_null(p_path);
if (!node) {
ERR_EXPLAIN("Node not found: " + p_path);
- ERR_FAIL_COND_V(!node, NULL);
+ ERR_FAIL_V(NULL);
}
return node;
}
@@ -2477,21 +2477,18 @@ bool Node::has_node_and_resource(const NodePath &p_path) const {
if (!has_node(p_path))
return false;
- Node *node = get_node(p_path);
-
- bool result = false;
-
- node->get_indexed(p_path.get_subnames(), &result);
+ RES res;
+ Vector<StringName> leftover_path;
+ Node *node = get_node_and_resource(p_path, res, leftover_path, false);
- return result;
+ return (node && res.is_valid());
}
Array Node::_get_node_and_resource(const NodePath &p_path) {
- Node *node;
RES res;
Vector<StringName> leftover_path;
- node = get_node_and_resource(p_path, res, leftover_path);
+ Node *node = get_node_and_resource(p_path, res, leftover_path, false);
Array result;
if (node)
@@ -2521,7 +2518,7 @@ Node *Node::get_node_and_resource(const NodePath &p_path, RES &r_res, Vector<Str
int j = 0;
// If not p_last_is_property, we shouldn't consider the last one as part of the resource
- for (; j < p_path.get_subname_count() - p_last_is_property; j++) {
+ for (; j < p_path.get_subname_count() - (int)p_last_is_property; j++) {
RES new_res = j == 0 ? node->get(p_path.get_subname(j)) : r_res->get(p_path.get_subname(j));
if (new_res.is_null()) {
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index 7f0cebd492..0e7cec57a4 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -614,6 +614,7 @@ void SceneTree::finish() {
root->_set_tree(NULL);
root->_propagate_after_exit_tree();
memdelete(root); //delete root
+ root = NULL;
}
}
@@ -1889,6 +1890,7 @@ void SceneTree::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "debug_navigation_hint"), "set_debug_navigation_hint", "is_debugging_navigation_hint");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "paused"), "set_pause", "is_paused");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "refuse_new_network_connections"), "set_refuse_new_network_connections", "is_refusing_new_network_connections");
+ ADD_PROPERTY_DEFAULT("refuse_new_network_connections", false);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_font_oversampling"), "set_use_font_oversampling", "is_using_font_oversampling");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "edited_scene_root", PROPERTY_HINT_RESOURCE_TYPE, "Node", 0), "set_edited_scene_root", "get_edited_scene_root");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "current_scene", PROPERTY_HINT_RESOURCE_TYPE, "Node", 0), "set_current_scene", "get_current_scene");
@@ -1962,7 +1964,7 @@ bool SceneTree::is_using_font_oversampling() const {
SceneTree::SceneTree() {
- singleton = this;
+ if (singleton == NULL) singleton = this;
_quit = false;
accept_quit = true;
quit_on_go_back = true;
@@ -2107,4 +2109,11 @@ SceneTree::SceneTree() {
}
SceneTree::~SceneTree() {
+ if (root) {
+ root->_set_tree(NULL);
+ root->_propagate_after_exit_tree();
+ memdelete(root);
+ }
+
+ if (singleton == this) singleton = NULL;
}
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 10e5ad78e2..dcd70a1844 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -532,7 +532,7 @@ void Viewport::_notification(int p_what) {
Map<ObjectID, uint64_t>::Element *F = physics_2d_mouseover.find(res[i].collider_id);
if (!F) {
- F = physics_2d_mouseover.insert(res[i].collider_id, frame);
+ physics_2d_mouseover.insert(res[i].collider_id, frame);
co->_mouse_enter();
} else {
F->get() = frame;
diff --git a/scene/resources/concave_polygon_shape_2d.cpp b/scene/resources/concave_polygon_shape_2d.cpp
index 51dd91fff5..de853f0c30 100644
--- a/scene/resources/concave_polygon_shape_2d.cpp
+++ b/scene/resources/concave_polygon_shape_2d.cpp
@@ -104,4 +104,6 @@ void ConcavePolygonShape2D::_bind_methods() {
ConcavePolygonShape2D::ConcavePolygonShape2D() :
Shape2D(Physics2DServer::get_singleton()->concave_polygon_shape_create()) {
+ PoolVector<Vector2> empty;
+ set_segments(empty);
}
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index 2c5dfc375c..4e2fe1f9b2 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -398,6 +398,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_color("font_color", "LineEdit", control_font_color);
theme->set_color("font_color_selected", "LineEdit", Color(0, 0, 0));
+ theme->set_color("font_color_uneditable", "LineEdit", Color(control_font_color.r, control_font_color.g, control_font_color.b, 0.5f));
theme->set_color("cursor_color", "LineEdit", control_font_color_hover);
theme->set_color("selection_color", "LineEdit", font_color_selection);
theme->set_color("clear_button_color", "LineEdit", control_font_color);
@@ -439,6 +440,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_color("completion_font_color", "TextEdit", Color::html("aaaaaa"));
theme->set_color("font_color", "TextEdit", control_font_color);
theme->set_color("font_color_selected", "TextEdit", Color(0, 0, 0));
+ theme->set_color("font_color_readonly", "TextEdit", Color(control_font_color.r, control_font_color.g, control_font_color.b, 0.5f));
theme->set_color("selection_color", "TextEdit", font_color_selection);
theme->set_color("mark_color", "TextEdit", Color(1.0, 0.4, 0.4, 0.4));
theme->set_color("bookmark_color", "TextEdit", Color(0.08, 0.49, 0.98));
diff --git a/scene/resources/multimesh.cpp b/scene/resources/multimesh.cpp
index 5d8adc0c8d..99a17fb5b9 100644
--- a/scene/resources/multimesh.cpp
+++ b/scene/resources/multimesh.cpp
@@ -35,7 +35,7 @@ void MultiMesh::_set_transform_array(const PoolVector<Vector3> &p_array) {
if (transform_format != TRANSFORM_3D)
return;
- PoolVector<Vector3> xforms = p_array;
+ const PoolVector<Vector3> &xforms = p_array;
int len = xforms.size();
ERR_FAIL_COND((len / 4) != instance_count);
if (len == 0)
@@ -85,7 +85,7 @@ void MultiMesh::_set_transform_2d_array(const PoolVector<Vector2> &p_array) {
if (transform_format != TRANSFORM_2D)
return;
- PoolVector<Vector2> xforms = p_array;
+ const PoolVector<Vector2> &xforms = p_array;
int len = xforms.size();
ERR_FAIL_COND((len / 3) != instance_count);
if (len == 0)
@@ -130,7 +130,7 @@ PoolVector<Vector2> MultiMesh::_get_transform_2d_array() const {
void MultiMesh::_set_color_array(const PoolVector<Color> &p_array) {
- PoolVector<Color> colors = p_array;
+ const PoolVector<Color> &colors = p_array;
int len = colors.size();
if (len == 0)
return;
@@ -162,7 +162,7 @@ PoolVector<Color> MultiMesh::_get_color_array() const {
void MultiMesh::_set_custom_data_array(const PoolVector<Color> &p_array) {
- PoolVector<Color> custom_datas = p_array;
+ const PoolVector<Color> &custom_datas = p_array;
int len = custom_datas.size();
if (len == 0)
return;
diff --git a/scene/resources/particles_material.cpp b/scene/resources/particles_material.cpp
index a80a57a09c..691d73c181 100644
--- a/scene/resources/particles_material.cpp
+++ b/scene/resources/particles_material.cpp
@@ -184,7 +184,8 @@ void ParticlesMaterial::_update_shader() {
} break;
case EMISSION_SHAPE_DIRECTED_POINTS: {
code += "uniform sampler2D emission_texture_normal : hint_black;\n";
- } //fallthrough
+ FALLTHROUGH;
+ }
case EMISSION_SHAPE_POINTS: {
code += "uniform sampler2D emission_texture_points : hint_black;\n";
code += "uniform int emission_texture_point_count;\n";
diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp
index 04d13c8869..74a493d3b5 100644
--- a/scene/resources/primitive_meshes.cpp
+++ b/scene/resources/primitive_meshes.cpp
@@ -743,8 +743,6 @@ void CylinderMesh::_create_mesh_array(Array &p_arr) const {
int i, j, prevrow, thisrow, point;
float x, y, z, u, v, radius;
- radius = bottom_radius > top_radius ? bottom_radius : top_radius;
-
PoolVector<Vector3> points;
PoolVector<Vector3> normals;
PoolVector<float> tangents;
diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp
index efc1082a6b..339f008a3d 100644
--- a/scene/resources/resource_format_text.cpp
+++ b/scene/resources/resource_format_text.cpp
@@ -1324,7 +1324,7 @@ Error ResourceFormatLoaderText::convert_file_to_binary(const String &p_src_path,
ERR_FAIL_COND_V(err != OK, ERR_CANT_OPEN);
Ref<ResourceInteractiveLoaderText> ria = memnew(ResourceInteractiveLoaderText);
- String path = p_src_path;
+ const String &path = p_src_path;
ria->local_path = ProjectSettings::get_singleton()->localize_path(path);
ria->res_path = ria->local_path;
//ria->set_local_path( ProjectSettings::get_singleton()->localize_path(p_path) );
@@ -1441,7 +1441,7 @@ void ResourceFormatSaverTextInstance::_find_resources(const Variant &p_variant,
int len = varray.size();
for (int i = 0; i < len; i++) {
- Variant v = varray.get(i);
+ const Variant &v = varray.get(i);
_find_resources(v);
}
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 6e0bc43296..3a0144849a 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -1502,6 +1502,7 @@ void CubeMap::set_side(Side p_side, const Ref<Image> &p_image) {
Ref<Image> CubeMap::get_side(Side p_side) const {
+ ERR_FAIL_INDEX_V(p_side, 6, Ref<Image>());
if (!valid[p_side])
return Ref<Image>();
return VS::get_singleton()->texture_get_data(cubemap, VS::CubeMapSide(p_side));
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp
index a3813f8fc6..7265c9b457 100644
--- a/scene/resources/visual_shader.cpp
+++ b/scene/resources/visual_shader.cpp
@@ -257,7 +257,7 @@ bool VisualShader::can_connect_nodes(Type p_type, int p_from_node, int p_from_po
VisualShaderNode::PortType from_port_type = g->nodes[p_from_node].node->get_output_port_type(p_from_port);
VisualShaderNode::PortType to_port_type = g->nodes[p_to_node].node->get_input_port_type(p_to_port);
- if (MAX(0, from_port_type - 2) != (MAX(0, to_port_type - 2))) {
+ if (!is_port_types_compatible(from_port_type, to_port_type)) {
return false;
}
@@ -271,6 +271,10 @@ bool VisualShader::can_connect_nodes(Type p_type, int p_from_node, int p_from_po
return true;
}
+bool VisualShader::is_port_types_compatible(int p_a, int p_b) const {
+ return MAX(0, p_a - 2) == (MAX(0, p_b - 2));
+}
+
void VisualShader::connect_nodes_forced(Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port) {
ERR_FAIL_INDEX(p_type, TYPE_MAX);
Graph *g = &graph[p_type];
@@ -295,8 +299,8 @@ Error VisualShader::connect_nodes(Type p_type, int p_from_node, int p_from_port,
VisualShaderNode::PortType from_port_type = g->nodes[p_from_node].node->get_output_port_type(p_from_port);
VisualShaderNode::PortType to_port_type = g->nodes[p_to_node].node->get_input_port_type(p_to_port);
- if (MAX(0, from_port_type - 2) != (MAX(0, to_port_type - 2))) {
- ERR_EXPLAIN("Incompatible port types (scalar/vec/bool with transform");
+ if (!is_port_types_compatible(from_port_type, to_port_type)) {
+ ERR_EXPLAIN("Incompatible port types (scalar/vec/bool) with transform");
ERR_FAIL_V(ERR_INVALID_PARAMETER);
return ERR_INVALID_PARAMETER;
}
diff --git a/scene/resources/visual_shader.h b/scene/resources/visual_shader.h
index a36776e701..83db51b1b0 100644
--- a/scene/resources/visual_shader.h
+++ b/scene/resources/visual_shader.h
@@ -138,6 +138,7 @@ public:
Error connect_nodes(Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port);
void disconnect_nodes(Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port);
void connect_nodes_forced(Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port);
+ bool is_port_types_compatible(int p_a, int p_b) const;
void rebuild();
void get_node_connections(Type p_type, List<Connection> *r_connections) const;
diff --git a/scene/resources/visual_shader_nodes.h b/scene/resources/visual_shader_nodes.h
index df753276e4..ef64b50711 100644
--- a/scene/resources/visual_shader_nodes.h
+++ b/scene/resources/visual_shader_nodes.h
@@ -699,7 +699,7 @@ public:
virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
- void set_function(Function p_op);
+ void set_function(Function p_func);
Function get_function() const;
virtual Vector<StringName> get_editable_properties() const;
@@ -740,7 +740,7 @@ public:
virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
- void set_function(Function p_op);
+ void set_function(Function p_func);
Function get_function() const;
virtual Vector<StringName> get_editable_properties() const;
@@ -895,7 +895,7 @@ public:
virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
- void set_function(Function p_op);
+ void set_function(Function p_func);
Function get_function() const;
virtual Vector<StringName> get_editable_properties() const;
@@ -935,7 +935,7 @@ public:
virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
- void set_function(Function p_op);
+ void set_function(Function p_func);
Function get_function() const;
virtual Vector<StringName> get_editable_properties() const;