Advice for "remove doubles" modifier implementation

Hi,

I’m trying to find the good approach to implement a remove doubles modifier.

Looking at the code, I’ve seen that this code already exists in BMO, via bmo_remove_doubles_exec, which calls:

  • bmesh_find_doubles_common
  • and another operator bmo_weld_verts_exec

So, what can be the good approach for this modifier?

  • Reimplementing all (except kdtree part) in the modifier context?
  • Reuse the operators “directly”? Is that good to do that in an non operator context?
  • Split what have been done in the op context so that it can be reused for both operator and modifier?
  • Other?

Thanks

2 Likes

Take a look at my temp-modifier-rm-cddm branch. I’ve recently ported the CDDM_merge_verts() function to BKE_mesh_merge_verts(), which can merge vertices in a Mesh. It’s used in the mirror and array modifiers, so it should be reasonably simple to use this in a new modifier that just does the merge.

in remove doubles we need this too