Skip adding color attributes when unneeded
This is a very small change to skip adding the vertex colours to the Blender mesh if no segment of the geometry being loaded has vertex colours.
This commit is contained in:
parent
0ac921d855
commit
ae42cda6ab
@ -59,6 +59,7 @@ def model_to_mesh_object(model: Model, scene : Scene, materials_map : Dict[str,
|
||||
|
||||
|
||||
if model.geometry:
|
||||
geometry_has_colors = any(segment.colors for segment in model.geometry)
|
||||
|
||||
for segment in model.geometry:
|
||||
|
||||
@ -79,7 +80,7 @@ def model_to_mesh_object(model: Model, scene : Scene, materials_map : Dict[str,
|
||||
|
||||
if segment.colors:
|
||||
vertex_colors.extend(segment.colors)
|
||||
else:
|
||||
elif geometry_has_colors:
|
||||
[vertex_colors.extend([0.0, 0.0, 0.0, 1.0]) for _ in range(len(segment.positions))]
|
||||
|
||||
if segment.weights:
|
||||
@ -135,8 +136,9 @@ def model_to_mesh_object(model: Model, scene : Scene, materials_map : Dict[str,
|
||||
blender_mesh.uv_layers[0].data.foreach_set("uv", [component for i in flat_indices for component in vertex_uvs[i]])
|
||||
|
||||
# Colors
|
||||
blender_mesh.color_attributes.new("COLOR0", "FLOAT_COLOR", "POINT")
|
||||
blender_mesh.color_attributes[0].data.foreach_set("color", vertex_colors)
|
||||
if geometry_has_colors:
|
||||
blender_mesh.color_attributes.new("COLOR0", "FLOAT_COLOR", "POINT")
|
||||
blender_mesh.color_attributes[0].data.foreach_set("color", vertex_colors)
|
||||
|
||||
|
||||
# POLYGONS/FACES
|
||||
|
Loading…
Reference in New Issue
Block a user