[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43758] branches/bmesh/blender/source/ blender/blenkernel/intern/DerivedMesh.c: simplify some of the shape key code.

Campbell Barton ideasman42 at gmail.com
Mon Jan 30 04:54:39 CET 2012


Revision: 43758
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43758
Author:   campbellbarton
Date:     2012-01-30 03:54:24 +0000 (Mon, 30 Jan 2012)
Log Message:
-----------
simplify some of the shape key code. no functional changes.

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c

Modified: branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c	2012-01-30 01:18:49 UTC (rev 43757)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c	2012-01-30 03:54:24 UTC (rev 43758)
@@ -397,28 +397,26 @@
 
 	if (CustomData_has_layer(&dm->vertData, CD_SHAPEKEY)) {
 		KeyBlock *kb;
-		int i=0;
+		int uid;
 		
 		if (ob) {
-			for (kb=me->key->block.first; kb; kb=kb->next, i++) {
-				if (i == ob->shapenr-1) {
-					i = kb->uid;
-					break;
-				}
+			kb = BLI_findlink(&me->key->block, ob->shapenr-1);
+			if (kb) {
+				uid = kb->uid;
 			}
-			
-			if (!kb) {
+			else {
 				printf("%s: error - could not find active shapekey %d!\n",
 				       __func__, ob->shapenr-1);
 
-				i = INT_MAX;
+				uid = INT_MAX;
 			}
-		} else {
+		}
+		else {
 			/*if no object, set to INT_MAX so we don't mess up any shapekey layers*/
-			i = INT_MAX;
+			uid = INT_MAX;
 		}
-		
-		shapekey_layers_to_keyblocks(dm, me, i);
+
+		shapekey_layers_to_keyblocks(dm, me, uid);
 		did_shapekeys = 1;
 	}
 	
@@ -711,19 +709,20 @@
 /***/
 
 DerivedMesh *mesh_create_derived_for_modifier(Scene *scene, Object *ob, 
-	ModifierData *md, int build_shapekey_layers)
+                                              ModifierData *md, int build_shapekey_layers)
 {
 	Mesh *me = ob->data;
 	ModifierTypeInfo *mti = modifierType_getInfo(md->type);
 	DerivedMesh *dm;
+	KeyBlock *kb;
 
 	md->scene= scene;
 	
 	if (!(md->mode&eModifierMode_Realtime)) return NULL;
 	if (mti->isDisabled && mti->isDisabled(md, 0)) return NULL;
 	
-	if (build_shapekey_layers && me->key && ob->shapenr <= BLI_countlist(&me->key->block)) {
-		key_to_mesh(BLI_findlink(&me->key->block, ob->shapenr-1), me);
+	if (build_shapekey_layers && me->key && (kb = BLI_findlink(&me->key->block, ob->shapenr-1))) {
+		key_to_mesh(kb, me);
 	}
 	
 	if (mti->type==eModifierTypeType_OnlyDeform) {



More information about the Bf-blender-cvs mailing list