[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60902] trunk/blender/source/blender/ editors: refactor transform.c - minor changes

Campbell Barton ideasman42 at gmail.com
Wed Oct 23 05:57:42 CEST 2013


Revision: 60902
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60902
Author:   campbellbarton
Date:     2013-10-23 03:57:42 +0000 (Wed, 23 Oct 2013)
Log Message:
-----------
refactor transform.c - minor changes
- use TREDRAW_HARD define
- use apply prefix for transform callbacks.
- make callbacks static.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/include/ED_transform.h
    trunk/blender/source/blender/editors/mesh/editmesh_extrude.c
    trunk/blender/source/blender/editors/transform/transform.c
    trunk/blender/source/blender/editors/transform/transform.h

Modified: trunk/blender/source/blender/editors/include/ED_transform.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_transform.h	2013-10-23 02:52:27 UTC (rev 60901)
+++ trunk/blender/source/blender/editors/include/ED_transform.h	2013-10-23 03:57:42 UTC (rev 60902)
@@ -130,8 +130,6 @@
 
 int BIF_countTransformOrientation(const struct bContext *C);
 
-void BIF_TransformSetUndo(const char *str);
-
 /* to be able to add operator properties to other operators */
 
 #define P_MIRROR        (1 << 0)

Modified: trunk/blender/source/blender/editors/mesh/editmesh_extrude.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_extrude.c	2013-10-23 02:52:27 UTC (rev 60901)
+++ trunk/blender/source/blender/editors/mesh/editmesh_extrude.c	2013-10-23 03:57:42 UTC (rev 60902)
@@ -377,7 +377,6 @@
 		BKE_object_handle_update(scene, obedit);
 
 		/* individual faces? */
-//		BIF_TransformSetUndo("Extrude");
 		if (nr == 2) {
 //			initTransform(TFM_SHRINKFATTEN, CTX_NO_PET|CTX_NO_MIRROR);
 //			Transform();

Modified: trunk/blender/source/blender/editors/transform/transform.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform.c	2013-10-23 02:52:27 UTC (rev 60901)
+++ trunk/blender/source/blender/editors/transform/transform.c	2013-10-23 03:57:42 UTC (rev 60902)
@@ -108,6 +108,95 @@
 static void len_v3_ensure(float v[3], const float length);
 static void postInputRotation(TransInfo *t, float values[3]);
 
+
+/* Transform Callbacks */
+static void initWarp(TransInfo *t);
+static int handleEventWarp(TransInfo *t, const struct wmEvent *event);
+static void Warp(TransInfo *t, const int mval[2]);
+
+static void initShear(TransInfo *t);
+static int handleEventShear(TransInfo *t, const struct wmEvent *event);
+static void applyShear(TransInfo *t, const int mval[2]);
+
+static void initResize(TransInfo *t);
+static void applyResize(TransInfo *t, const int mval[2]);
+
+static void initSkinResize(TransInfo *t);
+static void applySkinResize(TransInfo *t, const int mval[2]);
+
+static void initTranslation(TransInfo *t);
+static void applyTranslation(TransInfo *t, const int mval[2]);
+
+static void initToSphere(TransInfo *t);
+static void applyToSphere(TransInfo *t, const int mval[2]);
+
+static void initRotation(TransInfo *t);
+static void applyRotation(TransInfo *t, const int mval[2]);
+
+static void initShrinkFatten(TransInfo *t);
+static void applyShrinkFatten(TransInfo *t, const int mval[2]);
+
+static void initTilt(TransInfo *t);
+static void applyTilt(TransInfo *t, const int mval[2]);
+
+static void initCurveShrinkFatten(TransInfo *t);
+static void applyCurveShrinkFatten(TransInfo *t, const int mval[2]);
+
+static void initMaskShrinkFatten(TransInfo *t);
+static void applyMaskShrinkFatten(TransInfo *t, const int mval[2]);
+
+static void initTrackball(TransInfo *t);
+static void applyTrackball(TransInfo *t, const int mval[2]);
+
+static void initPushPull(TransInfo *t);
+static void applyPushPull(TransInfo *t, const int mval[2]);
+
+static void initBevelWeight(TransInfo *t);
+static void applyBevelWeight(TransInfo *t, const int mval[2]);
+
+static void initCrease(TransInfo *t);
+static void applyCrease(TransInfo *t, const int mval[2]);
+
+static void initBoneSize(TransInfo *t);
+static void applyBoneSize(TransInfo *t, const int mval[2]);
+
+static void initBoneEnvelope(TransInfo *t);
+static void applyBoneEnvelope(TransInfo *t, const int mval[2]);
+
+static void initBoneRoll(TransInfo *t);
+static void applyBoneRoll(TransInfo *t, const int mval[2]);
+
+static void initEdgeSlide(TransInfo *t);
+static int handleEventEdgeSlide(TransInfo *t, const struct wmEvent *event);
+static void applyEdgeSlide(TransInfo *t, const int mval[2]);
+
+static void initVertSlide(TransInfo *t);
+static int handleEventVertSlide(TransInfo *t, const struct wmEvent *event);
+static void applyVertSlide(TransInfo *t, const int mval[2]);
+
+static void initTimeTranslate(TransInfo *t);
+static void applyTimeTranslate(TransInfo *t, const int mval[2]);
+
+static void initTimeSlide(TransInfo *t);
+static void applyTimeSlide(TransInfo *t, const int mval[2]);
+
+static void initTimeScale(TransInfo *t);
+static void applyTimeScale(TransInfo *t, const int mval[2]);
+
+static void initBakeTime(TransInfo *t);
+static void applyBakeTime(TransInfo *t, const int mval[2]);
+
+static void initMirror(TransInfo *t);
+static void applyMirror(TransInfo *t, const int mval[2]);
+
+static void initAlign(TransInfo *t);
+static void applyAlign(TransInfo *t, const int mval[2]);
+
+static void initSeqSlide(TransInfo *t);
+static void applySeqSlide(TransInfo *t, const int mval[2]);
+/* end transform callbacks */
+
+
 static bool transdata_check_local_center(TransInfo *t)
 {
 	return ((t->around == V3D_LOCAL) && (
@@ -2197,7 +2286,7 @@
 
 /* ************************** TRANSFORM LOCKS **************************** */
 
-static void protectedTransBits(short protectflag, float *vec)
+static void protectedTransBits(short protectflag, float vec[3])
 {
 	if (protectflag & OB_LOCK_LOCX)
 		vec[0] = 0.0f;
@@ -2207,7 +2296,7 @@
 		vec[2] = 0.0f;
 }
 
-static void protectedSizeBits(short protectflag, float *size)
+static void protectedSizeBits(short protectflag, float size[3])
 {
 	if (protectflag & OB_LOCK_SCALEX)
 		size[0] = 1.0f;
@@ -2217,7 +2306,7 @@
 		size[2] = 1.0f;
 }
 
-static void protectedRotateBits(short protectflag, float *eul, float *oldeul)
+static void protectedRotateBits(short protectflag, float eul[3], const float oldeul[3])
 {
 	if (protectflag & OB_LOCK_ROTX)
 		eul[0] = oldeul[0];
@@ -2272,7 +2361,7 @@
 }
 
 /* this function only does the delta rotation */
-static void protectedQuaternionBits(short protectflag, float *quat, float *oldquat)
+static void protectedQuaternionBits(short protectflag, float quat[4], const float oldquat[4])
 {
 	/* check that protection flags are set */
 	if ((protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) == 0)
@@ -2576,8 +2665,13 @@
 	}
 }
 
-/* ************************** WARP *************************** */
 
+/* -------------------------------------------------------------------- */
+/* Transform (Warp) */
+
+/** \name Transform Warp
+ * \{ */
+
 struct WarpCustomData {
 	float warp_sta[3];
 	float warp_end[3];
@@ -2589,7 +2683,7 @@
 	float warp_init_dist;
 };
 
-void initWarp(TransInfo *t)
+static void initWarp(TransInfo *t)
 {
 	const float mval_fl[2] = {UNPACK2(t->mval)};
 	const float *curs;
@@ -2641,20 +2735,18 @@
 	t->customData = data;
 }
 
-int handleEventWarp(TransInfo *t, const wmEvent *event)
+static int handleEventWarp(TransInfo *UNUSED(t), const wmEvent *event)
 {
-	int status = 0;
+	int status = TREDRAW_NOTHING;
 	
 	if (event->type == MIDDLEMOUSE && event->val == KM_PRESS) {
-		(void)t;
-		
-		status = 1;
+		status = TREDRAW_HARD;
 	}
 	
 	return status;
 }
 
-int Warp(TransInfo *t, const int UNUSED(mval[2]))
+static void Warp(TransInfo *t, const int UNUSED(mval[2]))
 {
 	TransData *td = t->data;
 	float vec[3];
@@ -2771,21 +2863,25 @@
 	recalcData(t);
 	
 	ED_area_headerprint(t->sa, str);
-	
-	return 1;
 }
+/** \} */
 
-/* ************************** SHEAR *************************** */
 
+/* -------------------------------------------------------------------- */
+/* Transform (Shear) */
+
+/** \name Transform Shear
+ * \{ */
+
 static void postInputShear(TransInfo *UNUSED(t), float values[3])
 {
 	mul_v3_fl(values, 0.05f);
 }
 
-void initShear(TransInfo *t)
+static void initShear(TransInfo *t)
 {
 	t->mode = TFM_SHEAR;
-	t->transform = Shear;
+	t->transform = applyShear;
 	t->handleEvent = handleEventShear;
 	
 	setInputPostFct(&t->mouse, postInputShear);
@@ -2802,9 +2898,9 @@
 	t->flag |= T_NO_CONSTRAINT;
 }
 
-int handleEventShear(TransInfo *t, const wmEvent *event)
+static int handleEventShear(TransInfo *t, const wmEvent *event)
 {
-	int status = 0;
+	int status = TREDRAW_NOTHING;
 	
 	if (event->type == MIDDLEMOUSE && event->val == KM_PRESS) {
 		// Use customData pointer to signal Shear direction
@@ -2817,26 +2913,26 @@
 			t->customData = NULL;
 		}
 
-		status = 1;
+		status = TREDRAW_HARD;
 	}
 	else if (event->type == XKEY && event->val == KM_PRESS) {
 		initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_ABSOLUTE);
 		t->customData = NULL;
 		
-		status = 1;
+		status = TREDRAW_HARD;
 	}
 	else if (event->type == YKEY && event->val == KM_PRESS) {
 		initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_ABSOLUTE);
 		t->customData = (void *)1;
 		
-		status = 1;
+		status = TREDRAW_HARD;
 	}
 	
 	return status;
 }
 
 
-int Shear(TransInfo *t, const int UNUSED(mval[2]))
+static void applyShear(TransInfo *t, const int UNUSED(mval[2]))
 {
 	TransData *td = t->data;
 	float vec[3];
@@ -2910,16 +3006,20 @@
 	recalcData(t);
 	
 	ED_area_headerprint(t->sa, str);
-
-	return 1;
 }
+/** \} */
 
-/* ************************** RESIZE *************************** */
 
-void initResize(TransInfo *t)
+/* -------------------------------------------------------------------- */
+/* Transform (Resize) */
+
+/** \name Transform Resize
+ * \{ */
+
+static void initResize(TransInfo *t)
 {
 	t->mode = TFM_RESIZE;
-	t->transform = Resize;
+	t->transform = applyResize;
 	
 	initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP);
 	
@@ -2940,8 +3040,7 @@
 	t->num.increment = t->snap[1];
 }
 
-/* We assume str is MAX_INFO_LEN long. */
-static void headerResize(TransInfo *t, float vec[3], char *str)
+static void headerResize(TransInfo *t, float vec[3], char str[MAX_INFO_LEN])
 {
 	char tvec[NUM_STR_REP_LEN * 3];
 	size_t ofs = 0;
@@ -3117,7 +3216,7 @@
 	constraintTransLim(t, td);
 }
 
-int Resize(TransInfo *t, const int mval[2])
+static void applyResize(TransInfo *t, const int mval[2])
 {
 	TransData *td;
 	float size[3], mat[3][3];
@@ -3192,16 +3291,20 @@
 	recalcData(t);
 	
 	ED_area_headerprint(t->sa, str);
-	
-	return 1;
 }
+/** \} */
 
-/* ************************** SKIN *************************** */
 
-void initSkinResize(TransInfo *t)
+/* -------------------------------------------------------------------- */
+/* Transform (Skin) */
+
+/** \name Transform Skin
+ * \{ */
+
+static void initSkinResize(TransInfo *t)
 {
 	t->mode = TFM_SKIN_RESIZE;
-	t->transform = SkinResize;
+	t->transform = applySkinResize;
 	
 	initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP);
 	
@@ -3222,7 +3325,7 @@
 	t->num.increment = t->snap[1];
 }
 
-int SkinResize(TransInfo *t, const int UNUSED(mval[2]))

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list