@@ -1044,19 +1044,19 @@ void CPUParticles3D::_particles_process(double p_delta) {
10441044 position.z = 0.0 ;
10451045 }
10461046 // apply linear acceleration
1047- force += p.velocity .length () > 0.0 ? p.velocity .normalized () * tex_linear_accel * Math::lerp (parameters_min[PARAM_LINEAR_ACCEL], parameters_max[PARAM_LINEAR_ACCEL], rand_from_seed (alt_seed)) : Vector3 ();
1047+ force += p.velocity .length_squared () > 0 .0f ? p.velocity .normalized () * tex_linear_accel * Math::lerp (parameters_min[PARAM_LINEAR_ACCEL], parameters_max[PARAM_LINEAR_ACCEL], rand_from_seed (alt_seed)) : Vector3 ();
10481048 // apply radial acceleration
10491049 Vector3 org = emission_xform.origin ;
10501050 Vector3 diff = position - org;
1051- 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)) : Vector3 ();
1051+ force += diff.length_squared () > 0 .0f ? diff.normalized () * (tex_radial_accel)*Math::lerp (parameters_min[PARAM_RADIAL_ACCEL], parameters_max[PARAM_RADIAL_ACCEL], rand_from_seed (alt_seed)) : Vector3 ();
10521052 if (particle_flags[PARTICLE_FLAG_DISABLE_Z]) {
10531053 Vector2 yx = Vector2 (diff.y , diff.x );
10541054 Vector2 yx2 = (yx * Vector2 (-1.0 , 1.0 )).normalized ();
1055- force += yx.length () > 0.0 ? Vector3 (yx2.x , yx2.y , 0.0 ) * (tex_tangential_accel * Math::lerp (parameters_min[PARAM_TANGENTIAL_ACCEL], parameters_max[PARAM_TANGENTIAL_ACCEL], rand_from_seed (alt_seed))) : Vector3 ();
1055+ force += yx.length_squared () > 0 .0f ? Vector3 (yx2.x , yx2.y , 0.0 ) * (tex_tangential_accel * Math::lerp (parameters_min[PARAM_TANGENTIAL_ACCEL], parameters_max[PARAM_TANGENTIAL_ACCEL], rand_from_seed (alt_seed))) : Vector3 ();
10561056
10571057 } else {
10581058 Vector3 crossDiff = diff.normalized ().cross (gravity.normalized ());
1059- force += crossDiff.length () > 0.0 ? crossDiff.normalized () * (tex_tangential_accel * Math::lerp (parameters_min[PARAM_TANGENTIAL_ACCEL], parameters_max[PARAM_TANGENTIAL_ACCEL], rand_from_seed (alt_seed))) : Vector3 ();
1059+ force += crossDiff.length_squared () > 0 .0f ? crossDiff.normalized () * (tex_tangential_accel * Math::lerp (parameters_min[PARAM_TANGENTIAL_ACCEL], parameters_max[PARAM_TANGENTIAL_ACCEL], rand_from_seed (alt_seed))) : Vector3 ();
10601060 }
10611061 // apply attractor forces
10621062 p.velocity += force * local_delta;
@@ -1156,7 +1156,7 @@ void CPUParticles3D::_particles_process(double p_delta) {
11561156
11571157 if (particle_flags[PARTICLE_FLAG_DISABLE_Z]) {
11581158 if (particle_flags[PARTICLE_FLAG_ALIGN_Y_TO_VELOCITY]) {
1159- if (p.velocity .length () > 0.0 ) {
1159+ if (p.velocity .length_squared () > 0 .0f ) {
11601160 p.transform .basis .set_column (1 , p.velocity .normalized ());
11611161 } else {
11621162 p.transform .basis .set_column (1 , p.transform .basis .get_column (1 ));
@@ -1173,7 +1173,7 @@ void CPUParticles3D::_particles_process(double p_delta) {
11731173 } else {
11741174 // orient particle Y towards velocity
11751175 if (particle_flags[PARTICLE_FLAG_ALIGN_Y_TO_VELOCITY]) {
1176- if (p.velocity .length () > 0.0 ) {
1176+ if (p.velocity .length_squared () > 0 .0f ) {
11771177 p.transform .basis .set_column (1 , p.velocity .normalized ());
11781178 } else {
11791179 p.transform .basis .set_column (1 , p.transform .basis .get_column (1 ).normalized ());
0 commit comments