MichaelGlenMontague/shape_keys_plus

Terribly slow

mgrewe opened this issue · 6 comments

Hey @MontagueMGM, thanks so much for the addon. I really appreciate the work. However, already a very basic operation like adding a new folder is terribly slow (takes more than 10s). I don't know if someone has encountered the same issue or it is just unavoidable?

I'm on Linux with Blender 2.80. If I can help in bug tracing, please let me know.
Cheers

Is this happening on a production-ready object, such as one with many vertices, bones, and modifiers? Blender's source code doesn't expose an operator to move shape keys to a specific index, so the add-on has to move each one by one from its default location at the very bottom of the list to the target you have set under the "Add/Copy" placement setting. This includes folders, as those are also shape keys.

The only solution I can think of implementing on the Python side is to temporarily disable all of the object's modifiers when shape key movement is in progress. I have started working on a version 2.0.0 that includes this fix, and it's proven to work greatly, but there are many other unfinished features. For now I'll just patch the current version with that one fix.

Thanks for the quick reply. In fact, deactivating the modifiers (there was a subdivision enabled) improves performance. Not as quick as you would expect form such a seemingly simple operation, but significantly faster as before. In this case, the bottleneck is certainly blenders Python API.
However, I greatly appreciate this addon!!!

Just now fixed, or at least alleviated, in patch v1.3.3. I also reverted the 2.80 mute icon back to an eye since the checkbox is already used for multi-selection.

Fak3 commented

Why the plugin uses blender internal index of shapekey, if it is so hard to work with? Can't you save index as a custom property on the shapekey or object or mesh datablock and use this property to sort the list?

Why the plugin uses blender internal index of shapekey, if it is so hard to work with? Can't you save index as a custom property on the shapekey or object or mesh datablock and use this property to sort the list?

bpy.types.ShapeKey is only a bpy_struct, not an ID, so it can't be given custom properties. That's why folder data is held in the shape key's vertex group instead. The collection type of shape keys (bpy_prop_collection) doesn't have anything to help with sorting, either.

I attempted a visual workaround a long time ago while working on v2.0.0. The custom property's index would have to be updated every time the shape key's index changes, and a shape key doesn't store its index as a property. If you move a shape key while outside of the Shape Keys+ panel, the whole thing would break because the add-on still thinks the shape key is somewhere else. Theoretically, visual sorting as opposed to internal sorting, would have been as fast as filtering. But the current method sorts shape keys in a way that's sure to be compatible with the rest of Blender's functions, such as exporting.

I'm reopening this issue because it's not truly solved yet in v1.3. I'm currently adding finishing touches to v2.0, one of them utilizing the temporary disabling of the object's visibility (which I just learned actually maximizes performance, as the object is no longer being updated every time a shape key operation happens) as well as the disabling of the object's modifiers whenever the Shape Keys+ panel is open.

The reason modifiers still have to be disabled even when the object is hidden, is because modifiers like Multiresolution will greatly increase the amount of time it takes for an object to un-hide. I was surprised to see how quickly I was able to move dozens of shape keys across my complex 200-shape key character.

If anyone wants to achieve this performance boost manually, know that you have to use Object.hide_viewport (from the Object Properties tab), not ObjectBase.hide_viewport (from the Outliner).