Make armatures suitable for export to file types that limit the number of deform bones per vertex.
Background: Blender does not limit the number of deform weights per vertex, but many game engies do. Vertex Buffer Objects (VBOs) are limited in versions of OpenGL where hardware skinning deforms the mesh according to animation of the underlying bones. Meshes may have thousands of vertices, while an armature is usually between 20 and 60 bones. Therefore, storing animations on the bones and using that to drive the mesh deformations saves a tremendous amount of stored data. “Skinning” or driving the deformations of the mesh with the bone matrices, often takes place on the GPU where there may be a hard limit to the number of bone weights. Some versions/implimentations of openGL have a limit of 4, while the iPhone has a limit of 3.
Vertex Groups and Weights: Any collection of vertices can be put into a group. Particle emitters, hair and armatures all make use of vertex groups and the weights could correspond to emission rate, hair length and bone influence respectively, always ranging from 0 to 1.
Description: The “Lim Number Deform Weights” operator is available through the Weight Paint UI panel in Blender. An object is selected and the operator is applied. The result should leave non-deform weights (hair, particle emitters, etc) in tact while culling deform bone weights to the user-specified number. The default number of weights is 4, set in a panel below the button. The script will execute with the default when you press the button, so if you need to set the limit higher, you will need to “undo” = ctrl+z, to undo the cull to 4 bones, then select the value you want and re-apply.
Most rigs will not need more than 4 bones for good skinning, but facial rigs are an exception with 8 or more deform weights per vertex not un-common. A typical workflow might require high-res skinning for video sequences of characters talking, but then exporting to a low-res skinned mesh for exporting to a game engine for gameplay.
Exporters: The operator should be exposed so that exporter scripts can easily make use of it. If there are multiple characters in a scene we will want to be able to apply the script to all armature skinned objects in it.
Q Should we normalize after culling automatically or leave it to the user?
Q can we make the operator “undo” friendly? Yes. I tested Undo and Redo and it works automatically ( I copied the register undo section from another weight paint tool when i made the operator)
Q what should Cull Bone Deform Weights do with shape keys? Initial tests suggest that shape keys don't de-rail badly after applying the operator (no crashes!).