Remove certain slices from a spread or only keep certain slices / Space Invaders

Hello forum,

I’m still having trouble to solve the space invaders problem recently posted to the chat, trying to remove certain slices from a spread. The idea is to remove all slices of the spread, in which a condition is true (CircleIntersectsCircle).

In my current “solution”, it does not only remove the slice it should but most of the times also other slices as it seems to be true to long.

I have tried it with “IndexOf” and “RemoveSliceAt” as well as the “Select” Node, both with the same problem…

Probably there is a very simple solution on that?

Thanks for your help,
benju

Patch: space_invaders_list_013_MyCircle.vl (62.2 KB)

Sounds like you could use the Keep pin of the Foreach region to tell which slices should pass through the region or be discarded.

Another solution could be to use the Where region, where you can patch the condition that tells which items should remain in your spread.

edit : a little example here :

image

1 Like

Thanks a lot, @sebescudie and @tonfilm. “Keep” already does the job, now I understand what it does. Will figure out the Where region as well an post my patch later.

“Keep” is what I was looking for. It works like a charm. So solution found! Thx again.

Question 1:
I also tried to solve it with the “Where” region. But with the “Where” region I again have the same problem as I had with my both inital solutions (1.) RemoveSliceAt and 2.) Select): the Where region with CircleIntersectsCircle-Condition does “remove” more than just one of the slices. Is this a timing thing with the “recursive” spread?

Question 2: What ist the Input 2 of the “Where” region for?

Here’s the new patch with both variations “Keep” and “Where”:
space_invaders_list_015_Keep-and-where.vl (60.4 KB)

And a cleaner version of the patch using the keep variation only:
space_invaders_list_016_Keep.vl (39.4 KB)

the problem is similar to spreading problems in vvvv beta, you just remove slices somewhere with the Where region, but the upper Repeat loop doesn’t know which slices you mean… if the Where region filters out a slice in the middle, you will just remove the last one with the Repeat loop, as it just uses a Count that counts down as you remove slices.

So you need to feedback the actual objects that you have filtered out, instead of having them just sit there in the Repeat region.

this is the slice index, like the index pin in loop regions. sometimes, where conditions depend on the index.

here is the patch, basically the same as the particle system in the first gamma tutorials:
space_invaders_list_015_where.vl (42.5 KB)

1 Like

I updated my example patch using a record and operations for both the “Keep” as well as the “Where” Example (Where is basically the same as @tonfilm posted above):
space_invaders_list_017_Keep-and-where_Update.vl (63.2 KB)

It helped me a lot to finally understand how to build your own datatype, use Records and Operations watching Joreg’s Object Oriented Patching Workshop again after @baxtan was pointing me to in the chat, thx!: https://thenodeinstitute.org/courses/node20-vvvv-workshop-bundle/

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.