Skip to content

Commit

Permalink
[F3D] Material Ordered By Slot (#285)
Browse files Browse the repository at this point in the history
* sorted materials for a static mesh by material slot

* black format

* black format on debian, thank you based windows for not working even when changing git config

* Update fast64_internal/f3d/f3d_writer.py

dragon suggestion

Co-authored-by: Dragorn421 <[email protected]>

* black

---------

Co-authored-by: scut <scut>
Co-authored-by: Dragorn421 <[email protected]>
  • Loading branch information
Scut and Dragorn421 authored Jan 26, 2024
1 parent 84967dc commit dcb1891
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions fast64_internal/f3d/f3d_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,21 @@ def saveStaticModel(

# checkForF3DMaterial(obj)

facesByMat = {}
faces_by_mat = {}
for face in obj.data.loop_triangles:
if face.material_index not in facesByMat:
facesByMat[face.material_index] = []
facesByMat[face.material_index].append(face)
if face.material_index not in faces_by_mat:
faces_by_mat[face.material_index] = []
faces_by_mat[face.material_index].append(face)

# sort by material slot
faces_by_mat = {
mat_index: faces_by_mat[mat_index]
for mat_index, _ in enumerate(obj.material_slots)
if mat_index in faces_by_mat
}

fMeshes = {}
for material_index, faces in facesByMat.items():
for material_index, faces in faces_by_mat.items():
material = obj.material_slots[material_index].material

if drawLayerField is not None and material.mat_ver > 3:
Expand Down

0 comments on commit dcb1891

Please sign in to comment.