The purpose of doing this is so that removing the smallest weights doesn't increase the relative weights of bones other than those bones' parents.
As an implementation note, due to the fact that there could be multiple armature modifiers, with the same bones, but different hierarchies: the order we should check for a bone's parent is that we should start with the current context.pose_object if it is set, otherwise iterate through the armature modifiers in order until one of them has the bone we're looking for and that that bone has a parent bone.
This would of course only work with Deform Pose Bones.
If the weight to be dissolved has no parent bone we could give a user option:
Skip: Pick the next smallest weight instead
Transfer to children: Split the weight equally between child bones already assigned on that vertex (default)
There could be a third option to use Transfer to children if the bone has any children assigned to the vertex, otherwise Skip
Despite these options, there could still be more than the desired number of groups, e.g., multiple bones with no parents or children, in which case, then go through the weights again and simply delete the smallest weights. When doing this, we should record how many failed as we iterate initially, but then use Blender's existing Vertex Group Limit Total operator.
A force limit option could be provided for toggling whether this is enabled or not.
Realistically, the case of no parent bone would only usually happen for when the Hip weight is the smallest weight on a vertex.
If the weight to be dissolved does have a parent bone, but it's not assigned to the vertex we could:
Assign the vertex to the parent group and dissolve the weights into it (if there are still more weights that need to be dissolved, the newly assigned group should be ignored, otherwise it would be considered next group with the lowest weight), after doing so, if the number of assigned groups is still too high, the process should be repeated again.
Find the closest parent bone that is assigned to the vertex and dissolve the weight into there
A rarer case might be where there is a chain of bones that go around a corner like \_/ a vertex could be assigned to the first and last bones of the chain, but not the middle bone, in which case, dissolving the weight of the last bone would have nowhere to go. We would need to decide whether such a bone is allowed to be dissolved into the first bone, despite it not being its direct parent, we could call this the 'closest parent group assigned to the vertex'.
The existing Vertex Group Limit Total operator also provides the ability to operate on only the selected pose bones, it may be useful to also implement for this subset.
The purpose of doing this is so that removing the smallest weights doesn't increase the relative weights of bones other than those bones' parents.
As an implementation note, due to the fact that there could be multiple armature modifiers, with the same bones, but different hierarchies: the order we should check for a bone's parent is that we should start with the current context.pose_object if it is set, otherwise iterate through the armature modifiers in order until one of them has the bone we're looking for and that that bone has a parent bone.
This would of course only work with Deform Pose Bones.
If the weight to be dissolved has no parent bone we could give a user option:
Skip
: Pick the next smallest weight insteadTransfer to children
: Split the weight equally between child bones already assigned on that vertex (default)Transfer to children
if the bone has any children assigned to the vertex, otherwiseSkip
Despite these options, there could still be more than the desired number of groups, e.g., multiple bones with no parents or children, in which case, then go through the weights again and simply delete the smallest weights. When doing this, we should record how many failed as we iterate initially, but then use Blender's existing Vertex Group Limit Total operator. A
force limit
option could be provided for toggling whether this is enabled or not.Realistically, the case of no parent bone would only usually happen for when the
Hip
weight is the smallest weight on a vertex.If the weight to be dissolved does have a parent bone, but it's not assigned to the vertex we could:
A rarer case might be where there is a chain of bones that go around a corner like
\_/
a vertex could be assigned to the first and last bones of the chain, but not the middle bone, in which case, dissolving the weight of the last bone would have nowhere to go. We would need to decide whether such a bone is allowed to be dissolved into the first bone, despite it not being its direct parent, we could call this the 'closest parent group assigned to the vertex'.The existing Vertex Group Limit Total operator also provides the ability to operate on only the selected pose bones, it may be useful to also implement for this subset.