diff options
Diffstat (limited to 'animation_add_corrective_shape_key.py')
-rw-r--r-- | animation_add_corrective_shape_key.py | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/animation_add_corrective_shape_key.py b/animation_add_corrective_shape_key.py index 92a685ea..6e02d092 100644 --- a/animation_add_corrective_shape_key.py +++ b/animation_add_corrective_shape_key.py @@ -177,15 +177,15 @@ def func_add_corrective_pose_shape( source, target): if epsilon < threshold: epsilon = 0.0 - dx[0] += [x[i] + 0.5*epsilon*mathutils.Vector([1, 0, 0])] - dx[1] += [x[i] + 0.5*epsilon*mathutils.Vector([-1, 0, 0])] - dx[2] += [x[i] + 0.5*epsilon*mathutils.Vector([0, 1, 0])] - dx[3] += [x[i] + 0.5*epsilon*mathutils.Vector([0, -1, 0])] - dx[4] += [x[i] + 0.5*epsilon*mathutils.Vector([0, 0, 1])] - dx[5] += [x[i] + 0.5*epsilon*mathutils.Vector([0, 0, -1])] + dx[0] += [x[i] + 0.5 * epsilon * mathutils.Vector((1, 0, 0))] + dx[1] += [x[i] + 0.5 * epsilon * mathutils.Vector((-1, 0, 0))] + dx[2] += [x[i] + 0.5 * epsilon * mathutils.Vector((0, 1, 0))] + dx[3] += [x[i] + 0.5 * epsilon * mathutils.Vector((0, -1, 0))] + dx[4] += [x[i] + 0.5 * epsilon * mathutils.Vector((0, 0, 1))] + dx[5] += [x[i] + 0.5 * epsilon * mathutils.Vector((0, 0, -1))] for j in range(0, 6): - applyX(ob_1, mesh_1_key_verts, dx[j] ) + applyX(ob_1, mesh_1_key_verts, dx[j]) dx[j] = extractMappedX(ob_1, mesh_1_key_verts) # take a step in the direction of the gradient @@ -193,13 +193,13 @@ def func_add_corrective_pose_shape( source, target): epsilon = (targetx[i] - mapx[i]).length if epsilon >= threshold: - Gx = list((dx[0][i] - dx[1][i])/epsilon) - Gy = list((dx[2][i] - dx[3][i])/epsilon) - Gz = list((dx[4][i] - dx[5][i])/epsilon) + Gx = list((dx[0][i] - dx[1][i]) / epsilon) + Gy = list((dx[2][i] - dx[3][i]) / epsilon) + Gz = list((dx[4][i] - dx[5][i]) / epsilon) G = mathutils.Matrix((Gx, Gy, Gz)) G = flip_matrix_direction(G) - x[i] += (targetx[i] - mapx[i]) * G + x[i] += G * (targetx[i] - mapx[i]) applyX(ob_1, mesh_1_key_verts, x ) @@ -224,24 +224,22 @@ class add_corrective_pose_shape(bpy.types.Operator): return context.active_object != None def execute(self, context): - - if len(context.selected_objects) > 2: - print("Select source and target objects please") - return {'FINISHED'} - selection = context.selected_objects + if len(selection) != 2: + self.report({'ERROR'}, "Select source and target objects") + return {'CANCELLED'} + target = context.active_object if context.active_object == selection[0]: source = selection[1] else: source = selection[0] - #~ print(source) - #~ print(target) func_add_corrective_pose_shape( source, target) return {'FINISHED'} + def func_object_duplicate_flatten_modifiers(ob, scene): mesh = ob.to_mesh( bpy.context.scene, True, 'PREVIEW' ) name = ob.name + "_clean" |