[Bf-extensions-cvs] [56206ba] master: [LoopTools] Adds constraining to axis. Makes conversion of grease-pencil strokes more robust.
Bart Crouch
noreply at git.blender.org
Wed Aug 6 14:19:34 CEST 2014
Commit: 56206bae8058430495b1cc7f6d221ee4d438eb9b
Author: Bart Crouch
Date: Wed Aug 6 14:19:19 2014 +0200
Branches: master
https://developer.blender.org/rBA56206bae8058430495b1cc7f6d221ee4d438eb9b
[LoopTools] Adds constraining to axis.
Makes conversion of grease-pencil strokes more robust.
===================================================================
M mesh_looptools.py
===================================================================
diff --git a/mesh_looptools.py b/mesh_looptools.py
index 3f38833..0e4d26a 100644
--- a/mesh_looptools.py
+++ b/mesh_looptools.py
@@ -19,7 +19,7 @@
bl_info = {
"name": "LoopTools",
"author": "Bart Crouch",
- "version": (4, 5, 2),
+ "version": (4, 6, 0),
"blender": (2, 69, 3),
"location": "View3D > Toolbar and View3D > Specials (W-key)",
"warning": "",
@@ -741,7 +741,22 @@ def initialise():
# move the vertices to their new locations
-def move_verts(object, bm, mapping, move, influence):
+def move_verts(object, bm, mapping, move, lock, influence):
+ if lock:
+ lock_x, lock_y, lock_z = lock
+ orientation = bpy.context.space_data.transform_orientation
+ custom = bpy.context.space_data.current_orientation
+ if custom:
+ mat = custom.matrix.to_4x4().inverted() * object.matrix_world.copy()
+ elif orientation == 'LOCAL':
+ mat = mathutils.Matrix.Identity(4)
+ elif orientation == 'VIEW':
+ mat = bpy.context.region_data.view_matrix.copy() * \
+ object.matrix_world.copy()
+ else: # orientation == 'GLOBAL'
+ mat = object.matrix_world.copy()
+ mat_inv = mat.inverted()
+
for loop in move:
for index, loc in loop:
if mapping:
@@ -749,11 +764,22 @@ def move_verts(object, bm, mapping, move, influence):
continue
else:
index = mapping[index]
- if influence >= 0:
- bm.verts[index].co = loc*(influence/100) + \
- bm.verts[index].co*((100-influence)/100)
+ if lock:
+ delta = (loc - bm.verts[index].co) * mat_inv
+ if lock_x:
+ delta[0] = 0
+ if lock_y:
+ delta[1] = 0
+ if lock_z:
+ delta[2] = 0
+ delta = delta * mat
+ loc = bm.verts[index].co + delta
+ if influence < 0:
+ new_loc = loc
else:
- bm.verts[index].co = loc
+ new_loc = loc*(influence/100) + \
+ bm.verts[index].co*((100-influence)/100)
+ bm.verts[index].co = new_loc
bm.normal_update()
object.data.update()
@@ -1139,7 +1165,6 @@ def bridge_calculate_lines(bm, loops, mode, twist, reverse):
tri, quad = [(bm.verts[loop1[i+1]].co -
bm.verts[loop2[j]].co).length
for j in [prev_vert2, 0]]
-
circle_full = 2
elif len(loop1) - 1 - i == len(loop2) - 1 - prev_vert2 and \
not circle_full:
@@ -2130,7 +2155,6 @@ def curve_calculate_t(bm_mod, knots, points, pknots, regular, circular):
if circular:
tknots[-1] = tpoints[-1]
-
return(tknots, tpoints)
@@ -2516,7 +2540,6 @@ def gstretch_align_pairs(ls_pairs, object, bm_mod, method):
if ls_pairs:
for (loop, stroke) in ls_pairs:
- distance_loop_stroke
total_dist = distance_loop_stroke(loop, stroke, object, bm_mod,
method)
loop[0].reverse()
@@ -2553,6 +2576,7 @@ def gstretch_calculate_verts(loop, stroke, object, bm_mod, method):
vert_edges = dict_vert_edges(bm_mod)
for v_index in loop[0]:
+ intersection = None
for ek in vert_edges[v_index]:
v1, v2 = ek
v1 = bm_mod.verts[v1]
@@ -3280,6 +3304,15 @@ class Circle(bpy.types.Operator):
max = 100.0,
precision = 1,
subtype = 'PERCENTAGE')
+ lock_x = bpy.props.BoolProperty(name = "Lock X",
+ description = "Lock editing of the x-coordinate",
+ default = False)
+ lock_y = bpy.props.BoolProperty(name = "Lock Y",
+ description = "Lock editing of the y-coordinate",
+ default = False)
+ lock_z = bpy.props.BoolProperty(name = "Lock Z",
+ description = "Lock editing of the z-coordinate",
+ default = False)
radius = bpy.props.FloatProperty(name = "Radius",
description = "Custom radius for circle",
default = 1.0,
@@ -3311,7 +3344,21 @@ class Circle(bpy.types.Operator):
col.prop(self, "regular")
col.separator()
- col.prop(self, "influence")
+ col_move = col.column(align=True)
+ row = col_move.row(align=True)
+ if self.lock_x:
+ row.prop(self, "lock_x", text = "X", icon='LOCKED')
+ else:
+ row.prop(self, "lock_x", text = "X", icon='UNLOCKED')
+ if self.lock_y:
+ row.prop(self, "lock_y", text = "Y", icon='LOCKED')
+ else:
+ row.prop(self, "lock_y", text = "Y", icon='UNLOCKED')
+ if self.lock_z:
+ row.prop(self, "lock_z", text = "Z", icon='LOCKED')
+ else:
+ row.prop(self, "lock_z", text = "Z", icon='UNLOCKED')
+ col_move.prop(self, "influence")
def invoke(self, context, event):
# load custom settings
@@ -3375,7 +3422,11 @@ class Circle(bpy.types.Operator):
normal, single_loops[i]))
# move vertices to new locations
- move_verts(object, bm, mapping, move, -1)
+ if self.lock_x or self.lock_y or self.lock_z:
+ lock = [self.lock_x, self.lock_y, self.lock_z]
+ else:
+ lock = False
+ move_verts(object, bm, mapping, move, lock, -1)
# cleaning up
if derived:
@@ -3408,6 +3459,15 @@ class Curve(bpy.types.Operator):
("linear", "Linear", "Simple and fast linear algorithm")),
description = "Algorithm used for interpolation",
default = 'cubic')
+ lock_x = bpy.props.BoolProperty(name = "Lock X",
+ description = "Lock editing of the x-coordinate",
+ default = False)
+ lock_y = bpy.props.BoolProperty(name = "Lock Y",
+ description = "Lock editing of the y-coordinate",
+ default = False)
+ lock_z = bpy.props.BoolProperty(name = "Lock Z",
+ description = "Lock editing of the z-coordinate",
+ default = False)
regular = bpy.props.BoolProperty(name = "Regular",
description = "Distribute vertices at constant distances along the" \
"curve",
@@ -3436,7 +3496,21 @@ class Curve(bpy.types.Operator):
col.prop(self, "regular")
col.separator()
- col.prop(self, "influence")
+ col_move = col.column(align=True)
+ row = col_move.row(align=True)
+ if self.lock_x:
+ row.prop(self, "lock_x", text = "X", icon='LOCKED')
+ else:
+ row.prop(self, "lock_x", text = "X", icon='UNLOCKED')
+ if self.lock_y:
+ row.prop(self, "lock_y", text = "Y", icon='LOCKED')
+ else:
+ row.prop(self, "lock_y", text = "Y", icon='UNLOCKED')
+ if self.lock_z:
+ row.prop(self, "lock_z", text = "Z", icon='LOCKED')
+ else:
+ row.prop(self, "lock_z", text = "Z", icon='UNLOCKED')
+ col_move.prop(self, "influence")
def invoke(self, context, event):
# load custom settings
@@ -3480,7 +3554,11 @@ class Curve(bpy.types.Operator):
self.restriction))
# move vertices to new locations
- move_verts(object, bm, mapping, move, self.influence)
+ if self.lock_x or self.lock_y or self.lock_z:
+ lock = [self.lock_x, self.lock_y, self.lock_z]
+ else:
+ lock = False
+ move_verts(object, bm, mapping, move, lock, self.influence)
# cleaning up
if derived:
@@ -3504,6 +3582,15 @@ class Flatten(bpy.types.Operator):
max = 100.0,
precision = 1,
subtype = 'PERCENTAGE')
+ lock_x = bpy.props.BoolProperty(name = "Lock X",
+ description = "Lock editing of the x-coordinate",
+ default = False)
+ lock_y = bpy.props.BoolProperty(name = "Lock Y",
+ description = "Lock editing of the y-coordinate",
+ default = False)
+ lock_z = bpy.props.BoolProperty(name = "Lock Z",
+ description = "Lock editing of the z-coordinate",
+ default = False)
plane = bpy.props.EnumProperty(name = "Plane",
items = (("best_fit", "Best fit", "Calculate a best fitting plane"),
("normal", "Normal", "Derive plane from averaging vertex "\
@@ -3532,7 +3619,21 @@ class Flatten(bpy.types.Operator):
#col.prop(self, "restriction")
col.separator()
- col.prop(self, "influence")
+ col_move = col.column(align=True)
+ row = col_move.row(align=True)
+ if self.lock_x:
+ row.prop(self, "lock_x", text = "X", icon='LOCKED')
+ else:
+ row.prop(self, "lock_x", text = "X", icon='UNLOCKED')
+ if self.lock_y:
+ row.prop(self, "lock_y", text = "Y", icon='LOCKED')
+ else:
+ row.prop(self, "lock_y", text = "Y", icon='UNLOCKED')
+ if self.lock_z:
+ row.prop(self, "lock_z", text = "Z", icon='LOCKED')
+ else:
+ row.prop(self, "lock_z", text = "Z", icon='UNLOCKED')
+ col_move.prop(self, "influence")
def invoke(self, context, event):
# load custom settings
@@ -3566,7 +3667,13 @@ class Flatten(bpy.types.Operator):
move.append(to_move)
else:
move.append(to_move)
- move_verts(object, bm, False, move, self.influence)
+
+ # move vertices to new locations
+ if self.lock_x or self.lock_y or self.lock_z:
+ lock = [self.lock_x, self.lock_y, self.lock_z]
+ else:
+ lock = False
+ move_verts(object, bm, False, move, lock, self.influence)
# cleaning up
terminate(global_undo)
@@ -3633,6 +3740,15 @@ class GStretch(bpy.types.Operator):
max = 100.0,
precision = 1,
subtype = 'PERCENTAGE')
+ lock_x = bpy.props.BoolProperty(name = "Lock X",
+ description = "Lock editing of the x-coordinate",
+ default = False)
+ lock_y = bpy.props.BoolProperty(name = "Lock Y",
+ description = "Lock editing
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list