From 7f60546f058e5eaf6f6d439a7be1dc83b7cca33c Mon Sep 17 00:00:00 2001 From: aaronp64 Date: Tue, 31 Dec 2024 10:42:29 -0500 Subject: [PATCH] Fix CPUParticles2D repeatedly scaling particles with 0 velocity and Align Y CPUParticles2D with Align Y turned on would update particles' transforms based on the velocity when velocity was non-zero, but would not set the transform for zero velocity. This left the transfrom value from the previous call, which may have already been scaled. In this case, each call to _particles_process would apply the scale again, causing the particle to repeatedly grow (or shrink for scales < 1.0). Updated the Align Y logic to always normalize the transform values before scale is applied. --- scene/2d/cpu_particles_2d.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp index a25c02facd8..6c7030d1189 100644 --- a/scene/2d/cpu_particles_2d.cpp +++ b/scene/2d/cpu_particles_2d.cpp @@ -1097,10 +1097,11 @@ void CPUParticles2D::_particles_process(double p_delta) { if (particle_flags[PARTICLE_FLAG_ALIGN_Y_TO_VELOCITY]) { if (p.velocity.length() > 0.0) { - p.transform.columns[1] = p.velocity.normalized(); - p.transform.columns[0] = p.transform.columns[1].orthogonal(); + p.transform.columns[1] = p.velocity; } + p.transform.columns[1] = p.transform.columns[1].normalized(); + p.transform.columns[0] = p.transform.columns[1].orthogonal(); } else { p.transform.columns[0] = Vector2(Math::cos(p.rotation), -Math::sin(p.rotation)); p.transform.columns[1] = Vector2(Math::sin(p.rotation), Math::cos(p.rotation));