I want to access vertex colors directly from inside BMVerts, but I don't know how.
I am able to access vertex colors indirect for inside BMFaces:
import bpy
import bmesh
obj = bpy.context.active_object
mesh = obj.data
bm = bmesh.new()
bm.from_mesh(mesh)
layer_color = bm.loops.layers.color.get("col_test")
for bmf in bm.faces:
#bmf.loops[0][layer_color] = new_color
for loop in bmf.loops:
color = loop[layer_color]
print(color)
loop[layer_color] = new_color
bm.to_mesh(mesh)
bm.free()
But this way I loop multiple times through the same vertex colors, because a face vertex is owned by multiple faces.
I don't want to loop through all faces only to get access to the vertex colors.
I am looking for something more direct, like:
import bpy
import bmesh
obj = bpy.context.active_object
mesh = obj.data
bm = bmesh.new()
bm.from_mesh(mesh)
layer_color = bm.loops.layers.color.get("col_test")
for bmv in bm.verts:
color = bmv.????[layer_color]
print(color)
bmv.????[layer_color] = new_color
bm.to_mesh(mesh)
bm.free()
It seems there is no "interface" to access the vertex color from insider a BMVert directly, or am I doing something completely wrong?