Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2011-08-24 19:47:05 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2011-08-24 19:47:05 +0400
commit7eb10d1538a4df347a96b659b29fd24d74513dd9 (patch)
tree04d8917eb75d4586a0f6ae17da55419a01121985 /release/scripts/startup
parent33bb1ed53ee7527b507c4f30a9a0c46dcf0ac415 (diff)
Added a button to the UI of "Distance from Object" color/alpha/thickness
modifiers to fill the Range Min/Max entries by the min/max distance between selected mesh objects and the target object.
Diffstat (limited to 'release/scripts/startup')
-rw-r--r--release/scripts/startup/bl_operators/freestyle.py21
-rw-r--r--release/scripts/startup/bl_ui/properties_render.py9
2 files changed, 24 insertions, 6 deletions
diff --git a/release/scripts/startup/bl_operators/freestyle.py b/release/scripts/startup/bl_operators/freestyle.py
index ba9ace685b8..6d0cac65e8e 100644
--- a/release/scripts/startup/bl_operators/freestyle.py
+++ b/release/scripts/startup/bl_operators/freestyle.py
@@ -22,7 +22,7 @@ from bpy.props import (EnumProperty, StringProperty)
class SCENE_OT_freestyle_fill_range_by_selection(bpy.types.Operator):
- '''Fill the Range Min/Max entries by the min/max distance between selected mesh objects and the active camera.'''
+ '''Fill the Range Min/Max entries by the min/max distance between selected mesh objects and the source object (either a user-specified object or the active camera).'''
bl_idname = "scene.freestyle_fill_range_by_selection"
bl_label = "Fill Range by Selection"
@@ -43,17 +43,26 @@ class SCENE_OT_freestyle_fill_range_by_selection(bpy.types.Operator):
m = linestyle.alpha_modifiers[self.name]
else:
m = linestyle.thickness_modifiers[self.name]
- # Find the active camera
- camera = context.scene.camera
+ # Find the source object
+ if m.type == 'DISTANCE_FROM_CAMERA':
+ source = context.scene.camera
+ elif m.type == 'DISTANCE_FROM_OBJECT':
+ if m.target is None:
+ self.report({'ERROR'}, "Target object not specified")
+ return {'CANCELLED'}
+ source = m.target
+ else:
+ self.report({'ERROR'}, "Unexpected modifier type: " + m.type)
+ return {'CANCELLED'}
# Find selected mesh objects
- selection = [ob for ob in context.scene.objects if ob.select and ob.type == 'MESH']
+ selection = [ob for ob in context.scene.objects if ob.select and ob.type == 'MESH' and ob.name != source.name]
if len(selection) > 0:
- # Compute the min/max distance between selected mesh objects and the camera
+ # Compute the min/max distance between selected mesh objects and the source
min_dist = float('inf')
max_dist = -min_dist
for ob in selection:
for vert in ob.data.vertices:
- dist = (ob.matrix_world * vert.co - camera.location).length
+ dist = (ob.matrix_world * vert.co - source.location).length
min_dist = min(dist, min_dist)
max_dist = max(dist, max_dist)
# Fill the Range Min/Max entries with the computed distances
diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py
index 2c0ded20672..1ad1fb5f283 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -364,6 +364,9 @@ class RENDER_PT_freestyle_linestyle(RenderButtonsPanel, Panel):
elif modifier.type == "DISTANCE_FROM_OBJECT":
box.prop(modifier, "target")
self.draw_modifier_color_ramp_common(box, modifier, True)
+ prop = box.operator("scene.freestyle_fill_range_by_selection")
+ prop.type = 'COLOR'
+ prop.name = modifier.name
elif modifier.type == "DISTANCE_FROM_CAMERA":
self.draw_modifier_color_ramp_common(box, modifier, True)
@@ -400,6 +403,9 @@ class RENDER_PT_freestyle_linestyle(RenderButtonsPanel, Panel):
elif modifier.type == "DISTANCE_FROM_OBJECT":
box.prop(modifier, "target")
self.draw_modifier_curve_common(box, modifier, True, False)
+ prop = box.operator("scene.freestyle_fill_range_by_selection")
+ prop.type = 'ALPHA'
+ prop.name = modifier.name
elif modifier.type == "DISTANCE_FROM_CAMERA":
self.draw_modifier_curve_common(box, modifier, True, False)
@@ -426,6 +432,9 @@ class RENDER_PT_freestyle_linestyle(RenderButtonsPanel, Panel):
elif modifier.type == "DISTANCE_FROM_OBJECT":
box.prop(modifier, "target")
self.draw_modifier_curve_common(box, modifier, True, True)
+ prop = box.operator("scene.freestyle_fill_range_by_selection")
+ prop.type = 'THICKNESS'
+ prop.name = modifier.name
elif modifier.type == "DISTANCE_FROM_CAMERA":
self.draw_modifier_curve_common(box, modifier, True, True)