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

Fix a mistake from a previous PR, and workaround for a Blender 3.5 bug related to uvs #228

Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion fast64_internal/f3d/f3d_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1748,7 +1748,7 @@ def createMesh(self, obj, removeDoubles, importNormals, callDeleteMaterialContex
print("Vertices: " + str(len(self.verts)) + ", Triangles: " + str(triangleCount))

mesh.from_pydata(vertices=verts, edges=[], faces=faces)
uv_layer = mesh.uv_layers.new().data
uv_layer_name = mesh.uv_layers.new().name
# if self.materialContext.f3d_mat.rdp_settings.g_lighting:
alpha_layer = mesh.vertex_colors.new(name="Alpha").data
color_layer = mesh.vertex_colors.new(name="Col").data
Expand All @@ -1765,6 +1765,10 @@ def createMesh(self, obj, removeDoubles, importNormals, callDeleteMaterialContex
for i in range(len(mesh.polygons)):
mesh.polygons[i].material_index = self.triMatIndices[i]

# Workaround for an issue in Blender 3.5 where putting this above the `if importNormals` block
# causes wrong uvs/normals and sometimes crashes.
uv_layer = mesh.uv_layers[uv_layer_name].data

for i in range(len(mesh.loops)):
# This should be okay, since we aren't trying to optimize vertices
# There will be one loop for every vertex
Expand Down
3 changes: 2 additions & 1 deletion fast64_internal/f3d/flipbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
from .f3d_material import all_combiner_uses, update_tex_values_manual, iter_tex_nodes, TextureProperty
from ..utility import prop_split, CollectionProperty
from dataclasses import dataclass
import dataclasses


@dataclass
class TextureFlipbook:
name: str
exportMode: str
textureNames: list[str]
images: list[tuple[bpy.types.Image, FImage]]
images: list[tuple[bpy.types.Image, FImage]] = dataclasses.field(default_factory=list)


def flipbook_data_to_c(flipbook: TextureFlipbook):
Expand Down