Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-11-02 04:51:21 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-11-02 04:51:21 +0400
commit43e297c0c0cd18b0a9666fa55a4dc9411911ef24 (patch)
tree2bc24674ca5318eaf8802a848a12c1df489c4022 /source
parentb60f60453b6b70950257b269574aa51f00d55511 (diff)
minor cleanup for weightpaint fill
- SCE_SELECT_FACE and SCE_SELECT_VERTEX are mutually exclusive, use a macro to get a single value from them. - was allocating an array for no reason.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c102
-rw-r--r--source/blender/makesdna/DNA_mesh_types.h8
2 files changed, 48 insertions, 62 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 3e2c4666528..57f926b0612 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -387,37 +387,16 @@ void vpaint_fill(Object *ob, unsigned int paintcol)
/* fills in the selected faces with the current weight and vertex group */
void wpaint_fill(VPaint *wp, Object *ob, float paintweight)
{
- Mesh *me;
+ Mesh *me= ob->data;
+ MFace *mf;
MDeformWeight *dw, *uw;
- int *indexar;
- unsigned int index;
int vgroup, vgroup_mirror= -1;
- int selected;
-
- int use_vert_sel;
-
- me= ob->data;
- if(me==NULL || me->totface==0 || me->dvert==NULL || !me->mface) return;
-
- selected= (me->editflag & ME_EDIT_PAINT_MASK);
-
- use_vert_sel= (me->editflag & ME_EDIT_VERT_SEL) != 0;
+ unsigned int index;
- indexar= get_indexarray(me);
+ /* mutually exclusive, could be made into a */
+ const short paint_selmode= ME_EDIT_PAINT_SEL_MODE(me);
- if(selected) {
- MFace *mf;
- for(index=0, mf= me->mface; index<me->totface; index++, mf++) {
- if((mf->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;
- }
+ if(me->totface==0 || me->dvert==NULL || !me->mface) return;
vgroup= ob->actdef-1;
@@ -428,47 +407,47 @@ void wpaint_fill(VPaint *wp, Object *ob, float paintweight)
copy_wpaint_prev(wp, me->dvert, me->totvert);
- for(index=0; index<me->totface; index++) {
- if(indexar[index] && indexar[index]<=me->totface) {
- MFace *mf= &me->mface[indexar[index]-1];
- unsigned int fidx= mf->v4 ? 3:2;
+ for(index=0, mf= me->mface; index < me->totface; index++, mf++) {
+ unsigned int fidx= mf->v4 ? 3:2;
- do {
- unsigned int vidx= *(&mf->v1 + fidx);
+ if ((paint_selmode == SCE_SELECT_FACE) && !(mf->flag & ME_FACE_SEL)) {
+ continue;
+ }
- if(!me->dvert[vidx].flag) {
- if(use_vert_sel && !(me->mvert[vidx].flag & SELECT)) {
- continue;
- }
+ do {
+ unsigned int vidx= *(&mf->v1 + fidx);
- dw= defvert_verify_index(&me->dvert[vidx], vgroup);
- if(dw) {
- uw= defvert_verify_index(wp->wpaint_prev+vidx, vgroup);
- uw->weight= dw->weight; /* set the undo weight */
- dw->weight= paintweight;
-
- if(me->editflag & ME_EDIT_MIRROR_X) { /* x mirror painting */
- int j= mesh_get_x_mirror_vert(ob, vidx);
- if(j>=0) {
- /* copy, not paint again */
- if(vgroup_mirror != -1) {
- dw= defvert_verify_index(me->dvert+j, vgroup_mirror);
- uw= defvert_verify_index(wp->wpaint_prev+j, vgroup_mirror);
- } else {
- dw= defvert_verify_index(me->dvert+j, vgroup);
- uw= defvert_verify_index(wp->wpaint_prev+j, vgroup);
- }
- uw->weight= dw->weight; /* set the undo weight */
- dw->weight= paintweight;
+ if(!me->dvert[vidx].flag) {
+ if((paint_selmode == SCE_SELECT_VERTEX) && !(me->mvert[vidx].flag & SELECT)) {
+ continue;
+ }
+
+ dw= defvert_verify_index(&me->dvert[vidx], vgroup);
+ if(dw) {
+ uw= defvert_verify_index(wp->wpaint_prev+vidx, vgroup);
+ uw->weight= dw->weight; /* set the undo weight */
+ dw->weight= paintweight;
+
+ if(me->editflag & ME_EDIT_MIRROR_X) { /* x mirror painting */
+ int j= mesh_get_x_mirror_vert(ob, vidx);
+ if(j>=0) {
+ /* copy, not paint again */
+ if(vgroup_mirror != -1) {
+ dw= defvert_verify_index(me->dvert+j, vgroup_mirror);
+ uw= defvert_verify_index(wp->wpaint_prev+j, vgroup_mirror);
+ } else {
+ dw= defvert_verify_index(me->dvert+j, vgroup);
+ uw= defvert_verify_index(wp->wpaint_prev+j, vgroup);
}
+ uw->weight= dw->weight; /* set the undo weight */
+ dw->weight= paintweight;
}
}
- me->dvert[vidx].flag= 1;
}
+ me->dvert[vidx].flag= 1;
+ }
-
- } while (fidx--);
- }
+ } while (fidx--);
}
{
@@ -477,8 +456,7 @@ void wpaint_fill(VPaint *wp, Object *ob, float paintweight)
dv->flag= 0;
}
}
-
- MEM_freeN(indexar);
+
copy_wpaint_prev(wp, NULL, 0);
DAG_id_tag_update(&me->id, 0);
diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h
index ece6c84b0e8..bb67b46a7e5 100644
--- a/source/blender/makesdna/DNA_mesh_types.h
+++ b/source/blender/makesdna/DNA_mesh_types.h
@@ -125,6 +125,14 @@ typedef struct TFace {
#define ME_EDIT_MIRROR_TOPO (1 << 4)
#define ME_EDIT_VERT_SEL (1 << 5)
+/* we cant have both flags enabled at once,
+ * flags defined in DNA_scene_types.h */
+#define ME_EDIT_PAINT_SEL_MODE(_me) ( \
+ (_me->editflag & ME_EDIT_PAINT_MASK) ? SCE_SELECT_FACE : \
+ (_me->editflag & ME_EDIT_VERT_SEL) ? SCE_SELECT_VERTEX : \
+ 0 \
+ )
+
/* me->flag */
/* #define ME_ISDONE 1 */
#define ME_DEPRECATED 2