diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/include/ED_mesh.h | 1 | ||||
-rw-r--r-- | source/blender/editors/mesh/editface.c | 43 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image.c | 5 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_intern.h | 13 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_ops.c | 19 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_vertex.c | 88 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_select.c | 4 |
7 files changed, 108 insertions, 65 deletions
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 01444c0ecfb..991f87707c8 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -165,6 +165,7 @@ void EM_automerge(struct Scene *scene, struct Object *obedit, int update); /* 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 */ diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index 8f9dea00a1b..3b15593916c 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -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 @@ void object_facesel_flush_dm(Object *ob) } /* 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 @@ void seam_mark_clear_tface(Scene *scene, short mode) // 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 @@ void face_select(Scene *scene, View3D *v3d) 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 @@ void face_select(Scene *scene, View3D *v3d) /* 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) diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index ebda56274ca..92ef8ae8fd1 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -5252,3 +5252,8 @@ void PAINT_OT_texture_paint_radial_control(wmOperatorType *ot) } +int facemask_paint_poll(bContext *C) +{ + Object *obact = CTX_data_active_object(C); + return paint_facesel_test(obact); +} diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index 8251d1a5a1a..d1ecc3e4dc0 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -40,20 +40,21 @@ struct wmEvent; 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 weight_paint_poll(struct bContext *C); 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 imapaint_pick_uv(struct Scene *scene, struct Object *ob, struct Mesh *mesh, 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 */ diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 11dbeffdb22..8184471c8d8 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -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 @@ static int brush_add_exec(bContext *C, wmOperator *op) if(br) paint_brush_set(paint_get_active(CTX_data_scene(C)), br); - + return OPERATOR_FINISHED; } @@ -81,11 +82,12 @@ void BRUSH_OT_add(wmOperatorType *ot) 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 @@ void PAINT_OT_vertex_color_set(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - - RNA_def_boolean(ot->srna, "selected", 0, "Type", "Only color selected faces."); } /**************************** registration **********************************/ @@ -126,6 +126,7 @@ void ED_operatortypes_paint(void) 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 @@ void ED_keymap_paint(wmKeyConfig *keyconf) 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 @@ void ED_keymap_paint(wmKeyConfig *keyconf) 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; diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 4f38e1e0c84..1dac98780da 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -197,7 +197,7 @@ unsigned int rgba_to_mcol(float r, float g, float b, float a) } -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 @@ static void do_shared_vertexcol(Mesh *me) 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 @@ void make_vertexcol(Scene *scene, int shade) /* single ob */ mesh_update_customdata_pointers(me); } - if(shade) - shadeMeshMCol(scene, ob, me); - else - memset(me->mcol, 255, 4*sizeof(MCol)*me->totface); + //if(shade) + // shadeMeshMCol(scene, ob, me); + //else + + memset(me->mcol, 255, 4*sizeof(MCol)*me->totface); DAG_id_flush_update(&me->id, OB_RECALC_DATA); @@ -330,22 +324,20 @@ static void copy_wpaint_prev (VPaint *wp, MDeformVert *dverts, int dcount) } -void clear_vpaint(Scene *scene, int selected) +void vpaint_fill(Object *ob, unsigned int paintcol) { Mesh *me; MFace *mf; - Object *ob; - unsigned int paintcol, *mcol; - int i; + unsigned int *mcol; + int i, selected; - ob= OBACT; me= get_mesh(ob); if(me==0 || me->totface==0) return; if(!me->mcol) - make_vertexcol(scene, 0); + make_vertexcol(ob); - paintcol= vpaint_get_current_col(scene->toolsettings->vpaint); + selected= (me->editflag & ME_EDIT_PAINT_MASK); mf = me->mface; mcol = (unsigned int*)me->mcol; @@ -363,30 +355,34 @@ void clear_vpaint(Scene *scene, int selected) /* fills in the selected faces with the current weight and vertex group */ -void clear_wpaint_selectedfaces(Scene *scene) +void wpaint_fill(VPaint *wp, Object *ob, float paintweight) { - ToolSettings *ts= scene->toolsettings; - VPaint *wp= ts->wpaint; - float paintweight= ts->vgroup_weight; Mesh *me; MFace *mface; - Object *ob; MDeformWeight *dw, *uw; int *indexar; int index, vgroup; unsigned int faceverts[5]={0,0,0,0,0}; unsigned char i; int vgroup_mirror= -1; + int selected; - ob= OBACT; me= ob->data; if(me==0 || me->totface==0 || me->dvert==0 || !me->mface) return; + selected= (me->editflag & ME_EDIT_PAINT_MASK); + indexar= get_indexarray(); - for(index=0, mface=me->mface; index<me->totface; index++, mface++) { - if((mface->flag & ME_FACE_SEL)==0) - indexar[index]= 0; - else + if(selected) { + for(index=0, mface=me->mface; index<me->totface; index++, mface++) { + if((mface->flag & ME_FACE_SEL)==0) + indexar[index]= 0; + else + indexar[index]= index+1; + } + } + else { + for(index=0; index<me->totface; index++) indexar[index]= index+1; } @@ -1528,6 +1524,32 @@ void PAINT_OT_weight_paint(wmOperatorType *ot) RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", ""); } +static int weight_paint_set_exec(bContext *C, wmOperator *op) +{ + struct Scene *scene= CTX_data_scene(C); + Object *obact = CTX_data_active_object(C); + + wpaint_fill(scene->toolsettings->wpaint, obact, scene->toolsettings->vgroup_weight); + ED_region_tag_redraw(CTX_wm_region(C)); // XXX - should redraw all 3D views + return OPERATOR_FINISHED; +} + +void PAINT_OT_weight_set(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Weight Set"; + ot->idname= "PAINT_OT_weight_set"; + + /* api callbacks */ + ot->exec= weight_paint_set_exec; + ot->poll= facemask_paint_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend selection instead of deselecting everything first."); +} + /* ************ set / clear vertex paint mode ********** */ @@ -1551,7 +1573,7 @@ static int set_vpaint(bContext *C, wmOperator *op) /* toggle */ return OPERATOR_FINISHED; } - if(me && me->mcol==NULL) make_vertexcol(scene, 0); + if(me && me->mcol==NULL) make_vertexcol(ob); /* toggle: end vpaint */ if(ob->mode & OB_MODE_VERTEX_PAINT) { @@ -1642,7 +1664,7 @@ static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, wmEvent me= get_mesh(ob); if(me==NULL || me->totface==0) return OPERATOR_PASS_THROUGH; - if(me->mcol==NULL) make_vertexcol(CTX_data_scene(C), 0); + if(me->mcol==NULL) make_vertexcol(ob); if(me->mcol==NULL) return OPERATOR_CANCELLED; /* make mode data storage */ diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 8dc7d6a0518..adb40a017ba 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1631,7 +1631,9 @@ static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event) } else if(obact && obact->mode & OB_MODE_PARTICLE_EDIT) PE_mouse_particles(C, event->mval, extend); - else + else if(obact && paint_facesel_test(obact)) + face_select(C, obact, event->mval, extend); + else mouse_select(C, event->mval, extend, center, enumerate); /* allowing tweaks */ |