[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45567] trunk/blender/source/blender: code cleanup: remove unused KeyBlock.adrcode

Campbell Barton ideasman42 at gmail.com
Thu Apr 12 13:50:43 CEST 2012


Revision: 45567
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45567
Author:   campbellbarton
Date:     2012-04-12 11:50:43 +0000 (Thu, 12 Apr 2012)
Log Message:
-----------
code cleanup: remove unused KeyBlock.adrcode

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/key.c
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/bmesh/intern/bmesh_mesh_conv.c
    trunk/blender/source/blender/editors/mesh/meshtools.c
    trunk/blender/source/blender/editors/object/object_shapekey.c
    trunk/blender/source/blender/makesdna/DNA_key_types.h

Modified: trunk/blender/source/blender/blenkernel/intern/key.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/key.c	2012-04-12 11:42:18 UTC (rev 45566)
+++ trunk/blender/source/blender/blenkernel/intern/key.c	2012-04-12 11:50:43 UTC (rev 45567)
@@ -238,8 +238,6 @@
 void sort_keys(Key *key)
 {
 	KeyBlock *kb;
-	//short i, adrcode;
-	//IpoCurve *icu = NULL;
 	KeyBlock *kb2;
 
 	/* locate the key which is out of position */ 
@@ -259,43 +257,6 @@
 				break;
 			}
 		}
-		
-		/* if more than one Ipo curve, see if this key had a curve */
-#if 0 // XXX old animation system
-		if (key->ipo && key->ipo->curve.first != key->ipo->curve.last ) {
-			for (icu= key->ipo->curve.first; icu; icu= icu->next) {
-				/* if we find the curve, remove it and reinsert in the 
-				 * right place */
-				if (icu->adrcode==kb->adrcode) {
-					IpoCurve *icu2;
-					BLI_remlink(&key->ipo->curve, icu);
-					for (icu2= key->ipo->curve.first; icu2; icu2= icu2->next) {
-						if (icu2->adrcode >= kb2->adrcode) {
-							BLI_insertlink(&key->ipo->curve, icu2->prev, icu);
-							break;
-						}
-					}
-					break;
-				}
-			}
-		}
-		
-		/* kb points at the moved key, icu at the moved ipo (if it exists).
-		 * go back now and renumber adrcodes */
-
-		/* first new code */
-		adrcode = kb2->adrcode;
-		for (i = kb->adrcode - adrcode; i >= 0; i--, adrcode++) {
-			/* if the next ipo curve matches the current key, renumber it */
-			if (icu && icu->adrcode == kb->adrcode ) {
-				icu->adrcode = adrcode;
-				icu = icu->next;
-			}
-			/* renumber the shape key */
-			kb->adrcode = adrcode;
-			kb = kb->next;
-		}
-#endif // XXX old animation system
 	}
 
 	/* new rule; first key is refkey, this to match drawing channels... */
@@ -1463,8 +1424,6 @@
 
 	BLI_uniquename(&key->block, kb, "Key", '.', offsetof(KeyBlock, name), sizeof(kb->name));
 
-	// XXX this is old anim system stuff? (i.e. the 'index' of the shapekey)
-	kb->adrcode= tot-1;
 	kb->uid = key->uidgen++;
 
 	key->totkey++;

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c	2012-04-12 11:42:18 UTC (rev 45566)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c	2012-04-12 11:50:43 UTC (rev 45567)
@@ -6612,31 +6612,6 @@
 	
 }
 
-
-/* somehow, probably importing via python, keyblock adrcodes are not in order */
-static void sort_shape_fix(Main *main)
-{
-	Key *key;
-	KeyBlock *kb;
-	int sorted= 0;
-	
-	while (sorted==0) {
-		sorted= 1;
-		for (key= main->key.first; key; key= key->id.next) {
-			for (kb= key->block.first; kb; kb= kb->next) {
-				if (kb->next && kb->adrcode>kb->next->adrcode) {
-					KeyBlock *next= kb->next;
-					BLI_remlink(&key->block, kb);
-					BLI_insertlink(&key->block, next, kb);
-					kb= next;
-					sorted= 0;
-				}
-			}
-		}
-		if (sorted==0) printf("warning, shape keys were sorted incorrect, fixed it!\n");
-	}
-}
-
 static void customdata_version_242(Mesh *me)
 {
 	CustomDataLayer *layer;
@@ -9289,11 +9264,7 @@
 		for (key= main->key.first; key; key= key->id.next) {
 			KeyBlock *kb;
 			int index= 1;
-			
-			/* trick to find out if we already introduced adrcode */
-			for (kb= key->block.first; kb; kb= kb->next)
-				if (kb->adrcode) break;
-			
+
 			if (kb==NULL) {
 				for (kb= key->block.first; kb; kb= kb->next) {
 					if (kb==key->refkey) {
@@ -9304,7 +9275,7 @@
 						if (kb->name[0]==0) {
 							BLI_snprintf(kb->name, sizeof(kb->name), "Key %d", index);
 						}
-						kb->adrcode= index++;
+						index++;
 					}
 				}
 			}
@@ -9660,10 +9631,7 @@
 		for (group= main->group.first; group; group= group->id.next)
 			if (group->layer==0)
 				group->layer= (1<<20)-1;
-		
-		/* History fix (python?), shape key adrcode numbers have to be sorted */
-		sort_shape_fix(main);
-				
+
 		/* now, subversion control! */
 		if (main->subversionfile < 3) {
 			Image *ima;

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_mesh_conv.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_mesh_conv.c	2012-04-12 11:42:18 UTC (rev 45566)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_mesh_conv.c	2012-04-12 11:50:43 UTC (rev 45567)
@@ -764,7 +764,7 @@
 		if ((me->key->type == KEY_RELATIVE) && /* only need offsets for relative shape keys */
 		    (actkey   != NULL) &&              /* unlikely, but the active key may not be valid if the
 		                                        * bmesh and the mesh are out of sync */
-		    (oldverts != NULL))                /* not used here, but 'oldverts' is used later for applyig 'ofs' */
+		    (oldverts != NULL))                /* not used here, but 'oldverts' is used later for applying 'ofs' */
 		{
 			int act_is_basis = FALSE;
 
@@ -780,15 +780,13 @@
 				float (*fp)[3] = actkey->data;
 				int *keyi;
 
-				i = 0;
 				ofs = MEM_callocN(sizeof(float) * 3 * bm->totvert,  "currkey->data");
 				mvert = me->mvert;
-				BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) {
+				BM_ITER_INDEX(eve, &iter, bm, BM_VERTS_OF_MESH, NULL, i) {
 					keyi = CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_SHAPE_KEYINDEX);
 					if (keyi && *keyi != ORIGINDEX_NONE) {
 						sub_v3_v3v3(ofs[i], mvert->co, fp[*keyi]);
 					}
-					i++;
 					mvert++;
 				}
 			}

Modified: trunk/blender/source/blender/editors/mesh/meshtools.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/meshtools.c	2012-04-12 11:42:18 UTC (rev 45566)
+++ trunk/blender/source/blender/editors/mesh/meshtools.c	2012-04-12 11:50:43 UTC (rev 45567)
@@ -247,7 +247,7 @@
 							kbn = MEM_dupallocN(kb);
 							kbn->prev = kbn->next = NULL;
 							
-							/* adjust adrcode and other settings to fit (allocate a new data-array) */
+							/* adjust settings to fit (allocate a new data-array) */
 							kbn->data = MEM_callocN(sizeof(float) * 3 * totvert, "joined_shapekey");
 							kbn->totelem = totvert;
 							kbn->weights = NULL;
@@ -260,7 +260,6 @@
 								kbn->pos = curpos;
 							
 							BLI_addtail(&key->block, kbn);
-							kbn->adrcode = key->totkey;
 							key->totkey++;
 							if (key->totkey == 1) key->refkey = kbn;
 							

Modified: trunk/blender/source/blender/editors/object/object_shapekey.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_shapekey.c	2012-04-12 11:42:18 UTC (rev 45566)
+++ trunk/blender/source/blender/editors/object/object_shapekey.c	2012-04-12 11:50:43 UTC (rev 45567)
@@ -130,28 +130,10 @@
 			
 		if (kb->data) MEM_freeN(kb->data);
 		MEM_freeN(kb);
-		
-		for (kb= key->block.first; kb; kb= kb->next)
-			if (kb->adrcode>=ob->shapenr)
-				kb->adrcode--;
-		
-#if 0 // XXX old animation system
-		if (key->ipo) {
-			
-			for (icu= key->ipo->curve.first; icu; icu= icu->next) {
-				if (icu->adrcode==ob->shapenr-1) {
-					BLI_remlink(&key->ipo->curve, icu);
-					free_ipo_curve(icu);
-					break;
-				}
-			}
-			for (icu= key->ipo->curve.first; icu; icu= icu->next) 
-				if (icu->adrcode>=ob->shapenr)
-					icu->adrcode--;
+
+		if (ob->shapenr > 1) {
+			ob->shapenr--;
 		}
-#endif // XXX old animation system		
-		
-		if (ob->shapenr>1) ob->shapenr--;
 	}
 	
 	if (key->totkey==0) {

Modified: trunk/blender/source/blender/makesdna/DNA_key_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_key_types.h	2012-04-12 11:42:18 UTC (rev 45566)
+++ trunk/blender/source/blender/makesdna/DNA_key_types.h	2012-04-12 11:50:43 UTC (rev 45567)
@@ -43,8 +43,8 @@
 	
 	float pos;
 	float curval;
-	short type, adrcode, relative, flag;	/* relative == 0 means first key is reference */
-	int totelem, pad2;
+	short type, pad1, relative, flag;	/* relative == 0 means first key is reference */
+	int totelem, uid;
 	
 	void *data;
 	float *weights;
@@ -53,8 +53,6 @@
 
 	float slidermin;
 	float slidermax;
-
-	int uid, pad3;
 } KeyBlock;
 
 




More information about the Bf-blender-cvs mailing list