[Bf-blender-cvs] [4e1025376e] master: Freestyle: Use of the Fill Range by Selection operator in the mesh edit mode.
Tamito Kajiyama
noreply at git.blender.org
Tue Jan 31 01:20:03 CET 2017
Commit: 4e1025376ea18597b8f7b744be7629dc3396bcc4
Author: Tamito Kajiyama
Date: Tue Jan 31 09:04:05 2017 +0900
Branches: master
https://developer.blender.org/rB4e1025376ea18597b8f7b744be7629dc3396bcc4
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.
===================================================================
M release/scripts/startup/bl_operators/freestyle.py
===================================================================
diff --git a/release/scripts/startup/bl_operators/freestyle.py b/release/scripts/startup/bl_operators/freestyle.py
index e190572d44..fe3b00d54c 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:
More information about the Bf-blender-cvs
mailing list