rigidbody: code cleanup
Use bpy.data.objects.new() instead of the object.add() operator.
This commit is contained in:
@@ -146,7 +146,7 @@ class BakeToKeyframes(Operator):
|
|||||||
# this is a little roundabout but there's no better way right now
|
# this is a little roundabout but there's no better way right now
|
||||||
aa = mat.to_quaternion().to_axis_angle()
|
aa = mat.to_quaternion().to_axis_angle()
|
||||||
obj.rotation_axis_angle = (aa[1], ) + aa[0][:]
|
obj.rotation_axis_angle = (aa[1], ) + aa[0][:]
|
||||||
else: # euler
|
else: # euler
|
||||||
# make sure euler rotation is compatible to previous frame
|
# make sure euler rotation is compatible to previous frame
|
||||||
obj.rotation_euler = mat.to_euler(rot_mode, obj_prev.rotation_euler)
|
obj.rotation_euler = mat.to_euler(rot_mode, obj_prev.rotation_euler)
|
||||||
|
|
||||||
@@ -235,11 +235,13 @@ class ConnectRigidBodies(Operator):
|
|||||||
loc = obj.location
|
loc = obj.location
|
||||||
else:
|
else:
|
||||||
loc = (obj_act.location + obj.location) / 2.0
|
loc = (obj_act.location + obj.location) / 2.0
|
||||||
# TODO: use bpy.data.objects.new(...)
|
|
||||||
bpy.ops.object.add(type='EMPTY',
|
ob = bpy.data.objects.new("Constraint", object_data=None)
|
||||||
view_align=False,
|
ob.location = loc
|
||||||
enter_editmode=False,
|
context.scene.objects.link(ob)
|
||||||
location=loc)
|
context.scene.objects.active = ob
|
||||||
|
ob.select = True
|
||||||
|
|
||||||
bpy.ops.rigidbody.constraint_add()
|
bpy.ops.rigidbody.constraint_add()
|
||||||
con_obj = context.active_object
|
con_obj = context.active_object
|
||||||
con_obj.empty_draw_type = 'ARROWS'
|
con_obj.empty_draw_type = 'ARROWS'
|
||||||
|
Reference in New Issue
Block a user