[Bf-blender-cvs] [a4530f59d21] blender2.8: Transform: support for 2D cursor editing

Campbell Barton noreply at git.blender.org
Thu Oct 4 04:10:34 CEST 2018


Commit: a4530f59d2151ee56c58fdab8e1e202b612fe42e
Author: Campbell Barton
Date:   Thu Oct 4 11:50:12 2018 +1000
Branches: blender2.8
https://developer.blender.org/rBa4530f59d2151ee56c58fdab8e1e202b612fe42e

Transform: support for 2D cursor editing

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

M	source/blender/editors/transform/transform_conversions.c

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

diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 1676260d231..571608ac21d 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -345,7 +345,40 @@ static void createTransTexspace(TransInfo *t)
 	copy_v3_v3(td->ext->isize, td->ext->size);
 }
 
-static void createTransCursor3D(TransInfo *t)
+/* -------------------------------------------------------------------- */
+/** \name Cursor Transform Creation
+ *
+ * Instead of transforming the selection, move the 2D/3D cursor.
+ *
+ * \{ */
+
+static void createTransCursor_image(TransInfo *t)
+{
+	TransData *td;
+	SpaceImage *sima = t->sa->spacedata.first;
+	float *cursor_location = sima->cursor;
+
+	{
+		BLI_assert(t->data_container_len == 1);
+		TransDataContainer *tc = t->data_container;
+		tc->data_len = 1;
+		td = tc->data = MEM_callocN(sizeof(TransData), "TransTexspace");
+		td->ext = tc->data_ext = MEM_callocN(sizeof(TransDataExtension), "TransTexspace");
+	}
+
+	td->flag = TD_SELECTED;
+	copy_v3_v3(td->center, cursor_location);
+	td->ob = NULL;
+
+	unit_m3(td->mtx);
+	unit_m3(td->axismtx);
+	pseudoinverse_m3_m3(td->smtx, td->mtx, PSEUDOINVERSE_EPSILON);
+
+	td->loc = cursor_location;
+	copy_v3_v3(td->iloc, cursor_location);
+}
+
+static void createTransCursor_view3d(TransInfo *t)
 {
 	TransData *td;
 
@@ -382,6 +415,8 @@ static void createTransCursor3D(TransInfo *t)
 	copy_qt_qt(td->ext->iquat, cursor->rotation);
 }
 
+/** \} */
+
 /* ********************* edge (for crease) ***** */
 
 static void createTransEdge(TransInfo *t)
@@ -8418,7 +8453,12 @@ void createTransData(bContext *C, TransInfo *t)
 		t->flag |= T_CURSOR;
 		t->obedit_type = -1;
 
-		createTransCursor3D(t);
+		if (t->spacetype == SPACE_IMAGE) {
+			createTransCursor_image(t);
+		}
+		else {
+			createTransCursor_view3d(t);
+		}
 		countAndCleanTransDataContainer(t);
 	}
 	else if (t->options & CTX_TEXTURE) {



More information about the Bf-blender-cvs mailing list