diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2017-01-31 03:04:05 +0300 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2017-01-31 03:08:10 +0300 |
commit | 4e1025376ea18597b8f7b744be7629dc3396bcc4 (patch) | |
tree | 5b5cb5560568e58d22eb3d360e936ddd1d33f06f /release | |
parent | bc4aeefe82205efbc9803ba158ec7055cb13ae11 (diff) |
Freestyle: Use of the Fill Range by Selection operator in the mesh edit mode.
This revision extends the functionality of the "Fill Range by Selection" button in
the "Distance from Camera/Object" modifiers so that only selected mesh vertices
in the edit mode are taken into account (instead of considering all vertices when
in the object mode) to compute the min & max distances from the reference.
This will give users much finer control on the range values.
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/startup/bl_operators/freestyle.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/release/scripts/startup/bl_operators/freestyle.py b/release/scripts/startup/bl_operators/freestyle.py index e190572d440..fe3b00d54cd 100644 --- a/release/scripts/startup/bl_operators/freestyle.py +++ b/release/scripts/startup/bl_operators/freestyle.py @@ -75,6 +75,32 @@ class SCENE_OT_freestyle_fill_range_by_selection(bpy.types.Operator): else: self.report({'ERROR'}, "Unexpected modifier type: " + m.type) return {'CANCELLED'} + # Find selected vertices in editmesh + ob = bpy.context.active_object + if ob.type == 'MESH' and ob.mode == 'EDIT' and ob.name != ref.name: + bpy.ops.object.mode_set(mode='OBJECT') + selected_verts = [v for v in bpy.context.active_object.data.vertices if v.select] + bpy.ops.object.mode_set(mode='EDIT') + # Compute the min/max distance from the reference to mesh vertices + min_dist = sys.float_info.max + max_dist = -min_dist + if m.type == 'DISTANCE_FROM_CAMERA': + ob_to_cam = matrix_to_camera * ob.matrix_world + for vert in selected_verts: + # dist in the camera space + dist = (ob_to_cam * vert.co).length + min_dist = min(dist, min_dist) + max_dist = max(dist, max_dist) + elif m.type == 'DISTANCE_FROM_OBJECT': + for vert in selected_verts: + # dist in the world space + dist = (ob.matrix_world * vert.co - target_location).length + min_dist = min(dist, min_dist) + max_dist = max(dist, max_dist) + # Fill the Range Min/Max entries with the computed distances + m.range_min = min_dist + m.range_max = max_dist + return {'FINISHED'} # Find selected mesh objects selection = [ob for ob in scene.objects if ob.select and ob.type == 'MESH' and ob.name != ref.name] if selection: |