Page MenuHome

Fix T89709: Avoid double node links after delete and reconnect
ClosedPublic

Authored by Colin Marmond (Kdaf) on Nov 1 2021, 10:51 AM.

Diff Detail

Repository
rB Blender

Event Timeline

Colin Marmond (Kdaf) requested review of this revision.Nov 1 2021, 10:51 AM
Colin Marmond (Kdaf) created this revision.
Colin Marmond (Kdaf) edited the summary of this revision. (Show Details)Nov 1 2021, 10:54 AM
Colin Marmond (Kdaf) edited the summary of this revision. (Show Details)

Thanks for the patch!

This adds an O(n^2) loop. While it's often necessary with the current architecture of tree topology changes, I wonder if it should be avoided here. On the other hand, this is only called after an operator finishes. Maybe @Jacques Lucke (JacquesLucke) has an opinion here.

Hans Goudey (HooglyBoogly) retitled this revision from When using delete and reconnect node, evoid doubles to Fix T89709: Avoid double node links after delete and reconnect.Nov 2 2021, 5:05 AM
Hans Goudey (HooglyBoogly) edited the summary of this revision. (Show Details)

I think having a loop through all the links is the only solution. Because we can not actually list all the links of a multi input socket.

If I try a different approach, maybe getting all the links from the inputs of the deleted node, it would work in some cases. But, if the deleted node has a multi input socket, it wont work.

Maybe this patch will be pending until the link pointer of each sockets get more stable and multi input ready.

As talked with Jacques Lukes, there is probably no other options here until changing the pointer.
https://blender.chat/channel/geometry-nodes?msg=h3h6FYk0xZZO8OfCG

Should mention that in the worst case this is significantly worse than O(n^2). In total we have foreach node -> foreach link -> foreach link -> foreach link (if you count the loops in node_delete_reconnect_exec and adjust_multi_input_indices_after_removed_link). Given that some of the loops are only entered once though, it's not as bad as it first sounds (still bad though...). This specific change probably won't be a problem in practice any time soon. So I think it's fine.

A possible way to avoid too many nested loops is to do this duplicate-link removal as a separate post-processing step.

This revision is now accepted and ready to land.Nov 3 2021, 12:42 PM