Revision: 24053
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24053
Author:   campbellbarton
Date:     2009-10-22 14:59:14 +0200 (Thu, 22 Oct 2009)

Log Message:
-----------
added back face mask mouse selection and made shift+k fill weight paint and 
vertex color

Modified Paths:
--------------
    trunk/blender/source/blender/editors/include/ED_mesh.h
    trunk/blender/source/blender/editors/mesh/editface.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h
    trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c
    trunk/blender/source/blender/editors/space_view3d/view3d_select.c

Modified: trunk/blender/source/blender/editors/include/ED_mesh.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_mesh.h      2009-10-22 
09:48:44 UTC (rev 24052)
+++ trunk/blender/source/blender/editors/include/ED_mesh.h      2009-10-22 
12:59:14 UTC (rev 24053)
@@ -165,6 +165,7 @@
 
 /* editface.c */
 struct MTFace  *EM_get_active_mtface(struct EditMesh *em, struct EditFace 
**act_efa, struct MCol **mcol, int sloppy);
+int face_select(struct bContext *C, struct Object *ob, short mval[2], int 
extend);
 
 /* object_vgroup.c */
 

Modified: trunk/blender/source/blender/editors/mesh/editface.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editface.c        2009-10-22 
09:48:44 UTC (rev 24052)
+++ trunk/blender/source/blender/editors/mesh/editface.c        2009-10-22 
12:59:14 UTC (rev 24053)
@@ -82,8 +82,6 @@
 #include "mesh_intern.h"
 
 /* ***************** XXX **************** */
-static int sample_backbuf_rect() {return 0;}
-static int sample_backbuf() {return 0;}
 static void error() {}
 static int pupmenu() {return 0;}
 /* ***************** XXX **************** */
@@ -118,25 +116,30 @@
 }
 
 /* returns 0 if not found, otherwise 1 */
-int facesel_face_pick(View3D *v3d, Mesh *me, short *mval, unsigned int *index, 
short rect)
+int facesel_face_pick(struct bContext *C, Mesh *me, short *mval, unsigned int 
*index, short rect)
 {
+       ViewContext vc;
+       view3d_set_viewcontext(C, &vc);
+
        if (!me || me->totface==0)
                return 0;
 
-       if (v3d->flag & V3D_NEEDBACKBUFDRAW) {
+// XXX         if (v3d->flag & V3D_NEEDBACKBUFDRAW) {
 // XXX drawview.c!             check_backbuf();
 // XXX         persp(PERSP_VIEW);
-       }
+// XXX         }
 
        if (rect) {
                /* sample rect to increase changes of selecting, so that when 
clicking
                   on an edge in the backbuf, we can still select a face */
+
                int dist;
-               *index = sample_backbuf_rect(mval, 3, 1, me->totface+1, 
&dist,0,NULL);
+               *index = view3d_sample_backbuf_rect(&vc, mval, 3, 1, 
me->totface+1, &dist,0,NULL, NULL);
        }
-       else
+       else {
                /* sample only on the exact position */
-               *index = sample_backbuf(mval[0], mval[1]);
+               *index = view3d_sample_backbuf(&vc, mval[0], mval[1]);
+       }
 
        if ((*index)<=0 || (*index)>(unsigned int)me->totface)
                return 0;
@@ -646,32 +649,25 @@
 // XXX notifier!               object_tface_flags_changed(OBACT, 1);
 }
 
-void face_select(Scene *scene, View3D *v3d)
+int face_select(struct bContext *C, Object *ob, short mval[2], int extend)
 {
-       Object *ob;
        Mesh *me;
        MFace *mface, *msel;
-       short mval[2];
        unsigned int a, index;
-       int shift= 0; // XXX
        
        /* Get the face under the cursor */
-       ob = OBACT;
-       if (!(ob->lay & v3d->lay)) {
-               error("The active object is not in this layer");
-       }
        me = get_mesh(ob);
-// XXX getmouseco_areawin(mval);
 
-       if (!facesel_face_pick(v3d, me, mval, &index, 1)) return;
+       if (!facesel_face_pick(C, me, mval, &index, 1))
+               return 0;
        
        msel= (((MFace*)me->mface)+index);
-       if (msel->flag & ME_HIDE) return;
+       if (msel->flag & ME_HIDE) return 0;
        
        /* clear flags */
        mface = me->mface;
        a = me->totface;
-       if ((shift)==0) {
+       if (!extend) {
                while (a--) {
                        mface->flag &= ~ME_FACE_SEL;
                        mface++;
@@ -680,7 +676,7 @@
        
        me->act_face = (int)index;
 
-       if (shift) {
+       if (extend) {
                if (msel->flag & ME_FACE_SEL)
                        msel->flag &= ~ME_FACE_SEL;
                else
@@ -690,8 +686,11 @@
        
        /* image window redraw */
        
-       object_facesel_flush_dm(OBACT);
+       object_facesel_flush_dm(ob);
 // XXX notifier!               object_tface_flags_changed(OBACT, 1);
+       WM_event_add_notifier(C, NC_GEOM|ND_SELECT, ob->data);
+       ED_region_tag_redraw(CTX_wm_region(C)); // XXX - should redraw all 3D 
views
+       return 1;
 }
 
 void face_borderselect(Scene *scene, ScrArea *sa, ARegion *ar)

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image.c     
2009-10-22 09:48:44 UTC (rev 24052)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image.c     
2009-10-22 12:59:14 UTC (rev 24053)
@@ -5252,3 +5252,8 @@
 }
 
 
+int facemask_paint_poll(bContext *C)
+{
+       Object *obact = CTX_data_active_object(C);
+       return paint_facesel_test(obact);
+}

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h    
2009-10-22 09:48:44 UTC (rev 24052)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h    
2009-10-22 12:59:14 UTC (rev 24053)
@@ -40,20 +40,21 @@
 struct wmOperator;
 struct wmOperatorType;
 struct ARegion;
+struct VPaint;
 
 /* paint_stroke.c */
 typedef int (*StrokeTestStart)(struct bContext *C, struct wmOperator *op, 
struct wmEvent *event);
 typedef void (*StrokeUpdateStep)(struct bContext *C, struct PaintStroke 
*stroke, struct PointerRNA *itemptr);
 typedef void (*StrokeDone)(struct bContext *C, struct PaintStroke *stroke);
 
-struct PaintStroke *paint_stroke_new(bContext *C, StrokeTestStart test_start,
+struct PaintStroke *paint_stroke_new(struct bContext *C, StrokeTestStart 
test_start,
                                     StrokeUpdateStep update_step, StrokeDone 
done);
 int paint_stroke_modal(struct bContext *C, struct wmOperator *op, struct 
wmEvent *event);
 int paint_stroke_exec(struct bContext *C, struct wmOperator *op);
 struct ViewContext *paint_stroke_view_context(struct PaintStroke *stroke);
 void *paint_stroke_mode_data(struct PaintStroke *stroke);
 void paint_stroke_set_mode_data(struct PaintStroke *stroke, void *mode_data);
-int paint_poll(bContext *C);
+int paint_poll(struct bContext *C);
 void paint_cursor_start(struct bContext *C, int (*poll)(struct bContext *C));
 
 /* paint_vertex.c */
@@ -61,16 +62,20 @@
 int vertex_paint_poll(struct bContext *C);
 int vertex_paint_mode_poll(struct bContext *C);
 
-void clear_vpaint(Scene *scene, int selected);
+void vpaint_fill(struct Object *ob, unsigned int paintcol);
+void wpaint_fill(struct VPaint *wp, struct Object *ob, float paintweight);
 
 void PAINT_OT_weight_paint_toggle(struct wmOperatorType *ot);
 void PAINT_OT_weight_paint_radial_control(struct wmOperatorType *ot);
 void PAINT_OT_weight_paint(struct wmOperatorType *ot);
+void PAINT_OT_weight_set(struct wmOperatorType *ot);
 
 void PAINT_OT_vertex_paint_radial_control(struct wmOperatorType *ot);
 void PAINT_OT_vertex_paint_toggle(struct wmOperatorType *ot);
 void PAINT_OT_vertex_paint(struct wmOperatorType *ot);
 
+unsigned int vpaint_get_current_col(struct VPaint *vp);
+
 /* paint_image.c */
 int image_texture_paint_poll(struct bContext *C);
 
@@ -89,5 +94,7 @@
 void paint_sample_color(struct Scene *scene, struct ARegion *ar, int x, int y);
 void BRUSH_OT_curve_preset(struct wmOperatorType *ot);
 
+int facemask_paint_poll(struct bContext *C);
+
 #endif /* ED_PAINT_INTERN_H */
 

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c       
2009-10-22 09:48:44 UTC (rev 24052)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c       
2009-10-22 12:59:14 UTC (rev 24053)
@@ -28,6 +28,7 @@
 #include "BKE_paint.h"
 
 #include "ED_sculpt.h"
+#include "ED_screen.h"
 #include "UI_resources.h"
 
 #include "WM_api.h"
@@ -52,7 +53,7 @@
 
        if(br)
                paint_brush_set(paint_get_active(CTX_data_scene(C)), br);
-       
+
        return OPERATOR_FINISHED;
 }
 
@@ -81,11 +82,12 @@
 
 static int vertex_color_set_exec(bContext *C, wmOperator *op)
 {
-       int selected = RNA_boolean_get(op->ptr, "selected");
        Scene *scene = CTX_data_scene(C);
-
-       clear_vpaint(scene, selected);
+       Object *obact = CTX_data_active_object(C);
+       unsigned int paintcol = 
vpaint_get_current_col(scene->toolsettings->vpaint);
+       vpaint_fill(obact, paintcol);
        
+       ED_region_tag_redraw(CTX_wm_region(C)); // XXX - should redraw all 3D 
views
        return OPERATOR_FINISHED;
 }
 
@@ -101,8 +103,6 @@
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
-
-       RNA_def_boolean(ot->srna, "selected", 0, "Type", "Only color selected 
faces.");
 }
 
 /**************************** registration **********************************/
@@ -126,6 +126,7 @@
        WM_operatortype_append(PAINT_OT_weight_paint_toggle);
        WM_operatortype_append(PAINT_OT_weight_paint_radial_control);
        WM_operatortype_append(PAINT_OT_weight_paint);
+       WM_operatortype_append(PAINT_OT_weight_set);
 
        /* vertex */
        WM_operatortype_append(PAINT_OT_vertex_paint_radial_control);
@@ -158,6 +159,9 @@
        WM_keymap_verify_item(keymap, "PAINT_OT_vertex_paint", LEFTMOUSE, 
KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "PAINT_OT_sample_color", RIGHTMOUSE, 
KM_PRESS, 0, 0);
 
+       WM_keymap_add_item(keymap,
+                       "PAINT_OT_vertex_color_set",KKEY, KM_PRESS, KM_SHIFT, 
0);
+
        /* Weight Paint mode */
        keymap= WM_keymap_find(keyconf, "Weight Paint", 0, 0);
        keymap->poll= weight_paint_poll;
@@ -167,6 +171,9 @@
 
        WM_keymap_verify_item(keymap, "PAINT_OT_weight_paint", LEFTMOUSE, 
KM_PRESS, 0, 0);
 
+       WM_keymap_add_item(keymap,
+                       "PAINT_OT_weight_set", KKEY, KM_PRESS, KM_SHIFT, 0);
+
        /* Image/Texture Paint mode */
        keymap= WM_keymap_find(keyconf, "Image Paint", 0, 0);
        keymap->poll= image_texture_paint_poll;

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c    
2009-10-22 09:48:44 UTC (rev 24052)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c    
2009-10-22 12:59:14 UTC (rev 24053)
@@ -197,7 +197,7 @@
        
 }
 
-static unsigned int vpaint_get_current_col(VPaint *vp)
+unsigned int vpaint_get_current_col(VPaint *vp)
 {
        Brush *brush = paint_brush(&vp->paint);
        return rgba_to_mcol(brush->rgb[0], brush->rgb[1], brush->rgb[2], 1.0f);
@@ -269,20 +269,13 @@
        MEM_freeN(scolmain);
 }
 
-void make_vertexcol(Scene *scene, int shade)   /* single ob */
+static void make_vertexcol(Object *ob) /* single ob */
 {
-       Object *ob;
        Mesh *me;
-
-       if(scene->obedit) {
-               error("Unable to perform function in Edit Mode");
-               return;
-       }
-       
-       ob= OBACT;
        if(!ob || ob->id.lib) return;
        me= get_mesh(ob);
        if(me==0) return;
+       if(me->edit_mesh) return;
 
        /* copies from shadedisplist to mcol */
        if(!me->mcol) {
@@ -290,10 +283,11 @@
                mesh_update_customdata_pointers(me);
        }
 
-       if(shade)
-               shadeMeshMCol(scene, ob, me);
-       else

@@ Diff output truncated at 10240 characters. @@

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

Reply via email to