Merge pull request #84028 from QbieShay/qbe/fix-damp-fric

Fix friction being in the correct if/else branch
This commit is contained in:
Rémi Verschelde 2023-10-30 16:26:40 +01:00
commit ceaa8333f3
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 11 additions and 10 deletions

View File

@ -962,21 +962,22 @@ void ParticleProcessMaterial::_update_shader() {
code += " {\n";
code += " // copied from previous version\n";
code += " if (physics_params.damping > 0.0) {\n";
if (!particle_flags[PARTICLE_FLAG_DAMPING_AS_FRICTION]) {
code += " float v = length(VELOCITY);\n";
if (!particle_flags[PARTICLE_FLAG_DAMPING_AS_FRICTION]) {
code += " v -= physics_params.damping * DELTA;\n";
} else {
code += " if (v > 0.001) {\n";
code += " // Realistic friction formula. We assume the mass of a particle to be 0.05kg.\n";
code += " float damp = v * v * physics_params.damping * 0.05 * DELTA;\n";
code += " v -= damp;\n";
code += " }\n";
}
code += " if (v < 0.0) {\n";
code += " VELOCITY = vec3(0.0);\n";
code += " } else {\n";
code += " VELOCITY = normalize(VELOCITY) * v;\n";
code += " }\n";
} else {
code += " if (length(VELOCITY) > 0.01){\n";
code += " VELOCITY -= normalize(VELOCITY) * length(VELOCITY) * (physics_params.damping) * DELTA;\n";
code += " }\n";
}
code += " }\n";
code += " \n";
code += " }\n";