I append new material to multi-material, but after undoing this operation all faces that initially used ID#1 material now suddenly seen as black in viewports and still look correctly on render.
Is there anything I can do to fix or prevent that?
Here’s the code that demonstrates the issue
delete objects
gc()
b1 = convertToMesh (box lengthsegs:1 widthsegs:1 heightsegs:1)
b2 = box lengthsegs:1 widthsegs:1 heightsegs:1 pos:[40,0,0]
addModifier b2 (Materialmodifier materialID:2)
meshop.attach b1 b2
mm = Multimaterial numsubs:1
mm.materiallist[1].diffuse = yellow
b1.material = mm
redrawViews() -- both first and second boxes use first material
sleep 0.5
mm.numsubs += 1 -- add yet another material for ID 2
redrawViews() -- second box uses second mtl as expected
sleep 0.5
max undo -- emulate user undo
-- faces with ID 2 now ignore ID 1 material and seen as black in viewports, but render correctly
One thing I found to ‘fix’ it is to save & reload the scene, but that’s not a solution…
Another one is
replaceInstances mm (copy mm)