Fix #104706: Imported FBX shape key values outside the 0.0 to 1.0 range are clamped #104740

Merged
Bastien Montagne merged 1 commits from Mysteryem/blender-addons:fbx_extend_deformpercent_range_pr into main 2023-07-24 15:20:07 +02:00

1 Commits

Author SHA1 Message Date
Thomas Barlow bda669f05c Fix #104706: Imported FBX shape key values outside the 0.0 to 1.0 range are clamped
This patch changes the FBX import of shape keys by decreasing/increasing
their slider_min/slider_max to fit the imported Value (DeformPercent in
FBX). If the imported Value already fits within the slider range, no
changes are made.

To fit the imported Value, the slider_min/slider_max is set to double
the imported Value if that would fit it within the slider range,
otherwise the slider_min/slider_max is decreased/increased by double the
distance from the imported Value to the current slider_min/slider_max.

Expanded slider_min/slider_max values are rounded down/up to the nearest
integer to produce a more visually pleasing result.

The animated values of shape keys are also checked when animations are
imported and decrease/increase slider_min/slider_max in the same way.

Blender has a hard minimum of -10.0 for slider_min and hard max of 10.0
for slider_max (the importer gets these values from the ShapeKey type's
bl_rna rather than being hardcoded). If a shape key's current or
animated value goes outside that range, a warning is printed to the
system console.
2023-07-22 16:24:50 +01:00