handle Face Corner color attributes

fixes #15
This commit is contained in:
PrismaticFlower 2023-12-05 09:49:59 +13:00
parent 48c05380c6
commit daacdf1a5d
2 changed files with 11 additions and 9 deletions

View File

@ -1,8 +1,8 @@
bl_info = { bl_info = {
'name': 'SWBF .msh Import-Export', 'name': 'SWBF .msh Import-Export',
'author': 'Will Snyder, PrismaticFlower', 'author': 'Will Snyder, PrismaticFlower',
"version": (1, 3, 2), "version": (1, 3, 3),
'blender': (2, 80, 0), 'blender': (3, 0, 0),
'location': 'File > Import-Export', 'location': 'File > Import-Export',
'description': 'Export as SWBF .msh file', 'description': 'Export as SWBF .msh file',
'warning': '', 'warning': '',

View File

@ -215,9 +215,10 @@ def create_mesh_geometry(mesh: bpy.types.Mesh, valid_vgroup_indices: Set[int]) -
yield mesh.uv_layers.active.data[loop_index].uv.y yield mesh.uv_layers.active.data[loop_index].uv.y
if segment.colors is not None: if segment.colors is not None:
data_type = mesh.color_attributes.active_color.data_type active_color = mesh.color_attributes.active_color
if data_type == "FLOAT_COLOR" or data_type == "BYTE_COLOR": data_index = loop_index if active_color.domain == "CORNER" else vertex_index
for v in mesh.color_attributes.active_color.data[vertex_index].color:
for v in mesh.color_attributes.active_color.data[data_index].color:
yield v yield v
if segment.weights is not None: if segment.weights is not None:
@ -247,9 +248,10 @@ def create_mesh_geometry(mesh: bpy.types.Mesh, valid_vgroup_indices: Set[int]) -
segment.texcoords.append(mesh.uv_layers.active.data[loop_index].uv.copy()) segment.texcoords.append(mesh.uv_layers.active.data[loop_index].uv.copy())
if segment.colors is not None: if segment.colors is not None:
data_type = mesh.color_attributes.active_color.data_type active_color = mesh.color_attributes.active_color
if data_type == "FLOAT_COLOR" or data_type == "BYTE_COLOR": data_index = loop_index if active_color.domain == "CORNER" else vertex_index
segment.colors.append(list(mesh.color_attributes.active_color.data[vertex_index].color))
segment.colors.append(list(active_color.data[data_index].color))
if segment.weights is not None: if segment.weights is not None:
groups = mesh.vertices[vertex_index].groups groups = mesh.vertices[vertex_index].groups