tyFlow Forum
scriptOp particle count on event entry - Printable Version

+- tyFlow Forum (https://forum.tyflow.com)
+-- Forum: tyFlow Discussion (https://forum.tyflow.com/forum-1.html)
+--- Forum: Feature Requests (https://forum.tyflow.com/forum-4.html)
+--- Thread: scriptOp particle count on event entry (/thread-1345.html)



scriptOp particle count on event entry - Geoff - 12-14-2019

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



RE: scriptOp particle count on event entry - tyFlow - 12-15-2019

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++)



RE: scriptOp particle count on event entry - Geoff - 12-15-2019

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?


RE: scriptOp particle count on event entry - tyFlow - 12-15-2019

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.


RE: scriptOp particle count on event entry - Geoff - 12-15-2019

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.


RE: scriptOp particle count on event entry - tyFlow - 12-15-2019

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.


RE: scriptOp particle count on event entry - Geoff - 12-15-2019

I figured you’d say that Smile  thanks Tyson.