Negative indices in Geometry Nodes select indices from the end
it would be really convenient if we could use negative indices when selecting or sampling indices from the end of the spreadsheet, so -1 would mean the last index, -2 would mean penultimate index and so on. Just like it is done in Python lists.
Here is how it will be used in Geonodes. No changes to the interface required.
3 Comments
You can probably achieve this by adding "domain size node", which gives you the amount of elements in a domain, then "math node" > subtract 1.00 (or the number of the last indices you want) . Now you just use the compare node > greater than, compare the "index node" with the previous count. I've done this heaps of times, give it a shot
i know i can do it like that. Just would be so much easier if i didn't have to create 3 additional nodes just to achieve the same thing that could be done with a negative index. Just a minor quality of life update that i don't think is hard to implement.
I would prefer a 'Wrap Index' check box instead, that way one can choose between behaviors, since the default value has its uses, mainly for debugging the node tree.
Also maybe a 'Is Valid Index' output could be available when 'Wrap Index' isn't checked.