Recover and verify static collision traversal and body contracts

This commit is contained in:
UnixNight committed 2026-10-26 21:45:57 -04:00
1 parent 7c0d1a4b0c
commit df0263b26e
34 files changed
+1962 -17

No files matched your search

+9 -1
View File
@@ -272,6 +272,13 @@ def export_scene(database: Database, output: Path):
if entry.type == '3DSh':
shape = read_shape(payload)
for polygon_index, poly in enumerate(shape['polygons']):
link = poly['material']
resolved_material = link and link['type'] == '3DMa' and link['id'] in material_names
# Player43AA40 compares the signed long stored in the database
# chunk, independently of the render material/texture index.
material_id = link['id'] if resolved_material else None
if material_id is not None and material_id >= 0x80000000:
material_id -= 0x100000000
first_index = len(scene['indices'])
first_vertex = len(scene['vertices'])
for corner in poly['corners']:
@@ -282,7 +289,8 @@ def export_scene(database: Database, output: Path):
for i in range(1, len(poly['corners'])-1):
scene['indices'].extend((first_vertex, first_vertex+i, first_vertex+i+1))
scene['collisionPolygons'].append({'shapeId': entry.id, 'polygonIndex': polygon_index,
'normal': poly['normal'], 'materialName': material_names.get(poly['material']['id']) if poly['material'] else None})
'normal': poly['normal'], 'materialName': material_names[link['id']] if resolved_material else None,
'materialId': material_id})
if len(poly['corners']) > 3:
scene['warnings'].append(f'{entry.id}: polygon with {len(poly["corners"])} corners fan triangulated; concavity not validated')
material = poly['material']['id'] if poly['material'] else -1