Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Fast64

This requires Blender 3.2 - 5.0.1. Blender 4.0+ is recommended.
This requires Blender 3.2 - 5.1.2. Blender 4.0+ is recommended.

Forked from [kurethedead/fast64 on BitBucket](https://bitbucket.org/kurethedead/fast64/src).

Expand Down
29 changes: 21 additions & 8 deletions fast64_internal/f3d/f3d_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1864,7 +1864,7 @@ def deleteMaterialContext(self):
raise PluginError("Attempting to delete material context that is None.")

# if deleteMaterialContext is False, then manually call self.deleteMaterialContext() later.
def createMesh(self, obj, removeDoubles, importNormals, callDeleteMaterialContext: bool):
def createMesh(self, obj: bpy.types.Object, removeDoubles, importNormals, callDeleteMaterialContext: bool):
mesh = obj.data
if len(self.verts) % 3 != 0:
print(len(self.verts))
Expand Down Expand Up @@ -1902,13 +1902,26 @@ def createMesh(self, obj, removeDoubles, importNormals, callDeleteMaterialContex
# There will be one loop for every vertex
uv_layer[i].uv = self.verts[i].uv

color_layer = mesh.vertex_colors.new(name="Col").data
for i in range(len(mesh.loops)):
color_layer[i].color = self.verts[i].rgb.to_4d()

alpha_layer = mesh.vertex_colors.new(name="Alpha").data
for i in range(len(mesh.loops)):
alpha_layer[i].color = [self.verts[i].alpha] * 3 + [1]
# The mesh.vertex_colors is deprecated since a long time,
# and its usage by fast64 here breaks in Blender 5.1 somehow.
# (can't replicate in simple cases)
if bpy.app.version < (5, 1, 0):
color_layer = mesh.vertex_colors.new(name="Col").data
for i in range(len(mesh.loops)):
color_layer[i].color = self.verts[i].rgb.to_4d()

alpha_layer = mesh.vertex_colors.new(name="Alpha").data
for i in range(len(mesh.loops)):
alpha_layer[i].color = [self.verts[i].alpha] * 3 + [1]
else:
col_attr = mesh.color_attributes.new("Col", "BYTE_COLOR", "CORNER")
Comment thread
Dragorn421 marked this conversation as resolved.
for i in range(len(mesh.loops)):
col_attr.data[i].color = (*self.verts[i].rgb, 1)

alpha_attr = mesh.color_attributes.new("Alpha", "BYTE_COLOR", "CORNER")
for i in range(len(mesh.loops)):
a = self.verts[i].alpha
alpha_attr.data[i].color = (a, a, a, 1)

if bpy.context.mode != "OBJECT":
bpy.ops.object.mode_set(mode="OBJECT")
Expand Down