Fix incorrect merged weights from ignored bones in FBX import #104928

Merged
Thomas Barlow merged 3 commits from Mysteryem/blender-addons:fbx_cluster_import_no_divide into blender-v4.0-release 2023-10-06 05:25:42 +02:00
Member

Given a chain of bones A -> B -> C and a vertex weighted to all three
bones: When C is ignored and its weight is to be merged into its parent
B, the sum of the weights that are not A should remain the same as
before the merge. The current code is instead setting the B weight to
the average of the B and C weights, which does not maintain the sum of
the weights. The division that was creating the average has been
removed, so now the weights in C to be merged into B are added directly
to the B weight.

Because the maximum value a weight can be set to is 1.0, this poses a
problem when the weights to be added together exceed 1.0. Re-normalizing
all the weights on the vertex in this case sounds like it could work,
but unfortunately, we only have access to all the weights for one bone
at a time with the current implementation. Re-normalizing the weights
after adding all the weights to each vertex is too late because the
weights exceeding 1.0 would already have been clamped to 1.0. A comment
has been added to indicate that this is a known issue.


This weight merging feature is probably unlikely to have seen much use because the only ignored bones that could have their weights merged are the imported end bones when using the Armature>Ignore Leaf Bones option of the importer.

Examples showing one import with Armature>Ignore Leaf Bones enabled and one import with default settings. Then with the 'B' bone rotated:

Before After
image image
Given a chain of bones A -> B -> C and a vertex weighted to all three bones: When C is ignored and its weight is to be merged into its parent B, the sum of the weights that are not A should remain the same as before the merge. The current code is instead setting the B weight to the average of the B and C weights, which does not maintain the sum of the weights. The division that was creating the average has been removed, so now the weights in C to be merged into B are added directly to the B weight. Because the maximum value a weight can be set to is 1.0, this poses a problem when the weights to be added together exceed 1.0. Re-normalizing all the weights on the vertex in this case sounds like it could work, but unfortunately, we only have access to all the weights for one bone at a time with the current implementation. Re-normalizing the weights after adding all the weights to each vertex is too late because the weights exceeding 1.0 would already have been clamped to 1.0. A comment has been added to indicate that this is a known issue. --- This weight merging feature is probably unlikely to have seen much use because the only ignored bones that could have their weights merged are the imported end bones when using the `Armature`>`Ignore Leaf Bones` option of the importer. Examples showing one import with `Armature`>`Ignore Leaf Bones` enabled and one import with default settings. Then with the 'B' bone rotated: | Before | After | | -- | -- | | ![image](/attachments/c5597eb0-dd2b-4bed-a393-ed58f79dca24) | ![image](/attachments/4787a307-26cf-4910-a013-30e9cc243e6e) |
Thomas Barlow added 1 commit 2023-10-01 02:14:10 +02:00
a2e10e6a9c Fix incorrect merged weights from ignored bones in FBX import
Given a chain of bones A -> B -> C and a vertex weighted to all three
bones: When C is ignored and its weight is to be merged into its parent
B, the sum of the weights that are not A should remain the same as
before the merge. The current code is instead setting the B weight to
the average of the B and C weights, which does not maintain the sum of
the weights. The division that was creating the average has been
removed, so now the weights in C to be merged into B are added directly
to the B weight.

Because the maximum value a weight can be set to is 1.0, this poses a
problem when the weights to be added together exceed 1.0. Re-normalizing
all the weights on the vertex in this case sounds like it could work,
but unfortunately, we only have access to all the weights for one bone
at a time with the current implementation. Re-normalizing the weights
after adding all the weights to each vertex is too late because the
weights exceeding 1.0 would already have been clamped to 1.0. A comment
has been added to indicate that this is a known issue.
Thomas Barlow requested review from Bastien Montagne 2023-10-01 02:15:28 +02:00
Bastien Montagne approved these changes 2023-10-03 18:15:56 +02:00
Bastien Montagne left a comment
Owner

Thanks, think clamping to 1.0 is an acceptable solution for now indeed.

Thanks, think clamping to `1.0` is an acceptable solution for now indeed.
Thomas Barlow added 2 commits 2023-10-06 05:19:35 +02:00
Thomas Barlow merged commit 25697d80c2 into blender-v4.0-release 2023-10-06 05:25:42 +02:00
Thomas Barlow deleted branch fbx_cluster_import_no_divide 2023-10-06 05:25:42 +02:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#104928
No description provided.