Last Selected Quad on Top?

i`m searching for a way to sort the selected quads that the last selected quad is always on top

QuadOrder.v4p (15.1 kB)

in the attached patch the last selected quad is in front because the z-pos is slightly closer to the camera

QuadOrder.v4p (16.1 kB)

thanks for your attached patch

is there a way to work direct with the spread order, without this z-pos trick

of course, a lot of ways…
if you want to stay with the current patch, sth like this works…

QuadOrder_0.v4p (19.2 kB)

thank you, basically that’s what i need

but unfortunately the scaling animation of the quads jumps, if i insert a animation node (damper)

QuadOrder_0_0_Damper.v4p (19.7 kB)

well, if you want to damper the scaling i suggest to use the “z-pos-trick”.
if you want to use dammper you can not change the slice order.
if you really really want to / have to change the slice order, then you should check a plugin like store or the age-output-pin of particle.

you can use shift with getslice at the very end, so you don’t need to take care of the spreadorder with chaning values.

QuadOrder_0_0_0_Damper (2).v4p (20.8 kB)

my basic problem is avoid to give the full set of spreads to the layer with this opening quads. in my easy example there are only 6/10 quads, but i would like play arround with a lot more + textures, so for that reason i try to safe performance and give only the selected Spreads (X,Y coordinations) to the opening quad layer.

QuadOrder_NIL.v4p (16.0 kB)

hi, can you please register yourself?

i attach a patch which contains a “funny” solution, if you have a professional project, you probably shouldnt use this.

QuadOrder_NIL.v4p (23.3 kB)

well, this is one of the reasons why we made VL, its so much simpler to think object oriented. have a look into the QuadStuff data type which manages all the logic per quad. needs latest alpha of course:

Quad (9.5 kB)

hi tonfilm, nice to throw in some more vl-examples while dealing with everyday vvvv-problems!

the init,update,create & getProperty stuff is clear,
but can you please explain whats going on inside OrderBy?

you input the quadstuff-spread and receiving if its selected but what is happening then?
what is the boolean “key” for?
why is the output-source"result" not changing (while hovering with the mouse) even if i select a quad in teh renderer? (btw. not being able to check the spreads via io-boxes is one of the main barriers while trying to understand vl-patches)

thank you

OrderBy is one of many methods defined on Sequence (IEnumerable) which we imported from the .NET framework as explained here.

its basically a sort node which takes a sequence and a delegate as input and returns the sorted sequence. and since it takes a delegate as input, VL can create the node as a region.

the delegate is a function from the type of the elements of the sequence (QuadStuff in this case) to anything that can be compared with each other. the OrderBy then calls the delegate for each element in the sequence to gather the keys which define the new order. if several elements have the same key their order stays, this is called a stable sort which is what we want in this case.

here QuadStuff.Selected was chosen as key, which is a boolean and it worked out of the box since .NET knows how to compare booleans. you could return any property of the QuadStuff and it would be ordered by that, position.z if you are working in 3d would work as well.

the tooltip always shows the first slice of the spread/sequence. one speciality with operations on Sequences is that most of them are lazy, this means they collect everything to do the calculation but don’t actually do it unless someone wants the data. so all the delegate calling and sorting starts only if someone asks for the elements in the sequence, the ToSpread node in this case.

this is also true if you link many Sequence/LINQ methods together, they build up computations that only do something if you ask for the data. might sound complicated but most of the time you don’t have to care about this fact since in the end it behaves as you expect it. only the tooltip cannot know all the details since the computation was not started… but not 100% sure about that one, @elias knows more about that.