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-11-08 10:30:02 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2011-11-08 10:30:02 +0400
commit80e398e7b2cfbdf0192b11734cb02b378b423d65 (patch)
tree69bda0498a17f6a3ad5acb47465e1eef8a5e1faa /release/scripts/startup/bl_operators
parent72cfdfec3083cbb756ff07c860293be9ca25f8b4 (diff)
parentf086201518b85f6dd2ae60ae37dc14f1d1406c01 (diff)
Merged changes in the trunk up to revision 41638.
Conflicts resolved: doc/python_api/sphinx_doc_gen.py source/blender/blenkernel/BKE_main.h source/blender/blenkernel/intern/library.c source/blender/blenloader/intern/readfile.c source/blender/blenloader/intern/writefile.c source/blender/editors/include/UI_resources.h source/blender/editors/interface/resources.c source/blender/makesdna/DNA_ID.h source/blender/makesdna/intern/makesdna.c source/blender/makesrna/intern/rna_internal.h source/blender/makesrna/intern/rna_main.c source/blender/makesrna/intern/rna_main_api.c source/blender/makesrna/intern/rna_scene.c
Diffstat (limited to 'release/scripts/startup/bl_operators')
-rw-r--r--release/scripts/startup/bl_operators/__init__.py1
-rw-r--r--release/scripts/startup/bl_operators/clip.py319
-rw-r--r--release/scripts/startup/bl_operators/image.py2
-rw-r--r--release/scripts/startup/bl_operators/object_quick_effects.py3
-rw-r--r--release/scripts/startup/bl_operators/presets.py60
-rw-r--r--release/scripts/startup/bl_operators/uvcalc_smart_project.py18
-rw-r--r--release/scripts/startup/bl_operators/wm.py4
7 files changed, 396 insertions, 11 deletions
diff --git a/release/scripts/startup/bl_operators/__init__.py b/release/scripts/startup/bl_operators/__init__.py
index c1af1e8ab5e..8fb264eb411 100644
--- a/release/scripts/startup/bl_operators/__init__.py
+++ b/release/scripts/startup/bl_operators/__init__.py
@@ -25,6 +25,7 @@ if "bpy" in locals():
_modules = (
"add_mesh_torus",
"anim",
+ "clip",
"console",
"freestyle",
"image",
diff --git a/release/scripts/startup/bl_operators/clip.py b/release/scripts/startup/bl_operators/clip.py
new file mode 100644
index 00000000000..55592621112
--- /dev/null
+++ b/release/scripts/startup/bl_operators/clip.py
@@ -0,0 +1,319 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+import bpy
+import os
+import shutil
+from bpy.types import Operator
+from bpy_extras.io_utils import unpack_list
+
+
+class CLIP_OT_track_to_empty(Operator):
+ """Create an Empty object which will be copying movement of active track"""
+
+ bl_idname = "clip.track_to_empty"
+ bl_label = "2D Track to Empty"
+ bl_options = {'UNDO', 'REGISTER'}
+
+ @classmethod
+ def poll(cls, context):
+ if context.space_data.type != 'CLIP_EDITOR':
+ return False
+
+ sc = context.space_data
+ clip = sc.clip
+
+ return clip and clip.tracking.tracks.active
+
+ def execute(self, context):
+ sc = context.space_data
+ clip = sc.clip
+ track = clip.tracking.tracks.active
+ constraint = None
+ ob = None
+
+ ob = bpy.data.objects.new(name=track.name, object_data=None)
+ ob.select = True
+ bpy.context.scene.objects.link(ob)
+ bpy.context.scene.objects.active = ob
+
+ for con in ob.constraints:
+ if con.type == 'FOLLOW_TRACK':
+ constraint = con
+ break
+
+ if constraint is None:
+ constraint = ob.constraints.new(type='FOLLOW_TRACK')
+
+ constraint.clip = sc.clip
+ constraint.track = track.name
+ constraint.reference = 'TRACK'
+
+ return {'FINISHED'}
+
+
+class CLIP_OT_bundles_to_mesh(Operator):
+ """Create vertex cloud using coordinates of bundles"""
+
+ bl_idname = "clip.bundles_to_mesh"
+ bl_label = "Bundles to Mesh"
+ bl_options = {'UNDO', 'REGISTER'}
+
+ @classmethod
+ def poll(cls, context):
+ if context.space_data.type != 'CLIP_EDITOR':
+ return False
+
+ sc = context.space_data
+ clip = sc.clip
+
+ return clip
+
+ def execute(self, context):
+ sc = context.space_data
+ clip = sc.clip
+
+ new_verts = []
+
+ mesh = bpy.data.meshes.new(name="Bundles")
+ for track in clip.tracking.tracks:
+ if track.has_bundle:
+ new_verts.append(track.bundle)
+
+ if new_verts:
+ mesh.vertices.add(len(new_verts))
+ mesh.vertices.foreach_set("co", unpack_list(new_verts))
+
+ ob = bpy.data.objects.new(name="Bundles", object_data=mesh)
+
+ bpy.context.scene.objects.link(ob)
+
+ return {'FINISHED'}
+
+
+class CLIP_OT_delete_proxy(Operator):
+ """Delete movie clip proxy files from the hard drive"""
+
+ bl_idname = "clip.delete_proxy"
+ bl_label = "Delete Proxy"
+ bl_options = {'UNDO', 'REGISTER'}
+
+ @classmethod
+ def poll(cls, context):
+ sc = context.space_data
+
+ return sc.clip
+
+ def invoke(self, context, event):
+ wm = context.window_manager
+
+ return wm.invoke_confirm(self, event)
+
+ def _rmproxy(self, abspath):
+ if not os.path.exists(abspath):
+ return
+
+ if os.path.isdir(abspath):
+ shutil.rmtree(abspath)
+ else:
+ os.remove(abspath)
+
+ def execute(self, context):
+ sc = context.space_data
+ clip = sc.clip
+ if clip.use_proxy_custom_directory:
+ proxydir = clip.proxy.directory
+ else:
+ clipdir = os.path.dirname(clip.filepath)
+ proxydir = os.path.join(clipdir, 'BL_proxy')
+
+ clipfile = os.path.basename(clip.filepath)
+ proxy = os.path.join(proxydir, clipfile)
+ absproxy = bpy.path.abspath(proxy)
+
+ # proxy_<quality>[_undostorted]
+ for x in (25, 50, 75, 100):
+ d = os.path.join(absproxy, 'proxy_' + str(x))
+
+ self._rmproxy(d)
+ self._rmproxy(d + '_undistorted')
+ self._rmproxy(os.path.join(absproxy, 'proxy_' + str(x) + '.avi'))
+
+ tc = ('free_run.blen_tc',
+ 'interp_free_run.blen_tc',
+ 'record_run.blen_tc')
+
+ for x in tc:
+ self._rmproxy(os.path.join(absproxy, x))
+
+ # remove proxy per-clip directory
+ try:
+ os.rmdir(absproxy)
+ except OSError:
+ pass
+
+ # remove [custom] proxy directory if empty
+ try:
+ absdir = bpy.path.abspath(proxydir)
+ os.rmdir(absdir)
+ except OSError:
+ pass
+
+ return {'FINISHED'}
+
+
+class CLIP_OT_set_viewport_background(Operator):
+ """Set current movie clip as a camera background in 3D viewport"""
+
+ bl_idname = "clip.set_viewport_background"
+ bl_label = "Set as Background"
+ bl_options = {'UNDO', 'REGISTER'}
+
+ @classmethod
+ def poll(cls, context):
+ if context.space_data.type != 'CLIP_EDITOR':
+ return False
+
+ sc = context.space_data
+
+ return sc.clip
+
+ def _set_background(self, space_v3d, clip, user):
+ bgpic = None
+
+ for x in space_v3d.background_images:
+ if x.source == 'MOVIE':
+ bgpic = x
+ break
+
+ if not bgpic:
+ bgpic = space_v3d.background_images.add()
+
+ bgpic.source = 'MOVIE'
+ bgpic.clip = clip
+ bgpic.clip_user.proxy_render_size = user.proxy_render_size
+ bgpic.clip_user.use_render_undistorted = user.use_render_undistorted
+ bgpic.use_camera_clip = False
+ bgpic.view_axis = 'CAMERA'
+
+ space_v3d.show_background_images = True
+
+ def execute(self, context):
+ sc = context.space_data
+ clip = sc.clip
+
+ for area in context.window.screen.areas:
+ if area.type == 'VIEW_3D':
+ for space in area.spaces:
+ if space.type == 'VIEW_3D':
+ self._set_background(space, clip, sc.clip_user)
+
+ return {'FINISHED'}
+
+
+class CLIP_OT_constraint_to_fcurve(Operator):
+ """Create F-Curves for object which will copy object's movement caused by this constraint"""
+
+ bl_idname = "clip.constraint_to_fcurve"
+ bl_label = "Constraint to F-Curve"
+ bl_options = {'UNDO', 'REGISTER'}
+
+ def _bake_object(self, scene, ob):
+ con = None
+ clip = None
+ sfra = None
+ efra = None
+ frame_current = scene.frame_current
+ matrices = []
+
+ # Find constraint which would eb converting
+ # TODO: several camera solvers and track followers would fail,
+ # but can't think about eal workflow where it'll be useful
+ for x in ob.constraints:
+ if x.type in ('CAMERA_SOLVER', 'FOLLOW_TRACK'):
+ con = x
+
+ if not con:
+ return
+
+ if con.type == 'FOLLOW_TRACK' and con.reference == 'BUNDLE':
+ mat = ob.matrix_world.copy()
+ ob.constraints.remove(con)
+ ob.matrix_world = mat
+
+ return
+
+ # Get clip used for parenting
+ if con.use_active_clip:
+ clip = scene.active_clip
+ else:
+ clip = con.clip
+
+ if not clip:
+ return
+
+ # Find start and end frames
+ for track in clip.tracking.tracks:
+ if sfra is None:
+ sfra = track.markers[0].frame
+ else:
+ sfra = min(sfra, track.markers[0].frame)
+
+ if efra is None:
+ efra = track.markers[-1].frame
+ else:
+ efra = max(efra, track.markers[-1].frame)
+
+ if sfra is None or efra is None:
+ return
+
+ # Store object matrices
+ for x in range(sfra, efra + 1):
+ scene.frame_set(x)
+ matrices.append(ob.matrix_world.copy())
+
+ ob.animation_data_create()
+
+ # Apply matrices on object and insert keyframes
+ i = 0
+ for x in range(sfra, efra + 1):
+ scene.frame_set(x)
+ ob.matrix_world = matrices[i]
+
+ ob.keyframe_insert("location")
+
+ if ob.rotation_mode == 'QUATERNION':
+ ob.keyframe_insert("rotation_quaternion")
+ else:
+ ob.keyframe_insert("rotation_euler")
+
+ i += 1
+
+ ob.constraints.remove(con)
+
+ scene.frame_set(frame_current)
+
+ def execute(self, context):
+ scene = context.scene
+
+ for ob in scene.objects:
+ if ob.select:
+ self._bake_object(scene, ob)
+
+ return {'FINISHED'}
diff --git a/release/scripts/startup/bl_operators/image.py b/release/scripts/startup/bl_operators/image.py
index 790c22d57d0..8c12a6442f7 100644
--- a/release/scripts/startup/bl_operators/image.py
+++ b/release/scripts/startup/bl_operators/image.py
@@ -192,6 +192,8 @@ class ProjectEdit(Operator):
image_new.file_format = 'PNG'
image_new.save()
+ filepath_final = bpy.path.abspath(filepath_final)
+
try:
bpy.ops.image.external_edit(filepath=filepath_final)
except RuntimeError as re:
diff --git a/release/scripts/startup/bl_operators/object_quick_effects.py b/release/scripts/startup/bl_operators/object_quick_effects.py
index 490ee230220..a062ac6f4c5 100644
--- a/release/scripts/startup/bl_operators/object_quick_effects.py
+++ b/release/scripts/startup/bl_operators/object_quick_effects.py
@@ -105,8 +105,7 @@ class QuickFur(Operator):
psys.settings.child_type = 'INTERPOLATED'
obj.data.materials.append(mat)
- obj.particle_systems[-1].settings.material = \
- len(obj.data.materials)
+ psys.settings.material = len(obj.data.materials)
return {'FINISHED'}
diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py
index 2e42105fbf0..ac19bab4c66 100644
--- a/release/scripts/startup/bl_operators/presets.py
+++ b/release/scripts/startup/bl_operators/presets.py
@@ -195,6 +195,25 @@ class AddPresetRender(AddPresetBase, Operator):
preset_subdir = "render"
+class AddPresetCamera(AddPresetBase, Operator):
+ '''Add a Camera Preset'''
+ bl_idname = "camera.preset_add"
+ bl_label = "Add Camera Preset"
+ preset_menu = "CAMERA_MT_presets"
+
+ preset_defines = [
+ "cam = bpy.context.object.data"
+ ]
+
+ preset_values = [
+ "cam.sensor_width",
+ "cam.sensor_height",
+ "cam.sensor_fit"
+ ]
+
+ preset_subdir = "camera"
+
+
class AddPresetSSS(AddPresetBase, Operator):
'''Add a Subsurface Scattering Preset'''
bl_idname = "material.sss_preset_add"
@@ -300,6 +319,47 @@ class AddPresetInteraction(AddPresetBase, Operator):
preset_subdir = "interaction"
+class AddPresetTrackingCamera(AddPresetBase, Operator):
+ '''Add a Tracking Camera Intrinsics Preset'''
+ bl_idname = "clip.camera_preset_add"
+ bl_label = "Add Camera Preset"
+ preset_menu = "CLIP_MT_camera_presets"
+
+ preset_defines = [
+ "camera = bpy.context.edit_movieclip.tracking.camera"
+ ]
+
+ preset_values = [
+ "camera.sensor_width",
+ "camera.units",
+ "camera.focal_length",
+ "camera.pixel_aspect",
+ "camera.k1",
+ "camera.k2",
+ "camera.k3"
+ ]
+
+ preset_subdir = "tracking_camera"
+
+
+class AddPresetTrackingTrackColor(AddPresetBase, Operator):
+ '''Add a Clip Track Color Preset'''
+ bl_idname = "clip.track_color_preset_add"
+ bl_label = "Add Track Color Preset"
+ preset_menu = "CLIP_MT_track_color_presets"
+
+ preset_defines = [
+ "track = bpy.context.edit_movieclip.tracking.tracks"
+ ]
+
+ preset_values = [
+ "track.color",
+ "track.use_custom_color"
+ ]
+
+ preset_subdir = "tracking_track_color"
+
+
class AddPresetKeyconfig(AddPresetBase, Operator):
'''Add a Keyconfig Preset'''
bl_idname = "wm.keyconfig_preset_add"
diff --git a/release/scripts/startup/bl_operators/uvcalc_smart_project.py b/release/scripts/startup/bl_operators/uvcalc_smart_project.py
index 66d0d72efc1..17e353ff238 100644
--- a/release/scripts/startup/bl_operators/uvcalc_smart_project.py
+++ b/release/scripts/startup/bl_operators/uvcalc_smart_project.py
@@ -212,8 +212,11 @@ def islandIntersectUvIsland(source, target, SourceOffset):
# Edge intersect test
for ed in edgeLoopsSource:
for seg in edgeLoopsTarget:
- i = geometry.intersect_line_line_2d(\
- seg[0], seg[1], SourceOffset+ed[0], SourceOffset+ed[1])
+ i = geometry.intersect_line_line_2d(seg[0],
+ seg[1],
+ SourceOffset+ed[0],
+ SourceOffset+ed[1],
+ )
if i:
return 1 # LINE INTERSECTION
@@ -773,15 +776,16 @@ def main_consts():
global ROTMAT_2D_POS_45D
global RotMatStepRotation
- ROTMAT_2D_POS_90D = Matrix.Rotation( radians(90.0), 2)
- ROTMAT_2D_POS_45D = Matrix.Rotation( radians(45.0), 2)
+ ROTMAT_2D_POS_90D = Matrix.Rotation(radians(90.0), 2)
+ ROTMAT_2D_POS_45D = Matrix.Rotation(radians(45.0), 2)
RotMatStepRotation = []
rot_angle = 22.5 #45.0/2
while rot_angle > 0.1:
- RotMatStepRotation.append([\
- Matrix.Rotation( radians(rot_angle), 2),\
- Matrix.Rotation( radians(-rot_angle), 2)])
+ RotMatStepRotation.append([
+ Matrix.Rotation(radians(+rot_angle), 2),
+ Matrix.Rotation(radians(-rot_angle), 2),
+ ])
rot_angle = rot_angle/2.0
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py
index 0c9f1c33abb..aa661b76512 100644
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@ -1371,9 +1371,9 @@ class WM_OT_keyitem_add(Operator):
km = context.keymap
if km.is_modal:
- km.keymap_items.new_modal("", 'A', 'PRESS') #~ kmi
+ km.keymap_items.new_modal("", 'A', 'PRESS')
else:
- km.keymap_items.new("none", 'A', 'PRESS') #~ kmi
+ km.keymap_items.new("none", 'A', 'PRESS')
# clear filter and expand keymap so we can see the newly added item
if context.space_data.filter_text != "":