This was an uncommitted patch I had.
The idea is to move away from using BMesh exceptions entirely, since its almost always better to simply use a fallback or do nothing.
(instead of leaving the mesh in some invalid/broken state).
The patch is quite simple: If a BMesh Operator never raises an exception, don't preemptively make an entire copy of the mesh.
One reason I wasn't so confident about this patch, is some BMesh operators call other operators, so its possible an operator will use exceptions indirectly. This is why I would only apply this patch, with the intention of moving away from using exceptions all together.
I *think* this is OK to go into master... however some lower level functions raise exceptions, so I'm not totally sure all cases are covered (though initial checks seems this covers most cases, areas that are missed will assert so they can be resolved over time).
Further work...
Here are some loose plans I had, they aren't very large changes in fact.
- Remove exceptions entirely. (they're only needed in very few cases).
- Instead of raising exceptions, something like the current BMesh exception API could be used to report warnings.
- Slightly related, a BMesh operator's exec function could use a return value that signals if a change was made or not, this way a bmesh operator could do nothing, report a warning (which would in most cases be forwarded to wmOperator warning), and no undo push would be needed,
If for some reason we do need to support a tool which takes the mesh and puts it into an invalid state (where the previous state needs to be restored), its possible to use the edit-mode undo stack for this.
@Bastien Montagne (mont29), assigning to you, if you like to check look into this, otherwise, feel free to close.