[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37322] branches/soc-2011-radish: Heard that multi-bone selection would be better used for painting multiple bones ; took out select lock.
Jason Hays
jason_hays22 at mymail.eku.edu
Wed Jun 8 21:05:18 CEST 2011
Revision: 37322
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37322
Author: jason_hays22
Date: 2011-06-08 19:05:17 +0000 (Wed, 08 Jun 2011)
Log Message:
-----------
Heard that multi-bone selection would be better used for painting multiple bones; took out select lock.
Added a basic multiple bone group paint feature "Multi-Paint" and its corresponding checkbox next to "Auto Normalize," but I need to access the ToolSettings for it in armature to make bone selection function/draw correctly
When you multi-paint, it paints on selected bones while keeping the weight ratios on a vertex of the selected groups the same. You can't currently multi-paint on a vertex with a locked deform group.
Modified Paths:
--------------
branches/soc-2011-radish/release/scripts/startup/bl_ui/space_view3d_toolbar.py
branches/soc-2011-radish/source/blender/blenkernel/intern/DerivedMesh.c
branches/soc-2011-radish/source/blender/editors/armature/editarmature.c
branches/soc-2011-radish/source/blender/editors/sculpt_paint/paint_vertex.c
branches/soc-2011-radish/source/blender/makesdna/DNA_scene_types.h
branches/soc-2011-radish/source/blender/makesrna/intern/rna_scene.c
Modified: branches/soc-2011-radish/release/scripts/startup/bl_ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2011-radish/release/scripts/startup/bl_ui/space_view3d_toolbar.py 2011-06-08 17:59:24 UTC (rev 37321)
+++ branches/soc-2011-radish/release/scripts/startup/bl_ui/space_view3d_toolbar.py 2011-06-08 19:05:17 UTC (rev 37322)
@@ -639,6 +639,8 @@
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")
+ # Jason was here
+ layout.prop(context.tool_settings, "use_multipaint", text="Multi-Paint")
col = layout.column()
Modified: branches/soc-2011-radish/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- branches/soc-2011-radish/source/blender/blenkernel/intern/DerivedMesh.c 2011-06-08 17:59:24 UTC (rev 37321)
+++ branches/soc-2011-radish/source/blender/blenkernel/intern/DerivedMesh.c 2011-06-08 19:05:17 UTC (rev 37322)
@@ -40,6 +40,9 @@
#include "DNA_cloth_types.h"
#include "DNA_key_types.h"
#include "DNA_meshdata_types.h"
+// Jason
+#include "DNA_armature_types.h"
+
#include "DNA_object_types.h"
#include "DNA_scene_types.h" // N_T
@@ -72,6 +75,8 @@
#include "GPU_material.h"
#include "ED_sculpt.h" /* for ED_sculpt_modifiers_changed */
+// Jason was here, this is for multi-paint
+#include "ED_armature.h"
///////////////////////////////////
///////////////////////////////////
@@ -1602,7 +1607,7 @@
}
}
-static void calc_weightpaint_vert_color(Object *ob, ColorBand *coba, int vert, unsigned char *col)
+static void calc_weightpaint_vert_color(Object *ob, ColorBand *coba, int vert, unsigned char *col, char *dg_flags, int selected)
{
Mesh *me = ob->data;
float colf[4], input = 0.0f;
@@ -1610,9 +1615,15 @@
if (me->dvert) {
for (i=0; i<me->dvert[vert].totweight; i++)
- if (me->dvert[vert].dw[i].def_nr==ob->actdef-1)
- input+=me->dvert[vert].dw[i].weight;
+ // Jason was here
+ if ((selected<=1 && me->dvert[vert].dw[i].def_nr==ob->actdef-1) || dg_flags[me->dvert[vert].dw[i].def_nr]) {//
+ input+=me->dvert[vert].dw[i].weight;
+ }
}
+ // Jason was here
+ if(selected) {
+ input/=selected;
+ }
CLAMP(input, 0.0f, 1.0f);
@@ -1633,7 +1644,44 @@
{
stored_cb= coba;
}
+/* Jason was here */
+static char* get_selected_defgroups(Object *ob, int defcnt) {
+ bPoseChannel *chan;
+ bPose *pose;
+ bDeformGroup *defgroup;
+ //Bone *bone;
+ char was_selected = FALSE;
+ char *dg_flags = MEM_mallocN(defcnt*sizeof(char), "dg_selected_flags");
+ int i;
+ Object *armob = ED_object_pose_armature(ob);
+ if(armob) {
+ pose = armob->pose;
+ for (chan=pose->chanbase.first; chan; chan=chan->next) {
+ for (i = 0, defgroup = ob->defbase.first; i < defcnt && defgroup; defgroup = defgroup->next, i++) {
+ if(!strcmp(defgroup->name, chan->bone->name)) {
+ // TODO get BONE_SELECTED flag
+ dg_flags[i] = (chan->bone->flag & 1);
+ was_selected = TRUE;
+ }
+ }
+ }
+ }
+
+ return dg_flags;
+}
+/* Jason was here */
+static int count_true(char *list, int len)
+{
+ int i;
+ int cnt = 0;
+ for(i = 0; i < len; i++) {
+ if (list[i]) {
+ cnt++;
+ }
+ }
+ return cnt;
+}
static void add_weight_mcol_dm(Object *ob, DerivedMesh *dm)
{
Mesh *me = ob->data;
@@ -1641,18 +1689,24 @@
ColorBand *coba= stored_cb; /* warning, not a local var */
unsigned char *wtcol;
int i;
-
+ // Jason was here
+ int defcnt = BLI_countlist(&ob->defbase);
+ char *dg_flags = get_selected_defgroups(ob, defcnt);
+ int selected = count_true(dg_flags, defcnt);
+
wtcol = MEM_callocN (sizeof (unsigned char) * me->totface*4*4, "weightmap");
memset(wtcol, 0x55, sizeof (unsigned char) * me->totface*4*4);
for (i=0; i<me->totface; i++, mf++) {
- calc_weightpaint_vert_color(ob, coba, mf->v1, &wtcol[(i*4 + 0)*4]);
- calc_weightpaint_vert_color(ob, coba, mf->v2, &wtcol[(i*4 + 1)*4]);
- calc_weightpaint_vert_color(ob, coba, mf->v3, &wtcol[(i*4 + 2)*4]);
+ calc_weightpaint_vert_color(ob, coba, mf->v1, &wtcol[(i*4 + 0)*4], dg_flags, selected);
+ calc_weightpaint_vert_color(ob, coba, mf->v2, &wtcol[(i*4 + 1)*4], dg_flags, selected);
+ calc_weightpaint_vert_color(ob, coba, mf->v3, &wtcol[(i*4 + 2)*4], dg_flags, selected);
if (mf->v4)
- calc_weightpaint_vert_color(ob, coba, mf->v4, &wtcol[(i*4 + 3)*4]);
+ calc_weightpaint_vert_color(ob, coba, mf->v4, &wtcol[(i*4 + 3)*4], dg_flags, selected);
}
-
+ // Jason
+ MEM_freeN(dg_flags);
+
CustomData_add_layer(&dm->faceData, CD_WEIGHT_MCOL, CD_ASSIGN, wtcol, dm->numFaceData);
}
Modified: branches/soc-2011-radish/source/blender/editors/armature/editarmature.c
===================================================================
--- branches/soc-2011-radish/source/blender/editors/armature/editarmature.c 2011-06-08 17:59:24 UTC (rev 37321)
+++ branches/soc-2011-radish/source/blender/editors/armature/editarmature.c 2011-06-08 19:05:17 UTC (rev 37322)
@@ -4400,7 +4400,6 @@
return NULL;
}
-
/* called from editview.c, for mode-less pose selection */
/* assumes scene obact and basact is still on old situation */
int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, short hits, short extend)
@@ -4412,13 +4411,13 @@
if (!ob || !ob->pose) return 0;
nearBone= get_bone_from_selectbuffer(scene, base, buffer, hits, 1);
-
+
/* if the bone cannot be affected, don't do anything */
if ((nearBone) && !(nearBone->flag & BONE_UNSELECTABLE)) {
bArmature *arm= ob->data;
/* since we do unified select, we don't shift+select a bone if the armature object was not active yet */
- /* Jason was here, I'm doing a unified select for locking now */
+ /* Jason was here, I'm doing a select for multibone painting */
if ((base != scene->basact)) {//if (!(extend) || (base != scene->basact)) {
/* Jason was here */
/* only deselect all if they aren't using 'shift' */
@@ -4427,28 +4426,27 @@
nearBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
arm->act_bone= nearBone;
ED_vgroup_select_by_name(OBACT, nearBone->name);
- DAG_id_tag_update(&OBACT->id, OB_RECALC_DATA);
}
- // Jason deselect this bone specifically if it is selected already
else {
+ // Jason deselect this bone specifically if it is selected already
if (nearBone->flag & BONE_SELECTED) {
nearBone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
if(nearBone == arm->act_bone) {
// make a different bone the active one if it exists
-
new_act_bone = get_other_selected_bone(ob);
if(new_act_bone) {
new_act_bone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
arm->act_bone = new_act_bone;
ED_vgroup_select_by_name(OBACT, new_act_bone->name);
- DAG_id_tag_update(&OBACT->id, OB_RECALC_DATA);
}
}
+ // or select the bone if they are using shift
} else {
nearBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
arm->act_bone= nearBone;
}
}
+ DAG_id_tag_update(&OBACT->id, OB_RECALC_DATA);
// XXX old cruft! use notifiers instead
//select_actionchannel_by_name(ob->action, nearBone->name, 1);
}
Modified: branches/soc-2011-radish/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- branches/soc-2011-radish/source/blender/editors/sculpt_paint/paint_vertex.c 2011-06-08 17:59:24 UTC (rev 37321)
+++ branches/soc-2011-radish/source/blender/editors/sculpt_paint/paint_vertex.c 2011-06-08 19:05:17 UTC (rev 37322)
@@ -1153,8 +1153,6 @@
/*Jason was here
gen_lck_flags gets the status of "flag" for each bDeformGroup
in ob->defbase and returns an array containing them
-
-if there are multiple bones selected, however, they are the only ones that are treated as "unlocked"
*/
static char* gen_lck_flags(Object* ob, int defcnt, char *map)
{
@@ -1163,41 +1161,14 @@
//int defcnt = BLI_countlist(&ob->defbase);
char *flags = MEM_mallocN(defcnt*sizeof(char), "defflags");
bDeformGroup *defgroup;
- char was_selected = FALSE;
int selected = 0;
- bPose *pose;
- bPoseChannel *chan;
- Bone *bone;
- Object *armob = ED_object_pose_armature(ob);
-
- if(armob) {
- pose = armob->pose;
- for (chan=pose->chanbase.first; chan; chan=chan->next) {
- bone = chan->bone;
- was_selected = FALSE;
- for (i = 0, defgroup = ob->defbase.first; i < defcnt && defgroup; defgroup = defgroup->next, i++) {
- if(!strcmp(defgroup->name, bone->name)) {
- flags[i] = !(bone->flag & BONE_SELECTED);
- if(flags[i]) {
- is_locked = TRUE;
- } else if(!was_selected){
- selected++;
- was_selected = TRUE;
- }
- }
- }
+ for(i = 0, defgroup = ob->defbase.first; i < defcnt && defgroup; defgroup = defgroup->next, i++) {
+ flags[i] = defgroup->flag;
+ if(flags[i]) {
+ is_locked = TRUE;
}
}
- if(selected <= 1) {
- is_locked = FALSE;
- for(i = 0, defgroup = ob->defbase.first; i < defcnt && defgroup; defgroup = defgroup->next, i++) {
- flags[i] = defgroup->flag;
- if(flags[i]) {
- is_locked = TRUE;
- }
- }
- }
if(is_locked){
return flags;
}
@@ -1332,10 +1303,60 @@
MEM_freeN(change_status);
}
/* Jason */
-static void check_locks_and_normalize(Object *ob, Mesh *me, int index, int vgroup, MDeformWeight *dw, float oldw, char *validmap, char *flags, int defcnt, char *bone_groups)
+/* return TRUE on success, FALSE on failure
+failure occurs when zero elements exist in the selection,
+nonzero elements reach zero,
+and if they go above 1 if auto normalize is off */
+static int multipaint_vgroups(MDeformVert *dvert, MDeformWeight *dw, float oldw, char* validmap, char* bone_groups, char* selection, int defcnt) {
+ int i;
+ float change;
+ MDeformWeight *w;
+ float val;
+ if(oldw == 0 || !selection) {
+ return FALSE;
+ }
+ change = dw->weight/oldw;
+ if(change == 1 || !change) {
+ return FALSE;
+ }
+ dw->weight = oldw;
+ // make sure all selected dverts exist
+ for(i = 0; i < defcnt; i++) {
+ if(selection[i]){
+ defvert_verify_index(dvert, i);
+ }
+ }
+ // see if all changes are valid before doing any
+ for(i = 0; i < dvert->totweight; i++) {
+ w = (dvert->dw+i);
+ if(!selection[w->def_nr] || !bone_groups[w->def_nr]) {
+ continue;
+ }
+ if(w->weight == 0) {
+ if(selection[w->def_nr]) {
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list