I've been trying to solve it for a few days now and I am totally stuck. In naturall programming I would simply create a variable to update over each loop, but I can't seem to figure it out on Houdini.
I have 2 pieces of geometries - the point cloud with thousands of points and the fractured box with pieces joined by connectivity. What I need to do is to take each piece of the box and translate it into the location of given point from pointcloud. Sounds simple enough if you want to do just it.
However, I cannot just take any point from the point cloud - as what I am trying to create is actually the tool that procedurally finds a "spare space" to place each piece without overlapping with eaochother, without changing the piece scale or rotation. Copy to points with attribute from piece doesn't do the trick for me.
The way I try to do it - and possibly this is just wrong approach, so feel free to push me in the right direction - is to iterate every piece in for-each-loop, and in each iteration (e.g. iteration 2 for piece ID 2) I take the smallest available point from point cloud and check, if tranforming pieceID=2 to this locations is safe or not. If new location overlap with any of the already moved pieces - it's not safe and I need to search for the next point. I do this check within compile block actually and it's not to difficult. BUT after I find the safe target point I want to remove all of the points that have ID smaller than our safe target point. This means I need to update not only the fracture box geometry, but also the point cloud, and I have no clue how to approach it.
The only alternative way I see for this is to create a detail array attribute withing box geometry with list of all the "already used" points IDs and then just start seach in every other loop based on this detail attribute.
I've already tried to do it all solely in VEX and with for each loops nested in each other. I also tried to update the point cloud after each loop with compile block. I would share screenshots, but NONE of my solution works and maybe it is just better to hear your fresh ideas. I am totally stuck

Thank you in advance, I hope you can understand what I am trying to do.



