Way to reliably track vertices even after editing

Hi, I’m working on an add-on for modular, LEGO brick like character creation, I’ve been thinking about how to support user-generated meshes, you’d load one of the building blocks, sculpt to your hearts content, add it to the library and now your new building block can be applied to all the characters in the library. E.g. you extrude some horns on one character, commit it and now properly scaled horns are available for any of the other characters too.

The problem comes when trying to work backwards. The add-on needs to be able to map a custom mesh on to an existing building block as a series of deformations/loop cuts/vertex merges etc. Basically, a bit like shape-keys but for meshes that have different numbers of vertices.

Is there a reliable way to keep track of each vertex in a mesh even if a user adds or removes others? Something like a universally unique ID for vertices or some way to provide that functionality?

I know that Blender has vertex IDs but from what I gathered from the docs, those are only stable under deformations, removing even a single vertex could completely change all the vertex IDs in the mesh. I’m looking for a way to identify each vertex no matter what someone does to a mesh.

What you’re asking for is not really possible as written*, but it’s definitely possible to have interchangeable 3D decals, if you will.

You can just use a Boolean union modifier. You could also use Geometry Nodes to instance the 3D decals (not sure what else to call them), you’ll have more granular control with GN and it’ll probably be easier overall.

You could also just leave them as separate objects and parent the new objects to the base. Visually, parenting the horns to the head will look like they’re part of the base mesh, and it will save you a whole lot of hassle.

You could also join the two objects and use a remesh modifier. You might lose some detail this way, depending on your settings.

Lots of options!

    • to clarify: let’s say your horns have a loop with 8 vertices at the end. Your head must have 8 vertices in exactly the same places, or the horn will deform. This means that if you have a different horn with 6 vertices, it won’t work with that head. You’d have to recalculate the mesh on the head for every possible addition, but if the additions are user-provided, this is mathematically impossible

Yeah, I had a feeling that there was not going to be a simple solution. I figured I should ask anyway just in case I’d missed something.

I did think about keeping all the parts as separate meshes, but I’ve had mixed results with stock automatic weights on split meshes (and so would need manual tweaking afterwards) whereas it works very, very well when you have a single, unified mesh (at least on the meshes I’ve tried so far). As much as I don’t mind booleans, maintaining clean quads at all times could be challenging…

I’ll have to see if I can use the topology and edge flow to try and work it out. Oh well, maybe I’ll just have to create a special, more strict workflow for actual mesh changes.

Smaller parts you can just use normal maps, bigger parts like the horns… I honestly think leaving them as separate objects will be easiest. It should be fairly easy to rig them- just assign them to the Head bone vertex group. No weight painting needed, one click, very easy to automate with a script

If for example you think in terms of LEGO bricks, you can bypass Blender vertices entirely.

For instance, I have tried a few addons to create capsules, since capsules are a great shape for prototyping. However the problem is that once a capsule mesh exists it can’t be edited, changing scaling or length it distorts the shape.

For this reason I find it better to create a new addon of my own, to have capsule shapes appear on the scene as virtual objects. Once the blocking phase is completed, real 3D shapes can be generated with a click of a button.

Perhaps this is a good approach to consider.

I’ll have to look into that, but that might be a bit outside my current skill set, I’ve got a reasonable amount of experience with databases but not so much with the low-level Blender APIs. Still getting the hang of that.

Couple minutes ago, i realised i might be able to assign a unique vertex colour to each vertex (up to a point). I was playing with this just now and each vertex seems to keep it’s colour even when messing around with things (subdivding also subdivides the colour - so over short distances, you know where it came from).

Duplications wouldn’t work well, but between some kind of rainbow checkerboard and information on which vertices link to each other, I might be able to solve it…

Actually, that gives me an idea, I wonder if I can (ab)use vertex groups to do what I need. It doesn’t need work forever, it only has to cover the period between someone loading a base shape, modifying it and then saving it to the library, the database can take over from there (where I do have unique, unchanging vertex IDs). Probably not every vertex needs a unique ID within Blender, only enough of them to rebuild the topology… hmm

Just came across this: https://b3d.interplanety.org/en/assigning-custom-properties-to-vertexes/ and this BMesh Custom Float/Int Layers - #3 by supergra

Apparently the BMesh system has support for custom data layers where you can “tag” vertices with whatever data you want, that might solve my issue. Assuming the layers track the vertices themselves (and not the indexes) and won’t get broken by deleting or adding vertices, I wonder if I could tag each vertex with a globally unique ID as a BMesh layer and track them that way.

Good finding, this might do the trick.