[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54724] trunk/blender/release/scripts/ startup/bl_operators/rigidbody.py: rigidbody: code cleanup
Sergej Reich
sergej.reich at googlemail.com
Thu Feb 21 20:04:36 CET 2013
Revision: 54724
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54724
Author: sergof
Date: 2013-02-21 19:04:36 +0000 (Thu, 21 Feb 2013)
Log Message:
-----------
rigidbody: code cleanup
Use bpy.data.objects.new() instead of the object.add() operator.
Modified Paths:
--------------
trunk/blender/release/scripts/startup/bl_operators/rigidbody.py
Modified: trunk/blender/release/scripts/startup/bl_operators/rigidbody.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_operators/rigidbody.py 2013-02-21 19:04:34 UTC (rev 54723)
+++ trunk/blender/release/scripts/startup/bl_operators/rigidbody.py 2013-02-21 19:04:36 UTC (rev 54724)
@@ -146,7 +146,7 @@
# this is a little roundabout but there's no better way right now
aa = mat.to_quaternion().to_axis_angle()
obj.rotation_axis_angle = (aa[1], ) + aa[0][:]
- else: # euler
+ else: # euler
# make sure euler rotation is compatible to previous frame
obj.rotation_euler = mat.to_euler(rot_mode, obj_prev.rotation_euler)
@@ -235,11 +235,13 @@
loc = obj.location
else:
loc = (obj_act.location + obj.location) / 2.0
- # TODO: use bpy.data.objects.new(...)
- bpy.ops.object.add(type='EMPTY',
- view_align=False,
- enter_editmode=False,
- location=loc)
+
+ ob = bpy.data.objects.new("Constraint", object_data=None)
+ ob.location = loc
+ context.scene.objects.link(ob)
+ context.scene.objects.active = ob
+ ob.select = True
+
bpy.ops.rigidbody.constraint_add()
con_obj = context.active_object
con_obj.empty_draw_type = 'ARROWS'
More information about the Bf-blender-cvs
mailing list