Hi all,
In order to get familiar with BMesh, I just started translating my MATLAB implementations of surface subdivision schemes to Blender, using the Python console. Since I couldn’t find a comprehensive tutorial on how to use BMesh (I did find the Python API though), I’m not entirely sure whether my approach is correct. Concisely described:
I work in Edit Mode, so therefore I use from_edit_mesh(). Next, I use the components from this current BMesh to create a new BMesh from scratch. My approach in MATLAB was to first create all new vertices, then the (half)edges and finally the faces. But it seems that in Blender/BMesh I only need to create the new verts and faces, since the edges and loops are added automatically?
More to the point, once this new BMesh is finished, how can I then display it? The function update_edit_mesh() requires a Mesh type, not a BMesh type. And when I try to use to_mesh() to convert my new BMesh to an existing Mesh, it says “Mesh is in edit mode”. How should I handle this?
The idea is to start with the implementation of Catmull-Clark (I know it is already available in Blender) and Loop subdivision, including the rules for boundaries and creases, using some improved stencils. I noticed that an edge in a BMesh doesn’t have a crease property, why not? This might slightly complicate the support for creases in the surface. Additionally, it should also be possible to mark a vertex as a sharp/corner vertex - there doesn’t seem to be a property for this yet.
Finally, I also implemented the limit surface in MATLAB, i.e. the parametrization of the resulting surface after virtually applying the subdivision scheme an infinite number of times. Would this be useful for Blender somehow? Apart from NURBS/B-Splines I’m not sure whether it is possible to use parametric surfaces (i.e. using basis functions) in Blender?