Skip to content

Commit

Permalink
Merge pull request #84575 from rsburke4/fix-cpu-tangent-force
Browse files Browse the repository at this point in the history
Fix `CPUParticles2D` tangential force does not match `GPUParticles2D`
  • Loading branch information
YuriSizov committed Dec 19, 2023
2 parents 8a9aa30 + 7637723 commit 5d9dce4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scene/2d/cpu_particles_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ void CPUParticles2D::_particles_process(double p_delta) {
force += diff.length() > 0.0 ? diff.normalized() * (tex_radial_accel)*Math::lerp(parameters_min[PARAM_RADIAL_ACCEL], parameters_max[PARAM_RADIAL_ACCEL], rand_from_seed(alt_seed)) : Vector2();
//apply tangential acceleration;
Vector2 yx = Vector2(diff.y, diff.x);
force += yx.length() > 0.0 ? yx.normalized() * (tex_tangential_accel * Math::lerp(parameters_min[PARAM_TANGENTIAL_ACCEL], parameters_max[PARAM_TANGENTIAL_ACCEL], rand_from_seed(alt_seed))) : Vector2();
force += yx.length() > 0.0 ? (yx * Vector2(-1.0, 1.0)).normalized() * (tex_tangential_accel * Math::lerp(parameters_min[PARAM_TANGENTIAL_ACCEL], parameters_max[PARAM_TANGENTIAL_ACCEL], rand_from_seed(alt_seed))) : Vector2();
//apply attractor forces
p.velocity += force * local_delta;
//orbit velocity
Expand Down

0 comments on commit 5d9dce4

Please sign in to comment.