[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17304] branches/animsys2/source/blender: AnimSys2: IPO code cleanups

Joshua Leung aligorith at gmail.com
Mon Nov 3 09:26:43 CET 2008


Revision: 17304
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17304
Author:   aligorith
Date:     2008-11-03 09:26:43 +0100 (Mon, 03 Nov 2008)

Log Message:
-----------
AnimSys2: IPO code cleanups

* Formatting and style tidyups for most of the code (some parts haven't been touched yet)
* Patched up some areas where new code hasn't been integrated yet

Modified Paths:
--------------
    branches/animsys2/source/blender/include/BSE_editipo.h
    branches/animsys2/source/blender/src/editipo.c

Modified: branches/animsys2/source/blender/include/BSE_editipo.h
===================================================================
--- branches/animsys2/source/blender/include/BSE_editipo.h	2008-11-02 23:25:21 UTC (rev 17303)
+++ branches/animsys2/source/blender/include/BSE_editipo.h	2008-11-03 08:26:43 UTC (rev 17304)
@@ -109,8 +109,10 @@
 void set_ipotype(short code);
 void set_ipoextend(void);
 void borderselect_ipo(void);
+
 void del_ipo(int need_check);
-void del_ipoCurve ( struct IpoCurve * icu );
+void del_ipoCurve(struct IpoCurve * icu);
+
 void free_ipocopybuf(void);
 void copy_editipo(void);
 void paste_editipo(void);
@@ -133,8 +135,8 @@
 void movekey_obipo(int dir);
 void nextkey_ipo(int dir);
 void nextkey_obipo(int dir);
-void filter_sampledata(float *data, int sfra, int efra);
-void sampledata_to_ipocurve(float *data, int sfra, int efra, struct IpoCurve *icu);
+
+void sampledata_to_ipocurve(float data[], int sfra, int efra, struct IpoCurve *icu);
 void ipo_record(void); 
 
 void make_ipo_transdata(struct TransInfo *t);

Modified: branches/animsys2/source/blender/src/editipo.c
===================================================================
--- branches/animsys2/source/blender/src/editipo.c	2008-11-02 23:25:21 UTC (rev 17303)
+++ branches/animsys2/source/blender/src/editipo.c	2008-11-03 08:26:43 UTC (rev 17304)
@@ -213,17 +213,18 @@
 	return NULL;
 }
 
+/* sets the active shapekey */
 static void set_active_key(int index)
 {
-	if(G.sipo->blocktype==ID_KE && G.sipo->from) {
+	if ((G.sipo->blocktype==ID_KE) && (G.sipo->from)) {
 		Object *ob= (Object *)G.sipo->from;
 		Key *key= ob_get_key(ob);
 		
-		if(key) {
+		if (key) {
 			KeyBlock *curkb;
 			
 			curkb= BLI_findlink(&key->block, index-1);
-			if(curkb) {
+			if (curkb) {
 				ob->shapenr= index;
 				ob->shapeflag |= OB_SHAPE_TEMPLOCK;
 				
@@ -238,59 +239,56 @@
 
 void editipo_changed(SpaceIpo *si, int doredraw)
 {
-	EditIpo *ei;
-	View2D *v2d;
+	EditIpo *ei= si->editipo;
+	View2D *v2d = &si->v2d;
 	Key *key;
 	KeyBlock *kb;
 	int a, first=1;
 
-	ei= si->editipo;
-	if(ei==0)
+	if (ei == NULL)
 		return;
-	
-	for(a=0; a<si->totipo; a++, ei++) {
 		
-		if(ei->icu) {
-			
+	for (a=0; a<si->totipo; a++, ei++) {
+		if (ei->icu) {
 				/* twice because of ittererating new autohandle */
 			calchandles_ipocurve(ei->icu);
 			calchandles_ipocurve(ei->icu);
 			
-			if(ei->flag & IPO_VISIBLE) {
-		
+			if (ei->flag & IPO_VISIBLE) {
 				boundbox_ipocurve(ei->icu, 0);
 				sort_time_ipocurve(ei->icu);
-				if(first) {
+				
+				/* if no boundin box found yet, initialise max area */
+				if (first) {
 					si->v2d.tot= ei->icu->totrct;
 					first= 0;
 				}
-				else BLI_union_rctf(&(si->v2d.tot), &(ei->icu->totrct));
+				else 
+					BLI_union_rctf(&(si->v2d.tot), &(ei->icu->totrct));
 			}
 		}
 	}
 	
-
-	v2d= &(si->v2d);	
-
 	/* keylines? */
-	if(si->blocktype==ID_KE) {
+	if (si->blocktype==ID_KE) {
 		key= ob_get_key((Object *)G.sipo->from);
-		if(key && key->block.first) {
+		
+		if (key && key->block.first) {
 			kb= key->block.first;
-			if(kb->pos < v2d->tot.ymin) v2d->tot.ymin= kb->pos;
+			if (kb->pos < v2d->tot.ymin) v2d->tot.ymin= kb->pos;
 			kb= key->block.last;
-			if(kb->pos > v2d->tot.ymax) v2d->tot.ymax= kb->pos;
+			if (kb->pos > v2d->tot.ymax) v2d->tot.ymax= kb->pos;
 		}
 	}
 	
 	/* is there no curve? */
-	if(first) {
+	if (first) {
 		v2d->tot.xmin= (float)0.0;
 		v2d->tot.xmax= (float)EFRA;
 		v2d->tot.ymin= (float)-0.1;
 		v2d->tot.ymax= (float)1.1;
-	
-		if(si->blocktype==ID_SEQ) {
+		
+		if (si->blocktype==ID_SEQ) {
 			v2d->tot.xmin= (float)-5.0;
 			v2d->tot.xmax= (float)105.0;
 			v2d->tot.ymin= (float)-0.1;
@@ -300,100 +298,91 @@
 	
 	si->tot= v2d->tot;	
 	
-	if(doredraw) {
+	if (doredraw) {
 		/* if you always call do_ipo: you get problems with insertkey, for example
 		 * when inserting only a 'loc' the 'ob->rot' value then is changed.
 		 */
-
-		if(si->blocktype==ID_OB) { 			
-				/* clear delta loc,rot,size (when free/delete ipo) */
+		if (si->blocktype==ID_OB) { 			
+			/* clear delta loc,rot,size (when free/delete ipo) */
 			clear_delta_obipo(si->ipo);
-			
 		}
-	
+		
 		do_ipo(si->ipo);
-
-		allqueue(REDRAWIPO, 0);
-		allqueue(REDRAWACTION, 0);
-		allqueue(REDRAWTIME, 0);
-		allqueue(REDRAWNLA, 0);
+		
+		/* refreshes */
+		allqueue(REDRAWMARKER, 0);
+		allqueue(REDRAWVIEW3D, 0);
 		allqueue(REDRAWBUTSOBJECT, 0);
 		
-		if(si->blocktype==ID_OB) {
-			Object *ob= (Object *)si->from;			
-			if(ob) DAG_object_flush_update(G.scene, ob, OB_RECALC_OB);
-			allqueue(REDRAWVIEW3D, 0);
-			allqueue(REDRAWNLA, 0);
-		}
-
-		else if(si->blocktype==ID_MA) allqueue(REDRAWBUTSSHADING, 0);
-		else if(si->blocktype==ID_TE) allqueue(REDRAWBUTSSHADING, 0);
-		else if(si->blocktype==ID_WO) allqueue(REDRAWBUTSSHADING, 0);
-		else if(si->blocktype==ID_LA) allqueue(REDRAWBUTSSHADING, 0);
-//		else if(si->blocktype==ID_SO) allqueue(REDRAWBUTSSOUND, 0);
-		else if(si->blocktype==ID_CA) {
-			allqueue(REDRAWBUTSEDIT, 0);
-			allqueue(REDRAWVIEW3D, 0);
-		}
-		else if(si->blocktype==ID_SEQ) free_imbuf_seq_with_ipo(si->ipo);
-		else if(si->blocktype==ID_PO) {
-			Object *ob= OBACT;
-			if(ob && ob->pose) {
+		switch (si->blocktype) {
+			case ID_OB:	/* Object ----------------- */
+			{
+				Object *ob= (Object *)si->from;			
+				if (ob) 
+					DAG_object_flush_update(G.scene, ob, OB_RECALC_OB);
+			}
+				break;
+				
+			case ID_PO: /* Pose-Channel ------------ */
+			{
+				Object *ob= (Object *)si->from;
+				if (ob && ob->pose)
+					DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
+			}
+				break;
+				
+			case ID_MA: /* Shading ---------------- */
+			case ID_TE:
+			case ID_WO:
+			case ID_LA:
+				allqueue(REDRAWBUTSSHADING, 0);
+				break;
+				
+			case ID_CA: /* Camera ------------------ */
+				allqueue(REDRAWBUTSEDIT, 0);
+				break;
+				
+			case ID_SEQ: /* Sequencer -------------- */
+				free_imbuf_seq_with_ipo(si->ipo);
+				break;
+				
+			default: /* other blocktypes ----------- */
+				/* assume data comes from active object... */
 				DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
-			}
-			allqueue(REDRAWVIEW3D, 0);
-			allqueue(REDRAWACTION, 0);
-			allqueue(REDRAWNLA, 0);
+				break;
 		}
-		else if(si->blocktype==ID_KE) {
-			DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
-			allqueue(REDRAWVIEW3D, 0);
-		}
-		else if(si->blocktype==ID_CU) {
-			DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
-			allqueue(REDRAWVIEW3D, 0);
-		}
-		else if(si->blocktype==ID_PA){
-			DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
-			allqueue(REDRAWVIEW3D, 0);
-		}
 	}
-
-	if(si->showkey) make_ipokey();
 	
-	if(si->actname[0])
+	/* re-make ipo-keys */
+	if (si->showkey) make_ipokey();
+	
+	/* if from an action, adjust NLA references to action */
+	if (si->actname[0])
 		synchronize_action_strips();
 }
 
+/* comes from floating panel here, scale with G.sipo->tot rect */
 void scale_editipo(void)
 {
-	/* comes from buttons, scale with G.sipo->tot rect */
-	
-	EditIpo *ei;
-	BezTriple *bezt;
-	float facx, facy;
+	EditIpo *ei= G.sipo->editipo;
+	const float facx= (G.sipo->tot.xmax-G.sipo->tot.xmin)/(G.sipo->v2d.tot.xmax-G.sipo->v2d.tot.xmin);
+	const float facy= (G.sipo->tot.ymax-G.sipo->tot.ymin)/(G.sipo->v2d.tot.ymax-G.sipo->v2d.tot.ymin);
 	int a, b;	
 	
-	facx= (G.sipo->tot.xmax-G.sipo->tot.xmin)/(G.sipo->v2d.tot.xmax-G.sipo->v2d.tot.xmin);
-	facy= (G.sipo->tot.ymax-G.sipo->tot.ymin)/(G.sipo->v2d.tot.ymax-G.sipo->v2d.tot.ymin);
-
-	ei= G.sipo->editipo;
-	if(ei==0) return;
-	for(a=0; a<G.sipo->totipo; a++, ei++) {
+	if (ei == NULL) return;
+	
+	for (a=0; a<G.sipo->totipo; a++, ei++) {
 		if (ISPOIN(ei, flag & IPO_VISIBLE, icu)) {
-			bezt= ei->icu->bezt;
-			b= ei->icu->totvert;
-			while(b--) {
-				
+			BezTriple *bezt= ei->icu->bezt;
+			
+			for (b= 0; b < ei->icu->totvert; b++, bezt++) {
 				bezt->vec[0][0]= facx*(bezt->vec[0][0] - G.sipo->v2d.tot.xmin) + G.sipo->tot.xmin;
 				bezt->vec[1][0]= facx*(bezt->vec[1][0] - G.sipo->v2d.tot.xmin) + G.sipo->tot.xmin;
 				bezt->vec[2][0]= facx*(bezt->vec[2][0] - G.sipo->v2d.tot.xmin) + G.sipo->tot.xmin;
-			
+				
 				bezt->vec[0][1]= facy*(bezt->vec[0][1] - G.sipo->v2d.tot.ymin) + G.sipo->tot.ymin;
 				bezt->vec[1][1]= facy*(bezt->vec[1][1] - G.sipo->v2d.tot.ymin) + G.sipo->tot.ymin;
 				bezt->vec[2][1]= facy*(bezt->vec[2][1] - G.sipo->v2d.tot.ymin) + G.sipo->tot.ymin;
-
-				bezt++;
 			}
 		}
 	}
@@ -401,9 +390,7 @@
 	editipo_changed(G.sipo, 1);
 
 	BIF_undo_push("Scale Edit Ipo");
-	allqueue(REDRAWNLA, 0);
-	allqueue (REDRAWACTION, 0);
-	allqueue(REDRAWIPO, 0);
+	allqueue(REDRAWMARKER, 0);
 }
 
 static void make_ob_editipo(Object *ob, SpaceIpo *si)
@@ -1371,14 +1358,19 @@
 void set_editflag_editipo(void)
 {
 	EditIpo *ei;
-	int a; /*  , tot= 0, ok= 0; */
+	int a;
 	
 	/* after showkey immediately go to editing of selected points */
 	if (G.sipo->showkey) {
+		/* clear showkey... */
 		G.sipo->showkey= 0;
-		if(G.sipo->ipo) G.sipo->ipo->showkey= 0;
+		if (G.sipo->ipo)	
+			G.sipo->ipo->showkey= 0;
+		
 		ei= G.sipo->editipo;
-		for(a=0; a<G.sipo->totipo; a++, ei++) ei->flag |= IPO_SELECT;
+		for(a=0; a<G.sipo->totipo; a++, ei++) 
+			ei->flag |= IPO_SELECT;
+		
 		scrarea_queue_headredraw(curarea);
 		allqueue(REDRAWVIEW3D, 0);
 	}
@@ -1388,26 +1380,26 @@
 	if (G.sipo->ipo && G.sipo->ipo->id.lib) return;
 	
 	ei= G.sipo->editipo;
-	for(a=0; a<G.sipo->totipo; a++, ei++) {		
-		if(ei->icu) {
-			if(ei->flag & IPO_VISIBLE) {
-				
-				if(totipo_edit==0 && (ei->flag & IPO_SELECT)) {
+	for (a=0; a<G.sipo->totipo; a++, ei++) {		
+		if (ei->icu) {
+			if (ei->flag & IPO_VISIBLE) {
+				if (totipo_edit==0 && (ei->flag & IPO_SELECT)) {
 					ei->flag |= IPO_EDIT;
 					ei->icu->flag= ei->flag;
 				}
-				else if(totipo_edit && (ei->flag & IPO_EDIT)) {
+				else if (totipo_edit && (ei->flag & IPO_EDIT)) {
 					ei->flag -= IPO_EDIT;
 					ei->icu->flag= ei->flag;
 				}
-				else if(totipo_vis==1) {
-					if(ei->flag & IPO_EDIT) ei->flag -= IPO_EDIT;
+				else if (totipo_vis==1) {
+					if (ei->flag & IPO_EDIT) ei->flag -= IPO_EDIT;
 					else ei->flag |= IPO_EDIT;
 					ei->icu->flag= ei->flag;
 				}
 			}
 		}
 	}
+	
 	scrarea_queue_headredraw(curarea);
 	scrarea_queue_winredraw(curarea);
 }
@@ -1512,7 +1504,7 @@
 		actstrip_map_ipo_keys(OBACT, G.sipo->ipo, 0, 0);
 	}
 	
-	if(G.sipo->showkey) {
+	if (G.sipo->showkey) {
 		float pixelwidth;
 		
 		view2d_getscale(G.v2d, &pixelwidth, NULL);
@@ -1520,33 +1512,32 @@
 		getmouseco_areawin(mval);
 		areamouseco_to_ipoco(G.v2d, mval, &x, &y);
 		actik= 0;
-		mindist= 1000.0;

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list