Remove duplicate points in SoftBody3D gizmo plugin
Fixes #108149
With the old implementation, all the points were added without checking for duplicates.
This also fixes the problem in the linked issue where points were not highlightable, as there were often overlapping points on top.
For reference, in the provided image, it previously displayed that I had ~480 points. With the fix, it is showing the correct number (114). Just in case, I highlighted all the points on the mesh top-to-bottom (7, excluding the top-most & bottom-most point), and all the points along the circumference (16). 16*7 + 2 = 114, aligning with the resulting number of points.
Right, I see what you mean. I assume the intended behavior here would be to select all overlapping points in the same position?
I assume the intended behavior here would be to select all overlapping points in the same position?
Yes :slightly_smiling_face:
Edit: found an existing issue, 108059
~~While testing, I noticed an issue when changing the subdivide values and changing the selected nodes:
I checked with latest master, and it seems like its unrelated to my changes. I will open a separate issue regarding this.~~
Anything further that I need to do here? With the current implementation, whenever there is an update to the mesh, I update a mapping of a single point to a group of points which are in a close enough proximity. This grouping is later used on-click to select all the points in said overlap group.
I tried several things, but was unable to replicate your scenario.
What I assume happened is, you had point index 10 pinned in the project the previous time you tested (importing the original zip, it does indeed show up as selected in the array editor, but not visually) and now since this visual point contains 2 physical points, with 1 of them being de-selected, it visually shows it as such. In fact, point 10 was still selected even in the 2nd zip you sent (in the array editor, not visually, since there's a deselected overlapping point):
(the point in question, index 10, with 142 as the overlap point, coordinate axis for convenience)
In a realistic scenario, users can click the "old points" to deselect them, and click again to select all the overlapping ones. Furthermore, (as long as you can't replicate this from clicking or other such actions) I don't quite see this as a bug. The visual clicking adding all the overlapping points is a QoL improvement, but it shouldn't be forced on the users. If a user wants to select 1 specific physical point manually without all the overlapping ones, they should be able to do so (via array editor or in code).
Edit: I think I got your point after writing the entire comment - at this point, my solution no longer matches with the title of the PR. I can re-add the highlight as long as any point in the overlap is selected.
With the new change, I'm highlighting all overlapped points as long as any single point in it is selected. In hindsight, this should've been obvious 😅 I think this is what you had in mind?