1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-24 15:26:15 +00:00

Fix floating point precision errors when setting particle trail length

This commit is contained in:
Rudolph Bester
2025-06-15 20:38:50 +02:00
parent 019ab8745f
commit 3c5d4a2410
3 changed files with 3 additions and 3 deletions

View File

@@ -185,7 +185,7 @@ void GPUParticles2D::set_trail_enabled(bool p_enabled) {
} }
void GPUParticles2D::set_trail_lifetime(double p_seconds) { void GPUParticles2D::set_trail_lifetime(double p_seconds) {
ERR_FAIL_COND(p_seconds < 0.01); ERR_FAIL_COND(p_seconds < 0.01 - CMP_EPSILON);
trail_lifetime = p_seconds; trail_lifetime = p_seconds;
RS::get_singleton()->particles_set_trails(particles, trail_enabled, trail_lifetime); RS::get_singleton()->particles_set_trails(particles, trail_enabled, trail_lifetime);
queue_redraw(); queue_redraw();

View File

@@ -244,7 +244,7 @@ void GPUParticles3D::set_trail_enabled(bool p_enabled) {
} }
void GPUParticles3D::set_trail_lifetime(double p_seconds) { void GPUParticles3D::set_trail_lifetime(double p_seconds) {
ERR_FAIL_COND(p_seconds < 0.01); ERR_FAIL_COND(p_seconds < 0.01 - CMP_EPSILON);
trail_lifetime = p_seconds; trail_lifetime = p_seconds;
RS::get_singleton()->particles_set_trails(particles, trail_enabled, trail_lifetime); RS::get_singleton()->particles_set_trails(particles, trail_enabled, trail_lifetime);
} }

View File

@@ -439,7 +439,7 @@ void ParticlesStorage::particles_set_fractional_delta(RID p_particles, bool p_en
void ParticlesStorage::particles_set_trails(RID p_particles, bool p_enable, double p_length) { void ParticlesStorage::particles_set_trails(RID p_particles, bool p_enable, double p_length) {
Particles *particles = particles_owner.get_or_null(p_particles); Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_NULL(particles); ERR_FAIL_NULL(particles);
ERR_FAIL_COND(p_length < 0.01); ERR_FAIL_COND(p_length < 0.01 - CMP_EPSILON);
p_length = MIN(10.0, p_length); p_length = MIN(10.0, p_length);
particles->trails_enabled = p_enable; particles->trails_enabled = p_enable;