From 1d1cfaa34c2705bcabc33be0cde63241ca4de33d Mon Sep 17 00:00:00 2001 From: wangzhihao <492187276@qq.com> Date: Thu, 6 Aug 2026 15:03:43 +0800 Subject: [PATCH] fix(particle): handle floating-point precision in burst triggers Particle Burst determines whether the current frame crosses a trigger point using floating-point time. Account for precision errors during the comparison. Reference: https://forum.cocos.org/t/topic/176928 --- cocos/particle/burst.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/particle/burst.ts b/cocos/particle/burst.ts index 3148a9e1c25..581cc9d83fe 100644 --- a/cocos/particle/burst.ts +++ b/cocos/particle/burst.ts @@ -23,7 +23,7 @@ */ import { ccclass, type, serializable, editable, range } from 'cc.decorator'; -import { repeat } from '../core/math'; +import { EPSILON, repeat } from '../core/math'; import CurveRange from './animator/curve-range'; import type { ParticleSystem } from './particle-system'; @@ -108,7 +108,7 @@ export default class Burst { let preFrameTime = repeat(psys.time - psys.startDelay.evaluate(0, 1), psys.duration) - dt; preFrameTime = (preFrameTime > 0.0) ? preFrameTime : 0.0; const curFrameTime = repeat(psys.time - psys.startDelay.evaluate(0, 1), psys.duration); - if (this._curTime >= preFrameTime && this._curTime < curFrameTime) { + if (this._curTime >= preFrameTime - EPSILON && this._curTime < curFrameTime) { psys.emit(this.count.evaluate(this._curTime / psys.duration, 1), dt - (curFrameTime - this._curTime)); this._curTime += this.repeatInterval; --this._remainingCount;