edits to radish before merge with trunk

- removed some unused functions.
- renamed vars to make more sense paint_vertex.c 'flags' --> 'lock_flags'
- some odd modifications were made in unrealted, commented code, copy these back from trunk.
- rename vertex_group_fix 'cp' property to 'accuracy'
- make style more consistant with trunk.
- remove 'Radish' comments.
This commit is contained in:
2011-09-19 02:43:03 +00:00
parent 73863a1da5
commit a89b253aa6
19 changed files with 140 additions and 171 deletions

View File

@@ -1072,7 +1072,6 @@ class VIEW3D_MT_paint_weight(Menu):
layout.operator("object.vertex_group_invert", text="Invert")
layout.operator("object.vertex_group_clean", text="Clean")
layout.operator("object.vertex_group_levels", text="Levels")
# Radish
layout.operator("object.vertex_group_fix", text="Fix Deforms")
layout.separator()

View File

@@ -646,7 +646,6 @@ class VIEW3D_PT_tools_brush(PaintPanel, Panel):
elif context.weight_paint_object and brush:
layout.prop(context.tool_settings, "vertex_group_weight", text="Weight", slider=True)
layout.prop(context.tool_settings, "use_auto_normalize", text="Auto Normalize")
# Radish
layout.prop(context.tool_settings, "use_multipaint", text="Multi-Paint")
col = layout.column()

View File

@@ -59,8 +59,8 @@ void paint_brush_set(struct Paint *paint, struct Brush *br);
* Texture paint could be removed since selected faces are not used
* however hiding faces is useful */
int paint_facesel_test(struct Object *ob);
int paint_vertsel_test(struct Object *ob);
/* Session data (mode-specific) */
typedef struct SculptSession {

View File

@@ -40,9 +40,7 @@
#include "DNA_cloth_types.h"
#include "DNA_key_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_armature_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h" // N_T
@@ -1760,7 +1758,6 @@ static void add_weight_mcol_dm(Object *ob, DerivedMesh *dm, int const draw_flag)
ColorBand *coba= stored_cb; /* warning, not a local var */
unsigned char *wtcol;
int i;
int defbase_len = BLI_countlist(&ob->defbase);
char *defbase_sel = MEM_mallocN(defbase_len * sizeof(char), __func__);
@@ -1807,7 +1804,6 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
int has_multires = mmd != NULL, multires_applied = 0;
int sculpt_mode = ob->mode & OB_MODE_SCULPT && ob->sculpt;
int draw_flag= ((scene->toolsettings->multipaint ? CALC_WP_MULTIPAINT : 0) |
(scene->toolsettings->auto_normalize ? CALC_WP_AUTO_NORMALIZE : 0));

View File

@@ -2870,7 +2870,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra)
PARTICLE_P;
float birthtime = 0.0, dietime = 0.0;
float t, time = 0.0, dfra = 1.0 /* frs_sec = sim->scene->r.frs_sec*/ /*UNUSED*/;
float t, time = 0.0, dfra = 1.0 /* , frs_sec = sim->scene->r.frs_sec*/ /*UNUSED*/;
float col[4] = {0.5f, 0.5f, 0.5f, 1.0f};
float prev_tangent[3] = {0.0f, 0.0f, 0.0f}, hairmat[4][4];
float rotmat[3][3];

View File

@@ -657,26 +657,41 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource,
int *vertsflipped = NULL, *mask= NULL;
int a, totface, j, bbone, firstsegment, lastsegment;
MVert *mv = me->mvert;
MVert *mvert = me->mvert;
int use_vert_sel= FALSE;
int use_face_sel= FALSE;
*err_str= NULL;
/* count triangles and create mask */
if((me->editflag & ME_EDIT_PAINT_MASK) || (use_vert_sel= ((me->editflag & ME_EDIT_VERT_SEL) != 0)))
if( (use_face_sel= (me->editflag & ME_EDIT_PAINT_MASK) != 0) ||
(use_vert_sel= ((me->editflag & ME_EDIT_VERT_SEL) != 0)))
{
mask= MEM_callocN(sizeof(int)*me->totvert, "heat_bone_weighting mask");
}
for(totface=0, a=0, mface=me->mface; a<me->totface; a++, mface++) {
totface++;
if(mface->v4) totface++;
/* (added selectedVerts content for vertex mask, they used to just equal 1) */
if(mask && ((mface->flag & ME_FACE_SEL) || use_vert_sel)) {
mask[mface->v1]= use_vert_sel ? ((mv+mface->v1)->flag & 1): 1;
mask[mface->v2]= use_vert_sel ? ((mv+mface->v2)->flag & 1): 1;
mask[mface->v3]= use_vert_sel ? ((mv+mface->v3)->flag & 1): 1;
if(mface->v4)
mask[mface->v4]= use_vert_sel ? ((mv+mface->v4)->flag & 1): 1;
if(use_vert_sel) {
mask[mface->v1]= (mvert[mface->v1].flag & SELECT) != 0;
mask[mface->v2]= (mvert[mface->v2].flag & SELECT) != 0;
mask[mface->v3]= (mvert[mface->v3].flag & SELECT) != 0;
if(mface->v4) {
mask[mface->v4]= (mvert[mface->v4].flag & SELECT) != 0;
}
}
else {
if(use_face_sel) {
mask[mface->v1]= 1;
mask[mface->v2]= 1;
mask[mface->v3]= 1;
if(mface->v4) {
mask[mface->v4]= 1;
}
}
}
}

View File

@@ -216,9 +216,6 @@ void ED_view3d_project_float(struct ARegion *a, const float vec[3], float adr[2]
void ED_view3d_calc_camera_border(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, struct RegionView3D *rv3d, struct rctf *viewborder_r, short do_shift);
/* drawobject.c iterators */
void mesh_obmode_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData, struct MVert *mv, int x, int y, int index), void *userData, int clipVerts);
void mesh_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData, struct EditVert *eve, int x, int y, int index), void *userData, int clipVerts);
void mesh_foreachScreenEdge(struct ViewContext *vc, void (*func)(void *userData, struct EditEdge *eed, int x0, int y0, int x1, int y1, int index), void *userData, int clipVerts);
void mesh_foreachScreenFace(struct ViewContext *vc, void (*func)(void *userData, struct EditFace *efa, int x, int y, int index), void *userData);

View File

@@ -3778,7 +3778,7 @@ static int ui_numedit_but_WAVEFORM(uiBut *but, uiHandleButtonData *data, int mx,
Scopes *scopes = (Scopes *)but->poin;
/* rcti rect; */
int changed= 1;
float /* dx, */ dy /* yfac=1.f */; /* UNUSED */
float /* dx, */ dy /* , yfac=1.f */; /* UNUSED */
/* rect.xmin= but->x1; rect.xmax= but->x2; */
/* rect.ymin= but->y1; rect.ymax= but->y2; */

View File

@@ -2124,7 +2124,6 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe
//uiItemR(row, itemptr, "mute", 0, "", ICON_MUTE_IPO_OFF);
uiBlockSetEmboss(block, UI_EMBOSS);
}
/* I need the RNA struct for vertex groups */
else if(itemptr->type == &RNA_VertexGroup) {
bDeformGroup *dg= (bDeformGroup *)itemptr->data;
uiItemL(sub, name, icon);

View File

@@ -1967,28 +1967,33 @@ void paintvert_flush_flags(Object *ob)
{
Mesh *me= get_mesh(ob);
DerivedMesh *dm= ob->derivedFinal;
MVert *verts, *mv, *mv_orig;
MVert *dm_mvert, *dm_mv;
int *index_array = NULL;
int totvert;
int i;
if(me==NULL || dm==NULL)
return;
index_array = dm->getVertDataArray(dm, CD_ORIGINDEX);
verts = dm->getVertArray(dm);
dm_mvert = dm->getVertArray(dm);
totvert = dm->getNumVerts(dm);
mv= verts;
for (i= 0; i<totvert; i++, mv++) { /* loop over derived mesh faces */
if(index_array) {
mv_orig= me->mvert + index_array[i];
mv->flag= mv_orig->flag;
} else {
mv_orig= me->mvert + i;
mv->flag= mv_orig->flag;
dm_mv= dm_mvert;
if(index_array) {
int orig_index;
for (i= 0; i<totvert; i++, dm_mv++) {
orig_index= index_array[i];
if(orig_index != ORIGINDEX_NONE) {
dm_mv->flag= me->mvert[index_array[i]].flag;
}
}
}
else {
for (i= 0; i<totvert; i++, dm_mv++) {
dm_mv->flag= me->mvert[i].flag;
}
}
}

View File

@@ -200,10 +200,8 @@ void OBJECT_OT_vertex_group_copy(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_normalize(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_normalize_all(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_levels(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_lock(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_fix(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_invert(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_blend(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_clean(struct wmOperatorType *ot);

View File

@@ -174,10 +174,8 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_vertex_group_copy);
WM_operatortype_append(OBJECT_OT_vertex_group_normalize);
WM_operatortype_append(OBJECT_OT_vertex_group_normalize_all);
WM_operatortype_append(OBJECT_OT_vertex_group_lock);
WM_operatortype_append(OBJECT_OT_vertex_group_fix);
WM_operatortype_append(OBJECT_OT_vertex_group_invert);
WM_operatortype_append(OBJECT_OT_vertex_group_levels);
WM_operatortype_append(OBJECT_OT_vertex_group_blend);

View File

@@ -719,7 +719,7 @@ static void vgroup_normalize(Object *ob)
for(i = 0; i < dvert_tot; i++) {
if(use_vert_sel && !((mvert+i)->flag & SELECT)) {
if(use_vert_sel && !(mvert[i].flag & SELECT)) {
continue;
}
@@ -733,7 +733,7 @@ static void vgroup_normalize(Object *ob)
if(weight_max > 0.0f) {
for(i = 0; i < dvert_tot; i++) {
if(use_vert_sel && !((mvert+i)->flag & SELECT)) {
if(use_vert_sel && !(mvert[i].flag & SELECT)) {
continue;
}
@@ -1167,7 +1167,7 @@ static void vgroup_levels(Object *ob, float offset, float gain)
for(i = 0; i < dvert_tot; i++) {
if(use_vert_sel && !((mvert+i)->flag & SELECT)) {
if(use_vert_sel && !(mvert[i].flag & SELECT)) {
continue;
}
@@ -1207,7 +1207,7 @@ static void vgroup_normalize_all(Object *ob, int lock_active)
float lock_iweight= 1.0f;
int j;
if(use_vert_sel && !((mvert+i)->flag & SELECT)) {
if(use_vert_sel && !(mvert[i].flag & SELECT)) {
continue;
}
@@ -1251,7 +1251,7 @@ static void vgroup_normalize_all(Object *ob, int lock_active)
for(i = 0; i < dvert_tot; i++) {
int j;
if(use_vert_sel && !((mvert+i)->flag & SELECT)) {
if(use_vert_sel && !(mvert[i].flag & SELECT)) {
continue;
}
@@ -1332,7 +1332,7 @@ static void vgroup_invert(Object *ob, int auto_assign, int auto_remove)
for(i = 0; i < dvert_tot; i++) {
if(use_vert_sel && !((mvert+i)->flag & SELECT)) {
if(use_vert_sel && !(mvert[i].flag & SELECT)) {
continue;
}
dvert = dvert_array[i];
@@ -1461,7 +1461,7 @@ static void vgroup_clean(Object *ob, float eul, int keep_single)
for(i = 0; i < dvert_tot; i++) {
if(use_vert_sel && !((mvert+i)->flag & SELECT)) {
if(use_vert_sel && !(mvert[i].flag & SELECT)) {
continue;
}
dvert = dvert_array[i];
@@ -1496,7 +1496,7 @@ static void vgroup_clean_all(Object *ob, float eul, int keep_single)
for(i = 0; i < dvert_tot; i++) {
int j;
if(use_vert_sel && !((mvert+i)->flag & SELECT)) {
if(use_vert_sel && !(mvert[i].flag & SELECT)) {
continue;
}
@@ -2325,10 +2325,10 @@ static int vertex_group_fix_exec(bContext *C, wmOperator *op)
Object *ob= CTX_data_active_object(C);
Scene *scene= CTX_data_scene(C);
float distToBe= RNA_float_get(op->ptr,"dist");
float strength= RNA_float_get(op->ptr,"strength");
float cp= RNA_float_get(op->ptr,"cp");
ModifierData *md = ob->modifiers.first;
float distToBe= RNA_float_get(op->ptr, "dist");
float strength= RNA_float_get(op->ptr, "strength");
float cp= RNA_float_get(op->ptr, "accuracy");
ModifierData *md= ob->modifiers.first;
while(md) {
if(md->type == eModifierType_Mirror && (md->mode&eModifierMode_Realtime)) {
@@ -2365,7 +2365,7 @@ void OBJECT_OT_vertex_group_fix(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_float(ot->srna, "dist", 0.0f, -FLT_MAX, FLT_MAX, "Distance", "The distance to move to.", -10.0f, 10.0f);
RNA_def_float(ot->srna, "strength", 1.f, -2.0f, FLT_MAX, "Strength", "The distance moved can be changed by this multiplier.", -2.0f, 2.0f);
RNA_def_float(ot->srna, "cp", 1.0f, 0.05f, FLT_MAX, "Change Sensitivity", "Changes the amount weights are altered with each iteration: lower values are slower.", 0.05f, 1.f);
RNA_def_float(ot->srna, "accuracy", 1.0f, 0.05f, FLT_MAX, "Change Sensitivity", "Changes the amount weights are altered with each iteration: lower values are slower.", 0.05f, 1.f);
}

View File

@@ -443,8 +443,8 @@ void wpaint_fill(VPaint *wp, Object *ob, float paintweight)
faceverts[3]= mface->v4;
for (i=0; i<3 || faceverts[i]; i++) {
if(!me->dvert[faceverts[i]].flag) {
if(use_vert_sel && ((me->mvert[faceverts[i]].flag & SELECT) == 0)) {
if(use_vert_sel && !(me->mvert[faceverts[i]].flag & SELECT)) {
continue;
}
@@ -1147,11 +1147,11 @@ static void do_weight_paint_auto_normalize_all_groups(MDeformVert *dvert, char *
/*
See if the current deform vertex has a locked group
*/
static char has_locked_group(MDeformVert *dvert, char *flags)
static char has_locked_group(MDeformVert *dvert, char *lock_flags)
{
int i;
for(i = 0; i < dvert->totweight; i++) {
if(flags[(dvert->dw+i)->def_nr] && (dvert->dw+i)->weight > 0.0f) {
if(lock_flags[dvert->dw[i].def_nr] && dvert->dw[i].weight > 0.0f) {
return TRUE;
}
}
@@ -1166,25 +1166,25 @@ static char *gen_lck_flags(Object* ob, int defbase_len)
char is_locked = FALSE;
int i;
//int defbase_len = BLI_countlist(&ob->defbase);
char *flags = MEM_mallocN(defbase_len*sizeof(char), "defflags");
char *lock_flags = MEM_mallocN(defbase_len*sizeof(char), "defflags");
bDeformGroup *defgroup;
for(i = 0, defgroup = ob->defbase.first; i < defbase_len && defgroup; defgroup = defgroup->next, i++) {
flags[i] = ((defgroup->flag & DG_LOCK_WEIGHT) != 0);
is_locked |= flags[i];
lock_flags[i] = ((defgroup->flag & DG_LOCK_WEIGHT) != 0);
is_locked |= lock_flags[i];
}
if(is_locked){
return flags;
return lock_flags;
}
// don't forget to free it if it is unneeded
MEM_freeN(flags);
MEM_freeN(lock_flags);
return NULL;
}
static int has_locked_group_selected(int defbase_len, char *defbase_sel, char *flags) {
static int has_locked_group_selected(int defbase_len, char *defbase_sel, char *lock_flags) {
int i;
for(i = 0; i < defbase_len; i++) {
if(defbase_sel[i] && flags[i]) {
if(defbase_sel[i] && lock_flags[i]) {
return TRUE;
}
}
@@ -1193,13 +1193,13 @@ static int has_locked_group_selected(int defbase_len, char *defbase_sel, char *f
#if 0 /* UNUSED */
static int has_unselected_unlocked_bone_group(int defbase_len, char *defbase_sel, int selected, char *flags, char *bone_groups) {
static int has_unselected_unlocked_bone_group(int defbase_len, char *defbase_sel, int selected, char *lock_flags, char *bone_groups) {
int i;
if(defbase_len == selected) {
return FALSE;
}
for(i = 0; i < defbase_len; i++) {
if(bone_groups[i] && !defbase_sel[i] && !flags[i]) {
if(bone_groups[i] && !defbase_sel[i] && !lock_flags[i]) {
return TRUE;
}
}
@@ -1289,7 +1289,7 @@ static float redistribute_change(MDeformVert *ndv, char *change_status, int chan
// observe the changes made to the weights of groups.
// make sure all locked groups on the vertex have the same deformation
// by moving the changes made to groups onto other unlocked groups
static void enforce_locks(MDeformVert *odv, MDeformVert *ndv, int defbase_len, char *flags, char *bone_groups, char *validmap) {
static void enforce_locks(MDeformVert *odv, MDeformVert *ndv, int defbase_len, char *lock_flags, char *bone_groups, char *validmap) {
float totchange = 0.0f;
float totchange_allowed = 0.0f;
float left_over;
@@ -1307,7 +1307,7 @@ static void enforce_locks(MDeformVert *odv, MDeformVert *ndv, int defbase_len, c
char *change_status;
char new_weight_has_zero = FALSE;
if(!flags || !has_locked_group(ndv, flags)) {
if(!lock_flags || !has_locked_group(ndv, lock_flags)) {
return;
}
// record if a group was changed, unlocked and not changed, or locked
@@ -1318,7 +1318,7 @@ static void enforce_locks(MDeformVert *odv, MDeformVert *ndv, int defbase_len, c
odw = defvert_find_index(odv, i);
// the weights are zero, so we can assume a lot
if(!ndw || !odw) {
if (!flags[i] && bone_groups[i]){
if (!lock_flags[i] && bone_groups[i]){
defvert_verify_index(odv, i);
defvert_verify_index(ndv, i);
total_valid++;
@@ -1327,15 +1327,17 @@ static void enforce_locks(MDeformVert *odv, MDeformVert *ndv, int defbase_len, c
continue;
}
// locked groups should not be changed
if(flags[i]) {
if(lock_flags[i]) {
ndw->weight = odw->weight;
} else if(ndw->weight != odw->weight) { // changed groups are handled here
totchange += ndw->weight-odw->weight;
}
else if(ndw->weight != odw->weight) { // changed groups are handled here
totchange += ndw->weight - odw->weight;
change_status[i] = 2; // was altered already
total_changed++;
if(ndw->weight == 0) {
new_weight_has_zero = TRUE;
} else if(designatedw == -1){
}
else if(designatedw == -1){
designatedw = i;
}
} // unchanged, unlocked bone groups are handled here
@@ -1357,17 +1359,19 @@ static void enforce_locks(MDeformVert *odv, MDeformVert *ndv, int defbase_len, c
// on whether or not you are painting the weight(s) up or down
if(totchange < 0) {
totchange_allowed = total_valid - totchange_allowed;
} else {
}
else {
totchange_allowed *= -1;
}
left_over = 0;
if(fabs(totchange_allowed) < fabs(totchange)) {
if(fabsf(totchange_allowed) < fabsf(totchange)) {
// this amount goes back onto the changed, unlocked weights
left_over = fabs(fabs(totchange)-fabs(totchange_allowed));
left_over = fabsf(fabsf(totchange) - fabsf(totchange_allowed));
if(totchange > 0) {
left_over *= -1;
}
}else {
}
else {
// all of the change will be permitted
totchange_allowed = -totchange;
}
@@ -1389,7 +1393,7 @@ static void enforce_locks(MDeformVert *odv, MDeformVert *ndv, int defbase_len, c
ndw->weight = (totchange_allowed + odw->weight + odw2->weight)/(1 + ndw2->weight/ndw->weight);
designatedw_changed = TRUE;
}
ndw2->weight = ndw->weight*ndw2->weight/storedw;
ndw2->weight = ndw->weight * ndw2->weight / storedw;
}
}
}
@@ -1399,10 +1403,11 @@ static void enforce_locks(MDeformVert *odv, MDeformVert *ndv, int defbase_len, c
redistribute_change(ndv, change_status, 2, -2, validmap, left_over, total_changed);
}
}
} else {
}
else {
// reset the weights
for(i = 0; i < ndv->totweight; i++) {
(ndv->dw+i)->weight = (odv->dw+i)->weight;
ndv->dw[i].weight = odv->dw[i].weight;
}
}
}
@@ -1416,7 +1421,7 @@ static float get_mp_change(MDeformVert *odv, char *defbase_sel, float brush_chan
int i;
MDeformWeight *dw;
for(i=0; i < odv->totweight; i++) {
if(defbase_sel[(dw = (odv->dw+i))->def_nr]) {
if(defbase_sel[(dw= &odv->dw[i])->def_nr]) {
selwsum += dw->weight;
}
}
@@ -1433,14 +1438,10 @@ static void reset_to_prev(MDeformVert *wv, MDeformVert *dv) {
MDeformWeight *d;
MDeformWeight *w;
for(i = 0; i < dv->totweight; i++) {
d = dv->dw+i;
w = defvert_find_index(wv, d->def_nr);
// if there was no w when there is a d, then the old weight was 0
if(w) {
d->weight = w->weight;
} else {
d->weight = 0;
}
d= &dv->dw[i];
w= defvert_find_index(wv, d->def_nr);
/* if there was no w when there is a d, then the old weight was 0 */
d->weight = w ? w->weight : 0.0f;
}
}
@@ -1453,38 +1454,41 @@ static void clamp_weights(MDeformVert *dvert) {
/* fresh start to make multi-paint and locking modular */
/* returns TRUE if it thinks you need to reset the weights due to normalizing while multi-painting */
static int apply_mp_lcks_normalize(Mesh *me, int index, MDeformWeight *dw, MDeformWeight *tdw, int defbase_len, float change, float oldChange, float oldw, float neww, char *defbase_sel, int selected, char *bone_groups, char *validmap, char *flags, int multipaint) {
static int apply_mp_lcks_normalize(Mesh *me, int index, MDeformWeight *dw, MDeformWeight *tdw, int defbase_len, float change, float oldChange, float oldw, float neww, char *defbase_sel, int selected, char *bone_groups, char *validmap, char *lock_flags, int multipaint)
{
MDeformVert *dvert = me->dvert+index;
MDeformVert dv= {NULL};
dv.dw= MEM_dupallocN(dvert->dw);
dv.flag = dvert->flag;
dv.totweight = dvert->totweight;
// do not multi-paint if a locked group is selected or the active group is locked
// !flags[dw->def_nr] helps if nothing is selected, but active group is locked
if((flags == NULL) || (has_locked_group_selected(defbase_len, defbase_sel, flags) == FALSE && flags[dw->def_nr] == FALSE)) {
/* do not multi-paint if a locked group is selected or the active group is locked
* !lock_flags[dw->def_nr] helps if nothing is selected, but active group is locked */
if((lock_flags == NULL) || (lock_flags[dw->def_nr] == FALSE && has_locked_group_selected(defbase_len, defbase_sel, lock_flags) == FALSE)) {
if(multipaint && selected > 1) {
if(change && change!=1) {
multipaint_selection(dvert, change, defbase_sel, defbase_len);
}
} else {// this lets users paint normally, but don't let them paint locked groups
}
else { /* this lets users paint normally, but don't let them paint locked groups */
dw->weight = neww;
}
}
clamp_weights(dvert);
enforce_locks(&dv, dvert, defbase_len, flags, bone_groups, validmap);
enforce_locks(&dv, dvert, defbase_len, lock_flags, bone_groups, validmap);
do_weight_paint_auto_normalize_all_groups(dvert, validmap);
if(oldChange && multipaint && selected > 1) {
if(tdw->weight != oldw) {
if( neww > oldw ) {
if(neww > oldw) {
if(tdw->weight <= oldw) {
MEM_freeN(dv.dw);
return TRUE;
}
} else {
}
else {
if(tdw->weight >= oldw) {
MEM_freeN(dv.dw);
return TRUE;
@@ -1496,13 +1500,13 @@ static int apply_mp_lcks_normalize(Mesh *me, int index, MDeformWeight *dw, MDefo
return FALSE;
}
// within the current dvert index, get the dw that is selected and has a weight above 0
// this helps multi-paint
/* within the current dvert index, get the dw that is selected and has a weight
* above 0, this helps multi-paint */
static int get_first_selected_nonzero_weight(MDeformVert *dvert, char *defbase_sel) {
int i;
MDeformWeight *dw;
for(i=0; i< dvert->totweight; i++) {
dw = dvert->dw+i;
dw = &dvert->dw[i];
if(defbase_sel[dw->def_nr] && dw->weight > 0) {
return i;
}
@@ -1521,7 +1525,7 @@ static void do_weight_paint_vertex(VPaint *wp, Object *ob, int index,
MDeformWeight *dw, *uw;
int vgroup= ob->actdef-1;
char *flags;
char *lock_flags;
char *defbase_sel;
int selected;
@@ -1539,15 +1543,18 @@ static void do_weight_paint_vertex(VPaint *wp, Object *ob, int index,
if(dw==NULL || uw==NULL)
return;
flags = gen_lck_flags(ob, defbase_len = BLI_countlist(&ob->defbase));
lock_flags = gen_lck_flags(ob, defbase_len = BLI_countlist(&ob->defbase));
defbase_sel = MEM_mallocN(defbase_len * sizeof(char), "dg_selected_flags");
selected = get_selected_defgroups(ob, defbase_sel, defbase_len);
if(!selected && ob->actdef) {
selected = 1;
}
// TODO: De-duplicate the simple weight paint
// If there are no locks or multipaint, then there is no need to run the more complicated checks
if((multipaint == FALSE || selected <= 1) && (flags == NULL || has_locked_group(me->dvert+index, flags) == FALSE)) {
/* TODO: De-duplicate the simple weight paint */
/* If there are no locks or multipaint,
* then there is no need to run the more complicated checks */
if((multipaint == FALSE || selected <= 1) && (lock_flags == NULL || has_locked_group(&me->dvert[index], lock_flags) == FALSE)) {
wpaint_blend(wp, dw, uw, alpha, paintweight, flip, FALSE);
do_weight_paint_auto_normalize_all_groups(me->dvert+index, validmap);
@@ -1562,9 +1569,10 @@ static void do_weight_paint_vertex(VPaint *wp, Object *ob, int index,
do_weight_paint_auto_normalize_all_groups(me->dvert+j, validmap);
}
}
} else {
// use locks and/or multipaint
// Need to know which groups are bone groups
}
else { /* use locks and/or multipaint */
/* Need to know which groups are bone groups */
char *bone_groups = validmap ? validmap : wpaint_make_validmap(ob);
float oldw;
@@ -1593,7 +1601,7 @@ static void do_weight_paint_vertex(VPaint *wp, Object *ob, int index,
if(!tdw->weight) {
i = get_first_selected_nonzero_weight(me->dvert+index, defbase_sel);
if(i>=0) {
tdw = ((me->dvert+index)->dw+i);
tdw = &(me->dvert[index].dw[i]);
tuw = defvert_verify_index(wp->wpaint_prev+index, tdw->def_nr);
}
else {
@@ -1631,7 +1639,7 @@ static void do_weight_paint_vertex(VPaint *wp, Object *ob, int index,
}
}
if(apply_mp_lcks_normalize(me, index, dw, tdw, defbase_len, change, oldChange, oldw, neww, defbase_sel, selected, bone_groups, validmap, flags, multipaint)) {
if(apply_mp_lcks_normalize(me, index, dw, tdw, defbase_len, change, oldChange, oldw, neww, defbase_sel, selected, bone_groups, validmap, lock_flags, multipaint)) {
reset_to_prev(&dv, me->dvert+index);
change = 0;
oldChange = 0;
@@ -1650,15 +1658,15 @@ static void do_weight_paint_vertex(VPaint *wp, Object *ob, int index,
//uw->weight= dw->weight;
apply_mp_lcks_normalize(me, j, uw, tdw, defbase_len, change, oldChange, oldw, neww, defbase_sel, selected, bone_groups, validmap, flags, multipaint);
apply_mp_lcks_normalize(me, j, uw, tdw, defbase_len, change, oldChange, oldw, neww, defbase_sel, selected, bone_groups, validmap, lock_flags, multipaint);
}
}
if(!validmap) {
MEM_freeN(bone_groups);
}
}
if(flags) {
MEM_freeN(flags);
if(lock_flags) {
MEM_freeN(lock_flags);
}
MEM_freeN(defbase_sel);
}
@@ -1916,8 +1924,6 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
int totindex, index, totw, flip;
float alpha;
float mval[2], pressure;
int use_vert_sel;
/* cannot paint if there is no stroke data */
@@ -1946,7 +1952,6 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
swap_m4m4(wpd->vc.rv3d->persmat, mat);
use_vert_sel= (me->editflag & ME_EDIT_VERT_SEL) != 0;
/* which faces are involved */
@@ -1973,7 +1978,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
}
}
}
if((me->editflag & ME_EDIT_PAINT_MASK) && me->mface) {
for(index=0; index<totindex; index++) {
if(indexar[index] && indexar[index]<=me->totface) {

View File

@@ -77,7 +77,6 @@
#include "BKE_pointcache.h"
#include "BKE_unit.h"
#include "smoke_API.h"
#include "IMB_imbuf.h"
@@ -86,7 +85,6 @@
#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "GPU_buffers.h"
#include "GPU_draw.h"
#include "GPU_extensions.h"
@@ -1742,58 +1740,19 @@ void mesh_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, EditVe
dm->release(dm);
}
static void mesh_obmode_foreachScreenVert__mapFunc(void *userData, int index, float *co, float *UNUSED(no_f), short *UNUSED(no_s))
{
struct { void (*func)(void *userData, MVert *mv, int x, int y, int index); void *userData; ViewContext vc; int clipVerts; } *data = userData;
Mesh *me = data->vc.obact->data;
MVert *mv = me->mvert+index;
//MVert *dmv = CDDM_get_verts(data->vc.obact->derivedFinal)+index;
//MVert *mv = CDDM_get_verts(data->vc.obact->derivedFinal)+index;
if ((mv->flag & ME_HIDE)==0) {
short s[2]= {IS_CLIPPED, 0};
if (data->clipVerts) {
view3d_project_short_clip(data->vc.ar, co, s, 1);
} else {
view3d_project_short_noclip(data->vc.ar, co, s);
}
if (s[0]!=IS_CLIPPED)
data->func(data->userData, mv, s[0], s[1], index);
}
}
void mesh_obmode_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, MVert *mv, int x, int y, int index), void *userData, int clipVerts)
{
struct { void (*func)(void *userData, MVert *mv, int x, int y, int index); void *userData; ViewContext vc; int clipVerts; } data;
DerivedMesh *dm = mesh_get_derived_final(vc->scene, vc->obact, CD_MASK_BAREMESH);
data.vc= *vc;
data.func = func;
data.userData = userData;
data.clipVerts = clipVerts;
if(clipVerts)
ED_view3d_local_clipping(vc->rv3d, vc->obact->obmat); /* for local clipping lookups */
dm->foreachMappedVert(dm, mesh_obmode_foreachScreenVert__mapFunc, &data);
dm->release(dm);
}
/* draw callback */
static void drawSelectedVertices__mapFunc(void *userData, int index, float *co, float *no_f, short *no_s)
static void drawSelectedVertices__mapFunc(void *userData, int index, float *co, float *UNUSED(no_f), short *UNUSED(no_s))
{
MVert *mv = userData;
mv+=index;
//printf("%d\n", index);
MVert *mv = &((MVert *)userData)[index];
if(!(mv->flag & ME_HIDE)) {
const char sel= mv->flag & 1;
const char sel= mv->flag & SELECT;
// TODO define selected color
if(sel) {
glColor3f(1.0f, 1.0f, 0.0f);
}else {
}
else {
glColor3f(0.0f, 0.0f, 0.0f);
}
@@ -6594,7 +6553,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
static void bbs_obmode_mesh_verts__mapFunc(void *userData, int index, float *co, float *UNUSED(no_f), short *UNUSED(no_s))
{
struct {void* offset; MVert *mvert;} *data = userData;
MVert *mv = data->mvert+index;
MVert *mv = &data->mvert[index];
int offset = (intptr_t) data->offset;
if (!(mv->flag & ME_HIDE)) {
@@ -6720,7 +6679,7 @@ static int bbs_mesh_solid_hide2__setDrawOpts(void *userData, int index, int *UNU
{
Mesh *me = userData;
if (!(me->mface[index].flag&ME_HIDE)) {
if (!(me->mface[index].flag & ME_HIDE)) {
return 1;
} else {
return 0;

View File

@@ -502,7 +502,8 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
RNA_pointer_create(&ob->id, &RNA_Mesh, ob->data, &meshptr);
if(ob->mode & (OB_MODE_TEXTURE_PAINT|OB_MODE_VERTEX_PAINT)) {
uiItemR(layout, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
} else {
}
else {
row= uiLayoutRow(layout, 1);
uiItemR(row, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);

View File

@@ -2440,7 +2440,7 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op)
int select;
select= (gesture_mode==GESTURE_MODAL_SELECT);
if( CTX_data_edit_object(C) || paint_facesel_test(obact) || paint_vertsel_test(obact) ||
(obact && (obact->mode & (OB_MODE_PARTICLE_EDIT|OB_MODE_POSE))) )
{

View File

@@ -38,7 +38,7 @@
/* This array contains the bytes used to pad the buffer to the next
64-byte boundary. (RFC 1321, 3.1: Step 1) */
static const unsigned char fillbuf[64] = { 0x80, 0 /* 0, 0, ... */ };
static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
/* Initialize structure containing state of computation.

View File

@@ -762,8 +762,6 @@ typedef struct ToolSettings {
char pad[5];
char auto_normalize; /*auto normalizing mode in wpaint*/
char multipaint; /* paint multiple bones in wpaint */
short sculpt_paint_settings; /* user preferences for sculpt and paint */