diff options
Diffstat (limited to 'release/scripts/startup/bl_operators')
-rw-r--r-- | release/scripts/startup/bl_operators/__init__.py | 2 | ||||
-rw-r--r-- | release/scripts/startup/bl_operators/add_mesh_torus.py | 18 | ||||
-rw-r--r-- | release/scripts/startup/bl_operators/anim.py | 23 | ||||
-rw-r--r-- | release/scripts/startup/bl_operators/clip.py | 12 | ||||
-rw-r--r-- | release/scripts/startup/bl_operators/image.py | 3 | ||||
-rw-r--r-- | release/scripts/startup/bl_operators/mask.py | 1 | ||||
-rw-r--r-- | release/scripts/startup/bl_operators/mesh.py | 1 | ||||
-rw-r--r-- | release/scripts/startup/bl_operators/object.py | 8 | ||||
-rw-r--r-- | release/scripts/startup/bl_operators/object_align.py | 10 | ||||
-rw-r--r-- | release/scripts/startup/bl_operators/object_quick_effects.py | 2 | ||||
-rw-r--r-- | release/scripts/startup/bl_operators/presets.py | 159 | ||||
-rw-r--r-- | release/scripts/startup/bl_operators/screen_play_rendered_anim.py | 11 | ||||
-rw-r--r-- | release/scripts/startup/bl_operators/wm.py | 19 |
13 files changed, 206 insertions, 63 deletions
diff --git a/release/scripts/startup/bl_operators/__init__.py b/release/scripts/startup/bl_operators/__init__.py index 65f7bde1809..4047505652f 100644 --- a/release/scripts/startup/bl_operators/__init__.py +++ b/release/scripts/startup/bl_operators/__init__.py @@ -54,7 +54,7 @@ if bpy.app.build_options.freestyle: _modules.append("freestyle") __import__(name=__name__, fromlist=_modules) _namespace = globals() -_modules_loaded = {name: _namespace[name] for name in _modules if name != 'bpy'} +_modules_loaded = {name: _namespace[name] for name in _modules if name != "bpy"} del _namespace diff --git a/release/scripts/startup/bl_operators/add_mesh_torus.py b/release/scripts/startup/bl_operators/add_mesh_torus.py index dfb734e9b5b..82014c87be9 100644 --- a/release/scripts/startup/bl_operators/add_mesh_torus.py +++ b/release/scripts/startup/bl_operators/add_mesh_torus.py @@ -153,40 +153,40 @@ class AddTorus(Operator, object_utils.AddObjectHelper): col = layout.column(align=True) col.label(text="Location") - col.prop(self, 'location', text="") + col.prop(self, "location", text="") col = layout.column(align=True) col.label(text="Rotation") - col.prop(self, 'rotation', text="") + col.prop(self, "rotation", text="") col = layout.column(align=True) col.label(text="Major Segments") - col.prop(self, 'major_segments', text="") + col.prop(self, "major_segments", text="") col = layout.column(align=True) col.label(text="Minor Segments") - col.prop(self, 'minor_segments', text="") + col.prop(self, "minor_segments", text="") col = layout.column(align=True) col.label(text="Torus Dimensions") - col.row().prop(self, 'mode', expand=True) + col.row().prop(self, "mode", expand=True) if self.mode == 'MAJOR_MINOR': col = layout.column(align=True) col.label(text="Major Radius") - col.prop(self, 'major_radius', text="") + col.prop(self, "major_radius", text="") col = layout.column(align=True) col.label(text="Minor Radius") - col.prop(self, 'minor_radius', text="") + col.prop(self, "minor_radius", text="") else: col = layout.column(align=True) col.label(text="Exterior Radius") - col.prop(self, 'abso_major_rad', text="") + col.prop(self, "abso_major_rad", text="") col = layout.column(align=True) col.label(text="Interior Radius") - col.prop(self, 'abso_minor_rad', text="") + col.prop(self, "abso_minor_rad", text="") def invoke(self, context, event): object_utils.object_add_grid_scale_apply_operator(self, context) diff --git a/release/scripts/startup/bl_operators/anim.py b/release/scripts/startup/bl_operators/anim.py index 1b3e719b2bd..a1b10976fe0 100644 --- a/release/scripts/startup/bl_operators/anim.py +++ b/release/scripts/startup/bl_operators/anim.py @@ -29,6 +29,7 @@ import bpy from bpy.types import Operator from bpy.props import ( IntProperty, + FloatProperty, BoolProperty, EnumProperty, StringProperty, @@ -210,6 +211,19 @@ class BakeAction(Operator): description="Bake animation onto the object then clear parents (objects only)", default=False, ) + use_current_action = BoolProperty( + name="Overwrite Current Action", + description="Bake animation into current action, instead of creating a new one " + "(useful for baking only part of bones in an armature)", + default=False, + ) + clean_threshold = FloatProperty( + name="Clean Threshold", + description="Allowed error when simplifying baked curves (set to zero to disable)", + default=0.1, + min=0.0, + max=1.0, + ) bake_types = EnumProperty( name="Bake Data", description="Which data's transformations to bake", @@ -221,9 +235,14 @@ class BakeAction(Operator): ) def execute(self, context): - from bpy_extras import anim_utils + action = None + if self.use_current_action: + obj = context.object + if obj.animation_data: + action = obj.animation_data.action + action = anim_utils.bake_action(self.frame_start, self.frame_end, frame_step=self.step, @@ -234,6 +253,8 @@ class BakeAction(Operator): do_constraint_clear=self.clear_constraints, do_parents_clear=self.clear_parents, do_clean=True, + clean_threshold=self.clean_threshold, + action=action, ) if action is None: diff --git a/release/scripts/startup/bl_operators/clip.py b/release/scripts/startup/bl_operators/clip.py index 7e4e0ea9246..0c77ea2ab7e 100644 --- a/release/scripts/startup/bl_operators/clip.py +++ b/release/scripts/startup/bl_operators/clip.py @@ -225,7 +225,8 @@ class CLIP_OT_track_to_empty(Operator): bl_label = "Link Empty to Track" bl_options = {'UNDO', 'REGISTER'} - def _link_track(self, context, clip, tracking_object, track): + @staticmethod + def _link_track(context, clip, tracking_object, track): sc = context.space_data constraint = None ob = None @@ -331,7 +332,8 @@ class CLIP_OT_delete_proxy(Operator): return wm.invoke_confirm(self, event) - def _rmproxy(self, abspath): + @staticmethod + def _rmproxy(abspath): import shutil if not os.path.exists(abspath): @@ -552,8 +554,8 @@ class CLIP_OT_setup_tracking_scene(Operator): world.light_settings.sample_method = 'ADAPTIVE_QMC' world.light_settings.samples = 7 world.light_settings.threshold = 0.005 - if hasattr(scene, 'cycles'): - world.light_settings.ao_factor = 0.05 + if hasattr(scene, "cycles"): + world.light_settings.ao_factor = 0.05 @staticmethod def _findOrCreateCamera(context): @@ -841,7 +843,7 @@ class CLIP_OT_setup_tracking_scene(Operator): self._offsetNodes(tree) scene.render.alpha_mode = 'TRANSPARENT' - if hasattr(scene, 'cycles'): + if hasattr(scene, "cycles"): scene.cycles.film_transparent = True @staticmethod diff --git a/release/scripts/startup/bl_operators/image.py b/release/scripts/startup/bl_operators/image.py index 1653459bd71..f00f5d97c5e 100644 --- a/release/scripts/startup/bl_operators/image.py +++ b/release/scripts/startup/bl_operators/image.py @@ -33,7 +33,8 @@ class EditExternally(Operator): subtype='FILE_PATH', ) - def _editor_guess(self, context): + @staticmethod + def _editor_guess(context): import sys image_editor = context.user_preferences.filepaths.image_editor diff --git a/release/scripts/startup/bl_operators/mask.py b/release/scripts/startup/bl_operators/mask.py index 60208d27338..aa984659430 100644 --- a/release/scripts/startup/bl_operators/mask.py +++ b/release/scripts/startup/bl_operators/mask.py @@ -18,7 +18,6 @@ # <pep8-80 compliant> -import bpy from bpy.types import Menu diff --git a/release/scripts/startup/bl_operators/mesh.py b/release/scripts/startup/bl_operators/mesh.py index f86c31cd9cc..ea504d48448 100644 --- a/release/scripts/startup/bl_operators/mesh.py +++ b/release/scripts/startup/bl_operators/mesh.py @@ -75,7 +75,6 @@ class MeshMirrorUV(Operator): double_warn += co in mirror_lt mirror_lt[co] = i - #for i, v in enumerate(mesh.vertices): vmap = {} for mirror_a, mirror_b in ((mirror_gt, mirror_lt), (mirror_lt, mirror_gt)): diff --git a/release/scripts/startup/bl_operators/object.py b/release/scripts/startup/bl_operators/object.py index e3ceeca8abe..b89890a223c 100644 --- a/release/scripts/startup/bl_operators/object.py +++ b/release/scripts/startup/bl_operators/object.py @@ -579,7 +579,8 @@ class MakeDupliFace(Operator): bl_label = "Make Dupli-Face" bl_options = {'REGISTER', 'UNDO'} - def _main(self, context): + @staticmethod + def _main(context): from mathutils import Vector SCALE_FAC = 0.01 @@ -643,6 +644,9 @@ class MakeDupliFace(Operator): ob_new.use_dupli_faces_scale = True ob_new.dupli_faces_scale = 1.0 / SCALE_FAC + ob_inst.select = True + ob_new.select = True + def execute(self, context): self._main(context) return {'FINISHED'} @@ -924,7 +928,7 @@ class LodGenerate(Operator): lod.location.y = ob.location.y + 3.0 * i if i == 1: - modifier = lod.modifiers.new("lod_decimate", "DECIMATE") + modifier = lod.modifiers.new("lod_decimate", 'DECIMATE') else: modifier = lod.modifiers[-1] diff --git a/release/scripts/startup/bl_operators/object_align.py b/release/scripts/startup/bl_operators/object_align.py index e843209da3c..3c84e5dc553 100644 --- a/release/scripts/startup/bl_operators/object_align.py +++ b/release/scripts/startup/bl_operators/object_align.py @@ -70,7 +70,8 @@ def GlobalBB_HQ(obj): # Initialize the variables with the last vertex - verts = obj.data.vertices + me = obj.to_mesh(scene=bpy.context.scene, apply_modifiers=True, settings='PREVIEW') + verts = me.vertices val = matrix_world * verts[-1].co @@ -111,6 +112,8 @@ def GlobalBB_HQ(obj): if val > up: up = val + bpy.data.meshes.remove(me) + return Vector((left, front, up)), Vector((right, back, down)) @@ -338,7 +341,10 @@ def align_objects(context, return True -from bpy.props import EnumProperty, BoolProperty +from bpy.props import ( + EnumProperty, + BoolProperty + ) class AlignObjects(Operator): diff --git a/release/scripts/startup/bl_operators/object_quick_effects.py b/release/scripts/startup/bl_operators/object_quick_effects.py index 24e471ecfba..414855c7e35 100644 --- a/release/scripts/startup/bl_operators/object_quick_effects.py +++ b/release/scripts/startup/bl_operators/object_quick_effects.py @@ -75,7 +75,7 @@ class QuickFur(Operator): def execute(self, context): fake_context = context.copy() mesh_objects = [obj for obj in context.selected_objects - if obj.type == 'MESH'] + if obj.type == 'MESH' and obj.mode == 'OBJECT'] if not mesh_objects: self.report({'ERROR'}, "Select at least one mesh object") diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py index 7195b7819d1..ffaf1b7817b 100644 --- a/release/scripts/startup/bl_operators/presets.py +++ b/release/scripts/startup/bl_operators/presets.py @@ -45,12 +45,51 @@ class AddPresetBase: options={'HIDDEN', 'SKIP_SAVE'}, ) + # needed for mix-ins + order = [ + "name", + "remove_active", + ] + @staticmethod def as_filename(name): # could reuse for other presets for char in " !@#$%^&*(){}:\";'[]<>,.\\/?": name = name.replace(char, '_') return name.lower().strip() + def write_preset_py(self, file_preset): + def rna_recursive_attr_expand(value, rna_path_step, level): + if isinstance(value, bpy.types.PropertyGroup): + for sub_value_attr in value.bl_rna.properties.keys(): + if sub_value_attr == "rna_type": + continue + sub_value = getattr(value, sub_value_attr) + rna_recursive_attr_expand(sub_value, "%s.%s" % (rna_path_step, sub_value_attr), level) + elif type(value).__name__ == "bpy_prop_collection_idprop": # could use nicer method + file_preset.write("%s.clear()\n" % rna_path_step) + for sub_value in value: + file_preset.write("item_sub_%d = %s.add()\n" % (level, rna_path_step)) + rna_recursive_attr_expand(sub_value, "item_sub_%d" % level, level + 1) + else: + # convert thin wrapped sequences + # to simple lists to repr() + try: + value = value[:] + except: + pass + + file_preset.write("%s = %r\n" % (rna_path_step, value)) + + if hasattr(self, "preset_defines"): + for rna_path in self.preset_defines: + exec(rna_path) + file_preset.write("%s\n" % rna_path) + file_preset.write("\n") + + for rna_path in self.preset_values: + value = eval(rna_path) + rna_recursive_attr_expand(value, rna_path, 1) + def execute(self, context): import os @@ -95,41 +134,10 @@ class AddPresetBase: filepath, preset_menu_class.preset_xml_map) else: - - def rna_recursive_attr_expand(value, rna_path_step, level): - if isinstance(value, bpy.types.PropertyGroup): - for sub_value_attr in value.bl_rna.properties.keys(): - if sub_value_attr == "rna_type": - continue - sub_value = getattr(value, sub_value_attr) - rna_recursive_attr_expand(sub_value, "%s.%s" % (rna_path_step, sub_value_attr), level) - elif type(value).__name__ == "bpy_prop_collection_idprop": # could use nicer method - file_preset.write("%s.clear()\n" % rna_path_step) - for sub_value in value: - file_preset.write("item_sub_%d = %s.add()\n" % (level, rna_path_step)) - rna_recursive_attr_expand(sub_value, "item_sub_%d" % level, level + 1) - else: - # convert thin wrapped sequences - # to simple lists to repr() - try: - value = value[:] - except: - pass - - file_preset.write("%s = %r\n" % (rna_path_step, value)) - file_preset = open(filepath, 'w') file_preset.write("import bpy\n") - if hasattr(self, "preset_defines"): - for rna_path in self.preset_defines: - exec(rna_path) - file_preset.write("%s\n" % rna_path) - file_preset.write("\n") - - for rna_path in self.preset_values: - value = eval(rna_path) - rna_recursive_attr_expand(value, rna_path, 1) + self.write_preset_py(file_preset) file_preset.close() @@ -395,6 +403,93 @@ class AddPresetHairDynamics(AddPresetBase, Operator): ] +class AddPresetCacheLibraryHairSimulation(AddPresetBase, Operator): + """Add or remove a Hair Simulation Preset""" + bl_idname = "cachelibrary.hair_simulation_preset_add" + bl_label = "Add Hair Simulation Preset" + preset_menu = "CACHELIBRARY_MT_hair_simulation_presets" + + # XXX cache_modifier should be stored in the context, but using a confirm popup + # for the operator causes this to get lost + modifier_name = StringProperty(name="Modifier Name") + + ''' + preset_defines = [ + "cachelib = bpy.context.cache_library", + "md = bpy.context.cache_modifier", + ] + ''' + + @property + def preset_defines(self): + return [ + "cachelib = bpy.context.object.cache_library", + "md = cachelib.modifiers[%r]" % self.modifier_name, + "params = md.parameters", + ] + + preset_subdir = "cachelibrary_hair_simulation" + + preset_values = [ + "params.substeps", + "params.timescale", + "params.mass", + "params.drag", + "params.stretch_stiffness", + "params.stretch_damping", + "params.bend_stiffness", + "params.bend_damping", + "params.use_bend_stiffness_curve", + "params.goal_stiffness", + "params.goal_damping", + "params.use_goal_stiffness_curve", + "params.use_goal_deflect", + ] + + def write_curve_map(self, file_preset, cuma, prop): + if cuma is None: + return + + file_preset.write("from mathutils import *\n") + + file_preset.write("cuma = %s\n" % prop) + file_preset.write("if cuma:\n") + + file_preset.write(" cuma.black_level = %r\n" % cuma.black_level) + file_preset.write(" cuma.white_level = %r\n" % cuma.white_level) + + file_preset.write(" cuma.use_clip = %r\n" % cuma.use_clip) + if cuma.use_clip: + file_preset.write(" cuma.clip_min_x = %r\n" % cuma.clip_min_x) + file_preset.write(" cuma.clip_max_x = %r\n" % cuma.clip_max_x) + file_preset.write(" cuma.clip_min_y = %r\n" % cuma.clip_min_y) + file_preset.write(" cuma.clip_max_y = %r\n" % cuma.clip_max_y) + + for i, cu in enumerate(cuma.curves): + file_preset.write(" cu = cuma.curves[%d]\n" % i) + file_preset.write(" cu.extend = %r\n" % cu.extend) + file_preset.write(" for p in range(max(len(cu.points) - %d, 0)):\n" % len(cu.points)) + file_preset.write(" cu.points.remove(cu.points[0])\n") + file_preset.write(" for i in range(max(%d - len(cu.points), 0)):\n" % len(cu.points)) + file_preset.write(" cu.points.new(0, 0)\n") + for j, p in enumerate(cu.points): + file_preset.write(" cu.points[%d].handle_type = %r\n" % (j, p.handle_type)) + file_preset.write(" cu.points[%d].location = %r\n" % (j, p.location)) + file_preset.write(" cu.points[%d].select = %r\n" % (j, p.select)) + + file_preset.write(" cuma.update()\n") + + def write_preset_py(self, file_preset): + AddPresetBase.write_preset_py(self, file_preset) + + cachelib = bpy.context.object.cache_library + md = cachelib.modifiers[self.modifier_name] + params = md.parameters + + self.write_curve_map(file_preset, params.bend_stiffness_curve, "params.bend_stiffness_curve") + self.write_curve_map(file_preset, params.goal_stiffness_curve, "params.goal_stiffness_curve") + + class AddPresetSunSky(AddPresetBase, Operator): """Add or remove a Sky & Atmosphere Preset""" bl_idname = "lamp.sunsky_preset_add" diff --git a/release/scripts/startup/bl_operators/screen_play_rendered_anim.py b/release/scripts/startup/bl_operators/screen_play_rendered_anim.py index 3a7a9b99cde..a5565699364 100644 --- a/release/scripts/startup/bl_operators/screen_play_rendered_anim.py +++ b/release/scripts/startup/bl_operators/screen_play_rendered_anim.py @@ -107,11 +107,20 @@ class PlayRenderedAnim(Operator): del file_a, file_b, frame_tmp file = bpy.path.abspath(file) # expand '//' else: + path_valid = True # works for movies and images - file = rd.frame_path(frame=scene.frame_start) + file = rd.frame_path(frame=scene.frame_start, preview=scene.use_preview_range) file = bpy.path.abspath(file) # expand '//' if not os.path.exists(file): self.report({'WARNING'}, "File %r not found" % file) + path_valid = False + + #one last try for full range if we used preview range + if scene.use_preview_range and not path_valid: + file = rd.frame_path(frame=scene.frame_start, preview=False) + file = bpy.path.abspath(file) # expand '//' + if not os.path.exists(file): + self.report({'WARNING'}, "File %r not found" % file) cmd = [player_path] # extra options, fps controls etc. diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index a48415caa9b..d923c1869c9 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -143,6 +143,7 @@ class BRUSH_OT_active_index_set(Operator): "vertex_paint": "use_paint_vertex", "weight_paint": "use_paint_weight", "image_paint": "use_paint_image", + "hair_edit": "use_hair_edit", } def execute(self, context): @@ -719,7 +720,7 @@ class WM_OT_context_modal_mouse(Operator): """Adjust arbitrary values with mouse input""" bl_idname = "wm.context_modal_mouse" bl_label = "Context Modal Mouse" - bl_options = {'GRAB_POINTER', 'BLOCKING', 'UNDO', 'INTERNAL'} + bl_options = {'GRAB_CURSOR', 'BLOCKING', 'UNDO', 'INTERNAL'} data_path_iter = data_path_iter data_path_item = data_path_item @@ -974,10 +975,12 @@ class WM_OT_doc_view_manual(Operator): url = self._lookup_rna_url(rna_id) if url is None: - self.report({'WARNING'}, "No reference available %r, " - "Update info in 'rna_wiki_reference.py' " - " or callback to bpy.utils.manual_map()" % - self.doc_id) + self.report( + {'WARNING'}, + "No reference available %r, " + "Update info in 'rna_manual_reference.py' " + "or callback to bpy.utils.manual_map()" % + self.doc_id) return {'CANCELLED'} else: import webbrowser @@ -1296,9 +1299,13 @@ class WM_OT_properties_remove(Operator): property = rna_property def execute(self, context): + from rna_prop_ui import rna_idprop_ui_prop_clear data_path = self.data_path item = eval("context.%s" % data_path) - del item[self.property] + prop = self.property + del item[prop] + rna_idprop_ui_prop_clear(item, prop) + return {'FINISHED'} |