Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Meyer <florianfelix@web.de>2010-05-15 03:30:29 +0400
committerFlorian Meyer <florianfelix@web.de>2010-05-15 03:30:29 +0400
commit9216515dfd0a62ea79d2637dbf545cba76a9526e (patch)
treea5159e3d92cceaebdffeb7b208a989998faa3257 /add_mesh_gears.py
parent34be323f5e8a0db339c814c98374b456df5202b2 (diff)
- same view_align fix as in gears
Diffstat (limited to 'add_mesh_gears.py')
-rw-r--r--add_mesh_gears.py34
1 files changed, 16 insertions, 18 deletions
diff --git a/add_mesh_gears.py b/add_mesh_gears.py
index 75ba8647..221b7fb4 100644
--- a/add_mesh_gears.py
+++ b/add_mesh_gears.py
@@ -67,6 +67,18 @@ import mathutils
from math import *
from bpy.props import *
+# calculates the matrix for the new object
+# depending on user pref
+def align_matrix(context):
+ loc = mathutils.TranslationMatrix(context.scene.cursor_location)
+ obj_align = context.user_preferences.edit.object_align
+ if (context.space_data.type == 'VIEW_3D'
+ and obj_align == 'VIEW'):
+ rot = context.space_data.region_3d.view_matrix.rotation_part().invert().resize4x4()
+ else:
+ rot = mathutils.Matrix()
+ newMatrix = loc * rot
+ return newMatrix
# Stores the values of a list of properties and the
# operator id in a property group ('recall_op') inside the object.
@@ -752,7 +764,7 @@ class AddGear(bpy.types.Operator):
min=0.0,
max=100.0,
default=0.0)
- newMatrix = 'fromInvoke'
+ newMatrix = mathutils.Matrix()
def draw(self, context):
props = self.properties
@@ -818,14 +830,7 @@ class AddGear(bpy.types.Operator):
return {'FINISHED'}
def invoke(self, context, event):
- loc = mathutils.TranslationMatrix(context.scene.cursor_location)
- obj_align = context.user_preferences.edit.object_align
- if (context.space_data.type == 'VIEW_3D'
- and obj_align == 'VIEW'):
- rot = context.space_data.region_3d.view_matrix.rotation_part().invert().resize4x4()
- else:
- rot = mathutils.RotationMatrix()
- self.newMatrix = loc * rot
+ self.newMatrix = align_matrix(context)
self.execute(context)
return {'FINISHED'}
@@ -885,7 +890,7 @@ class AddWormGear(bpy.types.Operator):
min=0.0,
max=100.0,
default=0.0)
- newMatrix = 'fromInvoke'
+ newMatrix = mathutils.Matrix()
def draw(self, context):
props = self.properties
@@ -947,14 +952,7 @@ class AddWormGear(bpy.types.Operator):
return {'FINISHED'}
def invoke(self, context, event):
- loc = mathutils.TranslationMatrix(context.scene.cursor_location)
- obj_align = context.user_preferences.edit.object_align
- if (context.space_data.type == 'VIEW_3D'
- and obj_align == 'VIEW'):
- rot = context.space_data.region_3d.view_matrix.rotation_part().invert().resize4x4()
- else:
- rot = mathutils.RotationMatrix()
- self.newMatrix = loc * rot
+ self.newMatrix = align_matrix(context)
self.execute(context)
return {'FINISHED'}