Skip to content

Conversation

@zhefengzhang
Copy link
Contributor

@zhefengzhang zhefengzhang commented Sep 16, 2025

Re: https://github.com/cocos/3d-tasks/issues/19127

当粒子系统的播放时间与粒子可存活的总时间相差小于一帧时,允许在当前帧尝试播放粒子,避免游戏低帧率时粒子系统因为卡顿错过了可用于播放粒子的帧。
When the playback time of the particle system differs from the total survival time of the particles by less than one frame, it is allowed to attempt to play the particles in the current frame to prevent the particle system from missing the frames available for playing the particles due to lag when the game has a low frame rate.

此修改同时解决了以下类似情况的粒子播放问题:

  • 设定可播放粒子时间为 2 s ,每秒播放粒子数量为 3,粒子存活时间为 1 s。在此设定下粒子只发射了 5 次。(当需要发射最后一个粒子时因为粒子剩余可播放时间不足一帧的间隔时间,所以无法发射)

This modification also resolves the particle playback issues in the following similar scenarios:

  • Set the playable particle time to 2 s, the number of particles played per second to 3, and the particle survival time to 1 s. Under this setting, particles were only emitted 5 times. (When the last particle needed to be emitted, it could not be emitted because the remaining playable time of the particle was less than the interval time of one frame.)

@zhefengzhang
Copy link
Contributor Author

@cocos-robot run-test-cases-custom

@github-actions
Copy link

github-actions bot commented Sep 16, 2025

Code Size Check Report

Wechat (WASM) Before After Diff
2D Empty (legacy pipeline) 1009805 bytes 1009805 bytes ✅ 0 bytes
2D All (legacy pipeline) 2675364 bytes 2675364 bytes ✅ 0 bytes
2D All (new pipeline) 2767100 bytes 2767100 bytes ✅ 0 bytes
(2D + 3D) All 10024070 bytes 10024098 bytes ⚠️ +28 bytes
Web (WASM + ASMJS) Before After Diff
(2D + 3D) All 16843132 bytes 16843160 bytes ⚠️ +28 bytes

Interface Check Report

This pull request does not change any public interfaces !

@star-e star-e self-requested a review September 17, 2025 02:38
@star-e
Copy link
Contributor

star-e commented Sep 17, 2025

@cocos-robot run test cases

2 similar comments
@zhefengzhang
Copy link
Contributor Author

@cocos-robot run test cases

@star-e
Copy link
Contributor

star-e commented Sep 23, 2025

@cocos-robot run test cases

@zhefengzhang
Copy link
Contributor Author

@star-e

@zhefengzhang
Copy link
Contributor Author

@cocos-robot run test cases

6 similar comments
@zhefengzhang
Copy link
Contributor Author

@cocos-robot run test cases

@zhefengzhang
Copy link
Contributor Author

@cocos-robot run test cases

@sushanhong
Copy link
Contributor

@cocos-robot run test cases

@sushanhong
Copy link
Contributor

@cocos-robot run test cases

@star-e
Copy link
Contributor

star-e commented Oct 23, 2025

@cocos-robot run test cases

@sushanhong
Copy link
Contributor

@cocos-robot run test cases

@github-actions
Copy link

@zhefengzhang, Please check the result of run test cases:

Task Details

Platform build boot runned crashScene FailScene
web-mobile PASS PASS FAIL particle-compare,particles-noise-test
ios PASS PASS FAIL particle-compare,particles-noise-test
mac PASS PASS FAIL particle-compare,particles-noise-test

@github-actions
Copy link

@zhefengzhang, Please check the result of run test cases:

Task Details

Platform build boot runned crashScene FailScene
windows PASS PASS FAIL particle-compare,particles-noise-test
android PASS PASS FAIL particle-compare,particles-noise-test
wechatgame PASS PASS FAIL particle-compare,particles-noise-test

@zhefengzhang
Copy link
Contributor Author

@cocos-robot run test cases

4 similar comments
@zhefengzhang
Copy link
Contributor Author

@cocos-robot run test cases

@sushanhong
Copy link
Contributor

@cocos-robot run test cases

@zhefengzhang
Copy link
Contributor Author

@cocos-robot run test cases

@zhefengzhang
Copy link
Contributor Author

@cocos-robot run test cases

@github-actions
Copy link

@zhefengzhang, Please check the result of run test cases:

Task Details

Platform build boot runned crashScene FailScene
web-mobile PASS PASS FAIL particle-compare,particles-noise-test
ios PASS PASS FAIL particle-compare,particles-noise-test
mac PASS PASS FAIL particle-compare,particles-noise-test

@github-actions
Copy link

@zhefengzhang, Please check the result of run test cases:

Task Details

Platform build boot runned crashScene FailScene
windows PASS PASS FAIL particle-compare,particles-noise-test
android PASS PASS FAIL particle-compare,particles-noise-test
wechatgame PASS PASS FAIL particle-compare,particles-noise-test

@zhefengzhang
Copy link
Contributor Author

@cocos-robot run test cases

// bursts
for (const burst of self.bursts) {
burst.update(self, dt);
if (timeLeft <= 0) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

对于 burst 中使用固定频率发射的粒子使用原来的逻辑

if (self._time > startDelay) {
if (self._time > (self.duration + startDelay)) {
const timeLeft = self._time - (self.duration + startDelay);
if (timeLeft > dt) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

对于粒子系统已激活时间减去粒子可活动时间与延迟播放时间之后剩余的时间不足一帧的,允许播放一次粒子。

@zhefengzhang
Copy link
Contributor Author

@cocos-robot run test cases

@zhefengzhang
Copy link
Contributor Author

@cocos-robot run test cases

@github-actions
Copy link

@zhefengzhang, Please check the result of run test cases:

Task Details

Platform build boot runned crashScene FailScene
web-mobile PASS PASS FAIL particle-color,particle-compare,particle-size,particle-trail,
ios PASS PASS FAIL particle-color,particle-compare,particle-size,particle-trail
mac PASS PASS FAIL particle-color,particle-compare,particle-size,particle-trail

@github-actions
Copy link

@zhefengzhang, Please check the result of run test cases:

Task Details

Platform build boot runned crashScene FailScene
windows PASS PASS FAIL particle-color,particle-compare,particle-size,particle-trail
android PASS PASS FAIL particle-color,particle-compare,particle-size,particle-trail
wechatgame PASS PASS FAIL particle-color,particle-compare,particle-size,particle-trail

@zhefengzhang
Copy link
Contributor Author

@cocos-robot run test cases

3 similar comments
@zhefengzhang
Copy link
Contributor Author

@cocos-robot run test cases

@zhefengzhang
Copy link
Contributor Author

@cocos-robot run test cases

@zhefengzhang
Copy link
Contributor Author

@cocos-robot run test cases

@github-actions
Copy link

@zhefengzhang, Please check the result of run test cases:

Task Details

@github-actions
Copy link

@zhefengzhang, Please check the result of run test cases:

Task Details

Platform build boot runned crashScene FailScene
windows PASS PASS FAIL particle-compare
android PASS PASS PASS
wechatgame PASS PASS PASS

@github-actions
Copy link

@zhefengzhang, Please check the result of run test cases:

Task Details

@github-actions
Copy link

@zhefengzhang, Please check the result of run test cases:

Task Details

// bursts
for (const burst of self.bursts) {
burst.update(self, dt);
if (timeLeft <= 0 || self.loop) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

对于在 burst 中配置发射频率进行播放的粒子,使用原本的逻辑

@star-e star-e merged commit 8c944a9 into cocos:v3.8.8 Oct 29, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants