Skip to content
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

Infinite lifetime particles. #118

Closed
brandon-reinhart opened this issue Jan 11, 2023 · 6 comments · Fixed by #131
Closed

Infinite lifetime particles. #118

brandon-reinhart opened this issue Jan 11, 2023 · 6 comments · Fixed by #131
Labels
A - modifiers Change related to modifiers C - enhancement New feature or request

Comments

@brandon-reinhart
Copy link

brandon-reinhart commented Jan 11, 2023

It's not unusual to want particles with infinite lifetimes and some other criteria for their destruction.

Suggestions:

  • separate the destruction criteria and provide configurable DestructionModifiers
  • example destruction criteria: particle goes offscreen, particle enters volume, particle exits volume
  • remove the requirement that all particles have a bounded lifetime
  • adjust age/gradient to loop
  • init modifier that is able to set initial particle age (ex: to random value)
@brandon-reinhart
Copy link
Author

Also, continuous emitters should be configurable to do things like:

  • replace oldest particle with new particle
  • emit no further particles if emitter count has been reached
  • replace random particle with new particle

@djeedai
Copy link
Owner

djeedai commented Jan 11, 2023

Yes to all, thanks. This is going to be a lot easier to implement after #109 and any follow up refactor moving into the direction of a VFX graph with basic building blocks. Although the emitter one is probably doable already.

@djeedai djeedai added the C - enhancement New feature or request label Jan 11, 2023
@djeedai
Copy link
Owner

djeedai commented Feb 11, 2023

#109 just merged, and this solves a few items:

  • effects require an explicit InitLifetimeModifier; you can create an effect without and get an unbounded lifetime, although currently you'll get a warning because there's not much you can achieve with this so it's probably an error for most users
  • InitLifetimeModifier::lifetime now can be a random value, to add more variety
  • added InitAgeModifier with random value support

djeedai added a commit that referenced this issue Feb 11, 2023
Add a new update modifier `AabbKillModifier` which kills all particles
entering or exiting its AABB. This modifier is useful to confine the
particles to a space (_e.g._ a room) and avoid leaking into adjacent
areas, or ensuring no particle enter a defined space.

Partially fixes #118
djeedai added a commit that referenced this issue Feb 11, 2023
Add a new update modifier `AabbKillModifier` which kills all particles
entering or exiting its AABB. This modifier is useful to confine the
particles to a space (_e.g._ a room) and avoid leaking into adjacent
areas, or ensuring no particle enter a defined space.

Update the force field example to use that new `AabbKillModifier` to
define an "allow" box (green) and a "forbid" box (red) demonstrating how
the modifier works.

Partially fixes #118
djeedai added a commit that referenced this issue Feb 11, 2023
Add a new update modifier `AabbKillModifier` which kills all particles
entering or exiting its AABB. This modifier is useful to confine the
particles to a space (_e.g._ a room) and avoid leaking into adjacent
areas, or ensuring no particle enter a defined space.

Update the force field example to use that new `AabbKillModifier` to
define an "allow" box (green) and a "forbid" box (red) demonstrating how
the modifier works.

Incidentally, this change also fixes mouse clicks in the
`force_field.rs` example when the window is resized.

Partially fixes #118
@djeedai djeedai added the A - modifiers Change related to modifiers label Feb 11, 2023
djeedai added a commit that referenced this issue Feb 11, 2023
Add a new update modifier `AabbKillModifier` which kills all particles
entering or exiting its AABB. This modifier is useful to confine the
particles to a space (_e.g._ a room) and avoid leaking into adjacent
areas, or ensuring no particle enter a defined space.

Update the force field example to use that new `AabbKillModifier` to
define an "allow" box (green) and a "forbid" box (red) demonstrating how
the modifier works.

Incidentally, this change also fixes mouse clicks in the
`force_field.rs` example when the window is resized.

Partially fixes #118
@djeedai djeedai reopened this Feb 11, 2023
djeedai added a commit that referenced this issue Mar 16, 2023
Make particle aging and reaping conditional to the presence of the
`Attribute::AGE` and `Attribute::LIFETIME`, which are themselves not
mandatory anymore (not added by default) but instead depend on the
modifier(s) added to the `EffectAsset`.

Add two new modifiers:
- `SetColorModifier` to set the per-particle rendering color on spawn,
  to a constant value that do not vary with the age/lifetime of the
  particle.
- `SetSizeModifier` to set the per-particle size on spawn, also not
  varying after spawning.

This change further improves support for #118.
djeedai added a commit that referenced this issue Mar 17, 2023
Make particle aging and reaping conditional to the presence of the
`Attribute::AGE` and `Attribute::LIFETIME`, which are themselves not
mandatory anymore (not added by default) but instead depend on the
modifier(s) added to the `EffectAsset`.

Add two new modifiers:
- `SetColorModifier` to set the per-particle rendering color on spawn,
  to a constant value that do not vary with the age/lifetime of the
  particle.
- `SetSizeModifier` to set the per-particle size on spawn, also not
  varying after spawning.

This change further improves support for #118.
@djeedai
Copy link
Owner

djeedai commented Jul 10, 2023

@brandon-reinhart I believe the core feature of having infinite particle and control over how their die is now available. The InitAttributeModifier can be used to initialize the age with an arbitrarily complex expression. And particles won't die if they don't have both an Attribute::AGE and an Attribute::LIFETIME; see the init.rs example for a use of that. As for controling the particle killing, the AabbKillModifier provides one non-age-based option.

There's a few other secondary items there, some which are not available yet like killing particles going offscreen or replacing the oldest particle with a new one, which probably deserve their own separate issue. So I propose we close this, and can re-open individual items for anything that's still pending.

@djeedai
Copy link
Owner

djeedai commented Jul 16, 2023

Opened separate feature requests for the few remaining items. Closing this issue, as I think everything else is now available.

@djeedai djeedai closed this as completed Jul 16, 2023
@brandon-reinhart
Copy link
Author

Neat! I will check this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A - modifiers Change related to modifiers C - enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants