From 23f69cbe92bec250a1b850d379d921c34ecfd6a7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 20 Oct 2009 19:27:27 +0000 Subject: move G_FACESELECT from G.f to mesh->editflag, renamed to ME_EDIT_PAINT_MASK --- source/blender/blenkernel/BKE_global.h | 2 +- source/blender/blenkernel/intern/blender.c | 2 -- source/blender/blenkernel/intern/paint.c | 4 ++-- source/blender/editors/sculpt_paint/paint_image.c | 4 ++-- source/blender/editors/sculpt_paint/paint_vertex.c | 10 +++++----- source/blender/editors/space_view3d/drawobject.c | 2 +- source/blender/editors/space_view3d/view3d_header.c | 4 +++- source/blender/makesdna/DNA_mesh_types.h | 2 ++ source/blender/makesrna/intern/rna_mesh.c | 6 ++++++ 9 files changed, 22 insertions(+), 14 deletions(-) diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index ccd21603c49..dd846038603 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -110,7 +110,7 @@ typedef struct Global { #define G_BACKBUFSEL (1 << 4) #define G_PICKSEL (1 << 5) -#define G_FACESELECT (1 << 8) +/* #define G_FACESELECT (1 << 8) use mesh mode */ #define G_DEBUG (1 << 12) #define G_DOSCRIPTLINKS (1 << 13) diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 7570369827b..94b03730e54 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -226,8 +226,6 @@ static void clear_global(void) // free_vertexpaint(); G.main= NULL; - - G.f &= ~(G_FACESELECT); } /* make sure path names are correct for OS */ diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index f17d2fbdcac..9a8f6d284f3 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -29,6 +29,7 @@ #include "DNA_brush_types.h" #include "DNA_object_types.h" +#include "DNA_mesh_types.h" #include "DNA_scene_types.h" #include "BKE_brush.h" @@ -160,8 +161,7 @@ void paint_brush_slot_remove(Paint *p) int paint_facesel_test(Object *ob) { - return (G.f&G_FACESELECT) && (ob && (ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT))); - + return (ob && (((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_MASK) && (ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT))); } void paint_init(Paint *p, const char col[3]) diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 21651afe417..ebda56274ca 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -3182,7 +3182,7 @@ static void project_paint_begin(ProjPaintState *ps) } #endif - if (tf->tpage && ((G.f & G_FACESELECT)==0 || mf->flag & ME_FACE_SEL)) { + if (tf->tpage && ((((Mesh *)ps->ob->data)->editflag & ME_EDIT_PAINT_MASK)==0 || mf->flag & ME_FACE_SEL)) { float *v1coSS, *v2coSS, *v3coSS, *v4coSS=NULL; @@ -4290,7 +4290,7 @@ static int imapaint_paint_stroke(ViewContext *vc, ImagePaintState *s, BrushPaint if (texpaint) { /* pick new face and image */ if ( imapaint_pick_face(vc, s->me, mval, &newfaceindex) && - ((G.f & G_FACESELECT)==0 || (s->me->mface+newfaceindex)->flag & ME_FACE_SEL) + ((s->me->editflag & ME_EDIT_PAINT_MASK)==0 || (s->me->mface+newfaceindex)->flag & ME_FACE_SEL) ) { ImBuf *ibuf; diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 65893a9ede8..5dd69cdf030 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -203,7 +203,7 @@ static unsigned int vpaint_get_current_col(VPaint *vp) return rgba_to_mcol(brush->rgb[0], brush->rgb[1], brush->rgb[2], 1.0f); } -void do_shared_vertexcol(Mesh *me) +static void do_shared_vertexcol(Mesh *me) { /* if no mcol: do not do */ /* if tface: only the involved faces, otherwise all */ @@ -221,7 +221,7 @@ void do_shared_vertexcol(Mesh *me) mface= me->mface; mcol= (char *)me->mcol; for(a=me->totface; a>0; a--, mface++, mcol+=16) { - if((tface && tface->mode & TF_SHAREDCOL) || (G.f & G_FACESELECT)==0) { + if((tface && tface->mode & TF_SHAREDCOL) || (me->editflag & ME_EDIT_PAINT_MASK)==0) { scol= scolmain+4*mface->v1; scol[0]++; scol[1]+= mcol[1]; scol[2]+= mcol[2]; scol[3]+= mcol[3]; scol= scolmain+4*mface->v2; @@ -251,7 +251,7 @@ void do_shared_vertexcol(Mesh *me) mface= me->mface; mcol= (char *)me->mcol; for(a=me->totface; a>0; a--, mface++, mcol+=16) { - if((tface && tface->mode & TF_SHAREDCOL) || (G.f & G_FACESELECT)==0) { + if((tface && tface->mode & TF_SHAREDCOL) || (me->editflag & ME_EDIT_PAINT_MASK)==0) { scol= scolmain+4*mface->v1; mcol[1]= scol[1]; mcol[2]= scol[2]; mcol[3]= scol[3]; scol= scolmain+4*mface->v2; @@ -1361,7 +1361,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P } } - if((G.f & G_FACESELECT) && me->mface) { + if((me->editflag & ME_EDIT_PAINT_MASK) && me->mface) { for(index=0; indextotface) { MFace *mface= ((MFace *)me->mface) + (indexar[index]-1); @@ -1675,7 +1675,7 @@ static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob, int index int alpha, i; if((vp->flag & VP_COLINDEX && mface->mat_nr!=ob->actcol-1) || - (G.f & G_FACESELECT && !(mface->flag & ME_FACE_SEL))) + ((me->editflag & ME_EDIT_PAINT_MASK) && !(mface->flag & ME_FACE_SEL))) return; if(vp->mode==VP_BLUR) { diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 280a2e4e998..b4ffc022471 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -6121,7 +6121,7 @@ static void bbs_mesh_solid(Scene *scene, View3D *v3d, Object *ob) Mesh *me = (Mesh*)ob->data; MCol *colors; int i,j; - int face_sel_mode = (G.f & G_FACESELECT) ? 1:0; + int face_sel_mode = (me->flag & ME_EDIT_PAINT_MASK) ? 1:0; glColor3ub(0, 0, 0); diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index e6fe8fabc13..8a232b71c36 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -1818,6 +1818,7 @@ static void do_view3d_header_buttons(bContext *C, void *arg, int event) ED_area_tag_redraw(sa); break; case B_VIEW_BUTSEDIT: + ED_area_tag_redraw(sa); break; default: @@ -2031,7 +2032,8 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) } } else { if (obedit==NULL && ((ob && ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)))) { - uiDefIconButBitI(block, TOG, G_FACESELECT, B_VIEW_BUTSEDIT, ICON_FACESEL_HLT,xco,yco,XIC,YIC, &G.f, 0, 0, 0, 0, "Painting Mask (FKey)"); + Mesh *me= ob->data; + uiDefIconButBitS(block, TOG, ME_EDIT_PAINT_MASK, B_VIEW_BUTSEDIT, ICON_FACESEL_HLT,xco,yco,XIC,YIC, &me->editflag, 0, 0, 0, 0, "Painting Mask (FKey)"); header_xco_step(ar, &xco, &yco, &maxco, XIC+10); } else { /* Manipulators aren't used in weight paint mode */ diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h index 0f4dbaa8218..d12d81bb9f7 100644 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@ -121,6 +121,8 @@ typedef struct TFace { #define ME_EDIT_MIRROR_Y (1 << 1) // unused so far #define ME_EDIT_MIRROR_Z (1 << 2) // unused so far +#define ME_EDIT_PAINT_MASK (1 << 3) + /* me->flag */ #define ME_ISDONE 1 #define ME_NOPUNOFLIP 2 diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 039109f75a1..bdf60849a84 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -1615,6 +1615,12 @@ static void rna_def_mesh(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Z Mirror", "Z Axis mirror editing"); */ + prop= RNA_def_property(srna, "use_paint_mask", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "editflag", ME_EDIT_PAINT_MASK); + RNA_def_property_ui_text(prop, "Paint Mask", "Face selection masking for painting"); + + + rna_def_texmat_common(srna, "rna_Mesh_texspace_editable"); RNA_api_mesh(srna); -- cgit v1.2.3