Skip to content

Conversation

@WUCJ638
Copy link
Contributor

@WUCJ638 WUCJ638 commented Dec 12, 2025

Summary

This PR fixes several particle system bugs in Axmol 2.10.0, specifically related to:

  • SpawnFadeIn / SpawnScaleIn:

    • Memory not reallocated after setTotalParticles(), causing null pointer crashes.
    • New values ignored after initial allocation.
    • Particles become invisible if _spawnFadeIn or _spawnScaleIn is set to 0.0f.
  • Loop Animation crash:

    • After setTotalParticles(), _particleCount wasn’t set to 0, leading to invalid access in _animations.at(_particleData.animIndex[i]).

Changes

  • Reallocate attribute memory (fade/scale/HSV) in ParticleSystemQuad::setTotalParticles() if enabled.
  • Allow updating spawn fade/scale values even after allocation.
  • Skip fade/scale logic when value is 0.0f to avoid invisible particles.
  • Reset _particleCount = 0 in setTotalParticles() and resetSystem() to prevent stale animation indices.

Testing

  • Verified on Windows 10 with Visual Studio 2026 (MSVC 19.50).

  • ParticleTest from 42 to 55 pass without crash; emission shape unaffected, by simply adding

        this->runAction(Sequence::create(
            DelayTime::create(3.0f),
            CallFunc::create([this](){
                _emitter->setTotalParticles(2000);
                }),
            nullptr
        ));

    at the end of onEnter()

  • HSV & advanced animations not fully tested (because I haven't used them in my projects).

Note:

  1. Huge comments (//// BUG from WUCJ638... //) are removed to reduce space.
  2. Since I'm a student who is occupied with heavy academic tasks and preparing for final exam, delayed response may be unavoidable. Thanks for your understanding!

…ParticleSystem

Refactor memory allocation checks of particle system's attributes like fade-in, scale in, and fix bugs related to setting and updating opacity and scale fade-in. Let current particle count 0 (because all existed particles are removed)  during system reset.
All implementation is inside setTotalParticle(). Fix the missing allocation of scale in, opacity fade in, HSV, and animation. Meanwhile, added assertions and for particle limits
@j-jorge
Copy link
Contributor

j-jorge commented Dec 12, 2025

(I'm not a maintainer)

Note: Huge comments (//// BUG from WUCJ638... //) can be removed, since they occupy a lot of space.

I believe you should remove them indeed. Explanations for the bug and the fix are welcome in a commit message, comments about the current code's behavior are great in the code. And no need for so may slashes :)

@WUCJ638
Copy link
Contributor Author

WUCJ638 commented Dec 12, 2025

I believe you should remove them indeed. Explanations for the bug and the fix are welcome in a commit message, comments about the current code's behavior are great in the code. And no need for so may slashes :)

Got it, I'll erase them away later on because now it's time for me to go to bed. 🛏

For all comments written by me, I use neater comments in place of huge comments (`/// BUG from WUCJ638: ... //`).
For all comments written by me, I use neater comments in place of huge comments (`/// BUG from WUCJ638: ... //`).
@halx99 halx99 added this to the 2.10.1 milestone Dec 13, 2025
@halx99 halx99 merged commit 02ab65b into axmolengine:release/2.x Dec 13, 2025
15 checks passed
@halx99 halx99 added the bug Something isn't working label Dec 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants