use more conventional names in rigid body script.

This commit is contained in:
Campbell Barton 2013-01-28 12:15:50 +00:00
parent 753890d0e8
commit 8445a56b48
2 changed files with 21 additions and 21 deletions

@ -129,17 +129,17 @@ def align_objects(context,
flag_first = True flag_first = True
objs = [] objects = []
for obj in context.selected_objects: for obj in context.selected_objects:
matrix_world = obj.matrix_world.copy() 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]
objs.append((obj, bb_world)) objects.append((obj, bb_world))
if not objs: if not objects:
return False return False
for obj, bb_world in objs: for obj, bb_world in objects:
if bb_quality and obj.type == 'MESH': if bb_quality and obj.type == 'MESH':
GBB = GlobalBB_HQ(obj) GBB = GlobalBB_HQ(obj)
@ -201,7 +201,7 @@ def align_objects(context,
# Main Loop # Main Loop
for obj, bb_world in objs: for obj, bb_world in objects:
matrix_world = obj.matrix_world.copy() 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]

@ -37,21 +37,21 @@ class CopyRigidbodySettings(Operator):
def execute(self, context): def execute(self, context):
obj = context.object obj = context.object
scn = context.scene scene = context.scene
# deselect all but mesh objects # deselect all but mesh objects
for o in context.selected_objects: for o in context.selected_objects:
if o.type != 'MESH': if o.type != 'MESH':
o.select = False o.select = False
sel = context.selected_objects objects = context.selected_objects
if sel: if objects:
# add selected objects to active one groups and recalculate # add selected objects to active one groups and recalculate
bpy.ops.group.objects_add_active() bpy.ops.group.objects_add_active()
scn.frame_set(scn.frame_current) scene.frame_set(scene.frame_current)
# copy settings # copy settings
for o in sel: for o in objects:
if o.rigid_body is None: if o.rigid_body is None:
continue continue
@ -106,7 +106,7 @@ class BakeToKeyframes(Operator):
def execute(self, context): def execute(self, context):
bake = [] bake = []
objs = [] objects = []
scene = context.scene scene = context.scene
frame_orig = scene.frame_current frame_orig = scene.frame_current
frames = list(range(self.frame_start, self.frame_end + 1, self.step)) frames = list(range(self.frame_start, self.frame_end + 1, self.step))
@ -116,23 +116,23 @@ class BakeToKeyframes(Operator):
if not obj.rigid_body or obj.rigid_body.type != 'ACTIVE': if not obj.rigid_body or obj.rigid_body.type != 'ACTIVE':
obj.select = False obj.select = False
objs = context.selected_objects objects = context.selected_objects
if objs: if objects:
# store transformation data # store transformation data
for f in list(range(self.frame_start, self.frame_end + 1)): for f in list(range(self.frame_start, self.frame_end + 1)):
scene.frame_set(f) scene.frame_set(f)
if f in frames: if f in frames:
mat = {} mat = {}
for i, obj in enumerate(objs): for i, obj in enumerate(objects):
mat[i] = obj.matrix_world.copy() mat[i] = obj.matrix_world.copy()
bake.append(mat) bake.append(mat)
# apply transformations as keyframes # apply transformations as keyframes
for i, f in enumerate(frames): for i, f in enumerate(frames):
scene.frame_set(f) scene.frame_set(f)
obj_prev = objs[0] obj_prev = objects[0]
for j, obj in enumerate(objs): for j, obj in enumerate(objects):
mat = bake[i][j] mat = bake[i][j]
obj.location = mat.to_translation() obj.location = mat.to_translation()
@ -156,7 +156,7 @@ class BakeToKeyframes(Operator):
bpy.ops.rigidbody.objects_remove() bpy.ops.rigidbody.objects_remove()
# clean up keyframes # clean up keyframes
for obj in objs: for obj in objects:
action = obj.animation_data.action action = obj.animation_data.action
for fcu in action.fcurves: for fcu in action.fcurves:
keyframe_points = fcu.keyframe_points keyframe_points = fcu.keyframe_points
@ -214,15 +214,15 @@ class ConnectRigidBodies(Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
obj = context.object obj = context.object
objs = context.selected_objects objects = context.selected_objects
return (obj and obj.rigid_body and (len(objs) > 1)) return (obj and obj.rigid_body and (len(objects) > 1))
def execute(self, context): def execute(self, context):
objs = context.selected_objects objects = context.selected_objects
obj_act = context.active_object obj_act = context.active_object
for obj in objs: for obj in objects:
if obj == obj_act: if obj == obj_act:
continue continue
if self.pivot_type == 'ACTIVE': if self.pivot_type == 'ACTIVE':