Commit: 7dd2d6f9c699409ab7d99e0603546efae4d03816
Author: Campbell Barton
Date:   Mon Jun 23 23:38:38 2014 +1000
https://developer.blender.org/rB7dd2d6f9c699409ab7d99e0603546efae4d03816

Misc minor changes
- add WM_drag_free_list()
- use len_manhattan_v2v2 to compare point distance
- avoid calling BKE_scene_use_new_shading_nodes in a loop

===================================================================

M       source/blender/blenkernel/BKE_DerivedMesh.h
M       source/blender/blenkernel/intern/depsgraph.c
M       source/blender/editors/sculpt_paint/paint_curve.c
M       source/blender/windowmanager/WM_api.h
M       source/blender/windowmanager/intern/wm.c
M       source/blender/windowmanager/intern/wm_dragdrop.c
M       source/blender/windowmanager/intern/wm_event_system.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h 
b/source/blender/blenkernel/BKE_DerivedMesh.h
index 6fe6171..6f4352d 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -153,7 +153,7 @@ typedef enum DMDrawFlag {
        DM_DRAW_USE_COLORS          = (1 << 0),
        DM_DRAW_ALWAYS_SMOOTH       = (1 << 1),
        DM_DRAW_USE_ACTIVE_UV       = (1 << 2),
-       DM_DRAW_USE_TEXPAINT_UV     = (1 << 4),
+       DM_DRAW_USE_TEXPAINT_UV     = (1 << 3),
 } DMDrawFlag;
 
 typedef enum DMForeachFlag {
diff --git a/source/blender/blenkernel/intern/depsgraph.c 
b/source/blender/blenkernel/intern/depsgraph.c
index 944c662..4c8d1a3 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -2473,10 +2473,11 @@ static void dag_id_flush_update(Main *bmain, Scene 
*sce, ID *id)
                }
 
                if (ELEM(idtype, ID_MA, ID_TE)) {
+                       const bool new_shading_nodes = 
BKE_scene_use_new_shading_nodes(sce);
                        for (obt = bmain->object.first; obt; obt = 
obt->id.next) {
                                if (obt->mode & OB_MODE_TEXTURE_PAINT) {
                                        obt->recalc |= OB_RECALC_DATA;
-                                       refresh_object_texpaint_images(obt, 
BKE_scene_use_new_shading_nodes(sce));
+                                       refresh_object_texpaint_images(obt, 
new_shading_nodes);
                                        lib_id_recalc_data_tag(bmain, &obt->id);
                                }
                        }
diff --git a/source/blender/editors/sculpt_paint/paint_curve.c 
b/source/blender/editors/sculpt_paint/paint_curve.c
index ec4f693..b3748d5 100644
--- a/source/blender/editors/sculpt_paint/paint_curve.c
+++ b/source/blender/editors/sculpt_paint/paint_curve.c
@@ -373,7 +373,8 @@ static void paintcurve_point_select(bContext *C, wmOperator 
*op, const int loc[2
        PaintCurve *pc;
        PaintCurvePoint *pcp;
        int i;
-       int select = 0;
+       char select = 0;
+       const float loc_fl[2] = {UNPACK2(loc)};
 
        pc = br->paint_curve;
 
@@ -393,8 +394,9 @@ static void paintcurve_point_select(bContext *C, wmOperator 
*op, const int loc[2
                        }
                }
 
-               if (!selected)
+               if (!selected) {
                        select = SELECT;
+               }
        }
 
        if (!extend) {
@@ -408,18 +410,14 @@ static void paintcurve_point_select(bContext *C, 
wmOperator *op, const int loc[2
                for (i = 0; i < pc->tot_points; i++, pcp++) {
                        /* shift means constrained editing so exclude center 
handles from collision detection */
                        if (!handle) {
-                               if ((fabsf(loc[0] - pcp->bez.vec[1][0]) < 
PAINT_CURVE_SELECT_THRESHOLD) &&
-                                   (fabsf(loc[1] - pcp->bez.vec[1][1]) < 
PAINT_CURVE_SELECT_THRESHOLD))
-                               {
+                               if (len_manhattan_v2v2(loc_fl, pcp->bez.vec[1]) 
< PAINT_CURVE_SELECT_THRESHOLD) {
                                        pcp->bez.f2 ^= SELECT;
                                        pc->add_index = i + 1;
                                        break;
                                }
                        }
 
-                       if ((fabsf(loc[0] - pcp->bez.vec[0][0]) < 
PAINT_CURVE_SELECT_THRESHOLD) &&
-                           (fabsf(loc[1] - pcp->bez.vec[0][1]) < 
PAINT_CURVE_SELECT_THRESHOLD))
-                       {
+                       if (len_manhattan_v2v2(loc_fl, pcp->bez.vec[0]) < 
PAINT_CURVE_SELECT_THRESHOLD) {
                                pcp->bez.f1 ^= SELECT;
                                pc->add_index = i + 1;
                                if (handle)
@@ -427,9 +425,7 @@ static void paintcurve_point_select(bContext *C, wmOperator 
*op, const int loc[2
                                break;
                        }
 
-                       if ((fabsf(loc[0] - pcp->bez.vec[2][0]) < 
PAINT_CURVE_SELECT_THRESHOLD) &&
-                           (fabsf(loc[1] - pcp->bez.vec[2][1]) < 
PAINT_CURVE_SELECT_THRESHOLD))
-                       {
+                       if (len_manhattan_v2v2(loc_fl, pcp->bez.vec[2]) < 
PAINT_CURVE_SELECT_THRESHOLD) {
                                pcp->bez.f3 ^= SELECT;
                                pc->add_index = i + 1;
                                if (handle)
diff --git a/source/blender/windowmanager/WM_api.h 
b/source/blender/windowmanager/WM_api.h
index 69ae4ba..0f403f0 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -346,6 +346,7 @@ void                
WM_operator_region_active_win_set(struct bContext *C);
 struct wmDrag          *WM_event_start_drag(struct bContext *C, int icon, int 
type, void *poin, double value, unsigned int flags);
 void                           WM_event_drag_image(struct wmDrag *, struct 
ImBuf *, float scale, int sx, int sy);
 void                WM_drag_free(struct wmDrag *drag);
+void                WM_drag_free_list(struct ListBase *lb);
 
 struct wmDropBox       *WM_dropbox_add(ListBase *lb, const char *idname, int 
(*poll)(struct bContext *, struct wmDrag *, const struct wmEvent *event),
                                     void (*copy)(struct wmDrag *, struct 
wmDropBox *));
diff --git a/source/blender/windowmanager/intern/wm.c 
b/source/blender/windowmanager/intern/wm.c
index e81212b..d05cc57 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -441,7 +441,6 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm)
        wmWindow *win;
        wmOperator *op;
        wmKeyConfig *keyconf;
-       wmDrag *drag;
 
        if (wm->autosavetimer)
                wm_autosave_timer_ended(wm);
@@ -464,10 +463,7 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm)
        
        BLI_freelistN(&wm->paintcursors);
 
-       while ((drag = wm->drags.first)) {
-               BLI_remlink(&wm->drags, drag);
-               WM_drag_free(drag);
-       }
+       WM_drag_free_list(&wm->drags);
        
        wm_reports_free(wm);
        
diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c 
b/source/blender/windowmanager/intern/wm_dragdrop.c
index 3fb3baf..e5bba92 100644
--- a/source/blender/windowmanager/intern/wm_dragdrop.c
+++ b/source/blender/windowmanager/intern/wm_dragdrop.c
@@ -181,6 +181,14 @@ void WM_drag_free(wmDrag *drag)
        MEM_freeN(drag);
 }
 
+void WM_drag_free_list(struct ListBase *lb)
+{
+       wmDrag *drag;
+       while ((drag = BLI_pophead(lb))) {
+               WM_drag_free(drag);
+       }
+}
+
 static const char *dropbox_active(bContext *C, ListBase *handlers, wmDrag 
*drag, wmEvent *event)
 {
        wmEventHandler *handler = handlers->first;
diff --git a/source/blender/windowmanager/intern/wm_event_system.c 
b/source/blender/windowmanager/intern/wm_event_system.c
index 136ef86..5d02dc1 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -113,14 +113,11 @@ void wm_event_free(wmEvent *event)
                        /* note: pointer to listbase struct elsewhere */
                        if (event->custom == EVT_DATA_DRAGDROP) {
                                ListBase *lb = event->customdata;
-                               wmDrag *drag;
-                               while ((drag = lb->first)) {
-                                       BLI_remlink(lb, drag);
-                                       WM_drag_free(drag);
-                               }
+                               WM_drag_free_list(lb);
                        }
-                       else
+                       else {
                                MEM_freeN(event->customdata);
+                       }
                }
        }
 
@@ -1943,10 +1940,7 @@ static int wm_handlers_do_intern(bContext *C, wmEvent 
*event, ListBase *handlers
                                                                        
drop->copy(drag, drop);
                                                                        
                                                                        /* free 
the drags before calling operator */
-                                                                       while 
((drag = lb->first)) {
-                                                                               
BLI_remlink(lb, drag);
-                                                                               
WM_drag_free(drag);
-                                                                       }
+                                                                       
WM_drag_free_list(lb);
 
                                                                        
event->customdata = NULL;
                                                                        
event->custom = 0;
@@ -2149,14 +2143,11 @@ static void wm_event_drag_test(wmWindowManager *wm, 
wmWindow *win, wmEvent *even
                return;
        }
        
-       if (event->type == MOUSEMOVE || ISKEYMODIFIER(event->type))
+       if (event->type == MOUSEMOVE || ISKEYMODIFIER(event->type)) {
                win->screen->do_draw_drag = true;
+       }
        else if (event->type == ESCKEY) {
-               wmDrag *drag;
-               while ((drag = wm->drags.first)) {
-                       BLI_remlink(&wm->drags, drag);
-                       WM_drag_free(drag);
-               }
+               WM_drag_free_list(&wm->drags);
 
                win->screen->do_draw_drag = true;
        }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to