Fix #137: Shape keys start with 1.0 value on PSK import
There was an undocumented change in 5.0 where the shape keys now start with a weight of 1.0 instead of 0.0 when created. I have added an assert in the shape key test to make sure that the values are set to `0.0`. This also fixes the assertion in the poll function (asserts should never be in poll functions).
This commit is contained in:
@@ -13,7 +13,8 @@ from ..reader import PsaReader
|
||||
|
||||
|
||||
def psa_import_poll(cls, context: Context):
|
||||
assert context.view_layer and context.view_layer.objects.active
|
||||
if context.view_layer is None or context.view_layer.objects.active is None:
|
||||
return False
|
||||
active_object = context.view_layer.objects.active
|
||||
if active_object is None or active_object.type != 'ARMATURE':
|
||||
cls.poll_message_set('The active object must be an armature')
|
||||
|
||||
@@ -275,6 +275,7 @@ def import_psk(psk: Psk, context: Context, name: str, options: PskImportOptions)
|
||||
|
||||
for morph_info in psk.morph_infos:
|
||||
shape_key = mesh_object.shape_key_add(name=morph_info.name.decode('windows-1252'), from_mix=False)
|
||||
shape_key.value = 0.0
|
||||
|
||||
for _ in range(morph_info.vertex_count):
|
||||
morph_data = next(morph_data_iterator)
|
||||
|
||||
@@ -273,6 +273,7 @@ def test_psk_import_shape_keys():
|
||||
shape_keys = mesh_object.data.shape_keys.key_blocks
|
||||
assert len(shape_keys) == 6, "Mesh object should have 6 shape keys"
|
||||
for i, shape_key in enumerate(shape_keys):
|
||||
assert shape_key.value == 0.0, f"Shape key {i} should have a value of 0.0"
|
||||
assert shape_key.name == shape_key_names[i], f"Shape key {i} name should be {shape_key_names[i]}"
|
||||
|
||||
def test_psk_import_without_shape_keys():
|
||||
|
||||
Reference in New Issue
Block a user