Skip to content

Commit

Permalink
Fixed a compatibility issue caused by the fix to #43
Browse files Browse the repository at this point in the history
  • Loading branch information
cmbasnett committed Aug 15, 2023
1 parent d0d6deb commit fb2ab89
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
8 changes: 4 additions & 4 deletions io_scene_psk_psa/psa/export/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
from bpy_extras.io_utils import ExportHelper
from bpy_types import Operator

from io_scene_psk_psa.helpers import populate_bone_group_list, get_nla_strips_in_timeframe
from io_scene_psk_psa.psa.builder import build_psa, PsaBuildSequence, PsaBuildOptions
from io_scene_psk_psa.psa.export.properties import PSA_PG_export, PSA_PG_export_action_list_item, filter_sequences
from io_scene_psk_psa.psa.writer import write_psa
from ..builder import build_psa, PsaBuildSequence, PsaBuildOptions
from ..export.properties import PSA_PG_export, PSA_PG_export_action_list_item, filter_sequences
from ..writer import write_psa
from ...helpers import populate_bone_group_list, get_nla_strips_in_timeframe


def is_action_for_armature(armature: Armature, action: Action):
Expand Down
12 changes: 12 additions & 0 deletions io_scene_psk_psa/psk/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit fb2ab89

Please sign in to comment.