-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: Particles are never destroyed #70
Comments
If I remembered correctly they disappeared after some time in the Dart example in the repository, have you tried that one? |
Hmm, looking through the source of the examples it would appear that the lifetime of a particle is managed through Flame and its components rather than through the Forge2D library. Since I'm trying to port Forge2D to Xojo, I'll need to figure out a way to incorporate lifetimes into particles just in the physics engine alone. I'm guessing Flame does it by checking a timer in every particle step? |
I meant this example: |
Yeah I don't think the particles are getting destroyed in that example. Since I'm writing a port (not in Dart), what I've done (and it seems to work fine) is the following:
double _age = 0.0; // seconds
double lifespan = 0.5; // seconds
void preSolve(double dt) {
_age +=dt;
if (_age > lifespan) {
// The particle has expired. Set it to be a zombie and it'll get
// removed after the `solve()` step in `ParticleSystem`.
flags |= ParticleType.zombieParticle;
}
}
for (final particle in _particles) {
// Tell this particle we are beginning the `solve` step.
// This will determine if the particle has expired.
particle.PreSolve(step.dt);
allParticleFlags |= particle.flags;
} This seems to happily purge the particles after they have aged past their maximum lifespan. |
Great, thanks for the code! I'll put this into Forge2D when I have time (if you don't have the time to make the PR that is). :) |
Is someone still looking into this? 👀 |
I don't believe so! Would you like to work on this? We can assign you to it |
As far as I can see, particles in a particle system are never destroyed.
In the original LiquidFun library, particles expired after a certain time period:
https://google.github.io/liquidfun/Programmers-Guide/html/md__chapter11__particles.html
Looking through the particle system in Forge2D however, I can't see anyway that a particle is ever removed automatically from the particle system. The only time a particle is removed from the system's internal list is if it is a "zombie" by having it's
flags
property set to have the zombie flag. However, I can't see any code that ever does this.Am I missing something here?
The text was updated successfully, but these errors were encountered: