From d6a2ecc12a62adb5a10698386c2b43c11ed2fb25 Mon Sep 17 00:00:00 2001 From: santy-wang Date: Tue, 17 Oct 2023 11:05:16 +0800 Subject: [PATCH] fix error --- native/cocos/particle/ParticleSystem.cpp | 2 +- native/cocos/particle/modules/DistributableShape.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/native/cocos/particle/ParticleSystem.cpp b/native/cocos/particle/ParticleSystem.cpp index d5509f7a709..bd3025f06cd 100644 --- a/native/cocos/particle/ParticleSystem.cpp +++ b/native/cocos/particle/ParticleSystem.cpp @@ -62,7 +62,7 @@ void ParticleSystem::removeModule(ParticleSystemModule& module) { break; } - auto& index = std::find(stage->begin(), stage->end(), &module); + auto index = std::find(stage->begin(), stage->end(), &module); if (index != stage->end()) { stage->erase(index); } diff --git a/native/cocos/particle/modules/DistributableShape.cpp b/native/cocos/particle/modules/DistributableShape.cpp index 609166759ea..dcd9cdd3445 100644 --- a/native/cocos/particle/modules/DistributableShape.cpp +++ b/native/cocos/particle/modules/DistributableShape.cpp @@ -27,7 +27,7 @@ float DistributableShape::getDistributionAlpha(ParticleSystemContext& context, s if (spread > math::EPSILON) { current = std::floor(current / spread) * spread; } - current = std::modf(current, distributionRange); + current -= std::floor(current / distributionRange) * distributionRange; return current >= 0 ? current : current + distributionRange; } else if constexpr (mode == DistributionMode::PING_PONG) { float current = MathUtil::lerp(begin, end, alpha); @@ -35,7 +35,7 @@ float DistributableShape::getDistributionAlpha(ParticleSystemContext& context, s if (spread > math::EPSILON) { current = std::floor(current / spread) * spread; } - current = std::modf(current, 2.0 * distributionRange); + current -= std::floor(current / (2.0 * distributionRange)) * (2.0 * distributionRange); return current > distributionRange ? (2.0 * distributionRange - current) : current; } else { float current = alpha * distributionRange;