summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/audio_stream_player_2d.cpp2
-rw-r--r--scene/2d/cpu_particles_2d.cpp2
-rw-r--r--scene/3d/audio_stream_player_3d.cpp2
-rw-r--r--scene/3d/cpu_particles.cpp23
-rw-r--r--scene/3d/cpu_particles.h2
-rw-r--r--scene/gui/control.cpp2
-rw-r--r--scene/gui/text_edit.cpp4
-rw-r--r--scene/gui/tree.cpp7
-rw-r--r--scene/resources/particles_material.cpp2
9 files changed, 31 insertions, 15 deletions
diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp
index a1ae05d971..9de72a4fcd 100644
--- a/scene/2d/audio_stream_player_2d.cpp
+++ b/scene/2d/audio_stream_player_2d.cpp
@@ -179,7 +179,7 @@ void AudioStreamPlayer2D::_notification(int p_what) {
Physics2DDirectSpaceState::ShapeResult sr[MAX_INTERSECT_AREAS];
- int areas = space_state->intersect_point(global_pos, sr, MAX_INTERSECT_AREAS, Set<RID>(), area_mask);
+ int areas = space_state->intersect_point(global_pos, sr, MAX_INTERSECT_AREAS, Set<RID>(), area_mask, false, true);
for (int i = 0; i < areas; i++) {
diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp
index d29c6b37d5..e6dcd643be 100644
--- a/scene/2d/cpu_particles_2d.cpp
+++ b/scene/2d/cpu_particles_2d.cpp
@@ -985,7 +985,7 @@ void CPUParticles2D::_notification(int p_what) {
if (p_what == NOTIFICATION_INTERNAL_PROCESS) {
- if (particles.size() == 0)
+ if (particles.size() == 0 || !is_visible_in_tree())
return;
float delta = get_process_delta_time();
diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp
index abf022ecb3..7ad43b722d 100644
--- a/scene/3d/audio_stream_player_3d.cpp
+++ b/scene/3d/audio_stream_player_3d.cpp
@@ -290,7 +290,7 @@ void AudioStreamPlayer3D::_notification(int p_what) {
PhysicsDirectSpaceState::ShapeResult sr[MAX_INTERSECT_AREAS];
- int areas = space_state->intersect_point(global_pos, sr, MAX_INTERSECT_AREAS, Set<RID>(), area_mask);
+ int areas = space_state->intersect_point(global_pos, sr, MAX_INTERSECT_AREAS, Set<RID>(), area_mask, false, true);
Area *area = NULL;
for (int i = 0; i < areas; i++) {
diff --git a/scene/3d/cpu_particles.cpp b/scene/3d/cpu_particles.cpp
index ec51c31674..35a2049bda 100644
--- a/scene/3d/cpu_particles.cpp
+++ b/scene/3d/cpu_particles.cpp
@@ -592,7 +592,7 @@ void CPUParticles::_particles_process(float p_delta) {
Vector3 direction_xz = Vector3(Math::sin(angle1_rad), 0, Math::cos(angle1_rad));
Vector3 direction_yz = Vector3(0, Math::sin(angle2_rad), Math::cos(angle2_rad));
- direction_yz.z = direction_yz.z / Math::sqrt(direction_yz.z); //better uniform distribution
+ direction_yz.z = direction_yz.z / MAX(0.0001, Math::sqrt(ABS(direction_yz.z))); //better uniform distribution
Vector3 direction = Vector3(direction_xz.x * direction_yz.z, direction_yz.y, direction_xz.z * direction_yz.z);
direction.normalize();
p.velocity = direction * parameters[PARAM_INITIAL_LINEAR_VELOCITY] * Math::lerp(1.0f, float(Math::randf()), randomness[PARAM_INITIAL_LINEAR_VELOCITY]);
@@ -977,6 +977,8 @@ void CPUParticles::_update_particle_data_buffer() {
ptr += 17;
}
+
+ can_update = true;
}
#ifndef NO_THREADS
@@ -989,8 +991,10 @@ void CPUParticles::_update_render_thread() {
#ifndef NO_THREADS
update_mutex->lock();
#endif
-
- VS::get_singleton()->multimesh_set_as_bulk_array(multimesh, particle_data);
+ if (can_update) {
+ VS::get_singleton()->multimesh_set_as_bulk_array(multimesh, particle_data);
+ can_update = false; //wait for next time
+ }
#ifndef NO_THREADS
update_mutex->unlock();
@@ -1032,7 +1036,7 @@ void CPUParticles::_notification(int p_what) {
if (p_what == NOTIFICATION_INTERNAL_PROCESS) {
- if (particles.size() == 0)
+ if (particles.size() == 0 || !is_visible_in_tree())
return;
float delta = get_process_delta_time();
@@ -1061,6 +1065,8 @@ void CPUParticles::_notification(int p_what) {
}
}
+ bool processed = false;
+
if (time == 0 && pre_process_time > 0.0) {
float frame_time;
@@ -1073,6 +1079,7 @@ void CPUParticles::_notification(int p_what) {
while (todo >= 0) {
_particles_process(frame_time);
+ processed = true;
todo -= frame_time;
}
}
@@ -1091,6 +1098,7 @@ void CPUParticles::_notification(int p_what) {
while (todo >= frame_time) {
_particles_process(frame_time);
+ processed = true;
todo -= decr;
}
@@ -1098,9 +1106,12 @@ void CPUParticles::_notification(int p_what) {
} else {
_particles_process(delta);
+ processed = true;
}
- _update_particle_data_buffer();
+ if (processed) {
+ _update_particle_data_buffer();
+ }
}
}
@@ -1424,6 +1435,8 @@ CPUParticles::CPUParticles() {
flags[i] = false;
}
+ can_update = false;
+
set_color(Color(1, 1, 1, 1));
#ifndef NO_THREADS
diff --git a/scene/3d/cpu_particles.h b/scene/3d/cpu_particles.h
index 4e29d8d4ce..77a144b70b 100644
--- a/scene/3d/cpu_particles.h
+++ b/scene/3d/cpu_particles.h
@@ -142,6 +142,8 @@ private:
int fixed_fps;
bool fractional_delta;
+ volatile bool can_update;
+
DrawOrder draw_order;
Ref<Mesh> mesh;
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index effcd0abee..e155d0ef86 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -769,7 +769,7 @@ void Control::force_drag(const Variant &p_data, Control *p_control) {
void Control::set_drag_preview(Control *p_control) {
ERR_FAIL_COND(!is_inside_tree());
- ERR_FAIL_COND(get_viewport()->gui_is_dragging());
+ ERR_FAIL_COND(!get_viewport()->gui_is_dragging());
get_viewport()->_gui_set_drag_preview(this, p_control);
}
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 32580a5ae6..f8a5c4cea3 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -2331,9 +2331,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
// no need to indent if we are going upwards.
if (auto_indent && !(k->get_command() && k->get_shift())) {
- // indent once again if previous line will end with ':' or '{'
+ // indent once again if previous line will end with ':' or '{' and the line is not a comment
// (i.e. colon/brace precedes current cursor position)
- if (cursor.column > 0 && (text[cursor.line][cursor.column - 1] == ':' || text[cursor.line][cursor.column - 1] == '{')) {
+ if (cursor.column > 0 && (text[cursor.line][cursor.column - 1] == ':' || text[cursor.line][cursor.column - 1] == '{') && !is_line_comment(cursor.line)) {
if (indent_using_spaces) {
ins += space_indent;
} else {
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 3a540d187b..0c11181f98 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -2183,6 +2183,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
Ref<InputEventKey> k = p_event;
+ bool is_command = k.is_valid() && k->get_command();
if (p_event->is_action("ui_right") && p_event->is_pressed()) {
if (!cursor_can_exit_tree) accept_event();
@@ -2219,13 +2220,13 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
_go_left();
}
- } else if (p_event->is_action("ui_up") && p_event->is_pressed() && !k->get_command()) {
+ } else if (p_event->is_action("ui_up") && p_event->is_pressed() && !is_command) {
if (!cursor_can_exit_tree) accept_event();
_go_up();
- } else if (p_event->is_action("ui_down") && p_event->is_pressed() && !k->get_command()) {
+ } else if (p_event->is_action("ui_down") && p_event->is_pressed() && !is_command) {
if (!cursor_can_exit_tree) accept_event();
@@ -2933,7 +2934,7 @@ void Tree::_notification(int p_what) {
if (show_column_titles) {
- //title butons
+ //title buttons
int ofs = cache.bg->get_margin(MARGIN_LEFT);
for (int i = 0; i < columns.size(); i++) {
diff --git a/scene/resources/particles_material.cpp b/scene/resources/particles_material.cpp
index 6f67ba8af1..ba48982fda 100644
--- a/scene/resources/particles_material.cpp
+++ b/scene/resources/particles_material.cpp
@@ -308,7 +308,7 @@ void ParticlesMaterial::_update_shader() {
code += " float angle2_rad = rand_from_seed_m1_p1(alt_seed) * spread_rad * (1.0 - flatness);\n";
code += " vec3 direction_xz = vec3(sin(angle1_rad), 0, cos(angle1_rad));\n";
code += " vec3 direction_yz = vec3(0, sin(angle2_rad), cos(angle2_rad));\n";
- code += " direction_yz.z = direction_yz.z / sqrt(direction_yz.z); // better uniform distribution\n";
+ code += " direction_yz.z = direction_yz.z / max(0.0001,sqrt(abs(direction_yz.z))); // better uniform distribution\n";
code += " vec3 direction = vec3(direction_xz.x * direction_yz.z, direction_yz.y, direction_xz.z * direction_yz.z);\n";
code += " direction = normalize(direction);\n";
code += " VELOCITY = direction * initial_linear_velocity * mix(1.0, rand_from_seed(alt_seed), initial_linear_velocity_random);\n";