summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2018-07-23 12:28:15 -0300
committerJuan Linietsky <reduzio@gmail.com>2018-07-23 12:28:50 -0300
commitec85fd554b0ae9861fddabbda1667a93bdd52450 (patch)
tree09d58f29ab90d951c040f971552355b3d54e5f20 /scene
parent0e8f2c81cc58399746fd8f7401cea65a11709acf (diff)
Fix issues with CPUParticles and related conversion from Particles. Closes #20126
Diffstat (limited to 'scene')
-rw-r--r--scene/3d/cpu_particles.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/scene/3d/cpu_particles.cpp b/scene/3d/cpu_particles.cpp
index 2e897c1c73..c3b0196316 100644
--- a/scene/3d/cpu_particles.cpp
+++ b/scene/3d/cpu_particles.cpp
@@ -25,6 +25,8 @@ void CPUParticles::set_emitting(bool p_emitting) {
update_mutex->lock();
#endif
VS::get_singleton()->connect("frame_pre_draw", this, "_update_render_thread");
+ VS::get_singleton()->instance_geometry_set_flag(get_instance(), VS::INSTANCE_FLAG_REDRAW_FRAME_IF_VISIBLE, true);
+
#ifndef NO_THREADS
update_mutex->unlock();
#endif
@@ -446,6 +448,8 @@ float rand_from_seed_m1_p1(uint32_t &seed) {
void CPUParticles::_particles_process(float p_delta) {
+ p_delta *= speed_scale;
+
int pcount = particles.size();
PoolVector<Particle>::Write w = particles.write();
@@ -475,7 +479,7 @@ void CPUParticles::_particles_process(float p_delta) {
if (!emitting && !p.active)
continue;
- float restart_time = float(i) / float(pcount);
+ float restart_time = (float(i) / float(pcount)) * lifetime;
float local_delta = p_delta;
if (randomness_ratio > 0.0) {
@@ -643,7 +647,7 @@ void CPUParticles::_particles_process(float p_delta) {
uint32_t alt_seed = p.seed;
p.time += local_delta;
- p.custom[1] += p.time / lifetime;
+ p.custom[1] = p.time / lifetime;
float tex_linear_velocity = 0.0;
if (curve_parameters[PARAM_INITIAL_LINEAR_VELOCITY].is_valid()) {
@@ -979,6 +983,7 @@ void CPUParticles::_notification(int p_what) {
update_mutex->lock();
#endif
VS::get_singleton()->connect("frame_pre_draw", this, "_update_render_thread");
+ VS::get_singleton()->instance_geometry_set_flag(get_instance(), VS::INSTANCE_FLAG_REDRAW_FRAME_IF_VISIBLE, true);
#ifndef NO_THREADS
update_mutex->unlock();
#endif
@@ -992,6 +997,7 @@ void CPUParticles::_notification(int p_what) {
update_mutex->lock();
#endif
VS::get_singleton()->disconnect("frame_pre_draw", this, "_update_render_thread");
+ VS::get_singleton()->instance_geometry_set_flag(get_instance(), VS::INSTANCE_FLAG_REDRAW_FRAME_IF_VISIBLE, false);
#ifndef NO_THREADS
update_mutex->unlock();
#endif
@@ -1018,6 +1024,8 @@ void CPUParticles::_notification(int p_what) {
update_mutex->lock();
#endif
VS::get_singleton()->disconnect("frame_pre_draw", this, "_update_render_thread");
+ VS::get_singleton()->instance_geometry_set_flag(get_instance(), VS::INSTANCE_FLAG_REDRAW_FRAME_IF_VISIBLE, false);
+
#ifndef NO_THREADS
update_mutex->unlock();
#endif