Merging r58125 through r58143 from trunk into soc-2013-depsgraph_mt
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 10 Jul 2013 09:13:45 +0000 (09:13 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 10 Jul 2013 09:13:45 +0000 (09:13 +0000)
22 files changed:
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/customdata.c
source/blender/blenkernel/intern/particle.c
source/blender/compositor/nodes/COM_ChromaMatteNode.cpp
source/blender/editors/include/ED_mesh.h
source/blender/editors/include/ED_render.h
source/blender/editors/include/UI_interface.h
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_layout.c
source/blender/editors/interface/interface_templates.c
source/blender/editors/mesh/editmesh_loopcut.c
source/blender/editors/mesh/editmesh_utils.c
source/blender/editors/object/object_add.c
source/blender/editors/physics/particle_edit.c
source/blender/editors/render/render_internal.c
source/blender/editors/render/render_preview.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/util/undo.c
source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h
source/blender/makesrna/intern/rna_mesh.c

index 9260a1063087cc0b6552db7cc1ca19b59ee6472a..731d8f1ab1d0328b911117cff76050e605473308 100644 (file)
@@ -656,21 +656,25 @@ void DM_add_poly_layer(DerivedMesh *dm, int type, int alloctype, void *layer)
 
 void *DM_get_vert_data(DerivedMesh *dm, int index, int type)
 {
+       BLI_assert(index >= 0 && index < dm->getNumVerts(dm));
        return CustomData_get(&dm->vertData, index, type);
 }
 
 void *DM_get_edge_data(DerivedMesh *dm, int index, int type)
 {
+       BLI_assert(index >= 0 && index < dm->getNumEdges(dm));
        return CustomData_get(&dm->edgeData, index, type);
 }
 
 void *DM_get_tessface_data(DerivedMesh *dm, int index, int type)
 {
+       BLI_assert(index >= 0 && index < dm->getNumTessFaces(dm));
        return CustomData_get(&dm->faceData, index, type);
 }
 
 void *DM_get_poly_data(DerivedMesh *dm, int index, int type)
 {
+       BLI_assert(index >= 0 && index < dm->getNumPolys(dm));
        return CustomData_get(&dm->polyData, index, type);
 }
 
index b6c608661cd3e648d72f59cc9a2c2e0727bebe29..83685477725d7bc0f024a53aef949821412079cf 100644 (file)
@@ -2073,6 +2073,8 @@ void *CustomData_get(const CustomData *data, int index, int type)
        int offset;
        int layer_index;
        
+       BLI_assert(index >= 0);
+
        /* get the layer index of the active layer of type */
        layer_index = CustomData_get_active_layer_index(data, type);
        if (layer_index < 0) return NULL;
@@ -2088,6 +2090,8 @@ void *CustomData_get_n(const CustomData *data, int type, int index, int n)
        int layer_index;
        int offset;
 
+       BLI_assert(index >= 0 && n >= 0);
+
        /* get the layer index of the first layer of type */
        layer_index = data->typemap[type];
        if (layer_index < 0) return NULL;
index f6901c7b81b3889da9577a874c0ecaad8e2744cc..b3f29fe8ce16e552300a8772d2c2841225a327e7 100644 (file)
@@ -3414,8 +3414,7 @@ static void psys_face_mat(Object *ob, DerivedMesh *dm, ParticleData *pa, float m
        OrigSpaceFace *osface;
        float (*orcodata)[3];
 
-       int i = pa->num_dmcache == DMCACHE_NOTFOUND ? pa->num : pa->num_dmcache;
-       
+       int i = (ELEM(pa->num_dmcache, DMCACHE_ISCHILD, DMCACHE_NOTFOUND)) ? pa->num : pa->num_dmcache;
        if (i == -1 || i >= dm->getNumTessFaces(dm)) { unit_m4(mat); return; }
 
        mface = dm->getTessFaceData(dm, i, CD_MFACE);
index 4c4b77ba6cc5a12b028b677c1b5ebfe73c37d1da..d2598e661a96afe8da7565ba6fc7ab64c89a9527 100644 (file)
@@ -47,7 +47,7 @@ void ChromaMatteNode::convertToOperations(ExecutionSystem *graph, CompositorCont
        operation->setSettings((NodeChroma *)editorsnode->storage);
 
        inputSocketImage->relinkConnections(operationRGBToYCC_Image->getInputSocket(0), 0, graph);
-       inputSocketKey->relinkConnections(operationRGBToYCC_Key->getInputSocket(0), 0, graph);
+       inputSocketKey->relinkConnections(operationRGBToYCC_Key->getInputSocket(0), 1, graph);
 
        addLink(graph, operationRGBToYCC_Image->getOutputSocket(), operation->getInputSocket(0));
        addLink(graph, operationRGBToYCC_Key->getOutputSocket(), operation->getInputSocket(1));
index 51d5d42394cd48b8411395fc8abd51923fc61208..fd08039c24b2f71ed45faa7acf8570ab40d1254e 100644 (file)
@@ -95,6 +95,7 @@ void EDBM_selectmode_to_scene(struct bContext *C);
 void EDBM_mesh_make(struct ToolSettings *ts, struct Scene *scene, struct Object *ob);
 void EDBM_mesh_free(struct BMEditMesh *em);
 void EDBM_mesh_load(struct Object *ob);
+struct DerivedMesh *EDBM_mesh_deform_dm_get(struct BMEditMesh *em);
 
 void           EDBM_index_arrays_ensure(struct BMEditMesh *em, const char htype);
 void           EDBM_index_arrays_init(struct BMEditMesh *em, const char htype);
index e8e7643164f82215a35bc973d43e7b8cbd77c131..bdfbbbb9c7434351a535947b5ec640c1e4c8eabf 100644 (file)
@@ -52,7 +52,7 @@ void ED_render_engine_changed(struct Main *bmain);
 void ED_render_engine_area_exit(struct ScrArea *sa);
 void ED_render_scene_update(struct Main *bmain, struct Scene *scene, int updated);
 
-void ED_viewport_render_kill_jobs(const struct bContext *C);
+void ED_viewport_render_kill_jobs(const struct bContext *C, bool free_database);
 
 /* render_preview.c */
 
index b566fd360b6081e0628b54730d9232d8f6208aa0..e5cc0dd8ea726d31ddc28fd04aed3edbb4e0ba9c 100644 (file)
@@ -236,6 +236,8 @@ typedef enum {
        BUT_NORMAL    = (31 << 9),
        BUT_CURVE     = (32 << 9),
        ICONTOGN      = (34 << 9),
+       LISTBOX       = (35 << 9),
+       LISTROW       = (36 << 9),
        TOGBUT        = (37 << 9),
        OPTION        = (38 << 9),
        OPTIONN       = (39 << 9),
@@ -244,8 +246,6 @@ typedef enum {
        SEARCH_MENU   = (41 << 9),
        BUT_EXTRA     = (42 << 9),
        HSVCIRCLE     = (43 << 9),
-       LISTBOX       = (44 << 9),
-       LISTROW       = (45 << 9),
        HOTKEYEVT     = (46 << 9),
        BUT_IMAGE     = (47 << 9),
        HISTOGRAM     = (48 << 9),
index c3bc87ac6473055fe8f4c06c8b9b3b2b3f1ac354..898e653d5620589d582e182d810895a725da78ed 100644 (file)
@@ -2861,7 +2861,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str,
        }
 
        /* keep track of UI_interface.h */
-       if      (ELEM9(but->type, BLOCK, BUT, LABEL, PULLDOWN, ROUNDBOX, LISTBOX, BUTM, SCROLL, SEPR /* , FTPREVIEW */)) {}
+       if      (ELEM8(but->type, BLOCK, BUT, LABEL, PULLDOWN, ROUNDBOX, BUTM, SCROLL, SEPR)) {}
        else if (but->type >= SEARCH_MENU) {}
        else but->flag |= UI_BUT_UNDO;
 
index 8782076798eb421f5ac981d8022424dfc03f0706..b3ad99c9690b83c2065e5db29279f0c3848af585 100644 (file)
@@ -875,6 +875,10 @@ static bool ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data,
                        uiDragToggleHandle *drag_info = MEM_callocN(sizeof(*drag_info), __func__);
                        ARegion *ar_prev;
 
+                       /* call here because regular mouse-up event wont run,
+                        * typically 'button_activate_exit()' handles this */
+                       ui_apply_autokey(C, but);
+
                        drag_info->is_set = ui_is_but_push(but);
                        drag_info->but_cent_start[0] = BLI_rctf_cent_x(&but->rect);
                        drag_info->but_cent_start[1] = BLI_rctf_cent_y(&but->rect);
@@ -6419,7 +6423,6 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *ar)
 {
        uiBut *but = ui_list_find_mouse_over(ar, event->x, event->y);
        int retval = WM_UI_HANDLER_CONTINUE;
-       int value, min, max;
        int type = event->type, val = event->val;
 
        if (but) {
@@ -6442,8 +6445,11 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *ar)
                                if (ELEM(type, UPARROWKEY, DOWNARROWKEY) ||
                                        ((ELEM(type, WHEELUPMOUSE, WHEELDOWNMOUSE) && event->alt)))
                                {
+                                       const int value_orig = RNA_property_int_get(&but->rnapoin, but->rnaprop);
+                                       int value, min, max;
+
                                        /* activate up/down the list */
-                                       value = RNA_property_int_get(&but->rnapoin, but->rnaprop);
+                                       value = value_orig;
 
                                        if (ELEM(type, UPARROWKEY, WHEELUPMOUSE))
                                                value--;
@@ -6460,9 +6466,13 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *ar)
                                        RNA_property_int_range(&but->rnapoin, but->rnaprop, &min, &max);
                                        value = CLAMPIS(value, min, max);
 
-                                       RNA_property_int_set(&but->rnapoin, but->rnaprop, value);
-                                       RNA_property_update(C, &but->rnapoin, but->rnaprop);
-                                       ED_region_tag_redraw(ar);
+                                       if (value != value_orig) {
+                                               RNA_property_int_set(&but->rnapoin, but->rnaprop, value);
+                                               RNA_property_update(C, &but->rnapoin, but->rnaprop);
+
+                                               ui_apply_undo(but);
+                                               ED_region_tag_redraw(ar);
+                                       }
 
                                        retval = WM_UI_HANDLER_BREAK;
                                }
index 2a6a9600582f201b943b857cdd9109ccccbca604..461d0b24d576abd07d54bac08931f8ed1814b3b1 100644 (file)
@@ -2429,6 +2429,11 @@ uiLayout *uiLayoutListBox(uiLayout *layout, uiList *ui_list, PointerRNA *ptr, Pr
        but->rnapoin = *actptr;
        but->rnaprop = actprop;
 
+       /* only for the undo string */
+       if (but->flag & UI_BUT_UNDO) {
+               but->tip = RNA_property_description(actprop);
+       }
+
        return (uiLayout *)box;
 }
 
index 8caa059d168cbea45459857da5385f2c0bd8f748..275fa6a38f94b4ceaa0a5be0c30c2e9ddd56f6c0 100644 (file)
@@ -2648,7 +2648,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
                                                sub = uiLayoutRow(overlap, FALSE);
 
                                                but = uiDefButR_prop(subblock, LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
-                                                                    active_dataptr, activeprop, 0, 0, i, 0, 0, "");
+                                                                    active_dataptr, activeprop, 0, 0, i, 0, 0, NULL);
                                                uiButSetFlag(but, UI_BUT_NO_TOOLTIP);
 
                                                sub = uiLayoutRow(overlap, FALSE);
@@ -2662,6 +2662,8 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
                                                if (i == activei) {
                                                        ui_layout_list_set_labels_active(sub);
                                                }
+
+                                               uiBlockClearFlag(subblock, UI_BLOCK_LIST_ITEM);
                                        }
                                        i++;
                                }
@@ -2736,7 +2738,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
                                        sub = uiLayoutRow(overlap, FALSE);
 
                                        but = uiDefButR_prop(subblock, LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
-                                                            active_dataptr, activeprop, 0, 0, i, 0, 0, "");
+                                                            active_dataptr, activeprop, 0, 0, i, 0, 0, NULL);
                                        uiButSetFlag(but, UI_BUT_NO_TOOLTIP);
 
                                        sub = uiLayoutRow(overlap, FALSE);
@@ -2749,6 +2751,8 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
                                                ui_layout_list_set_labels_active(sub);
                                        }
 
+                                       uiBlockClearFlag(subblock, UI_BLOCK_LIST_ITEM);
+
                                        i++;
                                }
                                RNA_PROP_END;
index 2829aed4999845816bb05f8b8ff14f36ed23d6a8..97e6a6e8aad1a9ac615e40b2cf5c2f53a569ff8d 100644 (file)
@@ -42,6 +42,7 @@
 #include "BKE_modifier.h"
 #include "BKE_report.h"
 #include "BKE_editmesh.h"
+#include "BKE_DerivedMesh.h"
 
 #include "BIF_gl.h"
 
@@ -155,9 +156,30 @@ static void edgering_find_order(BMEdge *lasteed, BMEdge *eed,
        }
 }
 
+static void edgering_vcos_get(DerivedMesh *dm, BMVert *v[2][2], float r_cos[2][2][3])
+{
+       if (dm) {
+               int j, k;
+               for (j = 0; j < 2; j++) {
+                       for (k = 0; k < 2; k++) {
+                               dm->getVertCo(dm, BM_elem_index_get(v[j][k]), r_cos[j][k]);
+                       }
+               }
+       }
+       else {
+               int j, k;
+               for (j = 0; j < 2; j++) {
+                       for (k = 0; k < 2; k++) {
+                               copy_v3_v3(r_cos[j][k], v[j][k]->co);
+                       }
+               }
+       }
+}
+
 static void edgering_sel(RingSelOpData *lcd, int previewlines, bool select)
 {
        BMEditMesh *em = lcd->em;
+       DerivedMesh *dm = EDBM_mesh_deform_dm_get(em);
        BMEdge *eed_start = lcd->eed;
        BMEdge *eed, *eed_last;
        BMVert *v[2][2], *v_last;
@@ -195,6 +217,10 @@ static void edgering_sel(RingSelOpData *lcd, int previewlines, bool select)
                return;
        }
 
+       if (dm) {
+               EDBM_index_arrays_ensure(lcd->em, BM_VERT);
+       }
+
        BMW_init(&walker, em->bm, BMW_EDGERING,
                 BMW_MASK_NOP, BMW_MASK_NOP, BMW_MASK_NOP,
                 BMW_FLAG_TEST_HIDDEN,
@@ -222,8 +248,12 @@ static void edgering_sel(RingSelOpData *lcd, int previewlines, bool select)
 
                        for (i = 1; i <= previewlines; i++) {
                                const float fac = (i / ((float)previewlines + 1));
-                               interp_v3_v3v3(edges[tot][0], v[0][0]->co, v[0][1]->co, fac);
-                               interp_v3_v3v3(edges[tot][1], v[1][0]->co, v[1][1]->co, fac);
+                               float v_cos[2][2][3];
+
+                               edgering_vcos_get(dm, v, v_cos);
+
+                               interp_v3_v3v3(edges[tot][0], v_cos[0][0], v_cos[0][1], fac);
+                               interp_v3_v3v3(edges[tot][1], v_cos[1][0], v_cos[1][1], fac);
                                tot++;
                        }
                }
@@ -244,13 +274,16 @@ static void edgering_sel(RingSelOpData *lcd, int previewlines, bool select)
 
                for (i = 1; i <= previewlines; i++) {
                        const float fac = (i / ((float)previewlines + 1));
+                       float v_cos[2][2][3];
 
                        if (!v[0][0] || !v[0][1] || !v[1][0] || !v[1][1]) {
                                continue;
                        }
 
-                       interp_v3_v3v3(edges[tot][0], v[0][0]->co, v[0][1]->co, fac);
-                       interp_v3_v3v3(edges[tot][1], v[1][0]->co, v[1][1]->co, fac);
+                       edgering_vcos_get(dm, v, v_cos);
+
+                       interp_v3_v3v3(edges[tot][0], v_cos[0][0], v_cos[0][1], fac);
+                       interp_v3_v3v3(edges[tot][1], v_cos[1][0], v_cos[1][1], fac);
                        tot++;
                }
        }
index effbe3a619d7a741737d323a7873c90c118eef29..6e294d15dabe4994b0b7d9ac9a8c9a3e23bd4888 100644 (file)
@@ -171,6 +171,14 @@ void EDBM_stats_update(BMEditMesh *em)
        }
 }
 
+DerivedMesh *EDBM_mesh_deform_dm_get(BMEditMesh *em)
+{
+       return ((em->derivedFinal != NULL) &&
+               (em->derivedFinal) &&
+               (em->derivedFinal->type == DM_TYPE_EDITBMESH) &&
+               (em->derivedFinal->deformedOnly != false)) ? em->derivedFinal : NULL;
+}
+
 bool EDBM_op_init(BMEditMesh *em, BMOperator *bmop, wmOperator *op, const char *fmt, ...)
 {
        BMesh *bm = em->bm;
index f911495d5b4c0a3a4d535584343e62368dd699d8..430f44a0029d2a7a449431663f236f82d78774aa 100644 (file)
@@ -342,7 +342,7 @@ int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float loc[3], fl
                else if (RNA_struct_property_is_set(op->ptr, "view_align"))
                        *is_view_aligned = RNA_boolean_get(op->ptr, "view_align");
                else {
-                       *is_view_aligned = U.flag & USER_ADD_VIEWALIGNED;
+                       *is_view_aligned = (U.flag & USER_ADD_VIEWALIGNED) != 0;
                        RNA_boolean_set(op->ptr, "view_align", *is_view_aligned);
                }
 
index f84521fabbf92e2626875f0785ca9821dfc50f34..d6bb394ff79244295ed827c54a45599240d56174 100644 (file)
@@ -1722,13 +1722,17 @@ int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, bool
                                    BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], IS_CLIPPED) &&
                                    key_test_depth(&data, co, screen_co))
                                {
-                                       if (select && !(key->flag & PEK_SELECT)) {
-                                               key->flag |= PEK_SELECT;
-                                               point->flag |= PEP_EDIT_RECALC;
+                                       if (select) {
+                                               if (!(key->flag & PEK_SELECT)) {
+                                                       key->flag |= PEK_SELECT;
+                                                       point->flag |= PEP_EDIT_RECALC;
+                                               }
                                        }
-                                       else if (key->flag & PEK_SELECT) {
-                                               key->flag &= ~PEK_SELECT;
-                                               point->flag |= PEP_EDIT_RECALC;
+                                       else {
+                                               if (key->flag & PEK_SELECT) {
+                                                       key->flag &= ~PEK_SELECT;
+                                                       point->flag |= PEP_EDIT_RECALC;
+                                               }
                                        }
                                }
                        }
@@ -1742,13 +1746,17 @@ int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, bool
                            BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], IS_CLIPPED) &&
                            key_test_depth(&data, co, screen_co))
                        {
-                               if (select && !(key->flag & PEK_SELECT)) {
-                                       key->flag |= PEK_SELECT;
-                                       point->flag |= PEP_EDIT_RECALC;
+                               if (select) {
+                                       if (!(key->flag & PEK_SELECT)) {
+                                               key->flag |= PEK_SELECT;
+                                               point->flag |= PEP_EDIT_RECALC;
+                                       }
                                }
-                               else if (key->flag & PEK_SELECT) {
-                                       key->flag &= ~PEK_SELECT;
-                                       point->flag |= PEP_EDIT_RECALC;
+                               else {
+                                       if (key->flag & PEK_SELECT) {
+                                               key->flag &= ~PEK_SELECT;
+                                               point->flag |= PEP_EDIT_RECALC;
+                                       }
                                }
                        }
                }
@@ -2963,14 +2971,20 @@ static void brush_puff(PEData *data, int point_index)
        KEY_K;
        float mat[4][4], imat[4][4];
 
-       float lastco[3], rootco[3] = {0.0f, 0.0f, 0.0f}, co[3], nor[3], kco[3], dco[3], ofs[3] = {0.0f, 0.0f, 0.0f}, fac=0.0f, length=0.0f;
-       int puff_volume = 0;
-       int change= 0;
+       float onor_prev[3];  /* previous normal (particle-space) */
+       float ofs_prev[3];  /* accumulate offset for puff_volume (particle-space) */
+       float co_root[3], no_root[3];  /* root location and normal (global-space) */
+       float co_prev[3], co[3];  /* track key coords as we loop (global-space) */
+       float fac = 0.0f, length_accum = 0.0f;
+       bool puff_volume = false;
+       bool change = false;
+
+       zero_v3(ofs_prev);
 
        {
                ParticleEditSettings *pset= PE_settings(data->scene);
                ParticleBrushData *brush= &pset->brush[pset->brushtype];
-               puff_volume = brush->flag & PE_BRUSH_DATA_PUFF_VOLUME;
+               puff_volume = (brush->flag & PE_BRUSH_DATA_PUFF_VOLUME) != 0;
        }
 
        if (psys && !(psys->flag & PSYS_GLOBAL_HAIR)) {
@@ -2983,6 +2997,8 @@ static void brush_puff(PEData *data, int point_index)
        }
 
        LOOP_KEYS {
+               float kco[3];
+
                if (k==0) {
                        /* find root coordinate and normal on emitter */
                        copy_v3_v3(co, key->co);
@@ -2992,12 +3008,16 @@ static void brush_puff(PEData *data, int point_index)
                        point_index= BLI_kdtree_find_nearest(edit->emitter_field, kco, NULL, NULL);
                        if (point_index == -1) return;
 
-                       copy_v3_v3(rootco, co);
-                       copy_v3_v3(nor, &edit->emitter_cosnos[point_index*6+3]);
-                       mul_mat3_m4_v3(data->ob->obmat, nor); /* normal into worldspace */
+                       copy_v3_v3(co_root, co);
+                       copy_v3_v3(no_root, &edit->emitter_cosnos[point_index * 6 + 3]);
+                       mul_mat3_m4_v3(data->ob->obmat, no_root);  /* normal into global-space */
+                       normalize_v3(no_root);
 
-                       normalize_v3(nor);
-                       length= 0.0f;
+                       if (puff_volume) {
+                               copy_v3_v3(onor_prev, no_root);
+                               mul_mat3_m4_v3(imat, onor_prev); /* global-space into particle space */
+                               normalize_v3(onor_prev);
+                       }
 
                        fac= (float)pow((double)(1.0f - data->dist / data->rad), (double)data->pufffac);
                        fac *= 0.025f;
@@ -3007,16 +3027,23 @@ static void brush_puff(PEData *data, int point_index)
                else {
                        /* compute position as if hair was standing up straight.
                         * */
-                       copy_v3_v3(lastco, co);
+                       float length;
+                       copy_v3_v3(co_prev, co);
                        copy_v3_v3(co, key->co);
                        mul_m4_v3(mat, co);
-                       length += len_v3v3(lastco, co);
+                       length = len_v3v3(co_prev, co);
+                       length_accum += length;
+
                        if ((data->select==0 || (key->flag & PEK_SELECT)) && !(key->flag & PEK_HIDE)) {
-                               madd_v3_v3v3fl(kco, rootco, nor, length);
+                               float dco[3];  /* delta temp var */
+
+                               madd_v3_v3v3fl(kco, co_root, no_root, length_accum);
 
                                /* blend between the current and straight position */
                                sub_v3_v3v3(dco, kco, co);
                                madd_v3_v3fl(co, dco, fac);
+                               /* keep the same distance from the root or we get glitches [#35406] */
+                               dist_ensure_v3_v3fl(co, co_root, length_accum);
 
                                /* re-use dco to compare before and after translation and add to the offset  */
                                copy_v3_v3(dco, key->co);
@@ -3026,11 +3053,9 @@ static void brush_puff(PEData *data, int point_index)
                                if (puff_volume) {
                                        /* accumulate the total distance moved to apply to unselected
                                         * keys that come after */
-                                       ofs[0] += key->co[0] - dco[0];
-                                       ofs[1] += key->co[1] - dco[1];
-                                       ofs[2] += key->co[2] - dco[2];
+                                       sub_v3_v3v3(ofs_prev, key->co, dco);
                                }
-                               change = 1;
+                               change = true;
                        }
                        else {
 
@@ -3040,7 +3065,7 @@ static void brush_puff(PEData *data, int point_index)
                                        add_v3_v3(key->co, ofs);
 #else
                                        /* translate (not rotate) the rest of the hair if its not selected  */
-                                       if (ofs[0] || ofs[1] || ofs[2]) {
+                                       {
 #if 0                                  /* kindof works but looks worse then whats below */
 
                                                /* Move the unselected point on a vector based on the
@@ -3070,11 +3095,18 @@ static void brush_puff(PEData *data, int point_index)
                                                        mul_mat3_m4_v3(data->ob->obmat, onor); /* normal into worldspace */
                                                        mul_mat3_m4_v3(imat, onor); /* worldspace into particle space */
                                                        normalize_v3(onor);
+                                               }
+                                               else {
+                                                       copy_v3_v3(onor, onor_prev);
+                                               }
 
+                                               if (!is_zero_v3(ofs_prev)) {
+                                                       mul_v3_fl(onor, len_v3(ofs_prev));
 
-                                                       mul_v3_fl(onor, len_v3(ofs));
                                                        add_v3_v3(key->co, onor);
                                                }
+
+                                               copy_v3_v3(onor_prev, onor);
 #endif
                                        }
 #endif
index fbb8ceae6070b304afe9ff52c9726de73f294a4a..971dc49577c57c7b50bf7d12f983b581982ca025 100644 (file)
@@ -1172,7 +1172,7 @@ void render_view3d_draw(RenderEngine *engine, const bContext *C)
        RE_ReleaseResultImage(re);
 }
 
-void ED_viewport_render_kill_jobs(const bContext *C)
+void ED_viewport_render_kill_jobs(const bContext *C, bool free_database)
 {
        wmWindowManager *wm = CTX_wm_manager(C);
        Main *bmain = CTX_data_main(C);
@@ -1203,17 +1203,23 @@ void ED_viewport_render_kill_jobs(const bContext *C)
                                if (rv3d->render_engine) {
                                        /* free render database now before we change data, because
                                         * RE_Database_Free will also loop over blender data */
-                                       char name[32];
-                                       Render *re;
-
-                                       sprintf(name, "View3dPreview %p", (void *)ar);
-                                       re = RE_GetRender(name);
-
-                                       if (re)
-                                               RE_Database_Free(re);
-
-                                       /* tag render engine to update entire database */
-                                       rv3d->render_engine->update_flag |= RE_ENGINE_UPDATE_DATABASE;
+                                       if (free_database) {
+                                               char name[32];
+                                               Render *re;
+
+                                               sprintf(name, "View3dPreview %p", (void *)ar);
+                                               re = RE_GetRender(name);
+
+                                               if (re)
+                                                       RE_Database_Free(re);
+
+                                               /* tag render engine to update entire database */
+                                               rv3d->render_engine->update_flag |= RE_ENGINE_UPDATE_DATABASE;
+                                       }
+                                       else {
+                                               /* quick shader update */
+                                               rv3d->render_engine->update_flag |= RE_ENGINE_UPDATE_MA;
+                                       }
                                }
                        }
                }
index 76fa79029fd027074ac05ff4761857634c72733e..8da66c114d5e4b7b99505f82ef565dd7aaa91dbe 100644 (file)
@@ -1180,5 +1180,7 @@ void ED_preview_kill_jobs(const struct bContext *C)
        wmWindowManager *wm = CTX_wm_manager(C);
        if (wm)
                WM_jobs_kill(wm, NULL, common_preview_startjob);
+       
+       ED_viewport_render_kill_jobs(C, false);
 }
 
index d5860606b65ee8d4d2cb278d2ad2cc9d3f95917c..9ada94e524c08e660c8a7c443ad8ec5146e7a38f 100644 (file)
@@ -2700,9 +2700,7 @@ static void draw_em_measure_stats(ARegion *ar, View3D *v3d, Object *ob, BMEditMe
        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;
+       DerivedMesh *dm = EDBM_mesh_deform_dm_get(em);
        BMIter iter;
        int i;
 
index 52f87c19dc8824d81fa595b2e016c3d321b0b291..e285fd8bea440f6dd550ade7b17be68b3edbe90b 100644 (file)
@@ -143,7 +143,7 @@ static int ed_undo_step(bContext *C, int step, const char *undoname)
                if ((obact && (obact->mode & OB_MODE_TEXTURE_PAINT)) || (sima->mode == SI_MODE_PAINT)) {
                        if (!ED_undo_paint_step(C, UNDO_PAINT_IMAGE, step, undoname) && undoname) {
                                if (U.uiflag & USER_GLOBALUNDO) {
-                                       ED_viewport_render_kill_jobs(C);
+                                       ED_viewport_render_kill_jobs(C, true);
                                        BKE_undo_name(C, undoname);
                                }
                        }
@@ -196,7 +196,7 @@ static int ed_undo_step(bContext *C, int step, const char *undoname)
                        /* for example, texface stores image pointers */
                        undo_editmode_clear();
                        
-                       ED_viewport_render_kill_jobs(C);
+                       ED_viewport_render_kill_jobs(C, true);
 
                        if (undoname)
                                BKE_undo_name(C, undoname);
@@ -369,7 +369,7 @@ int ED_undo_operator_repeat(bContext *C, struct wmOperator *op)
                {
                        int retval;
 
-                       ED_viewport_render_kill_jobs(C);
+                       ED_viewport_render_kill_jobs(C, true);
 
                        if (G.debug & G_DEBUG)
                                printf("redo_cb: operator redo %s\n", op->type->name);
@@ -537,7 +537,7 @@ static int undo_history_exec(bContext *C, wmOperator *op)
                        WM_event_add_notifier(C, NC_GEOM | ND_DATA, NULL);
                }
                else {
-                       ED_viewport_render_kill_jobs(C);
+                       ED_viewport_render_kill_jobs(C, true);
                        BKE_undo_number(C, item);
                        WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, CTX_data_scene(C));
                }
index 2f98a042e2736c1f9ba12a3c6952c0267600df91..85956dbcac89c8eee1a8009c97fdabd752f40c7f 100644 (file)
  *  \ingroup freestyle
  */
 
-#include <assert.h>
-
 #include "BlenderFileLoader.h"
 
+#include "BLI_utildefines.h"
+
 #include "BKE_global.h"
 
 namespace Freestyle {
@@ -60,8 +60,23 @@ NodeGroup *BlenderFileLoader::Load()
        _viewplane_right =  _re->viewplane.xmax;
        _viewplane_bottom = _re->viewplane.ymin;
        _viewplane_top =    _re->viewplane.ymax;
-       _z_near = -_re->clipsta;
-       _z_far =  -_re->clipend;
+
+       if ((_re->r.scemode & R_VIEWPORT_PREVIEW) && (_re->r.mode & R_ORTHO)) {
+               // Adjust clipping start/end and set up a Z offset when the viewport preview
+               // is used with the orthographic view.  In this case, _re->clipsta is negative,
+               // while Freestyle assumes that imported mesh data are in the camera coordinate
+               // system with the view point located at origin [bug #36009].
+               BLI_assert(_re->clipsta < 0.f);
+               _z_near = -0.001f;
+               _z_offset = _re->clipsta + _z_near;
+               _z_far = -_re->clipend + _z_offset;
+       }
+       else {
+               _z_near = -_re->clipsta;
+               _z_far = -_re->clipend;
+               _z_offset = 0.f;
+       }
+
 #if 0
        if (G.debug & G_DEBUG_FREESTYLE) {
                cout << "Frustum: l " << _viewplane_left << " r " << _viewplane_right
@@ -225,7 +240,7 @@ void BlenderFileLoader::clipTriangle(int numTris, float triCoords[][3], float v1
                        }
                }
        }
-       assert(k == 2 + numTris);
+       BLI_assert(k == 2 + numTris);
 }
 
 void BlenderFileLoader::addTriangle(struct LoaderState *ls, float v1[3], float v2[3], float v3[3],
@@ -378,6 +393,11 @@ void BlenderFileLoader::insertShapeNode(ObjectInstanceRen *obi, int id)
                        if (vlr->v4)
                                mul_m4_v3(obi->mat, v4);
                }
+               v1[2] += _z_offset;
+               v2[2] += _z_offset;
+               v3[2] += _z_offset;
+               if (vlr->v4)
+                       v4[2] += _z_offset;
 #if 0
                print_v3("v1", v1);
                print_v3("v2", v2);
@@ -472,6 +492,11 @@ void BlenderFileLoader::insertShapeNode(ObjectInstanceRen *obi, int id)
                        if (vlr->v4)
                                mul_m4_v3(obi->mat, v4);
                }
+               v1[2] += _z_offset;
+               v2[2] += _z_offset;
+               v3[2] += _z_offset;
+               if (vlr->v4)
+                       v4[2] += _z_offset;
                if (_smooth && (vlr->flag & R_SMOOTH)) {
                        copy_v3_v3(n1, vlr->v1->n);
                        copy_v3_v3(n2, vlr->v2->n);
index 494dd375be0b792dfcddc3dc01dc6ef93f899ea7..c505eab40f170844a6389527373ef0f97a94675e 100644 (file)
@@ -122,6 +122,7 @@ protected:
        float _viewplane_bottom;
        float _viewplane_top;
        float _z_near, _z_far;
+       float _z_offset;
 
        RenderMonitor *_pRenderMonitor;
 
index 3a0e52aa3f255c82613532e7d0b5769cd2921739..15a3861b7788917781d5c5b225c0c6335ac7ef19 100644 (file)
@@ -2374,14 +2374,14 @@ void rna_def_texmat_common(StructRNA *srna, const char *texspace_editable)
        RNA_def_property_ui_text(prop, "Texture Space Location", "Texture space location");
        RNA_def_property_float_funcs(prop, "rna_Mesh_texspace_loc_get", NULL, NULL);
        RNA_def_property_editable_func(prop, texspace_editable);
-       RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
+       RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
 
        prop = RNA_def_property(srna, "texspace_size", PROP_FLOAT, PROP_XYZ);
        RNA_def_property_float_sdna(prop, NULL, "size");
        RNA_def_property_ui_text(prop, "Texture Space Size", "Texture space size");
        RNA_def_property_float_funcs(prop, "rna_Mesh_texspace_size_get", NULL, NULL);
        RNA_def_property_editable_func(prop, texspace_editable);
-       RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
+       RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
 
        /* not supported yet */
 #if 0
@@ -2389,7 +2389,7 @@ void rna_def_texmat_common(StructRNA *srna, const char *texspace_editable)
        RNA_def_property_float(prop, NULL, "rot");
        RNA_def_property_ui_text(prop, "Texture Space Rotation", "Texture space rotation");
        RNA_def_property_editable_func(prop, texspace_editable);
-       RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
+       RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
 #endif
 
        /* materials */