From d8f09ea57d05ff0dc4f439324a15fd8a4b6d10fa Mon Sep 17 00:00:00 2001 From: zxx43 Date: Thu, 1 Sep 2022 23:49:17 +0800 Subject: [PATCH] 3.6.1 trail buffer insufficient space fix (#12567) * enlarge trail buffer * add warning information * use warn id instead --- EngineErrorMap.md | 4 ++++ cocos/particle/renderer/trail.ts | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/EngineErrorMap.md b/EngineErrorMap.md index c9f1ff2518..d5f17a4d00 100644 --- a/EngineErrorMap.md +++ b/EngineErrorMap.md @@ -2471,6 +2471,10 @@ cc.ParticleSystem: shouldn't be initialized repetitively, otherwise there will b cc.ParticleSystem: change material failed, please use proper particle material +### 6036 + +cc.ParticleSystem: life time should bigger than 1 or buffer will be insufficient + ### 6100 diff --git a/cocos/particle/renderer/trail.ts b/cocos/particle/renderer/trail.ts index 453b7dc815..52e6fbab82 100644 --- a/cocos/particle/renderer/trail.ts +++ b/cocos/particle/renderer/trail.ts @@ -38,6 +38,7 @@ import { Space, TextureMode, TrailMode } from '../enum'; import { Particle } from '../particle'; import { legacyCC } from '../../core/global-exports'; import { TransformBit } from '../../core/scene-graph/node-enum'; +import { warnID } from '../../core'; const PRE_TRIANGLE_INDEX = 1; const NEXT_TRIANGLE_INDEX = 1 << 2; @@ -368,7 +369,10 @@ export default class TrailModule { const b = ps.bursts[i]; burstCount += b.getMaxCount(ps) * Math.ceil(psTime / duration); } - this._trailNum = Math.ceil(psTime * this.lifeTime.getMax() * 60 * (psRate * duration + burstCount)); + if (this.lifeTime.getMax() < 1.0) { + warnID(6036); + } + this._trailNum = Math.ceil(psTime * Math.ceil(this.lifeTime.getMax()) * 60 * (psRate * duration + burstCount)); this._trailSegments = new Pool(() => new TrailSegment(10), Math.ceil(psRate * duration), (obj: TrailSegment) => obj.trailElements.length = 0); if (this._enable) { this.enable = this._enable;