mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 08:02:39 +08:00
Update particle-system.ts (#13615)
Even if the rateOverDistance is 0, it will still get the world position and calculate the distance, which is waste. To improve performance, only if the rateOverDistance is above 0, it would get the world position and calculate the distance
This commit is contained in:
@@ -1389,10 +1389,13 @@ export class ParticleSystem extends ModelRenderer {
|
||||
}
|
||||
|
||||
// emit by rateOverDistance
|
||||
this.node.getWorldPosition(this._curWPos);
|
||||
const distance = Vec3.distance(this._curWPos, this._oldWPos);
|
||||
Vec3.copy(this._oldWPos, this._curWPos);
|
||||
this._emitRateDistanceCounter += distance * this.rateOverDistance.evaluate(this._time / this.duration, 1)!;
|
||||
const rateOverDistance = this.rateOverDistance.evaluate(this._time / this.duration, 1)!;
|
||||
if (rateOverDistance > 0) {
|
||||
Vec3.copy(this._oldWPos, this._curWPos);
|
||||
this.node.getWorldPosition(this._curWPos);
|
||||
const distance = Vec3.distance(this._curWPos, this._oldWPos);
|
||||
this._emitRateDistanceCounter += distance * rateOverDistance;
|
||||
}
|
||||
|
||||
if (this._emitRateDistanceCounter > 1) {
|
||||
const emitNum = Math.floor(this._emitRateDistanceCounter);
|
||||
|
||||
Reference in New Issue
Block a user