Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/startup/bl_operators/freestyle.py
| Show First 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | def execute(self, context): | ||||
| if ob.type == 'MESH' and ob.mode == 'EDIT' and ob.name != ref.name: | if ob.type == 'MESH' and ob.mode == 'EDIT' and ob.name != ref.name: | ||||
| bpy.ops.object.mode_set(mode='OBJECT') | bpy.ops.object.mode_set(mode='OBJECT') | ||||
| selected_verts = [v for v in ob.data.vertices if v.select] | selected_verts = [v for v in ob.data.vertices if v.select] | ||||
| bpy.ops.object.mode_set(mode='EDIT') | bpy.ops.object.mode_set(mode='EDIT') | ||||
| # Compute the min/max distance from the reference to mesh vertices | # Compute the min/max distance from the reference to mesh vertices | ||||
| min_dist = sys.float_info.max | min_dist = sys.float_info.max | ||||
| max_dist = -min_dist | max_dist = -min_dist | ||||
| if m.type == 'DISTANCE_FROM_CAMERA': | if m.type == 'DISTANCE_FROM_CAMERA': | ||||
| ob_to_cam = matrix_to_camera * ob.matrix_world | ob_to_cam = matrix_to_camera @ ob.matrix_world | ||||
| for vert in selected_verts: | for vert in selected_verts: | ||||
| # dist in the camera space | # dist in the camera space | ||||
| dist = (ob_to_cam * vert.co).length | dist = (ob_to_cam @ vert.co).length | ||||
| min_dist = min(dist, min_dist) | min_dist = min(dist, min_dist) | ||||
| max_dist = max(dist, max_dist) | max_dist = max(dist, max_dist) | ||||
| elif m.type == 'DISTANCE_FROM_OBJECT': | elif m.type == 'DISTANCE_FROM_OBJECT': | ||||
| for vert in selected_verts: | for vert in selected_verts: | ||||
| # dist in the world space | # dist in the world space | ||||
| dist = (ob.matrix_world * vert.co - target_location).length | dist = (ob.matrix_world @ vert.co - target_location).length | ||||
| min_dist = min(dist, min_dist) | min_dist = min(dist, min_dist) | ||||
| max_dist = max(dist, max_dist) | max_dist = max(dist, max_dist) | ||||
| # Fill the Range Min/Max entries with the computed distances | # Fill the Range Min/Max entries with the computed distances | ||||
| m.range_min = min_dist | m.range_min = min_dist | ||||
| m.range_max = max_dist | m.range_max = max_dist | ||||
| return {'FINISHED'} | return {'FINISHED'} | ||||
| # Find selected mesh objects | # Find selected mesh objects | ||||
| selection = [ob for ob in scene.objects if ob.select_get() and ob.type == 'MESH' and ob.name != ref.name] | selection = [ob for ob in scene.objects if ob.select_get() and ob.type == 'MESH' and ob.name != ref.name] | ||||
| ▲ Show 20 Lines • Show All 123 Lines • Show Last 20 Lines | |||||