svn merge ^/trunk/blender -r41226:41227 .
[blender.git] / source / blender / blenkernel / intern / object.c
index 6e09aef..fcdb39c 100644 (file)
@@ -83,6 +83,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"
@@ -756,7 +757,9 @@ void make_local_camera(Camera *cam)
        
        if(cam->id.lib==NULL) return;
        if(cam->id.us==1) {
-               id_clear_lib_data(&bmain->camera, (ID *)cam);
+               cam->id.lib= NULL;
+               cam->id.flag= LIB_LOCAL;
+               new_id(&bmain->camera, (ID *)cam, NULL);
                return;
        }
        
@@ -768,7 +771,9 @@ void make_local_camera(Camera *cam)
        }
        
        if(local && lib==0) {
-               id_clear_lib_data(&bmain->camera, (ID *)cam);
+               cam->id.lib= NULL;
+               cam->id.flag= LIB_LOCAL;
+               new_id(&bmain->camera, (ID *)cam, NULL);
        }
        else if(local && lib) {
                Camera *camn= copy_camera(cam);
@@ -917,7 +922,9 @@ void make_local_lamp(Lamp *la)
        
        if(la->id.lib==NULL) return;
        if(la->id.us==1) {
-               id_clear_lib_data(&bmain->lamp, (ID *)la);
+               la->id.lib= NULL;
+               la->id.flag= LIB_LOCAL;
+               new_id(&bmain->lamp, (ID *)la, NULL);
                return;
        }
        
@@ -931,7 +938,9 @@ void make_local_lamp(Lamp *la)
        }
        
        if(local && lib==0) {
-               id_clear_lib_data(&bmain->lamp, (ID *)la);
+               la->id.lib= NULL;
+               la->id.flag= LIB_LOCAL;
+               new_id(&bmain->lamp, (ID *)la, NULL);
        }
        else if(local && lib) {
                lan= copy_lamp(la);
@@ -1083,7 +1092,6 @@ Object *add_only_object(int type, const char *name)
        /* ob->pad3 == Contact Processing Threshold */
        ob->m_contactProcessingThreshold = 1.;
        ob->obstacleRad = 1.;
-       ob->col_group = ob->col_mask = 1;
        
        /* NT fluid sim defaults */
        ob->fluidsimFlag = 0;
@@ -1461,8 +1469,9 @@ void make_local_object(Object *ob)
        ob->proxy= ob->proxy_from= NULL;
        
        if(ob->id.us==1) {
-               id_clear_lib_data(&bmain->object, (ID *)ob);
-               extern_local_object(ob);
+               ob->id.lib= NULL;
+               ob->id.flag= LIB_LOCAL;
+               new_id(&bmain->object, (ID *)ob, NULL);
        }
        else {
                for(sce= bmain->scene.first; sce && ELEM(0, lib, local); sce= sce->id.next) {
@@ -1473,8 +1482,9 @@ void make_local_object(Object *ob)
                }
 
                if(local && lib==0) {
-                       id_clear_lib_data(&bmain->object, (ID *)ob);
-                       extern_local_object(ob);
+                       ob->id.lib= NULL;
+                       ob->id.flag= LIB_LOCAL;
+                       new_id(&bmain->object, (ID *)ob, NULL);
                }
                else if(local && lib) {
                        Object *obn= copy_object(ob);
@@ -1497,6 +1507,8 @@ void make_local_object(Object *ob)
                        }
                }
        }
+       
+       extern_local_object(ob);
 }
 
 /*
@@ -1958,7 +1970,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;
@@ -1967,7 +1979,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) {
@@ -1995,9 +2022,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;
@@ -2664,22 +2688,19 @@ 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);
+                                               makeDerivedMesh(scene, ob, em,  scene->customdata_mask, 0); /* was CD_MASK_BAREMESH */
                                        } else
-                                               makeDerivedMesh(scene, ob, NULL, scene->customdata_mask);
+                                               makeDerivedMesh(scene, ob, NULL, scene->customdata_mask, 0);
 
 #else                          /* ensure CD_MASK_BAREMESH for now */
-                                       EditMesh *em = (ob == scene->obedit)? BKE_mesh_get_editmesh(ob->data): NULL;
-                                       unsigned int data_mask= scene->customdata_mask | ob->customdata_mask | CD_MASK_BAREMESH;
+                                       BMEditMesh *em = (ob == scene->obedit)? ((Mesh*)ob->data)->edit_btmesh : NULL;
                                        if(em) {
-                                               makeDerivedMesh(scene, ob, em,  data_mask); /* was CD_MASK_BAREMESH */
-                                               BKE_mesh_end_editmesh(ob->data, em);
+                                               makeDerivedMesh(scene, ob, em,  scene->customdata_mask | CD_MASK_BAREMESH, 0); /* was CD_MASK_BAREMESH */
                                        } else
-                                               makeDerivedMesh(scene, ob, NULL, data_mask);
+                                               makeDerivedMesh(scene, ob, NULL, scene->customdata_mask | CD_MASK_BAREMESH, 0);
 #endif
 
                                }