What links editmesh files to their bmesh counterpart?

Take editmesh_inset, for example. What in that code tells blender to use functions in bmo_inset such as bmo_inset_region_exec?
I suspect that it is through functions in editmesh_inset like BMO_op_exec, but I’m not sure how it works :stuck_out_tongue:

“Bmesh Operators” are described very briefly in a section of that name in https://archive.blender.org/wiki/index.php/Dev:Source/Modeling/BMesh/Design/ (sadly, so much documentation is archived until it is rewritten for modern Blender; everything there should be taken with a grain of salt as it may be outdated, but there is still a lot of useful info there).

As you suspect, the BMO_op_exec call in, say, edbm_inset_calc, makes the connection. You init an op with a printf-like string that gives the name of the operator and the string forms of values, and also uses special formats to indicate things like “all of the edges with a given header flag set go in this slot”.

The Bmesh Operators are defined/specified in bmesh_opdefines.c. So for example inset_individual is defined at the declaration of bmo_inset_individual_def, where you will see that when the BMO_op_exec_call is executed in the editmesh routine, it will pass control to bmo_inset_individual_exec in bmo_inset.c.

1 Like

Thanks. I think I got it. :smiley:

Got another Bmesh question, you seem like a good person to ask :smiley: Is there a function to merge verts from within a bmo file? I saw the pointmerge operator, but I’m not sure how or if it can be called within a bmo file. Otherwise I could transfer the code to a higher-level editmesh file.

I’m pretty sure BMesh Operators can call other BMesh Operators. Looks like the one to call is weld_verts or pointmerge.

Got it.

Before I try to program it, do you know if bmesh operators support iteration, as in an operator calling itself with new parameters?

I guess you mean recursion? I believe that is OK, as long as you have some test that will stop infinite recursion, of course. And you have to make a new BMOperator storage for each new recursive call (either put it as a local variable of the routine that does the recursion, or allocate it and free it after the call.

1 Like

Yep; recursion, not iteration. Thanks for the pointers.

How could one rip a vert from all faces except for a desired face? Is there, perhaps, a function to disconnect a face from one of its vertices? Then I could apply that function to all the other connected faces.

Better yet, Is there some function to incorporate an existing vertex into an existing face? It could replace my current process of subdividing an edge, ripping the vert from all other connected faces (not sure on how to do that anyway), and merging it to the desired vert.

Sorry, don’t know the answers off the top of my head. For your first question, I suggest looking around the code that implements vertex rip (edbm_rip_invoke__vert for instance). For the latter, I don’t know of a way to do that. Your current process sounds like what I would do.

Thanks; found BM_face_loop_separate_multi after some digging which seems to work :smiley:

Is there a function to get the BMEdge formed by two specified vertices?

BM_edge_exists(v1, v2) will return an existing BMEdge between vertices v1 and v2 if it exists.

1 Like