diff --git a/io_scene_psk_psa/__init__.py b/io_scene_psk_psa/__init__.py index 6618659..1fd436a 100644 --- a/io_scene_psk_psa/__init__.py +++ b/io_scene_psk_psa/__init__.py @@ -1,7 +1,7 @@ bl_info = { "name": "PSK/PSA Importer/Exporter", "author": "Colin Basnett, Yurii Ti", - "version": (5, 0, 2), + "version": (5, 0, 3), "blender": (3, 4, 0), "description": "PSK/PSA Import/Export (.psk/.psa)", "warning": "", diff --git a/io_scene_psk_psa/psk/reader.py b/io_scene_psk_psa/psk/reader.py index 7f9cb1f..6fa2da7 100644 --- a/io_scene_psk_psa/psk/reader.py +++ b/io_scene_psk_psa/psk/reader.py @@ -78,4 +78,16 @@ def read_psk(path: str) -> Psk: ''' psk.material_references = _read_material_references(path) + ''' + Tools like UEViewer and CUE4Parse write the point index as a 32-bit integer, exploiting the fact that due to struct + alignment, there were 16-bits of padding following the original 16-bit point index in the wedge struct. + However, this breaks compatibility with PSK files that were created with older tools that treated the + point index as a 16-bit integer and might have junk data written to the padding bits. + To work around this, we check if each point is still addressable using a 16-bit index, and if it is, assume the + point index is a 16-bit integer and truncate the high bits. + ''' + if len(psk.points) <= 65536: + for wedge in psk.wedges: + wedge.point_index &= 0xFFFF + return psk