simplify some of the shape key code. no functional changes.
authorCampbell Barton <ideasman42@gmail.com>
Mon, 30 Jan 2012 03:54:24 +0000 (03:54 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 30 Jan 2012 03:54:24 +0000 (03:54 +0000)
source/blender/blenkernel/intern/DerivedMesh.c

index fda0fad65d214d2eaa6533aa446401b2a8344436..b4af827b44d4573facffcd5dcdb1ee80242574ca 100644 (file)
@@ -397,28 +397,26 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob)
 
        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(Mesh *me, Object *ob, float (*vertCos)[3])
 /***/
 
 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) {