Fix #140: PSKX with multiple extra UV channels not importing correctly
This was caused by a missing refactor after the underlying data structure of the extra UVs was changed. An additional test has been added to ensure this won't happen again.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
schema_version = "1.0.0"
|
||||
id = "io_scene_psk_psa"
|
||||
version = "9.0.1"
|
||||
version = "9.0.2"
|
||||
name = "Unreal PSK/PSA (.psk/.psa)"
|
||||
tagline = "Import and export PSK and PSA files used in Unreal Engine"
|
||||
maintainer = "Colin Basnett <cmbasnett@gmail.com>"
|
||||
|
||||
@@ -201,7 +201,6 @@ def import_psk(psk: Psk, context: Context, name: str, options: PskImportOptions)
|
||||
|
||||
# Extra UVs
|
||||
if psk.has_extra_uvs and options.should_import_extra_uvs:
|
||||
wedge_index_offset = 0
|
||||
for extra_uv_index, extra_uvs in enumerate(psk.extra_uvs):
|
||||
uv_layer_data = np.zeros((face_count * 3, 2), dtype=np.float32)
|
||||
uv_layer_data_index = 0
|
||||
@@ -209,10 +208,9 @@ def import_psk(psk: Psk, context: Context, name: str, options: PskImportOptions)
|
||||
if face_index in invalid_face_indices:
|
||||
continue
|
||||
for wedge_index in reversed(face.wedge_indices):
|
||||
u, v = extra_uvs[wedge_index_offset + wedge_index]
|
||||
u, v = extra_uvs[wedge_index]
|
||||
uv_layer_data[uv_layer_data_index] = u, 1.0 - v
|
||||
uv_layer_data_index += 1
|
||||
wedge_index_offset += len(psk.wedges)
|
||||
uv_layer = mesh_data.uv_layers.new(name=f'EXTRAUV{extra_uv_index}')
|
||||
uv_layer.uv.foreach_set('vector', uv_layer_data.ravel())
|
||||
|
||||
|
||||
BIN
tests/data/SK_1033_1033001.pskx
LFS
Normal file
BIN
tests/data/SK_1033_1033001.pskx
LFS
Normal file
Binary file not shown.
@@ -8,6 +8,7 @@ SUZANNE_FILEPATH = 'tests/data/Suzanne.psk'
|
||||
SARGE_FILEPATH = 'tests/data/CS_Sarge_S0_Skelmesh.pskx'
|
||||
SLURP_MONSTER_AXE_FILEPATH = 'tests/data/Slurp_Monster_Axe_LOD0.psk'
|
||||
BAT_FILEPATH = 'tests/data/Bat.psk'
|
||||
BLACK_WIDOW_FILEPATH = 'tests/data/SK_1033_1033001.pskx'
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
@@ -230,6 +231,38 @@ def test_psk_import_extra_uvs():
|
||||
assert mesh_data.uv_layers[1].uv[0].vector.y == 0.999969482421875
|
||||
|
||||
|
||||
def test_psk_import_many_extra_uvs():
|
||||
assert bpy.ops.psk.import_file(
|
||||
filepath=BLACK_WIDOW_FILEPATH,
|
||||
components='MESH',
|
||||
should_import_vertex_colors=False,
|
||||
should_import_vertex_normals=False,
|
||||
should_import_shape_keys=False,
|
||||
) == {'FINISHED'}
|
||||
|
||||
mesh_object = bpy.data.objects.get('SK_1033_1033001', None)
|
||||
assert mesh_object is not None, "Mesh object not found in the scene"
|
||||
assert mesh_object.type == 'MESH', "Mesh object type should be MESH"
|
||||
|
||||
mesh_data = typing_cast(Mesh, mesh_object.data)
|
||||
assert mesh_data is not None, "Mesh data not found in the scene"
|
||||
assert len(mesh_data.uv_layers) == 4, "Mesh should have two UV layers"
|
||||
|
||||
assert mesh_data.uv_layers[0].name == 'UVMap', "First UV layer should be named 'UVMap'"
|
||||
assert mesh_data.uv_layers[1].name == 'EXTRAUV0', "Second UV layer should be named 'EXTRAUV0'"
|
||||
assert mesh_data.uv_layers[2].name == 'EXTRAUV1', "Third UV layer should be named 'EXTRAUV1'"
|
||||
assert mesh_data.uv_layers[3].name == 'EXTRAUV2', "Fourth UV layer should be named 'EXTRAUV2'"
|
||||
|
||||
|
||||
def test_psk_import_multiple_extra_uvs():
|
||||
assert bpy.ops.psk.import_file(
|
||||
filepath=SARGE_FILEPATH,
|
||||
components='MESH',
|
||||
should_import_vertex_colors=True,
|
||||
vertex_color_space='LINEAR',
|
||||
) == {'FINISHED'}
|
||||
|
||||
|
||||
def test_psk_import_materials():
|
||||
assert bpy.ops.psk.import_file(
|
||||
filepath=SARGE_FILEPATH,
|
||||
|
||||
Reference in New Issue
Block a user