Fix #135: Extra UV maps have incorrect data
This was caused by a regression caused by 29831d7f09.
The test for importing extra UVs has been updated to check that the data is different between the different UV layers.
This commit is contained in:
@@ -210,8 +210,9 @@ def import_psk(psk: Psk, context: Context, name: str, options: PskImportOptions)
|
|||||||
for face_index, face in enumerate(psk.faces):
|
for face_index, face in enumerate(psk.faces):
|
||||||
if face_index in invalid_face_indices:
|
if face_index in invalid_face_indices:
|
||||||
continue
|
continue
|
||||||
for wedge in map(lambda i: psk.wedges[i], reversed(face.wedge_indices)):
|
for wedge_index in reversed(face.wedge_indices):
|
||||||
uv_layer_data[uv_layer_data_index] = wedge.u, 1.0 - wedge.v
|
u, v = psk.extra_uvs[wedge_index_offset + wedge_index]
|
||||||
|
uv_layer_data[uv_layer_data_index] = u, 1.0 - v
|
||||||
uv_layer_data_index += 1
|
uv_layer_data_index += 1
|
||||||
wedge_index_offset += len(psk.wedges)
|
wedge_index_offset += len(psk.wedges)
|
||||||
uv_layer = mesh_data.uv_layers.new(name=f'EXTRAUV{extra_uv_index}')
|
uv_layer = mesh_data.uv_layers.new(name=f'EXTRAUV{extra_uv_index}')
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ def read_psk(path: str) -> Psk:
|
|||||||
case b'MRPHDATA':
|
case b'MRPHDATA':
|
||||||
_read_types(fp, Psk.MorphData, section, psk.morph_data)
|
_read_types(fp, Psk.MorphData, section, psk.morph_data)
|
||||||
case _:
|
case _:
|
||||||
if section.name.startswith(b'EXTRAUVS'):
|
if section.name.startswith(b'EXTRAUV'):
|
||||||
_read_types(fp, Vector2, section, psk.extra_uvs)
|
_read_types(fp, Vector2, section, psk.extra_uvs)
|
||||||
else:
|
else:
|
||||||
# Section is not handled, skip it.
|
# Section is not handled, skip it.
|
||||||
|
|||||||
@@ -220,6 +220,12 @@ def test_psk_import_extra_uvs():
|
|||||||
assert mesh_data.uv_layers[0].name == 'UVMap', "First UV layer should be named 'UVMap'"
|
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[1].name == 'EXTRAUV0', "Second UV layer should be named 'EXTRAUV0'"
|
||||||
|
|
||||||
|
# Verify that the data is actually different
|
||||||
|
assert mesh_data.uv_layers[0].uv[0].vector.x == 0.92480468750
|
||||||
|
assert mesh_data.uv_layers[0].uv[0].vector.y == 0.90533447265625
|
||||||
|
assert mesh_data.uv_layers[1].uv[0].vector.x == 3.0517578125e-05
|
||||||
|
assert mesh_data.uv_layers[1].uv[0].vector.y == 0.999969482421875
|
||||||
|
|
||||||
|
|
||||||
def test_psk_import_materials():
|
def test_psk_import_materials():
|
||||||
assert bpy.ops.psk.import_file(
|
assert bpy.ops.psk.import_file(
|
||||||
|
|||||||
Reference in New Issue
Block a user