fix list index out of range for color_per_vertex #2

Merged
Cedric Steiert merged 5 commits from Bujus_Krachus/io_scene_x3d:fix-list-index-out-of-range-vertex-color into main 2024-08-06 17:19:38 +02:00
Showing only changes of commit 6cb7049fa3 - Show all commits

View File

@ -1975,12 +1975,19 @@ def importMesh_IndexedFaceSet(geom, ancestry):
color_per_vertex = geom.getFieldAsBool('colorPerVertex', True, ancestry)
color_index = geom.getFieldAsArray('colorIndex', 0, ancestry)
has_color_index = len(color_index) >= len(index)
# TODO: check color index for -1 values and rebuild if not existent
d = bpymesh.vertex_colors.new().data
if color_per_vertex:
if color_per_vertex and has_color_index: # Color per vertex with index
cco = [cco for f in processPerVertexIndex(color_index)
for (i, v) in enumerate(f)
for cco in rgb[i]]
for v in f
for cco in rgb[v]]
elif color_per_vertex: # Color per vertex without index
cco = [cco for f in processPerVertexIndex(color_index)
for (i, v) in enumerate(f)
for cco in rgb[i]]
elif color_index: # Color per face with index
cco = [cco for (i, f) in enumerate(faces)
for j in f