[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12739] trunk/blender/source/blender/src: == Bone Paths - More Tweaks (Cessen requests) ==

Joshua Leung aligorith at gmail.com
Sat Dec 1 12:57:16 CET 2007


Revision: 12739
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12739
Author:   aligorith
Date:     2007-12-01 12:57:16 +0100 (Sat, 01 Dec 2007)

Log Message:
-----------
== Bone Paths - More Tweaks (Cessen requests) ==

* "Around Current Frame" option now works differently. When this option is activated, the path range calculated remains the same (PSta -> PEnd), but only PPre and PPost amount of path-points on either side of the current frame get shown. This is less clumsy to use, and looks quite neat!

* "Clear Paths" now only clears the paths of the selected bones, not all bones. The old behaviour can still be obtained by selecting all bones, but previously there was no way to only clear paths of selected bones.

* Own fix: path colours are now drawn less saturated, as they were showing up TOO strongly.


TODO:
* Fix up interface for "Around current..." option. It's quite confusing atm.
* Selective recalculation of path on certain operations could also be investigated further...

Modified Paths:
--------------
    trunk/blender/source/blender/src/buttons_editing.c
    trunk/blender/source/blender/src/drawarmature.c
    trunk/blender/source/blender/src/poseobject.c
    trunk/blender/source/blender/src/transform_conversions.c

Modified: trunk/blender/source/blender/src/buttons_editing.c
===================================================================
--- trunk/blender/source/blender/src/buttons_editing.c	2007-12-01 11:33:55 UTC (rev 12738)
+++ trunk/blender/source/blender/src/buttons_editing.c	2007-12-01 11:57:16 UTC (rev 12739)
@@ -4014,7 +4014,7 @@
 	uiBlockEndAlign(block);
 	
 	uiBlockBeginAlign(block);
-	uiDefButBitS(block, TOG, ARM_PATH_ACFRA, REDRAWVIEW3D, "Around Current Frame", 170, 105, 160, 20, &arm->pathflag, 0, 0, 0, 0, "Calculate Bone Path around the current frame");
+	uiDefButBitS(block, TOG, ARM_PATH_ACFRA, REDRAWVIEW3D, "Around Current Frame", 170, 105, 160, 20, &arm->pathflag, 0, 0, 0, 0, "Only show Bone Path around the current frame");
 	if (arm->pathflag & ARM_PATH_ACFRA) {
 		uiDefButI(block, NUM,REDRAWVIEW3D,"PPre:",170,85,80,20, &arm->pathbc, 1.0, MAXFRAMEF/2, 0, 0, "The number of frames before current frame for Bone Path display range");
 		uiDefButI(block, NUM,REDRAWVIEW3D,"PPost:",250,85,80,20, &arm->pathac, 1.0, MAXFRAMEF/2, 0, 0, "The number of frames after current frame for Bone Path display range");	
@@ -4028,7 +4028,7 @@
 	
 	uiBlockBeginAlign(block);
 	uiDefBut(block, BUT, B_ARM_CALCPATHS, "Calculate Paths", 170,30,160,20, 0, 0, 0, 0, 0, "(Re)calculates the paths of the selected bones");
-	uiDefBut(block, BUT, B_ARM_CLEARPATHS, "Clear All Paths", 170,10,160,20, 0, 0, 0, 0, 0, "Clears all bone paths");
+	uiDefBut(block, BUT, B_ARM_CLEARPATHS, "Clear All Paths", 170,10,160,20, 0, 0, 0, 0, 0, "Clears bone paths of the selected bones");
 	uiBlockEndAlign(block);
 }
 

Modified: trunk/blender/source/blender/src/drawarmature.c
===================================================================
--- trunk/blender/source/blender/src/drawarmature.c	2007-12-01 11:33:55 UTC (rev 12738)
+++ trunk/blender/source/blender/src/drawarmature.c	2007-12-01 11:57:16 UTC (rev 12739)
@@ -1736,9 +1736,9 @@
 	bActionChannel *achan;
 	CfraElem *ce;
 	ListBase ak;
-	float *fp;
+	float *fp, *fp_start;
 	int a, stepsize;
-	int sfra, efra;
+	int sfra, efra, len;
 	
 	if(G.vd->zbuf) glDisable(GL_DEPTH_TEST);
 	
@@ -1758,10 +1758,37 @@
 					pchan->pathef= EFRA;
 				}
 				
-				/* get frame ranges */
-				sfra= pchan->pathsf;
-				efra = sfra + pchan->pathlen;
+				/* get frame ranges 
+				 *	- sfra,efra are the start and end frame numbers (respectively)
+				 *	- sind is the starting array index, nind is the number of array items (location array)
+				 */
+				if (arm->pathflag & ARM_PATH_ACFRA) {
+					int sind;
+					
+					/* With "Around Current", we only choose frames from around 
+					 * the current frame to draw. However, this range is still 
+					 * restricted by the limits of the original path.
+					 */
+					sfra= CFRA - arm->pathbc;
+					efra= CFRA + arm->pathac;
+					if (sfra < pchan->pathsf) sfra= pchan->pathsf;
+					if (efra > pchan->pathef) efra= pchan->pathef;
+					
+					len= efra - sfra;
+					
+					sind= sfra - pchan->pathsf;
+					fp_start= (pchan->path + (3*sind));
+				}
+				else {
+					sfra= pchan->pathsf;
+					efra = sfra + pchan->pathlen;
+					len = pchan->pathlen;
+					fp_start = pchan->path;
+				}
 				
+				/* get pointer to place in path-array to start from */
+				
+				
 				/* draw curve-line of path */
 				if ((CFRA > sfra) && (CFRA < efra)) {
 					/* Show before/after current frame with slight difference in colour intensity 
@@ -1770,16 +1797,16 @@
 					 */
 					
 					/* 	before cfra (darker) */
-					BIF_ThemeColorBlend(TH_WIRE, TH_BACK, 0.2);
+					BIF_ThemeColorBlend(TH_WIRE, TH_BACK, 0.5);
 					glBegin(GL_LINE_STRIP);
-					for (a=0, fp=pchan->path; (sfra+a)<=CFRA; a++, fp+=3)
+					for (a=0, fp=fp_start; (sfra+a)<=CFRA; a++, fp+=3)
 						glVertex3fv(fp);
 					glEnd();
 					
 					/* after cfra (lighter) - backtrack a bit so that we don't have gaps */
-					BIF_ThemeColorBlend(TH_WIRE, TH_BONE_POSE, 0.7);
+					BIF_ThemeColorBlend(TH_BONE_POSE, TH_BACK, 0.5);
 					glBegin(GL_LINE_STRIP);
-					for (--a, fp-=3; a<pchan->pathlen; a++, fp+=3)
+					for (--a, fp-=3; a<len; a++, fp+=3)
 						glVertex3fv(fp);
 					glEnd();
 				}
@@ -1787,7 +1814,7 @@
 					/* show both directions with same intensity (cfra somewhere else) */
 					BIF_ThemeColorBlend(TH_WIRE, TH_BACK, 0.7);
 					glBegin(GL_LINE_STRIP);
-					for (a=0, fp= pchan->path; a<pchan->pathlen; a++, fp+=3)
+					for (a=0, fp=fp_start; a<len; a++, fp+=3)
 						glVertex3fv(fp);
 					glEnd();
 				}
@@ -1798,20 +1825,20 @@
 				 * NOTE: this is not really visible/noticable
 				 */
 				glBegin(GL_POINTS);
-				for(a=0, fp= pchan->path; a<pchan->pathlen; a++, fp+=3) 
+				for (a=0, fp=fp_start; a<len; a++, fp+=3) 
 					glVertex3fv(fp);
 				glEnd();
 				
 				/* Draw little white dots at each framestep value */
 				BIF_ThemeColor(TH_TEXT_HI);
 				glBegin(GL_POINTS);
-				for (a=0, fp= pchan->path; a<pchan->pathlen; a+=stepsize, fp+=(stepsize*3)) 
+				for (a=0, fp=fp_start; a<len; a+=stepsize, fp+=(stepsize*3)) 
 					glVertex3fv(fp);
 				glEnd();
 				
 				/* Draw frame numbers at each framestep value */
 				if (arm->pathflag & ARM_PATH_FNUMS) {
-					for(a=0, fp= pchan->path; a<pchan->pathlen; a+=stepsize, fp+=(stepsize*3)) {
+					for (a=0, fp=fp_start; a<len; a+=stepsize, fp+=(stepsize*3)) {
 						char str[32];
 						
 						/* only draw framenum if several consecutive highlighted points don't occur on same point */
@@ -1820,7 +1847,7 @@
 							sprintf(str, "  %d\n", (a+sfra));
 							BMF_DrawString(G.font, str);
 						}
-						else if ((a > stepsize) && (a < pchan->pathlen-stepsize)) { 
+						else if ((a > stepsize) && (a < len-stepsize)) { 
 							if ((VecEqual(fp, fp-(stepsize*3))==0) || (VecEqual(fp, fp+(stepsize*3))==0)) {
 								glRasterPos3fv(fp);
 								sprintf(str, "  %d\n", (a+sfra));
@@ -1844,7 +1871,7 @@
 					/* Draw little yellow dots at each keyframe */
 					BIF_ThemeColor(TH_VERTEX_SELECT);
 					glBegin(GL_POINTS);
-					for(a=0, fp= pchan->path; a<pchan->pathlen; a++, fp+=3) {
+					for(a=0, fp=fp_start; a<len; a++, fp+=3) {
 						for (ce= ak.first; ce; ce= ce->next) {
 							if (ce->cfra == (a+sfra))
 								glVertex3fv(fp);
@@ -1854,7 +1881,7 @@
 					
 					/* Draw frame numbers of keyframes  */
 					if (arm->pathflag & ARM_PATH_FNUMS) {
-						for(a=0, fp= pchan->path; a<pchan->pathlen; a++, fp+=3) {
+						for(a=0, fp=fp_start; a<len; a++, fp+=3) {
 							for (ce= ak.first; ce; ce= ce->next) {
 								if (ce->cfra == (a+sfra)) {
 									char str[32];

Modified: trunk/blender/source/blender/src/poseobject.c
===================================================================
--- trunk/blender/source/blender/src/poseobject.c	2007-12-01 11:33:55 UTC (rev 12738)
+++ trunk/blender/source/blender/src/poseobject.c	2007-12-01 11:57:16 UTC (rev 12739)
@@ -219,7 +219,9 @@
 
 /* ********************************************** */
 
-/* for the object with pose/action: create path curves for selected bones */
+/* For the object with pose/action: create path curves for selected bones 
+ * This recalculates the WHOLE path within the pchan->pathsf and pchan->pathef range
+ */
 void pose_calculate_path(Object *ob)
 {
 	bArmature *arm;
@@ -238,24 +240,14 @@
 		arm->pathsf = SFRA;
 		arm->pathef = EFRA;
 	}
-	if ((arm->pathbc == 0) || (arm->pathac == 0)) {
-		arm->pathbc = 15;
-		arm->pathac = 15;
-	}
 	if (arm->pathsize == 0) {
 		arm->pathsize = 1;
 	}
 	
 	/* set frame values */
 	cfra= CFRA;
-	if (arm->pathflag & ARM_PATH_ACFRA) {
-		sfra = cfra - arm->pathbc;
-		efra = cfra + arm->pathac;
-	}
-	else {
-		sfra = arm->pathsf;
-		efra = arm->pathef;
-	}
+	sfra = arm->pathsf;
+	efra = arm->pathef;
 	if (efra<=sfra) return;
 	
 	DAG_object_update_flags(G.scene, ob, screen_view3d_layers());
@@ -310,7 +302,7 @@
 }
 
 
-/* for the object with pose/action: clear all path curves */
+/* for the object with pose/action: clear path curves for selected bones only */
 void pose_clear_paths(Object *ob)
 {
 	bPoseChannel *pchan;
@@ -319,8 +311,8 @@
 		return;
 	
 	/* free the path blocks */
-	for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
-		if(pchan->path) {
+	for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+		if (pchan->path) {
 			MEM_freeN(pchan->path);
 			pchan->path= NULL;
 		}

Modified: trunk/blender/source/blender/src/transform_conversions.c
===================================================================
--- trunk/blender/source/blender/src/transform_conversions.c	2007-12-01 11:33:55 UTC (rev 12738)
+++ trunk/blender/source/blender/src/transform_conversions.c	2007-12-01 11:57:16 UTC (rev 12739)
@@ -3064,7 +3064,7 @@
 		
 		/* do the bone paths */
 		if (arm->pathflag & ARM_PATH_ACFRA) {
-			pose_clear_paths(ob);
+			//pose_clear_paths(ob);
 			pose_calculate_path(ob);
 		}		
 		





More information about the Bf-blender-cvs mailing list