New Developer: Help with implementation

Hello,
I would like to implement a persistent edge borders display in blender.
There are some requests in rightclickselect but no one took it up so I decided to take it up myself.
Here is my post:

And here’s another one thats 4 years old.

I could get started and try it out but it would be much faster if someone could point me in the right direction as I don’t wanna spend too much time on this feature in C. I am comfortable with C programming but unfamiliar with the Blender source code.
I basically wanna add a new Mesh Edit Mode display called Border

Mesh Edit Mode
Creases | Sharp | Bevel | Seams | Border

It should persistently show the mesh borders like so:


I currently made a hacky prototype with python and it works fine but I have to manually update it and lose my selection:

import bpy

def main(context):
    bpy.ops.mesh.select_all(action='SELECT')
    bpy.ops.mesh.mark_seam(clear=True)
    bpy.ops.mesh.select_all(action='DESELECT')
    bpy.ops.mesh.select_non_manifold()
    bpy.ops.mesh.mark_seam(clear=False)
    bpy.ops.mesh.select_all(action='DESELECT')

class ToggleBorder(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.toggle_border"
    bl_label = "Toggle Border Operator"

    @classmethod
    def poll(cls, context):
        return context.active_object is not None

    def execute(self, context):
        main(context)
        return {'FINISHED'}


def menu_func(self, context):
    self.layout.operator(ToggleBorder.bl_idname, text=ToggleBorder.bl_label)


# Register and add to the "object" menu (required to also use F3 search "Simple Object Operator" for quick access).
def register():
    bpy.utils.register_class(ToggleBorder)
    bpy.types.VIEW3D_MT_object.append(menu_func)


def unregister():
    bpy.utils.unregister_class(ToggleBorder)
    bpy.types.VIEW3D_MT_object.remove(menu_func)


if __name__ == "__main__":
    register()

    # test call
    bpy.ops.object.toggle_border()

I already have blender running with Visual Studio 2022 ready for programming, just want someone to give me hints to speed things up please.
Thank you so much!

1 Like

It should behave the same as Mark Seam. I tried:

            BM_edge_select_set(em->bm, e, true);
            wmOperatorType ot = {0};
            MESH_OT_mark_seam(&ot);

inside edbm_select_non_manifold_exec but got ***cont*** was nullptr.

1 Like

Its gonna be a while before I’m able to get into the Blender source code and actually implement something… I believe this feature is quite simple to add so if anyone can add it it would be GREAT! :smile_cat:

What do you think about using Geometry nodes for highlighting?

Here an example (I created a while ago).

Quads are green. Tri’s are blue’ish. And NGons are orange to pink.

I had to create a special material, because I was not able to visualize the data properly with the overlay alone.

That’s very cool but I don’t think you can get the blender seams display from geometry nodes.
When you mark a seam in blender, it creates a special visual effect whereby your edge is surrounded by colored lines as an outline which is perfect because you can still see if your edge is selected or not and its highly performant.

It is interesting to play with modifiers, which only marks edges/faces/points to visualize something like topology information (NGons, Poles, etc.) in Edit mode.
It is an ‘odd’ kind of modifier, because its purpose is mostly to influence the appearance of the mesh in the 3D view (and Edit mode).

Its a draft …

borders

Sadly …
Viewport Shading // Attribute
… is not a working option.

Workaround … border edges are turned to curves to visualize. Not that fast. And true border edges are hidden behind the curves.

That’s a neat trick, but feels like drawing curves is a workaround and wouldn’t be too efficient compared to the C implementation. It should be very trivial for a Blender developer so IDK why no one is taking it up.
Literally just re-use the existing code for drawing seams for non-manifold edges, done, no new code.