Merging r58112 through r58124 from trunk into soc-2013-depsgraph_mt
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 9 Jul 2013 19:22:26 +0000 (19:22 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 9 Jul 2013 19:22:26 +0000 (19:22 +0000)
source/blender/blenkernel/BKE_DerivedMesh.h
source/blender/blenkernel/intern/editderivedmesh.c
source/blender/blenkernel/intern/scene.c
source/blender/blenlib/BLI_threads.h
source/blender/editors/interface/interface_handlers.c
source/blender/editors/space_view3d/drawobject.c
source/blender/makesrna/intern/rna_object.c
source/blender/makesrna/intern/rna_space.c
source/blender/render/intern/source/envmap.c

index fdb43f5467e22fc59fc66fcc40df7352533898b7..ae936a1659a6d98f77313b78014c378f9684f2c3 100644 (file)
@@ -323,6 +323,7 @@ struct DerivedMesh {
 
        /** Get smooth vertex normal, undefined if index is not valid */
        void (*getVertNo)(DerivedMesh *dm, int index, float no_r[3]);
+       void (*getPolyNo)(DerivedMesh *dm, int index, float no_r[3]);
 
        /** Get a map of vertices to faces
         */
index 87f7da8a1fb2cd462b5e98616f8996e979e07bc4..46cee96a53716d0f61656ba2248a335432524c5b 100644 (file)
@@ -1109,6 +1109,66 @@ static void emDM_getVert(DerivedMesh *dm, int index, MVert *r_vert)
                copy_v3_v3(r_vert->co, bmdm->vertexCos[index]);
 }
 
+static void emDM_getVertCo(DerivedMesh *dm, int index, float r_co[3])
+{
+       EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
+       BMesh *bm = bmdm->em->bm;
+
+       if (UNLIKELY(index < 0 || index >= bm->totvert)) {
+               BLI_assert(!"error in emDM_getVertCo");
+               return;
+       }
+
+       if (bmdm->vertexCos) {
+               copy_v3_v3(r_co, bmdm->vertexCos[index]);
+       }
+       else {
+               BMVert *ev = bmdm->em->vert_index[index];  /* should be EDBM_vert_at_index() */
+               // ev = BM_vert_at_index(bm, index); /* warning, does list loop, _not_ ideal */
+               copy_v3_v3(r_co, ev->co);
+       }
+}
+
+static void emDM_getVertNo(DerivedMesh *dm, int index, float r_no[3])
+{
+       EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
+       BMesh *bm = bmdm->em->bm;
+
+       if (UNLIKELY(index < 0 || index >= bm->totvert)) {
+               BLI_assert(!"error in emDM_getVertNo");
+               return;
+       }
+
+       if (bmdm->vertexNos) {
+               copy_v3_v3(r_no, bmdm->vertexNos[index]);
+       }
+       else {
+               BMVert *ev = bmdm->em->vert_index[index];  /* should be EDBM_vert_at_index() */
+               // ev = BM_vert_at_index(bm, index); /* warning, does list loop, _not_ ideal */
+               copy_v3_v3(r_no, ev->no);
+       }
+}
+
+static void emDM_getPolyNo(DerivedMesh *dm, int index, float r_no[3])
+{
+       EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
+       BMesh *bm = bmdm->em->bm;
+
+       if (UNLIKELY(index < 0 || index >= bm->totface)) {
+               BLI_assert(!"error in emDM_getPolyNo");
+               return;
+       }
+
+       if (bmdm->polyNos) {
+               copy_v3_v3(r_no, bmdm->polyNos[index]);
+       }
+       else {
+               BMFace *efa = bmdm->em->face_index[index];  /* should be EDBM_vert_at_index() */
+               // efa = BM_face_at_index(bm, index); /* warning, does list loop, _not_ ideal */
+               copy_v3_v3(r_no, efa->no);
+       }
+}
+
 static void emDM_getEdge(DerivedMesh *dm, int index, MEdge *r_edge)
 {
        EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
@@ -1456,6 +1516,9 @@ DerivedMesh *getEditDerivedBMesh(BMEditMesh *em,
        bmdm->dm.getNumPolys = emDM_getNumPolys;
 
        bmdm->dm.getVert = emDM_getVert;
+       bmdm->dm.getVertCo = emDM_getVertCo;
+       bmdm->dm.getVertNo = emDM_getVertNo;
+       bmdm->dm.getPolyNo = emDM_getPolyNo;
        bmdm->dm.getEdge = emDM_getEdge;
        bmdm->dm.getTessFace = emDM_getTessFace;
        bmdm->dm.copyVertArray = emDM_copyVertArray;
@@ -1487,6 +1550,7 @@ DerivedMesh *getEditDerivedBMesh(BMEditMesh *em,
        bmdm->dm.release = emDM_release;
 
        bmdm->vertexCos = vertexCos;
+       bmdm->dm.deformedOnly = (vertexCos != NULL);
 
        if (cd_dvert_offset != -1) {
                BMIter iter;
index 3ccd7b6e67489010d45fe80783c2e49d68a72848..0735ff63606c5c5a21db2207caf9b7b26dcc3dce 100644 (file)
@@ -749,7 +749,7 @@ void BKE_scene_unlink(Main *bmain, Scene *sce, Scene *newsce)
  */
 int BKE_scene_base_iter_next(SceneBaseIter *iter, Scene **scene, int val, Base **base, Object **ob)
 {
-       static ThreadVariable int in_next_object = 0;
+       static int in_next_object = 0;
        int run_again = 1;
        
        /* init */
index 329cc2959ca4808a038ef5ac54f6226058b459e3..d2ad8e3ec9f9ed3444289f4124b840891d7aa4da 100644 (file)
@@ -193,13 +193,6 @@ void BLI_condition_notify_one(ThreadCondition *cond);
 void BLI_condition_notify_all(ThreadCondition *cond);
 void BLI_condition_end(ThreadCondition *cond);
 
-/* Thread Local Storage */
-#ifdef _MSC_VER
-#  define ThreadVariable  __declspec(thread)
-#else
-#  define ThreadVariable  __thread
-#endif
-
 #ifdef __cplusplus
 }
 #endif
index 342c0569f411080939c13a1f3f9c72b2be195b8e..8782076798eb421f5ac981d8022424dfc03f0706 100644 (file)
@@ -1297,9 +1297,14 @@ static void ui_but_drop(bContext *C, const wmEvent *event, uiBut *but, uiHandleB
                        if (ELEM3(but->type, TEX, SEARCH_MENU, SEARCH_MENU_UNLINK)) {
                                ID *id = (ID *)wmd->poin;
                                
-                               if (but->poin == NULL && but->rnapoin.data == NULL) {}
                                button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
                                BLI_strncpy(data->str, id->name + 2, data->maxlen);
+
+                               if (ELEM(but->type, SEARCH_MENU, SEARCH_MENU_UNLINK)) {
+                                       but->changed = true;
+                                       ui_searchbox_update(C, data->searchbox, but, true);
+                               }
+
                                button_activate_state(C, but, BUTTON_STATE_EXIT);
                        }
                }
@@ -1420,6 +1425,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
 
                        if (ELEM(but->type, SEARCH_MENU, SEARCH_MENU_UNLINK)) {
                                /* else uiSearchboxData.active member is not updated [#26856] */
+                               but->changed = true;
                                ui_searchbox_update(C, data->searchbox, but, true);
                        }
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
index cef4e1880ab99b07ef84b43adc922f97c10aca0a..d5860606b65ee8d4d2cb278d2ad2cc9d3f95917c 100644 (file)
@@ -2699,7 +2699,10 @@ static void draw_em_measure_stats(ARegion *ar, View3D *v3d, Object *ob, BMEditMe
        const bool do_global = (v3d->flag & V3D_GLOBAL_STATS) != 0;
        const bool do_moving = (G.moving & G_TRANSFORM_EDIT) != 0;
        float clip_planes[4][4];
-
+       /* allow for displaying shape keys and deform mods */
+       DerivedMesh *dm = ((em->derivedFinal != NULL) &&
+                          (em->derivedFinal->type == DM_TYPE_EDITBMESH) &&
+                          (em->derivedFinal->deformedOnly != false)) ? em->derivedFinal : NULL;
        BMIter iter;
        int i;
 
@@ -2725,23 +2728,33 @@ static void draw_em_measure_stats(ARegion *ar, View3D *v3d, Object *ob, BMEditMe
 
                UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGELEN, col);
 
-               eed = BM_iter_new(&iter, em->bm, BM_EDGES_OF_MESH, NULL);
-               for (; eed; eed = BM_iter_step(&iter)) {
+               if (dm) {
+                       BM_mesh_elem_index_ensure(em->bm, BM_VERT);
+               }
+
+               BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
                        /* draw selected edges, or edges next to selected verts while draging */
                        if (BM_elem_flag_test(eed, BM_ELEM_SELECT) ||
                            (do_moving && (BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) ||
                                           BM_elem_flag_test(eed->v2, BM_ELEM_SELECT))))
                        {
+                               float v1_clip[3], v2_clip[3];
 
-                               copy_v3_v3(v1, eed->v1->co);
-                               copy_v3_v3(v2, eed->v2->co);
+                               if (dm) {
+                                       dm->getVertCo(dm, BM_elem_index_get(eed->v1), v1);
+                                       dm->getVertCo(dm, BM_elem_index_get(eed->v2), v2);
+                               }
+                               else {
+                                       copy_v3_v3(v1, eed->v1->co);
+                                       copy_v3_v3(v2, eed->v2->co);
+                               }
 
-                               if (clip_segment_v3_plane_n(v1, v2, clip_planes, 4)) {
+                               copy_v3_v3(v1_clip, v1);
+                               copy_v3_v3(v2_clip, v2);
 
-                                       mid_v3_v3v3(vmid, v1, v2);
+                               if (clip_segment_v3_plane_n(v1_clip, v2_clip, clip_planes, 4)) {
 
-                                       copy_v3_v3(v1, eed->v1->co);
-                                       copy_v3_v3(v2, eed->v2->co);
+                                       mid_v3_v3v3(vmid, v1_clip, v2_clip);
 
                                        if (do_global) {
                                                mul_mat3_m4_v3(ob->obmat, v1);
@@ -2768,10 +2781,13 @@ static void draw_em_measure_stats(ARegion *ar, View3D *v3d, Object *ob, BMEditMe
 
                UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGEANG, col);
 
+               if (dm) {
+                       BM_mesh_elem_index_ensure(em->bm, BM_VERT | BM_FACE);
+               }
+
                // invert_m4_m4(ob->imat, ob->obmat);  // this is already called
 
-               eed = BM_iter_new(&iter, em->bm, BM_EDGES_OF_MESH, NULL);
-               for (; eed; eed = BM_iter_step(&iter)) {
+               BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
                        BMLoop *l_a, *l_b;
                        if (BM_edge_loop_pair(eed, &l_a, &l_b)) {
                                /* draw selected edges, or edges next to selected verts while draging */
@@ -2786,30 +2802,44 @@ static void draw_em_measure_stats(ARegion *ar, View3D *v3d, Object *ob, BMEditMe
                                                   BM_elem_flag_test(l_b->prev->v, BM_ELEM_SELECT)
                                                   )))
                                {
-                                       copy_v3_v3(v1, eed->v1->co);
-                                       copy_v3_v3(v2, eed->v2->co);
-
-                                       if (clip_segment_v3_plane_n(v1, v2, clip_planes, 4)) {
-                                               float angle;
-
-                                               mid_v3_v3v3(vmid, v1, v2);
+                                       float v1_clip[3], v2_clip[3];
 
+                                       if (dm) {
+                                               dm->getVertCo(dm, BM_elem_index_get(eed->v1), v1);
+                                               dm->getVertCo(dm, BM_elem_index_get(eed->v2), v2);
+                                       }
+                                       else {
                                                copy_v3_v3(v1, eed->v1->co);
                                                copy_v3_v3(v2, eed->v2->co);
+                                       }
 
-                                               if (do_global) {
-                                                       float no_a[3];
-                                                       float no_b[3];
+                                       copy_v3_v3(v1_clip, v1);
+                                       copy_v3_v3(v2_clip, v2);
+
+                                       if (clip_segment_v3_plane_n(v1_clip, v2_clip, clip_planes, 4)) {
+                                               float no_a[3], no_b[3];
+                                               float angle;
+
+                                               mid_v3_v3v3(vmid, v1_clip, v2_clip);
+
+                                               if (dm) {
+                                                       dm->getPolyNo(dm, BM_elem_index_get(l_a->f), no_a);
+                                                       dm->getPolyNo(dm, BM_elem_index_get(l_b->f), no_b);
+                                               }
+                                               else {
                                                        copy_v3_v3(no_a, l_a->f->no);
                                                        copy_v3_v3(no_b, l_b->f->no);
+                                               }
+
+                                               if (do_global) {
                                                        mul_mat3_m4_v3(ob->imat, no_a);
                                                        mul_mat3_m4_v3(ob->imat, no_b);
-                                                       angle = angle_v3v3(no_a, no_b);
-                                               }
-                                               else {
-                                                       angle = angle_normalized_v3v3(l_a->f->no, l_b->f->no);
+                                                       normalize_v3(no_a);
+                                                       normalize_v3(no_b);
                                                }
 
+                                               angle = angle_normalized_v3v3(no_a, no_b);
+
                                                BLI_snprintf(numstr, sizeof(numstr), "%.3f", is_rad ? angle : RAD2DEGF(angle));
 
                                                view3d_cached_text_draw_add(vmid, numstr, 0, txt_flag, col);
@@ -2844,6 +2874,10 @@ static void draw_em_measure_stats(ARegion *ar, View3D *v3d, Object *ob, BMEditMe
 
                UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEAREA, col);
                
+               if (dm) {
+                       BM_mesh_elem_index_ensure(em->bm, BM_VERT);
+               }
+
                f = NULL;
                area = 0.0;
                zero_v3(vmid);
@@ -2858,9 +2892,18 @@ static void draw_em_measure_stats(ARegion *ar, View3D *v3d, Object *ob, BMEditMe
                        }
 
                        f = l[0]->f;
-                       copy_v3_v3(v1, l[0]->v->co);
-                       copy_v3_v3(v2, l[1]->v->co);
-                       copy_v3_v3(v3, l[2]->v->co);
+
+                       if (dm) {
+                               dm->getVertCo(dm, BM_elem_index_get(l[0]->v), v1);
+                               dm->getVertCo(dm, BM_elem_index_get(l[1]->v), v2);
+                               dm->getVertCo(dm, BM_elem_index_get(l[2]->v), v3);
+                       }
+                       else {
+                               copy_v3_v3(v1, l[0]->v->co);
+                               copy_v3_v3(v2, l[1]->v->co);
+                               copy_v3_v3(v3, l[2]->v->co);
+                       }
+
                        add_v3_v3(vmid, v1);
                        add_v3_v3(vmid, v2);
                        add_v3_v3(vmid, v3);
@@ -2885,6 +2928,9 @@ static void draw_em_measure_stats(ARegion *ar, View3D *v3d, Object *ob, BMEditMe
 
                UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col);
 
+               if (dm) {
+                       BM_mesh_elem_index_ensure(em->bm, BM_VERT);
+               }
 
                BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
                        const int is_face_sel = BM_elem_flag_test(efa, BM_ELEM_SELECT);
@@ -2897,35 +2943,50 @@ static void draw_em_measure_stats(ARegion *ar, View3D *v3d, Object *ob, BMEditMe
                                BM_ITER_ELEM (loop, &liter, efa, BM_LOOPS_OF_FACE) {
                                        if (is_face_sel || (do_moving && BM_elem_flag_test(loop->v, BM_ELEM_SELECT))) {
                                                float angle;
+                                               float v2_local[3];
 
                                                /* lazy init center calc */
                                                if (is_first) {
-                                                       BM_face_calc_center_bounds(efa, vmid);
-                                                       /* Avoid triple matrix multiply every vertex for 'global' */
-                                                       if (do_global) {
-                                                               copy_v3_v3(v1, loop->prev->v->co);
-                                                               copy_v3_v3(v2, loop->v->co);
-                                                               mul_mat3_m4_v3(ob->obmat, v1);
-                                                               mul_mat3_m4_v3(ob->obmat, v2);
+                                                       if (dm) {
+                                                               BMLoop *l_iter, *l_first;
+                                                               float tvec[3];
+                                                               zero_v3(vmid);
+                                                               l_iter = l_first = BM_FACE_FIRST_LOOP(efa);
+                                                               do {
+                                                                       dm->getVertCo(dm, BM_elem_index_get(l_iter->v), tvec);
+                                                                       add_v3_v3(vmid, tvec);
+                                                               } while ((l_iter = l_iter->next) != l_first);
+                                                               mul_v3_fl(vmid, 1.0f / (float)efa->len);
+                                                       }
+                                                       else {
+                                                               BM_face_calc_center_bounds(efa, vmid);
                                                        }
                                                        is_first = false;
                                                }
 
-                                               if (do_global) {
+                                               if (dm) {
+                                                       dm->getVertCo(dm, BM_elem_index_get(loop->prev->v), v1);
+                                                       dm->getVertCo(dm, BM_elem_index_get(loop->v),       v2);
+                                                       dm->getVertCo(dm, BM_elem_index_get(loop->next->v), v3);
+                                               }
+                                               else {
+                                                       copy_v3_v3(v1, loop->prev->v->co);
+                                                       copy_v3_v3(v2, loop->v->co);
                                                        copy_v3_v3(v3, loop->next->v->co);
+                                               }
 
-                                                       mul_mat3_m4_v3(ob->obmat, v3);
+                                               copy_v3_v3(v2_local, v2);
 
-                                                       angle = angle_v3v3v3(v1, v2, v3);
-                                                       copy_v3_v3(v1, v2);
-                                                       copy_v3_v3(v2, v3);
-                                               }
-                                               else {
-                                                       angle = angle_v3v3v3(loop->prev->v->co, loop->v->co, loop->next->v->co);
+                                               if (do_global) {
+                                                       mul_mat3_m4_v3(ob->obmat, v1);
+                                                       mul_mat3_m4_v3(ob->obmat, v2);
+                                                       mul_mat3_m4_v3(ob->obmat, v3);
                                                }
 
+                                               angle = angle_v3v3v3(v1, v2, v3);
+
                                                BLI_snprintf(numstr, sizeof(numstr), "%.3f", is_rad ? angle : RAD2DEGF(angle));
-                                               interp_v3_v3v3(fvec, vmid, loop->v->co, 0.8f);
+                                               interp_v3_v3v3(fvec, vmid, v2_local, 0.8f);
                                                view3d_cached_text_draw_add(fvec, numstr, 0, txt_flag, col);
                                        }
                                }
index 3a5869c8300167b600713d365d935f81d7be6602..d48dbbb130046f496988fc8eddb01842f797a2db 100644 (file)
@@ -460,17 +460,20 @@ static EnumPropertyItem *rna_Object_parent_type_itemf(bContext *UNUSED(C), Point
        if (ob->parent) {
                Object *par = ob->parent;
                
-               if (par->type == OB_CURVE)
+               if (par->type == OB_CURVE) {
                        RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARCURVE);
-               else if (par->type == OB_LATTICE)
+               }
+               else if (par->type == OB_LATTICE) {
                        /* special hack: prevents this overriding others */
                        RNA_enum_items_add_value(&item, &totitem, &parent_type_items[4], PARSKEL);
+               }
                else if (par->type == OB_ARMATURE) {
                        /* special hack: prevents this being overrided */
                        RNA_enum_items_add_value(&item, &totitem, &parent_type_items[3], PARSKEL);
                        RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARBONE);
                }
-               else if (par->type == OB_MESH) {
+
+               if (ELEM4(par->type, OB_MESH, OB_CURVE, OB_SURF, OB_LATTICE)) {
                        RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARVERT1);
                        RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARVERT3);
                }
index 38ada7bf74f4a8bf5a816c0f9139bd3e00be56e8..2555e925eed0e85d8b27ea3e5cfc88c414969e43 100644 (file)
@@ -1249,6 +1249,12 @@ void rna_SpaceNodeEditor_path_pop(SpaceNode *snode, bContext *C)
        ED_node_tree_update(C);
 }
 
+static void rna_SpaceNodeEditor_show_backdrop_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
+{
+       WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
+       WM_main_add_notifier(NC_SCENE | ND_NODES, NULL);
+}
+
 static void rna_SpaceClipEditor_clip_set(PointerRNA *ptr, PointerRNA value)
 {
        SpaceClip *sc = (SpaceClip *)(ptr->data);
@@ -3369,7 +3375,7 @@ static void rna_def_space_node(BlenderRNA *brna)
        prop = RNA_def_property(srna, "show_backdrop", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", SNODE_BACKDRAW);
        RNA_def_property_ui_text(prop, "Backdrop", "Use active Viewer Node output as backdrop for compositing nodes");
-       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL);
+       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, "rna_SpaceNodeEditor_show_backdrop_update");
 
        prop = RNA_def_property(srna, "show_grease_pencil", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", SNODE_SHOW_GPENCIL);
index 3111c4c079ed540919275cc0bf7b6a14fa88e067..3cd9020fb89aa0173433b07e99a8b6540dc72c77 100644 (file)
@@ -722,6 +722,10 @@ int envmaptex(Tex *tex, const float texvec[3], float dxt[3], float dyt[3], int o
                                        envmap_split_ima(env, ibuf_ima);
                                else
                                        env->ok = 0;
+
+                               if (env->type == ENV_PLANE)
+                                       tex->extend = TEX_EXTEND;
+
                                BKE_image_pool_release_ibuf(env->ima, ibuf_ima, pool);
                        }
                }