Fix per vertex normals and colors import #6

Merged
Cedric Steiert merged 10 commits from Hombre57/io_scene_x3d:per-vertex_normals_and_colors into main 2024-08-07 12:04:13 +02:00
Showing only changes of commit 30c46be9ff - Show all commits

View File

@ -1959,6 +1959,7 @@ def importMesh_IndexedFaceSet(geom, ancestry):
co = [co for f in processPerVertexIndex(normal_index)
for v in f
for co in vectors[v]]
bpymesh.vertices.foreach_set("normal", co)
# Mesh must be validated before assigning normals, but validation might
# reorder corners. We must store normals in a temporary attribute
@ -2063,7 +2064,8 @@ def importMesh_IndexedFaceSet(geom, ancestry):
if colors and color_per_vertex:
cco2 = [0.0 for x in range(int(len(bpymesh.attributes["temp_custom_colors"].data)*4))]
bpymesh.attributes["temp_custom_colors"].data.foreach_get("color", cco2)
bpymesh.color_attributes["Col"].data.foreach_set("color", cco2)
bpymesh.color_attributes.new('ColorPerCoin', 'FLOAT_COLOR', 'CORNER')
bpymesh.color_attributes["ColorPerCoin"].data.foreach_set("color", cco2)
bpymesh.attributes.remove(bpymesh.attributes["temp_custom_colors"])
bpymesh.update()