restorer / zame-haxe-particles

Particle emitter for OpenFL compatible with Particle Designer
MIT License
77 stars 18 forks source link

Is it possible to simulate passed time somehow? #19

Open CrazyFlasher opened 4 years ago

restorer commented 4 years ago

Currently it is possible only using following hack (because timer usage is hard-coded into ParticleSystem):

  1. Make prevTime in ParticleSystem public.
  2. ps.pervTime = Timer.stamp() - desired_time_to_pass.
Dimensionscape commented 3 years ago

Frame drops, such as when moving the window, create gaps in created particle elements although the existing particles move appropriately based on time. Is there a simple workaround to force creation of particles during the elapsed time to prevent unwanted gaps in effects in this scenario?

restorer commented 3 years ago

@Dimensionscape you can try to jump in time by some step (say, 1 second) in a loop. This will be inefficient, especially when desired time to pass is much larger than step, but it should "fix" gaps.

But what exactly you are trying to achieve?

Dimensionscape commented 3 years ago

I just want to preserve the fidelity of particle effects through frame drops. I have a game using a snow particle but if the user drags the window around, the main thread gets block. When frame rate comes back theres a giant gap in particles depending on how long its been and breaks the illusion. It's not a big issue, but does effect quality of production.

Dimensionscape commented 3 years ago

I prevented the issue in my case by adding if (dt > .5) return false; after prevTime is set in the update..... its not really ideal but it prevents any gaps in the event the main thread gets blocked for any amount of time. What do you think might be a long term solution for this?

restorer commented 3 years ago

@Dimensionscape I think it is the optimal for your case, because it will prevent visual lags, and at the same time it is super fast solution (comparing to "fair" solution in my prev comment).

I think you can even use 1.0 instead of .5, but not sure about it 😄

Dimensionscape commented 3 years ago

Thanks for the feedback. I appreciate your work.

Oh yeah, 1 is feasible, but still creates a small gap. >.5 is less noticeable, but still "technically" 1fps.