Fix: Grease Pencil: Wrong layer attributes after reorder
Reordering layer nodes by drag-drop, move up/down, add new etc. swaps layer attributes with wrong layers. This is due to mistake in map `new_by_old_map`. Values of this map is used as indices in src array. And keys are indices of dst array. Expected behavior is to copy attribute from old position (`layer_i_old`) of src array to new position (`layer_i_new`) of dst array. See: `array_utils::gather`. Noticed during !141772. Pull Request: https://projects.blender.org/blender/blender/pulls/141935
This commit is contained in:
committed by
Falk David
parent
20eaa1b1b0
commit
ef89c75382
@@ -24,12 +24,17 @@ class TestGreasePencil(unittest.TestCase):
|
||||
|
||||
|
||||
class TestGreasePencilLayers(unittest.TestCase):
|
||||
tint_factors = [0.3, 0.6, 0.9]
|
||||
|
||||
def setUp(self):
|
||||
self.gp = bpy.data.grease_pencils_v3.new("test_grease_pencil")
|
||||
self.gp.layers.new("test_layer01")
|
||||
self.gp.layers.new("test_layer02")
|
||||
self.gp.layers.new("test_layer03")
|
||||
|
||||
for i, layer in enumerate(self.gp.layers):
|
||||
layer.tint_factor = self.tint_factors[i]
|
||||
|
||||
def tearDown(self):
|
||||
bpy.data.grease_pencils_v3.remove(self.gp)
|
||||
del self.gp
|
||||
@@ -69,6 +74,14 @@ class TestGreasePencilLayers(unittest.TestCase):
|
||||
self.assertEqual(self.gp.layers[1].name, "test_layer01")
|
||||
self.assertEqual(self.gp.layers[2].name, "test_layer03")
|
||||
|
||||
def test_grease_pencil_layers_attribute_reorder(self):
|
||||
layer = self.gp.layers[0]
|
||||
self.gp.layers.move_top(layer)
|
||||
# Check layer attribute
|
||||
self.assertEqual(round(self.gp.layers[0].tint_factor, 1), self.tint_factors[1])
|
||||
self.assertEqual(round(self.gp.layers[1].tint_factor, 1), self.tint_factors[2])
|
||||
self.assertEqual(round(self.gp.layers[2].tint_factor, 1), self.tint_factors[0])
|
||||
|
||||
|
||||
class TestGreasePencilFrame(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
||||
Reference in New Issue
Block a user