[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29084] trunk/blender/release/scripts: add torus now works like other C add-object operators, location and rotation are initialized and kept even when settings are changed after .
Campbell Barton
ideasman42 at gmail.com
Sun May 30 19:18:16 CEST 2010
Revision: 29084
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29084
Author: campbellbarton
Date: 2010-05-30 19:18:16 +0200 (Sun, 30 May 2010)
Log Message:
-----------
add torus now works like other C add-object operators, location and rotation are initialized and kept even when settings are changed after.
Modified Paths:
--------------
trunk/blender/release/scripts/modules/add_object_utils.py
trunk/blender/release/scripts/op/add_mesh_torus.py
Modified: trunk/blender/release/scripts/modules/add_object_utils.py
===================================================================
--- trunk/blender/release/scripts/modules/add_object_utils.py 2010-05-30 16:09:16 UTC (rev 29083)
+++ trunk/blender/release/scripts/modules/add_object_utils.py 2010-05-30 17:18:16 UTC (rev 29084)
@@ -21,22 +21,30 @@
import bpy
import mathutils
-def _align_matrix(context):
- # TODO, local view cursor!
- location = mathutils.TranslationMatrix(context.scene.cursor_location)
+def add_object_align_init(context, operator):
- if context.user_preferences.edit.object_align == 'VIEW' and context.space_data.type == 'VIEW_3D':
- rotation = context.space_data.region_3d.view_matrix.rotation_part().invert().resize4x4()
+ if operator and operator.properties.is_property_set("location") and operator.properties.is_property_set("rotation"):
+ location = mathutils.TranslationMatrix(mathutils.Vector(operator.properties.location))
+ rotation = mathutils.Euler(operator.properties.rotation).to_matrix().resize4x4()
else:
- rotation = mathutils.Matrix()
+ # TODO, local view cursor!
+ location = mathutils.TranslationMatrix(context.scene.cursor_location)
- align_matrix = location * rotation
+ if context.user_preferences.edit.object_align == 'VIEW' and context.space_data.type == 'VIEW_3D':
+ rotation = context.space_data.region_3d.view_matrix.rotation_part().invert().resize4x4()
+ else:
+ rotation = mathutils.Matrix()
- return align_matrix
+ # set the operator properties
+ if operator:
+ operator.properties.location = location.translation_part()
+ operator.properties.rotation = rotation.to_euler()
+ return location * rotation
-def add_object_data(obdata, context):
+def add_object_data(context, obdata, operator=None):
+
scene = context.scene
# ugh, could be made nicer
@@ -52,7 +60,7 @@
base.layers_from_view(context.space_data)
- obj_new.matrix = _align_matrix(context)
+ obj_new.matrix = add_object_align_init(context, operator)
obj_act = scene.objects.active
Modified: trunk/blender/release/scripts/op/add_mesh_torus.py
===================================================================
--- trunk/blender/release/scripts/op/add_mesh_torus.py 2010-05-30 16:09:16 UTC (rev 29083)
+++ trunk/blender/release/scripts/op/add_mesh_torus.py 2010-05-30 17:18:16 UTC (rev 29084)
@@ -102,6 +102,10 @@
description="Total Interior Radius of the torus",
default=0.5, min=0.01, max=100.0)
+ # generic transform props
+ location = FloatVectorProperty(name="Location")
+ rotation = FloatVectorProperty(name="Rotation")
+
def execute(self, context):
props = self.properties
@@ -123,7 +127,7 @@
mesh.update()
import add_object_utils
- add_object_utils.add_object_data(mesh, context)
+ add_object_utils.add_object_data(context, mesh, operator=self)
return {'FINISHED'}
More information about the Bf-blender-cvs
mailing list