fix bad initialized value in clipboard paste.
4.3 do not initialize points opacity and radius as expected
This commit is contained in:
		
							parent
							
								
									edfefa874a
								
							
						
					
					
						commit
						f5c20a3499
					
				@ -24,19 +24,13 @@ def convertAttr(Attr):
 | 
				
			|||||||
def getMatrix(layer) :
 | 
					def getMatrix(layer) :
 | 
				
			||||||
    matrix = mathutils.Matrix.Identity(4)
 | 
					    matrix = mathutils.Matrix.Identity(4)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ## FIXME: not "is_parent" or parent_type anymore
 | 
					    if parent := layer.parent:
 | 
				
			||||||
    if layer.parent:
 | 
					        if parent.type == 'ARMATURE' and layer.parent_bone:
 | 
				
			||||||
        ## temp solution
 | 
					            bone = parent.pose.bones[layer.parent_bone]
 | 
				
			||||||
        matrix = layer.parent.matrix_world @ layer.matrix_inverse
 | 
					            matrix = bone.matrix @ parent.matrix_world
 | 
				
			||||||
 | 
					            matrix = matrix.copy() @ layer.matrix_parent_inverse            
 | 
				
			||||||
        ### if layer.parent_type == 'BONE':
 | 
					        else:
 | 
				
			||||||
        # if layer.parent.type == 'ARMATURE':
 | 
					            matrix = parent.matrix_world @ layer.matrix_parent_inverse
 | 
				
			||||||
        #     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
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return matrix.copy()
 | 
					    return matrix.copy()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -312,39 +306,37 @@ def add_stroke(s, frame, layer, obj, select=False):
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
    ns = frame.drawing.strokes[-1]
 | 
					    ns = frame.drawing.strokes[-1]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ## set strokes atrributes
 | 
				
			||||||
    for att, val in s.items():
 | 
					    for att, val in s.items():
 | 
				
			||||||
        if att not in ('points'):
 | 
					        if att not in ('points'):
 | 
				
			||||||
            setattr(ns, att, val)
 | 
					            setattr(ns, att, val)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # ns.points.add(pts_to_add)
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    ob_mat_inv = obj.matrix_world.inverted()
 | 
					    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:
 | 
					    if layer.parent:
 | 
				
			||||||
        mat = getMatrix(layer).inverted()
 | 
					        layer_matrix = getMatrix(layer).inverted()
 | 
				
			||||||
 | 
					        transform_matrix = ob_mat_inv @ layer_matrix
 | 
				
			||||||
 | 
					    else:
 | 
				
			||||||
 | 
					        transform_matrix = ob_mat_inv
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ## Set points attributes
 | 
				
			||||||
    for i, pt in enumerate(s['points']):
 | 
					    for i, pt in enumerate(s['points']):
 | 
				
			||||||
        for k, v in pt.items():
 | 
					        for k, v in pt.items():
 | 
				
			||||||
            if k == 'position':
 | 
					            if k == 'position':
 | 
				
			||||||
                setattr(ns.points[i], k, v)
 | 
					                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
 | 
					                ns.points[i].position = transform_matrix @ ns.points[i].position # invert of object * invert of layer * coordinate
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                setattr(ns.points[i], k, v)
 | 
					                setattr(ns.points[i], k, v)
 | 
				
			||||||
            if select:
 | 
					            if select:
 | 
				
			||||||
                ns.points[i].select = True
 | 
					                ns.points[i].select = True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    else:
 | 
					        ## Opacity initialized at 0.0 (should be 1.0)
 | 
				
			||||||
        for i, pt in enumerate(s['points']):
 | 
					        if not 'opacity' in pt:
 | 
				
			||||||
            for k, v in pt.items():
 | 
					            ns.points[i].opacity = 1.0
 | 
				
			||||||
                if k == 'position':
 | 
					
 | 
				
			||||||
                    setattr(ns.points[i], k, v)
 | 
					        ## Radius initialized at 0.0 (should probably be 0.01)
 | 
				
			||||||
                    ns.points[i].position = ob_mat_inv @ ns.points[i].position# invert of object * coordinate
 | 
					        if not 'radius' in pt:
 | 
				
			||||||
                else:
 | 
					            ns.points[i].radius = 0.01
 | 
				
			||||||
                    setattr(ns.points[i], k, v)
 | 
					 | 
				
			||||||
                if select:
 | 
					 | 
				
			||||||
                    ns.points[i].select = True
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def add_multiple_strokes(stroke_list, layer=None, use_current_frame=True, select=False):
 | 
					def add_multiple_strokes(stroke_list, layer=None, use_current_frame=True, select=False):
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user