Performance of bmesh operators with multiple input values

Hi. I’m trying to utilize Blender features for procedural modeling in Sverchok.
Bmesh data structure is great but existing operators, looks like, does not designed for procedural modeling.

For example bmesh.ops.inset_individual operator.

It works perfectly in this way.

bm = bmesh.new()
bm.from_mesh("My huge mesh")
bmesh.ops.inset_individual(bm, faces=bm_faces, thickness=my_value, **kwargs)

And result will look like this.
image
But in procedural modeling we would like to have more control! And would like to see something like this:
image
As you see I try to apply different values offset values for each face. In this case the code looks like this:

values = [random.random() for _ in bm.faces]
for face, value in zip(bm.faces, values):
     bmesh.ops.inset_individual(bm, faces=[face], thickness=value, **kwasrgs)

But performance in such approach increases exponentially with linear increasing number of faces.

Actually I does not see reasons for such increasing. Probably when the operator is finishing its work it checks something what involves all elements of input mesh. Probably it recalculate indexes each time after operator was called but it would be nice if it could be done later after all process. In this case I expect to see call of operator in this way:

bmesh.ops.inset_individual(bm, faces=[face], thickness=value, **kwasrgs, post_process=False)

Or probably there is another solution of this problem?

2 Likes