scriptOp particle count on event entry
#1
Sorry Tyson.., it might be an idiot request but won't it be handy to have this property in the script operator?
Code:
// [int] onEntryParticleCount = number of particles entering this event prior to script execution

so we could do this kind of loop even when particle deaths occur:
Code:
for (int i = eventParticleCount - onEntryParticleCount; i < eventParticleCount; i++)

// this for-loop iterates only through particles entering this event
  Reply
#2
That's what the eventParticleCount variable is....it doesn't change until the next timestep, even if you birth particles in the Script op. So keep track of how many particles you birth, then you can iterate them like this:

Code:
for (int i = eventParticleCount; i < eventParticleCount + numNewParticles; i++)
  Reply
#3
maybe i don't understand what you mean..  what i want is just for optimization purpose,
I want to reproduce what an operator does when set to "Event entry" so that loops are limited to the new particles entering the event.
though, how can I have the exact count of new entered particles if some others have left the event at the same time, this with unpredictable birth/death or event entry/exit?
  Reply
#4
What's wrong with just checking their event age like in the tutorial script shown in the Script operator? Event age of 0 means the particle is new in the event.

I guess I don't understand what you're trying to do.
  Reply
#5
I don't know the real cost of a loop, in term of performances, when particle count is very high, but I thaught it would be preferable to avoid looping thru all the event particles if just a few enter it.
  Reply
#6
There's no way to see which particles are new without iterating through all of them. The cost of doing so is pretty low...even less if you setup your Script code to be multithreaded using the provided functions.
  Reply
#7
I figured you’d say that Smile  thanks Tyson.
  Reply


Forum Jump: