[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13449] trunk/blender/source/blender/src/ poselib.c: == PoseLib - Tab Key in Pose-Preview ==

Joshua Leung aligorith at gmail.com
Tue Jan 29 10:51:31 CET 2008


Revision: 13449
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13449
Author:   aligorith
Date:     2008-01-29 10:51:29 +0100 (Tue, 29 Jan 2008)

Log Message:
-----------
== PoseLib - Tab Key in Pose-Preview ==

Now when previewing poses with Ctrl-L, pressing the Tab key toggles whether the 'original' (i.e. the pose before previewing started) pose gets shown temporarily. This allows the user to quickly compare the pose being previewed to the 'original'. No pose browsing is possible while the original pose is shown.

Modified Paths:
--------------
    trunk/blender/source/blender/src/poselib.c

Modified: trunk/blender/source/blender/src/poselib.c
===================================================================
--- trunk/blender/source/blender/src/poselib.c	2008-01-29 09:44:26 UTC (rev 13448)
+++ trunk/blender/source/blender/src/poselib.c	2008-01-29 09:51:29 UTC (rev 13449)
@@ -534,7 +534,7 @@
 	
 	short state;			/* state of main loop */
 	short redraw;			/* redraw/update settings during main loop */
-	short firsttime;		/* first loop... (no restore) */
+	short flag;				/* flags for various settings */
 	
 	int selcount;			/* number of selected elements to work on */
 	int totcount;			/* total number of elements to work on */
@@ -562,6 +562,12 @@
 	PL_PREVIEW_REDRAWHEADER,
 };
 
+/* defines for tPoseLib_PreviewData->flag values */
+enum {
+	PL_PREVIEW_FIRSTTIME	= (1<<0),
+	PL_PREVIEW_SHOWORIGINAL	= (1<<1)
+};
+
 /* ---------------------------- */
 
 /* simple struct for storing backup info */
@@ -890,6 +896,49 @@
 	 */
 	strcpy(pld->searchold, pld->searchstr);
 	
+	/* if we're currently showing the original pose, only certain events are handled */
+	if (pld->flag & PL_PREVIEW_SHOWORIGINAL) {
+		switch (event) {
+			/* exit - cancel */
+			case ESCKEY:
+			case RIGHTMOUSE:
+				pld->state= PL_PREVIEW_CANCEL;
+				break;
+				
+			/* exit - confirm */
+			case LEFTMOUSE:
+			case RETKEY:
+			case PADENTER:
+			case SPACEKEY:
+				pld->state= PL_PREVIEW_CONFIRM;
+				break;
+			
+			/* view manipulation */
+			case MIDDLEMOUSE:
+				// there's a little bug here that causes the normal header to get drawn while view is manipulated 
+				handle_view_middlemouse();
+				pld->redraw= PL_PREVIEW_REDRAWHEADER;
+				break;
+				
+			/* view manipulation, or searching */
+			case PAD0: case PAD1: case PAD2: case PAD3: case PAD4:
+			case PAD5: case PAD6: case PAD7: case PAD8: case PAD9:
+			case PADPLUSKEY: case PADMINUS:
+				persptoetsen(event);
+				pld->redraw= PL_PREVIEW_REDRAWHEADER;
+				break;
+				
+			case TABKEY:
+				pld->flag &= ~PL_PREVIEW_SHOWORIGINAL;
+				pld->redraw= PL_PREVIEW_REDRAWALL;
+				break;
+		}
+		
+		/* EXITS HERE... */
+		return;
+	}
+	
+	/* NORMAL EVENT HANDLING... */
 	/* searching takes priority over normal activity */
 	switch (event) {
 		/* exit - cancel */
@@ -905,6 +954,12 @@
 		case SPACEKEY:
 			pld->state= PL_PREVIEW_CONFIRM;
 			break;
+			
+		/* toggle between original pose and poselib pose*/
+		case TABKEY:
+			pld->flag |= PL_PREVIEW_SHOWORIGINAL;
+			pld->redraw= PL_PREVIEW_REDRAWALL;
+			break;
 		
 		/* change to previous pose (cyclic) */
 		case PAGEUPKEY:
@@ -1064,7 +1119,7 @@
 	/* set flags for running */
 	pld->state= (apply_active) ? PL_PREVIEW_RUNONCE : PL_PREVIEW_RUNNING;
 	pld->redraw= PL_PREVIEW_REDRAWALL;
-	pld->firsttime= 1;
+	pld->flag= PL_PREVIEW_FIRSTTIME;
 	
 	/* set depsgraph flags */
 		/* make sure the lock is set OK, unlock can be accidentally saved? */
@@ -1177,13 +1232,14 @@
 			/* only recalc pose (and its dependencies) if pose has changed */
 			if (pld.redraw == PL_PREVIEW_REDRAWALL) {
 				/* don't clear pose if firsttime */
-				if (pld.firsttime == 0)
+				if ((pld.flag & PL_PREVIEW_FIRSTTIME)==0)
 					poselib_backup_restore(&pld);
 				else
-					pld.firsttime = 0;
+					pld.flag &= ~PL_PREVIEW_FIRSTTIME;
 					
-				/* pose should be the right one to draw */
-				poselib_apply_pose(&pld);
+				/* pose should be the right one to draw (unless we're temporarily not showing it) */
+				if ((pld.flag & PL_PREVIEW_SHOWORIGINAL)==0)
+					poselib_apply_pose(&pld);
 				
 				/* old optimize trick... this enforces to bypass the depgraph 
 				 *	- note: code copied from transform_generics.c -> recalcData()
@@ -1205,7 +1261,11 @@
 			
 			/* do header print - if interactively previewing */
 			if (pld.state == PL_PREVIEW_RUNNING) {
-				if (pld.searchstr[0]) {
+				if (pld.flag & PL_PREVIEW_SHOWORIGINAL) {
+					sprintf(pld.headerstr, "PoseLib Previewing Pose: [Showing Original Pose] | Use Tab to start previewing poses again");
+					headerprint(pld.headerstr);
+				}
+				else if (pld.searchstr[0]) {
 					char tempstr[65];
 					char markern[64];
 					short index;





More information about the Bf-blender-cvs mailing list