Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[F3D] Material Ordered By Slot #285

Merged
merged 6 commits into from
Jan 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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