trimesh icon indicating copy to clipboard operation
trimesh copied to clipboard

face_colors not updated when triangulating quad mesh

Open deGravity opened this issue 2 years ago • 1 comments

If you create a Trimesh object using quad faces and also pass in per-face colors, the faces are automatically triangulated, but the per-face colors array is not updated to reflect the new triangulation. To reproduce:

V = np.array([
    [0.,0],
    [1,0],
    [1,1],
    [0,1]
])
F = np.array([[0,1,2,3]])
C = np.array([[255,0,0]])

mesh = trimesh.Trimesh(vertices=V, faces=F, face_colors=C)

print(mesh.faces)
print(mesh.visual.face_colors)

Output:

[[0 1 3]
 [3 2 0]]
[[255   0   0 255]]

Expected Output:

[[0 1 3]
 [3 2 0]]
[[255   0   0 255]
 [255   0   0 255]]

deGravity avatar Jan 27 '22 07:01 deGravity

Hey, yeah this isn't implemented, you probably are best off triangulating the faces and stacking the colors yourself. PR's welcome!

mikedh avatar Jan 27 '22 20:01 mikedh