Ashley
Thanks for the reply and the detailed explanation.
The reason i used the "picked" flag was that it could reduce the CPU time quite a bit, before running the distance comparison. If I remove it, it would check distance to instances that already have the opacity set to 20. With the picked flag I filter out those, so they don't have to be checked again. And when you're deselecting, you don't have to check every single instance in the layout. Only those that have their opacity set to 20... You can try disable the "picked" boolean in the first example and suddenly the whole distance checking operation uses almost twice as much CPU.
So by using booleans I can easily filter out how many that needs to be distance checked.
Using the first test with pick by comparison.
With the boolean I'm getting around 25% CPU usage, for the distance calculation.
Without the boolean I'm getting about 43% CPU usage , for the distance calculation.
Because I filtered out how many candidates that needs to be checked.
I'm trying to figure out ways to do do things as close to as effective as the LOS behaviour as possible only using events.
If the only reason LOS is so much faster is because the Collision cells, is that something that can be accessed by events in the future? Maybe a system condition or something similar? In the test project though, "Use Collision cells" is disabled for the LOS behaviour, and didn't make any difference if I enabled it or not. So that means math in behaviours are faster than events, or loops in behaviours are faster or maybe both?
How would one benchmark that?
I often tend to use very few behaviours/plugins as they are not as flexible as events. So that's why I'm curious if there is any measurable difference in loops and picking between the C2 and C3 runtime, and how one would go about to benchmark that?
Last year I payed a developer make a simple behaviour for me (As I don't know how to code) that only does one thing. Checking Bounding Box Overlap.
function intersectRect(r1, r2) {
return !(r2.left > r1.right ||
r2.right < r1.left ||
r2.top > r1.bottom ||
r2.bottom < r1.top);
}[/code:33yvx5ul]
I had to pay someone to do that, as it was not feasible to do that with events. It was just too heavy and CPU hungry doing the same thing with events.
So that's why I'm curious. If events can ever get up to par with behaviours, performance wise.