merge with/from trunk at r35190
[blender.git] / source / blender / blenkernel / intern / object.c
index 21a53d5365ad110fb17b1c712b9d18147554575b..9910392e2d0b1bf4ad35f5a17e6ea0f5aa0cb59e 100644 (file)
@@ -81,6 +81,7 @@
 #include "BKE_lattice.h"
 #include "BKE_library.h"
 #include "BKE_mesh.h"
+#include "BKE_tessmesh.h"
 #include "BKE_mball.h"
 #include "BKE_modifier.h"
 #include "BKE_object.h"
@@ -947,7 +948,7 @@ void free_lamp(Lamp *la)
        
        BKE_free_animdata((ID *)la);
 
-       curvemapping_free(la->curfalloff);
+       curvemapping_free(la->curfalloff); 
        
        BKE_previewimg_free(&la->preview);
        BKE_icon_delete(&la->id);
@@ -1897,7 +1898,7 @@ static void ob_parbone(Object *ob, Object *par, float mat[][4])
 
 static void give_parvert(Object *par, int nr, float *vec)
 {
-       EditMesh *em;
+       BMEditMesh *em;
        int a, count;
        
        vec[0]=vec[1]=vec[2]= 0.0f;
@@ -1906,7 +1907,22 @@ static void give_parvert(Object *par, int nr, float *vec)
                Mesh *me= par->data;
                DerivedMesh *dm;
 
-               em = BKE_mesh_get_editmesh(me);
+               em = me->edit_btmesh;
+
+               if(em) {
+                       BMVert *eve;
+                       BMIter iter;
+
+                       BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
+                               int *keyindex = CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_SHAPE_KEYINDEX);
+                               
+                               if(keyindex && *keyindex==nr) {
+                                       memcpy(vec, eve->co, sizeof(float)*3);
+                                       break;
+                               }
+                       }
+               }
+
                dm = (em)? em->derivedFinal: par->derivedFinal;
                        
                if(dm) {
@@ -1933,9 +1949,6 @@ static void give_parvert(Object *par, int nr, float *vec)
                                dm->getVertCo(dm, 0, vec);
                        }
                }
-
-               if(em)
-                       BKE_mesh_end_editmesh(me, em);
        }
        else if (ELEM(par->type, OB_CURVE, OB_SURF)) {
                Nurb *nu;
@@ -2568,11 +2581,14 @@ void object_handle_update(Scene *scene, Object *ob)
                        
                        if (G.f & G_DEBUG)
                                printf("recalcdata %s\n", ob->id.name+2);
+                       
 
                        if(adt) {
                                /* evaluate drivers */
                                // XXX: for mesh types, should we push this to derivedmesh instead?
                                BKE_animsys_evaluate_animdata(data_id, adt, ctime, ADT_RECALC_DRIVERS);
+
+                               
                        }
 
                        /* includes all keys and modifiers */
@@ -2580,19 +2596,17 @@ void object_handle_update(Scene *scene, Object *ob)
                        case OB_MESH:
                                {
 #if 0                          // XXX, comment for 2.56a release, background wont set 'scene->customdata_mask'
-                                       EditMesh *em = (ob == scene->obedit)? BKE_mesh_get_editmesh(ob->data): NULL;
+                                       BMEditMesh *em = (ob == scene->obedit)? ((Mesh*)ob->data)->edit_btmesh : NULL;
                                        BLI_assert((scene->customdata_mask & CD_MASK_BAREMESH) == CD_MASK_BAREMESH);
                                        if(em) {
                                                makeDerivedMesh(scene, ob, em,  scene->customdata_mask); /* was CD_MASK_BAREMESH */
-                                               BKE_mesh_end_editmesh(ob->data, em);
                                        } else
                                                makeDerivedMesh(scene, ob, NULL, scene->customdata_mask);
 
 #else                          /* ensure CD_MASK_BAREMESH for now */
-                                       EditMesh *em = (ob == scene->obedit)? BKE_mesh_get_editmesh(ob->data): NULL;
+                                       BMEditMesh *em = (ob == scene->obedit)? ((Mesh*)ob->data)->edit_btmesh : NULL;
                                        if(em) {
                                                makeDerivedMesh(scene, ob, em,  scene->customdata_mask | CD_MASK_BAREMESH); /* was CD_MASK_BAREMESH */
-                                               BKE_mesh_end_editmesh(ob->data, em);
                                        } else
                                                makeDerivedMesh(scene, ob, NULL, scene->customdata_mask | CD_MASK_BAREMESH);
 #endif