re-commit temp workaround [#35920], this still fails for OSX retina display,
[blender-staging.git] / release / scripts / startup / bl_operators / object_align.py
index a32bb8c53532efef16c1000f73f7d0065b358211..e843209da3cd76d5a707ea7364632b9a724e26ac 100644 (file)
@@ -114,31 +114,32 @@ def GlobalBB_HQ(obj):
     return Vector((left, front, up)), Vector((right, back, down))
 
 
-def align_objects(align_x,
+def align_objects(context,
+                  align_x,
                   align_y,
                   align_z,
                   align_mode,
                   relative_to,
                   bb_quality):
 
-    cursor = bpy.context.scene.cursor_location
+    cursor = context.scene.cursor_location
 
     Left_Front_Up_SEL = [0.0, 0.0, 0.0]
     Right_Back_Down_SEL = [0.0, 0.0, 0.0]
 
     flag_first = True
 
-    objs = []
+    objects = []
 
-    for obj in bpy.context.selected_objects:
+    for obj in context.selected_objects:
         matrix_world = obj.matrix_world.copy()
         bb_world = [matrix_world * Vector(v[:]) for v in obj.bound_box]
-        objs.append((obj, bb_world))
+        objects.append((obj, bb_world))
 
-    if not objs:
+    if not objects:
         return False
 
-    for obj, bb_world in objs:
+    for obj, bb_world in objects:
 
         if bb_quality and obj.type == 'MESH':
             GBB = GlobalBB_HQ(obj)
@@ -150,7 +151,7 @@ def align_objects(align_x,
 
         # Active Center
 
-        if obj == bpy.context.active_object:
+        if obj == context.active_object:
 
             center_active_x = (Left_Front_Up[0] + Right_Back_Down[0]) / 2.0
             center_active_y = (Left_Front_Up[1] + Right_Back_Down[1]) / 2.0
@@ -200,7 +201,7 @@ def align_objects(align_x,
 
     # Main Loop
 
-    for obj, bb_world in objs:
+    for obj, bb_world in objects:
         matrix_world = obj.matrix_world.copy()
         bb_world = [matrix_world * Vector(v[:]) for v in obj.bound_box]
 
@@ -386,7 +387,8 @@ class AlignObjects(Operator):
 
     def execute(self, context):
         align_axis = self.align_axis
-        ret = align_objects('X' in align_axis,
+        ret = align_objects(context,
+                            'X' in align_axis,
                             'Y' in align_axis,
                             'Z' in align_axis,
                             self.align_mode,