fix bad initialized value in clipboard paste.

4.3 do not  initialize points opacity and radius as expected
master
pullusb 2024-11-26 16:30:21 +01:00
parent edfefa874a
commit f5c20a3499
1 changed files with 31 additions and 39 deletions

View File

@ -24,19 +24,13 @@ def convertAttr(Attr):
def getMatrix(layer) :
matrix = mathutils.Matrix.Identity(4)
## FIXME: not "is_parent" or parent_type anymore
if layer.parent:
## temp solution
matrix = layer.parent.matrix_world @ layer.matrix_inverse
### if layer.parent_type == 'BONE':
# if layer.parent.type == 'ARMATURE':
# object = layer.parent
# bone = object.pose.bones[layer.parent_bone]
# matrix = bone.matrix @ object.matrix_world
# matrix = matrix.copy() @ layer.matrix_inverse
# else :
# matrix = layer.parent.matrix_world @ layer.matrix_inverse
if parent := layer.parent:
if parent.type == 'ARMATURE' and layer.parent_bone:
bone = parent.pose.bones[layer.parent_bone]
matrix = bone.matrix @ parent.matrix_world
matrix = matrix.copy() @ layer.matrix_parent_inverse
else:
matrix = parent.matrix_world @ layer.matrix_parent_inverse
return matrix.copy()
@ -312,40 +306,38 @@ def add_stroke(s, frame, layer, obj, select=False):
ns = frame.drawing.strokes[-1]
## set strokes atrributes
for att, val in s.items():
if att not in ('points'):
setattr(ns, att, val)
# ns.points.add(pts_to_add)
ob_mat_inv = obj.matrix_world.inverted()
## patch radius 1
# radius_flat_list = [di['radius'] for di in s['points']] #get all radius flatened
if layer.parent:
mat = getMatrix(layer).inverted()
for i, pt in enumerate(s['points']):
for k, v in pt.items():
if k == 'position':
setattr(ns.points[i], k, v)
ns.points[i].position = ob_mat_inv @ mat @ ns.points[i].position # invert of object * invert of layer * coordinate
else:
setattr(ns.points[i], k, v)
if select:
ns.points[i].select = True
layer_matrix = getMatrix(layer).inverted()
transform_matrix = ob_mat_inv @ layer_matrix
else:
for i, pt in enumerate(s['points']):
for k, v in pt.items():
if k == 'position':
setattr(ns.points[i], k, v)
ns.points[i].position = ob_mat_inv @ ns.points[i].position# invert of object * coordinate
else:
setattr(ns.points[i], k, v)
if select:
ns.points[i].select = True
transform_matrix = ob_mat_inv
## Set points attributes
for i, pt in enumerate(s['points']):
for k, v in pt.items():
if k == 'position':
setattr(ns.points[i], k, v)
ns.points[i].position = transform_matrix @ ns.points[i].position # invert of object * invert of layer * coordinate
else:
setattr(ns.points[i], k, v)
if select:
ns.points[i].select = True
## Opacity initialized at 0.0 (should be 1.0)
if not 'opacity' in pt:
ns.points[i].opacity = 1.0
## Radius initialized at 0.0 (should probably be 0.01)
if not 'radius' in pt:
ns.points[i].radius = 0.01
def add_multiple_strokes(stroke_list, layer=None, use_current_frame=True, select=False):
'''