[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13000] trunk/blender/source/blender: == Transform: Warp ==

Martin Poirier theeth at yahoo.com
Wed Dec 26 04:07:01 CET 2007


Revision: 13000
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13000
Author:   theeth
Date:     2007-12-26 04:06:59 +0100 (Wed, 26 Dec 2007)

Log Message:
-----------
== Transform: Warp ==

Adding special hotkey (MMB) to reverse the direction of the warp.

Normal input is 0..360 mapped to the horizontal position of the mouse on the 3D view (the 3D view becomes a sort of giant horizontal slider), pressing MMB reverses the value to 0..-360 and back if you press it again.

I've used MMB mostly because it's unused in Warp, easily accessible and already used to switches mode for Shear (shear x/y).

Indirectly suggested by a user question on ba.

Modified Paths:
--------------
    trunk/blender/source/blender/include/transform.h
    trunk/blender/source/blender/src/transform.c

Modified: trunk/blender/source/blender/include/transform.h
===================================================================
--- trunk/blender/source/blender/include/transform.h	2007-12-25 20:31:07 UTC (rev 12999)
+++ trunk/blender/source/blender/include/transform.h	2007-12-26 03:06:59 UTC (rev 13000)
@@ -303,6 +303,7 @@
 void convertDisplayNumToVec(float *num, float *vec);
 
 void initWarp(TransInfo *t);
+int handleEventWarp(TransInfo *t, unsigned short event, short val);
 int Warp(TransInfo *t, short mval[2]);
 
 void initShear(TransInfo *t);

Modified: trunk/blender/source/blender/src/transform.c
===================================================================
--- trunk/blender/source/blender/src/transform.c	2007-12-25 20:31:07 UTC (rev 12999)
+++ trunk/blender/source/blender/src/transform.c	2007-12-26 03:06:59 UTC (rev 13000)
@@ -1399,6 +1399,7 @@
 	
 	t->mode = TFM_WARP;
 	t->transform = Warp;
+	t->handleEvent = handleEventWarp;
 	
 	t->idx_max = 0;
 	t->num.idx_max = 0;
@@ -1435,6 +1436,24 @@
 	t->val= (max[0]-min[0])/2.0f; /* t->val is X dimension projected boundbox */
 }
 
+int handleEventWarp(TransInfo *t, unsigned short event, short val)
+{
+	int status = 0;
+	
+	if (event == MIDDLEMOUSE && val)
+	{
+		// Use customData pointer to signal warp direction
+		if	(t->customData == 0)
+			t->customData = (void*)1;
+		else
+			t->customData = 0;
+			
+		status = 1;
+	}
+	
+	return status;
+}
+
 int Warp(TransInfo *t, short mval[2])
 {
 	TransData *td = t->data;
@@ -1465,6 +1484,11 @@
 
 	/* amount of degrees for warp */
 	circumfac= 360.0f * InputHorizontalRatio(t, mval);
+	
+	if (t->customData) /* non-null value indicates reversed input */
+	{
+		circumfac *= -1;
+	}
 
 	snapGrid(t, &circumfac);
 	applyNumInput(&t->num, &circumfac);





More information about the Bf-blender-cvs mailing list