[Bf-extensions-cvs] [da9a0d0c] master: Fix T71782: Curve/Point doesn't get generated at Cursor.

Spivak Vladimir cwolf3d noreply at git.blender.org
Sat Nov 23 03:09:16 CET 2019


Commit: da9a0d0c51d87e96aa04cbaf84e790a606f76d5f
Author: Spivak Vladimir (cwolf3d)
Date:   Sat Nov 23 04:08:43 2019 +0200
Branches: master
https://developer.blender.org/rBAda9a0d0c51d87e96aa04cbaf84e790a606f76d5f

Fix T71782: Curve/Point doesn't get generated at Cursor.

===================================================================

M	add_curve_extra_objects/__init__.py
M	add_curve_extra_objects/add_curve_aceous_galore.py
M	add_curve_extra_objects/add_curve_curly.py
M	add_curve_extra_objects/add_curve_simple.py

===================================================================

diff --git a/add_curve_extra_objects/__init__.py b/add_curve_extra_objects/__init__.py
index e5a1bbcd..e64944fe 100644
--- a/add_curve_extra_objects/__init__.py
+++ b/add_curve_extra_objects/__init__.py
@@ -23,7 +23,7 @@
 bl_info = {
     "name": "Extra Objects",
     "author": "Multiple Authors",
-    "version": (0, 1, 3),
+    "version": (0, 1, 4),
     "blender": (2, 80, 0),
     "location": "View3D > Add > Curve > Extra Objects",
     "description": "Add extra curve object types",
diff --git a/add_curve_extra_objects/add_curve_aceous_galore.py b/add_curve_extra_objects/add_curve_aceous_galore.py
index c27d26dd..493b38d1 100644
--- a/add_curve_extra_objects/add_curve_aceous_galore.py
+++ b/add_curve_extra_objects/add_curve_aceous_galore.py
@@ -716,21 +716,6 @@ def NoiseCurve(type=0, number=100, length=2.0, size=0.5,
     return newpoints
 
 
-# ------------------------------------------------------------
-# calculates the matrix for the new object
-# depending on user pref
-def align_matrix(context, location):
-    loc = Matrix.Translation(location)
-    obj_align = context.preferences.edit.object_align
-    if (context.space_data.type == 'VIEW_3D' and
-            obj_align == 'VIEW'):
-        rot = context.space_data.region_3d.view_matrix.to_3x3().inverted().to_4x4()
-    else:
-        rot = Matrix()
-    align_matrix = loc @ rot
-
-    return align_matrix
-
 # get array of vertcoordinates according to splinetype
 def vertsToPoints(Verts, splineType):
 
@@ -756,7 +741,7 @@ def vertsToPoints(Verts, splineType):
 
 
 # create new CurveObject from vertarray and splineType
-def createCurve(context, vertArray, self, align_matrix):
+def createCurve(context, vertArray, self):
     # output splineType 'POLY' 'NURBS' 'BEZIER'
     splineType = self.outputType
     
@@ -774,8 +759,6 @@ def createCurve(context, vertArray, self, align_matrix):
         
         # create object with newCurve
         Curve = object_utils.object_data_add(context, dataCurve, operator=self)  # place in active scene
-        Curve.matrix_world = align_matrix  # apply matrix
-        Curve.rotation_euler = self.rotation_euler
         
     # set newSpline Options
     newSpline.use_cyclic_u = self.use_cyclic_u
@@ -819,17 +802,35 @@ def createCurve(context, vertArray, self, align_matrix):
             
     # move and rotate spline in edit mode
     if bpy.context.mode == 'EDIT_CURVE':
-        bpy.ops.transform.translate(value = self.startlocation)
-        bpy.ops.transform.rotate(value = self.rotation_euler[0], orient_axis = 'X')
-        bpy.ops.transform.rotate(value = self.rotation_euler[1], orient_axis = 'Y')
-        bpy.ops.transform.rotate(value = self.rotation_euler[2], orient_axis = 'Z')
+        if self.align == "WORLD":
+            location = self.location - context.active_object.location
+            bpy.ops.transform.translate(value = location, orient_type='GLOBAL')
+            bpy.ops.transform.rotate(value = self.rotation[0], orient_axis = 'X', orient_type='GLOBAL')
+            bpy.ops.transform.rotate(value = self.rotation[1], orient_axis = 'Y', orient_type='GLOBAL')
+            bpy.ops.transform.rotate(value = self.rotation[2], orient_axis = 'Z', orient_type='GLOBAL')
+            
+        elif self.align == "VIEW":
+            bpy.ops.transform.translate(value = self.location)
+            bpy.ops.transform.rotate(value = self.rotation[0], orient_axis = 'X')
+            bpy.ops.transform.rotate(value = self.rotation[1], orient_axis = 'Y')
+            bpy.ops.transform.rotate(value = self.rotation[2], orient_axis = 'Z')
+
+        elif self.align == "CURSOR":
+            location = context.active_object.location
+            self.location = bpy.context.scene.cursor.location - location
+            self.rotation = bpy.context.scene.cursor.rotation_euler
+
+            bpy.ops.transform.translate(value = self.location)
+            bpy.ops.transform.rotate(value = self.rotation[0], orient_axis = 'X')
+            bpy.ops.transform.rotate(value = self.rotation[1], orient_axis = 'Y')
+            bpy.ops.transform.rotate(value = self.rotation[2], orient_axis = 'Z')
 
     return
 
 
 # ------------------------------------------------------------
 # Main Function
-def main(context, self, align_matrix):
+def main(context, self):
     # options
     proType = self.ProfileType
     splineType = self.outputType
@@ -935,7 +936,7 @@ def main(context, self, align_matrix):
     vertArray = vertsToPoints(verts, splineType)
 
     # create object
-    createCurve(context, vertArray, self, align_matrix)
+    createCurve(context, vertArray, self)
 
     return
 
@@ -946,9 +947,6 @@ class Curveaceous_galore(Operator, object_utils.AddObjectHelper):
     bl_description = "Construct many types of curves"
     bl_options = {'REGISTER', 'UNDO', 'PRESET'}
 
-    # align_matrix for the invoke
-    align_matrix : Matrix()
-
     # general properties
     ProfileType : EnumProperty(
             name="Type",
@@ -1307,20 +1305,6 @@ class Curveaceous_galore(Operator, object_utils.AddObjectHelper):
             description="Show in edit mode"
             )
 
-    # Line properties
-    startlocation : FloatVectorProperty(
-            name="",
-            description="Start location",
-            default=(0.0, 0.0, 0.0),
-            subtype='TRANSLATION'
-            )
-    rotation_euler : FloatVectorProperty(
-            name="",
-            description="Rotation",
-            default=(0.0, 0.0, 0.0),
-            subtype='EULER'
-            )
-
     def draw(self, context):
         layout = self.layout
 
@@ -1458,12 +1442,11 @@ class Curveaceous_galore(Operator, object_utils.AddObjectHelper):
         col = layout.column()
         col.row().prop(self, "edit_mode", expand=True)
         
-        box = layout.box()
-        box.label(text="Location:")
-        box.prop(self, "startlocation")
-        box = layout.box()
-        box.label(text="Rotation:")
-        box.prop(self, "rotation_euler")
+        col = layout.column()
+        # AddObjectHelper props
+        col.prop(self, "align")
+        col.prop(self, "location")
+        col.prop(self, "rotation")
 
     @classmethod
     def poll(cls, context):
@@ -1475,8 +1458,7 @@ class Curveaceous_galore(Operator, object_utils.AddObjectHelper):
         bpy.context.preferences.edit.use_enter_edit_mode = False
         
         # main function
-        self.align_matrix = align_matrix(context, self.startlocation)
-        main(context, self, self.align_matrix or Matrix())
+        main(context, self)
         
         if use_enter_edit_mode:
             bpy.ops.object.mode_set(mode = 'EDIT')
diff --git a/add_curve_extra_objects/add_curve_curly.py b/add_curve_extra_objects/add_curve_curly.py
index 1ac76341..65990ee2 100644
--- a/add_curve_extra_objects/add_curve_curly.py
+++ b/add_curve_extra_objects/add_curve_curly.py
@@ -418,10 +418,6 @@ def make_curve(self, context, verts, lh, rh):
             if types == 1 or types == 2 or types == 3:
                 newSpline.bezier_points[3].handle_left.xyz = lh[p][3]
                 
-        bpy.ops.transform.translate(value = self.location)
-        bpy.ops.transform.rotate(value = self.rotation[0], orient_axis = 'X')
-        bpy.ops.transform.rotate(value = self.rotation[1], orient_axis = 'Y')
-        bpy.ops.transform.rotate(value = self.rotation[2], orient_axis = 'Z')
     else:
         # create curve
         dataCurve = bpy.data.curves.new(name='CurlyCurve', type='CURVE')  # curvedatablock
@@ -455,6 +451,31 @@ def make_curve(self, context, verts, lh, rh):
         Curve.data.fill_mode = 'FULL'
     else:
         Curve.data.fill_mode = 'BOTH'
+        
+    # move and rotate spline in edit mode
+    if bpy.context.mode == 'EDIT_CURVE':
+        if self.align == "WORLD":
+            location = self.location - context.active_object.location
+            bpy.ops.transform.translate(value = location, orient_type='GLOBAL')
+            bpy.ops.transform.rotate(value = self.rotation[0], orient_axis = 'X', orient_type='GLOBAL')
+            bpy.ops.transform.rotate(value = self.rotation[1], orient_axis = 'Y', orient_type='GLOBAL')
+            bpy.ops.transform.rotate(value = self.rotation[2], orient_axis = 'Z', orient_type='GLOBAL')
+            
+        elif self.align == "VIEW":
+            bpy.ops.transform.translate(value = self.location)
+            bpy.ops.transform.rotate(value = self.rotation[0], orient_axis = 'X')
+            bpy.ops.transform.rotate(value = self.rotation[1], orient_axis = 'Y')
+            bpy.ops.transform.rotate(value = self.rotation[2], orient_axis = 'Z')
+
+        elif self.align == "CURSOR":
+            location = context.active_object.location
+            self.location = bpy.context.scene.cursor.location - location
+            self.rotation = bpy.context.scene.cursor.rotation_euler
+
+            bpy.ops.transform.translate(value = self.location)
+            bpy.ops.transform.rotate(value = self.rotation[0], orient_axis = 'X')
+            bpy.ops.transform.rotate(value = self.rotation[1], orient_axis = 'Y')
+            bpy.ops.transform.rotate(value = self.rotation[2], orient_axis = 'Z')
 
 class add_curlycurve(Operator, AddObjectHelper):
     bl_idname = "curve.curlycurve"
diff --git a/add_curve_extra_objects/add_curve_simple.py b/add_curve_extra_objects/add_curve_simple.py
index c73cb623..0e92c652 100644
--- a/add_curve_extra_objects/add_curve_simple.py
+++ b/add_curve_extra_objects/add_curve_simple.py
@@ -18,8 +18,8 @@
 
 bl_info = {
     "name": "Simple Curve",
-    "author": "Spivak Vladimir (http://cwolf3d.korostyshev.net)",
-    "version": (1, 6, 0),
+    "author": "Vladimir Spivak (cwolf3d)",
+    "version": (1, 6, 1),
     "blender": (2, 80, 0),
     "location": "View3D > Add > Curve",
     "description": "Adds Simple Curve",
@@ -377,22 +377,6 @@ def SimpleTrapezoid(a=2.0, b=1.0, h=1.0, center=True):
     return newpoints
 
 
-# ------------------------------------------------------------
-# calculates the matrix for the new object
-# depending on user pref
-
-def align_matrix(context, location):
-    loc = Matrix.Translation(location)
-    obj_align = context.preferences.edit.object_align
-    if (context.

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list