FBX IO: Fix error importing BlendShapeChannels with extraneous FullWeights #104956

Merged
Thomas Barlow merged 6 commits from Mysteryem/blender-addons:fbx_fix_extra_fullweights_error into main 2023-11-05 10:16:56 +01:00

6 Commits

Author SHA1 Message Date
4bd757f0db Increase FBX version 2023-11-05 08:53:31 +00:00
33e1373492 Fix bad merge in rebase 2023-11-05 08:01:35 +00:00
f1cb952249 Missed comment update in the merge 2023-11-05 07:18:36 +00:00
c10fea6546 Include bug report comment on the same line as the exception
This will make it show up in tracebacks.
2023-11-05 07:16:08 +00:00
1ea4d1f110 Add more checks for determining whether to import FullWeights as vertex weights
This should eliminate the case of FBX from Unreal with extraneous
FullWeights because those always seem to be negative for some reason.

An alternative check that could be made for these extraneous Unreal
FullWeights is that their absolute values seem to always be far smaller
than the smallest single precision non-zero float (vertex weights are
single-precision). The smallest subnormal single-precision float is
1e-45, but these extraneous FullWeights are usually around 1e-200.
Though if there are systems running Blender where single precision float
is 64 bits, this check wouldn't work.
2023-11-05 07:16:07 +00:00
9ff5b81433 Fix error importing BlendShapeChannels with extraneous FullWeights
Fixes a rare cause of #84111, but does not fix the main issue.

Aside from Shape Keys with Vertex Groups exported by Blender, rarely, a
BlendShapeChannel can have more FullWeights than Shapes assigned to it,
which would fail an assertion that the number of FullWeights equals the
number of vertices moved by the Shape with an allowed exception of when
there is only a single FullWeight.

This assertion was not correct because each FullWeight is the
deformation percentage of the BlendShapeChannel that fully activates
each Shape assigned to the BlendShapeChannel.

This patch keeps track of the Shapes assigned to each BlendShapeChannel
so that the number of FullWeights can be correctly compared against the
number of Shapes. FBX appears to ignore any excess FullWeights, so the
updated assertion allows this too.

Blender exported Shape Keys with Vertex Groups are then handled
separately by initially checking if the number of FullWeights equals the
number of vertices moved by the imported Shape.

The main cause of #84111 is when there is more than one Shape assigned
to a BlendShapeChannel. This is still not supported because it requires
larger changes and allowing it now would cause more issues. Because the
assertion is no longer sufficient to cause an error when there is more
than one Shape, an explicitly thrown RuntimeException has been added to
fulfil the same role.
2023-11-05 07:16:02 +00:00