diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-08-12 08:01:26 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-08-12 08:22:58 +0300 |
commit | 4b6fa4d897a0bb3252b16383492b526d2cef3920 (patch) | |
tree | 2793afc516c9a97e0d23d33a62028a6a9d87e8e2 /release/scripts/startup | |
parent | 444a0202d40705b6a6f21e59e883518be577cf4e (diff) |
PyAPI: update scripts for matrix multiply operator
Operators:
- add torus
- align objects
- bake physics
- make dupli faces
- smart project
Templates:
- 3D view ray cast
Other:
- Methods for bones/edit-bones
Diffstat (limited to 'release/scripts/startup')
6 files changed, 22 insertions, 19 deletions
diff --git a/release/scripts/startup/bl_operators/add_mesh_torus.py b/release/scripts/startup/bl_operators/add_mesh_torus.py index 4460af173ff..68f49acc186 100644 --- a/release/scripts/startup/bl_operators/add_mesh_torus.py +++ b/release/scripts/startup/bl_operators/add_mesh_torus.py @@ -46,10 +46,11 @@ def add_torus(major_rad, minor_rad, major_seg, minor_seg): for minor_index in range(minor_seg): angle = pi_2 * minor_index / minor_seg - vec = matrix * Vector((major_rad + (cos(angle) * minor_rad), - 0.0, - sin(angle) * minor_rad, - )) + vec = matrix @ Vector(( + major_rad + (cos(angle) * minor_rad), + 0.0, + sin(angle) * minor_rad, + )) verts.extend(vec[:]) diff --git a/release/scripts/startup/bl_operators/clip.py b/release/scripts/startup/bl_operators/clip.py index a94076ab61b..d05082b0dd8 100644 --- a/release/scripts/startup/bl_operators/clip.py +++ b/release/scripts/startup/bl_operators/clip.py @@ -300,7 +300,7 @@ class CLIP_OT_bundles_to_mesh(Operator): reconstruction = tracking_object.reconstruction framenr = scene.frame_current - clip.frame_start + 1 reconstructed_matrix = reconstruction.cameras.matrix_from_frame(framenr) - matrix = camera.matrix_world * reconstructed_matrix.inverted() + matrix = camera.matrix_world @ reconstructed_matrix.inverted() for track in tracking_object.tracks: if track.has_bundle and track.select: @@ -580,10 +580,12 @@ class CLIP_OT_setup_tracking_scene(Operator): scene.camera = camob - camob.matrix_local = (Matrix.Translation((7.481, -6.508, 5.344)) * - Matrix.Rotation(0.815, 4, 'Z') * - Matrix.Rotation(0.011, 4, 'Y') * - Matrix.Rotation(1.109, 4, 'X')) + camob.matrix_local = ( + Matrix.Translation((7.481, -6.508, 5.344)) @ + Matrix.Rotation(0.815, 4, 'Z') @ + Matrix.Rotation(0.011, 4, 'Y') @ + Matrix.Rotation(1.109, 4, 'X') + ) return camob diff --git a/release/scripts/startup/bl_operators/object.py b/release/scripts/startup/bl_operators/object.py index be379ec6089..c49591ff300 100644 --- a/release/scripts/startup/bl_operators/object.py +++ b/release/scripts/startup/bl_operators/object.py @@ -599,7 +599,7 @@ class MakeDupliFace(Operator): trans = matrix.to_translation() rot = matrix.to_3x3() # also contains scale - return [(rot * b) + trans for b in base_tri] + return [(rot @ b) + trans for b in base_tri] scene = context.scene linked = {} for obj in context.selected_objects: diff --git a/release/scripts/startup/bl_operators/object_align.py b/release/scripts/startup/bl_operators/object_align.py index f627fd30162..60fb360480f 100644 --- a/release/scripts/startup/bl_operators/object_align.py +++ b/release/scripts/startup/bl_operators/object_align.py @@ -75,7 +75,7 @@ def worldspace_bounds_from_object_data(scene, obj): me = obj.to_mesh(scene=scene, apply_modifiers=True, settings='PREVIEW') verts = me.vertices - val = matrix_world * (verts[-1].co if verts else Vector((0.0, 0.0, 0.0))) + val = matrix_world @ (verts[-1].co if verts else Vector((0.0, 0.0, 0.0))) left, right, front, back, down, up = ( val[0], @@ -88,7 +88,7 @@ def worldspace_bounds_from_object_data(scene, obj): # Test against all other verts for v in verts: - vco = matrix_world * v.co + vco = matrix_world @ v.co # X Range val = vco[0] @@ -146,7 +146,7 @@ def align_objects(context, for obj in context.selected_objects: matrix_world = obj.matrix_world.copy() - bb_world = [matrix_world * Vector(v) for v in obj.bound_box] + bb_world = [matrix_world @ Vector(v) for v in obj.bound_box] objects.append((obj, bb_world)) if not objects: @@ -216,7 +216,7 @@ def align_objects(context, for obj, bb_world in objects: matrix_world = obj.matrix_world.copy() - bb_world = [matrix_world * Vector(v[:]) for v in obj.bound_box] + bb_world = [matrix_world @ Vector(v[:]) for v in obj.bound_box] if bb_quality and obj.type == 'MESH': GBB = worldspace_bounds_from_object_data(scene, obj) diff --git a/release/scripts/startup/bl_operators/rigidbody.py b/release/scripts/startup/bl_operators/rigidbody.py index 6b76fb96b62..46f3d0a1436 100644 --- a/release/scripts/startup/bl_operators/rigidbody.py +++ b/release/scripts/startup/bl_operators/rigidbody.py @@ -149,7 +149,7 @@ class BakeToKeyframes(Operator): mat = bake[i][j] # convert world space transform to parent space, so parented objects don't get offset after baking if (obj.parent): - mat = obj.matrix_parent_inverse.inverted() * obj.parent.matrix_world.inverted() * mat + mat = obj.matrix_parent_inverse.inverted() @ obj.parent.matrix_world.inverted() @ mat obj.location = mat.to_translation() diff --git a/release/scripts/startup/bl_operators/uvcalc_smart_project.py b/release/scripts/startup/bl_operators/uvcalc_smart_project.py index fe15b9fa345..b01a50d5d6a 100644 --- a/release/scripts/startup/bl_operators/uvcalc_smart_project.py +++ b/release/scripts/startup/bl_operators/uvcalc_smart_project.py @@ -89,7 +89,7 @@ def pointInTri2D(v, v1, v2, v3): dict_matrix[key] = mtx - uvw = (v - v1) * mtx + uvw = (v - v1) @ mtx return 0 <= uvw[0] and 0 <= uvw[1] and uvw[0] + uvw[1] <= 1 @@ -258,7 +258,7 @@ def rotate_uvs(uv_points, angle): if angle != 0.0: mat = Matrix.Rotation(angle, 2) for uv in uv_points: - uv[:] = mat * uv + uv[:] = mat @ uv def optiRotateUvIsland(faces): @@ -858,7 +858,7 @@ def main(context, # Initialize projectVecs if USER_VIEW_INIT: # Generate Projection - projectVecs = [Vector(Window.GetViewVector()) * ob.matrix_world.inverted().to_3x3()] # We add to this along the way + projectVecs = [Vector(Window.GetViewVector()) @ ob.matrix_world.inverted().to_3x3()] # We add to this along the way else: projectVecs = [] @@ -975,7 +975,7 @@ def main(context, f_uv = f.uv for j, v in enumerate(f.v): # XXX - note, between mathutils in 2.4 and 2.5 the order changed. - f_uv[j][:] = (MatQuat * v.co).xy + f_uv[j][:] = (MatQuat @ v.co).xy if USER_SHARE_SPACE: # Should we collect and pack later? |