From 3c5d4a2410b38bdc7d3a92e24d95755fd294feb8 Mon Sep 17 00:00:00 2001 From: Rudolph Bester Date: Sun, 15 Jun 2025 20:38:50 +0200 Subject: [PATCH] Fix floating point precision errors when setting particle trail length --- scene/2d/gpu_particles_2d.cpp | 2 +- scene/3d/gpu_particles_3d.cpp | 2 +- servers/rendering/renderer_rd/storage_rd/particles_storage.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scene/2d/gpu_particles_2d.cpp b/scene/2d/gpu_particles_2d.cpp index d40b9047b6..c0939abe45 100644 --- a/scene/2d/gpu_particles_2d.cpp +++ b/scene/2d/gpu_particles_2d.cpp @@ -185,7 +185,7 @@ void GPUParticles2D::set_trail_enabled(bool p_enabled) { } 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; RS::get_singleton()->particles_set_trails(particles, trail_enabled, trail_lifetime); queue_redraw(); diff --git a/scene/3d/gpu_particles_3d.cpp b/scene/3d/gpu_particles_3d.cpp index 7555a9af02..927db4d2c8 100644 --- a/scene/3d/gpu_particles_3d.cpp +++ b/scene/3d/gpu_particles_3d.cpp @@ -244,7 +244,7 @@ void GPUParticles3D::set_trail_enabled(bool p_enabled) { } 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; RS::get_singleton()->particles_set_trails(particles, trail_enabled, trail_lifetime); } diff --git a/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp b/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp index 6bd9dc4949..a0b3176763 100644 --- a/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp @@ -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) { Particles *particles = particles_owner.get_or_null(p_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); particles->trails_enabled = p_enable;