From 1cf7440ca08eeca5f1a6c282c379501430ad2efe Mon Sep 17 00:00:00 2001 From: DelinWorks Date: Tue, 3 May 2022 20:01:12 +0300 Subject: [PATCH 1/6] Update CCMotionStreak.cpp --- core/2d/CCMotionStreak.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/2d/CCMotionStreak.cpp b/core/2d/CCMotionStreak.cpp index da3a1b806b..441ba58bf4 100644 --- a/core/2d/CCMotionStreak.cpp +++ b/core/2d/CCMotionStreak.cpp @@ -101,7 +101,12 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Co _stroke = stroke; _fadeDelta = 1.0f / fade; - double fps = 1 / _director->getAnimationInterval(); + // Fix animation interval 0 because of vsync being off + double interval = _director->getAnimationInterval(); + double fps = 1 / interval; + if (roundf(fps) == (float)(1e+300 * 1e+300)) + fps = 60.0; + _maxPoints = (int)(fade * fps) + 2; _pointState = (float*)malloc(sizeof(float) * _maxPoints); From d042af2d991b6d48ad937e109073c2dc8c5f9d0d Mon Sep 17 00:00:00 2001 From: DelinWorks Date: Tue, 3 May 2022 20:10:26 +0300 Subject: [PATCH 2/6] Update CCMotionStreak.cpp --- core/2d/CCMotionStreak.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/2d/CCMotionStreak.cpp b/core/2d/CCMotionStreak.cpp index 441ba58bf4..fc1153288b 100644 --- a/core/2d/CCMotionStreak.cpp +++ b/core/2d/CCMotionStreak.cpp @@ -104,7 +104,7 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Co // Fix animation interval 0 because of vsync being off double interval = _director->getAnimationInterval(); double fps = 1 / interval; - if (roundf(fps) == (float)(1e+300 * 1e+300)) + if (roundf(fps) == /* INFINITY */ (float)(1e+300 * 1e+300)) fps = 60.0; _maxPoints = (int)(fade * fps) + 2; From 646f04f1c9aef314afe05df985f89ee07e9163d5 Mon Sep 17 00:00:00 2001 From: DelinWorks Date: Tue, 3 May 2022 20:14:12 +0300 Subject: [PATCH 3/6] Update CCMotionStreak.cpp --- core/2d/CCMotionStreak.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/2d/CCMotionStreak.cpp b/core/2d/CCMotionStreak.cpp index fc1153288b..861eacfeff 100644 --- a/core/2d/CCMotionStreak.cpp +++ b/core/2d/CCMotionStreak.cpp @@ -104,7 +104,7 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Co // Fix animation interval 0 because of vsync being off double interval = _director->getAnimationInterval(); double fps = 1 / interval; - if (roundf(fps) == /* INFINITY */ (float)(1e+300 * 1e+300)) + if (roundf(fps) == INFINITY) fps = 60.0; _maxPoints = (int)(fade * fps) + 2; From edf0f5632e5a34b5eca8a57bf2058cbb05a2a8b2 Mon Sep 17 00:00:00 2001 From: DelinWorks Date: Tue, 3 May 2022 20:54:44 +0300 Subject: [PATCH 4/6] Update CCMotionStreak.cpp --- core/2d/CCMotionStreak.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/2d/CCMotionStreak.cpp b/core/2d/CCMotionStreak.cpp index 861eacfeff..940b32e05a 100644 --- a/core/2d/CCMotionStreak.cpp +++ b/core/2d/CCMotionStreak.cpp @@ -101,7 +101,7 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Co _stroke = stroke; _fadeDelta = 1.0f / fade; - // Fix animation interval 0 because of vsync being off + // Fix #629 Motion streak vsync off crash double interval = _director->getAnimationInterval(); double fps = 1 / interval; if (roundf(fps) == INFINITY) From 6be3ac3d507032af3768fe50678f0058c9e0014a Mon Sep 17 00:00:00 2001 From: Turky Mohammed <45469625+DelinWorks@users.noreply.github.com> Date: Wed, 4 May 2022 09:26:54 +0300 Subject: [PATCH 5/6] Update CCMotionStreak.cpp --- core/2d/CCMotionStreak.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/2d/CCMotionStreak.cpp b/core/2d/CCMotionStreak.cpp index 940b32e05a..037182b83d 100644 --- a/core/2d/CCMotionStreak.cpp +++ b/core/2d/CCMotionStreak.cpp @@ -105,7 +105,7 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Co double interval = _director->getAnimationInterval(); double fps = 1 / interval; if (roundf(fps) == INFINITY) - fps = 60.0; + fps = 240.0; _maxPoints = (int)(fade * fps) + 2; From f8b7f20e96c43171c565e4acc7987ff495f8afd1 Mon Sep 17 00:00:00 2001 From: Turky Mohammed <45469625+DelinWorks@users.noreply.github.com> Date: Wed, 4 May 2022 10:00:38 +0300 Subject: [PATCH 6/6] Update core/2d/CCMotionStreak.cpp [skip ci] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 一线灵 --- core/2d/CCMotionStreak.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/2d/CCMotionStreak.cpp b/core/2d/CCMotionStreak.cpp index 037182b83d..831607725e 100644 --- a/core/2d/CCMotionStreak.cpp +++ b/core/2d/CCMotionStreak.cpp @@ -104,7 +104,7 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Co // Fix #629 Motion streak vsync off crash double interval = _director->getAnimationInterval(); double fps = 1 / interval; - if (roundf(fps) == INFINITY) + if (roundf(fps) > 240.0) fps = 240.0; _maxPoints = (int)(fade * fps) + 2;