Revision: 27776
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27776
Author: blendix
Date: 2010-03-26 16:28:43 +0100 (Fri, 26 Mar 2010)
Log Message:
-----------
Render Branch: Assign weight from bones in weight paint mode now respects
paint face mask, also avoid making vertex groups if they will not be filled.
Modified Paths:
--------------
branches/render25/source/blender/editors/armature/editarmature.c
branches/render25/source/blender/editors/armature/meshlaplacian.c
Modified: branches/render25/source/blender/editors/armature/editarmature.c
===================================================================
--- branches/render25/source/blender/editors/armature/editarmature.c
2010-03-26 15:22:50 UTC (rev 27775)
+++ branches/render25/source/blender/editors/armature/editarmature.c
2010-03-26 15:28:43 UTC (rev 27776)
@@ -4573,20 +4573,23 @@
* pointers to bDeformGroups, all with names
* of skinnable bones.
*/
- bDeformGroup ***hgroup, *defgroup;
+ bDeformGroup ***hgroup, *defgroup= NULL;
int a, segments;
struct { Object *armob; void *list; int heat; } *data= datap;
+ int wpmode = (ob->mode & OB_MODE_WEIGHT_PAINT);
+ bArmature *arm= data->armob->data;
- if (!(ob->mode & OB_MODE_WEIGHT_PAINT) || !(bone->flag &
BONE_HIDDEN_P)) {
+ if (!wpmode || !(bone->flag & BONE_HIDDEN_P)) {
if (!(bone->flag & BONE_NO_DEFORM)) {
if (data->heat && data->armob->pose &&
get_pose_channel(data->armob->pose, bone->name))
segments = bone->segments;
else
segments = 1;
+
+ if(!wpmode || ((arm->layer & bone->layer) &&
(bone->flag & BONE_SELECTED)))
+ if (!(defgroup = defgroup_find_name(ob,
bone->name)))
+ defgroup = ED_vgroup_add_name(ob,
bone->name);
- if (!(defgroup = defgroup_find_name(ob, bone->name)))
- defgroup = ED_vgroup_add_name(ob, bone->name);
-
if (data->list != NULL) {
hgroup = (bDeformGroup ***) &data->list;
@@ -4711,7 +4714,7 @@
selected = MEM_callocN(numbones*sizeof(int), "selected");
for (j=0; j < numbones; ++j) {
- bone = bonelist[j];
+ bone = bonelist[j];
dgroup = dgrouplist[j];
/* handle bbone */
@@ -4759,7 +4762,7 @@
selected[j] = 1;
/* find flipped group */
- if (mirror) {
+ if (dgroup && mirror) {
char name[32];
BLI_strncpy(name, dgroup->name, 32);
Modified: branches/render25/source/blender/editors/armature/meshlaplacian.c
===================================================================
--- branches/render25/source/blender/editors/armature/meshlaplacian.c
2010-03-26 15:22:50 UTC (rev 27775)
+++ branches/render25/source/blender/editors/armature/meshlaplacian.c
2010-03-26 15:28:43 UTC (rev 27776)
@@ -618,13 +618,24 @@
LaplacianSystem *sys;
MFace *mface;
float solution, weight;
- int *vertsflipped = NULL;
+ int *vertsflipped = NULL, *mask= NULL;
int a, totface, j, bbone, firstsegment, lastsegment, thrownerror = 0;
- /* count triangles */
+ /* count triangles and create mask */
+ if(me->editflag & ME_EDIT_PAINT_MASK)
+ 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++;
+
+ if(mask && (mface->flag & ME_FACE_SEL)) {
+ mask[mface->v1]= 1;
+ mask[mface->v2]= 1;
+ mask[mface->v3]= 1;
+ if(mface->v4)
+ mask[mface->v4]= 1;
+ }
}
/* create laplacian */
@@ -661,6 +672,9 @@
/* clear weights */
if(bbone && firstsegment) {
for(a=0; a<me->totvert; a++) {
+ if(mask && !mask[a])
+ continue;
+
ED_vgroup_vert_remove(ob, dgrouplist[j], a);
if(vertsflipped && dgroupflip[j] &&
vertsflipped[a] >= 0)
ED_vgroup_vert_remove(ob,
dgroupflip[j], vertsflipped[a]);
@@ -679,6 +693,9 @@
if(laplacian_system_solve(sys)) {
/* load solution into vertex groups */
for(a=0; a<me->totvert; a++) {
+ if(mask && !mask[a])
+ continue;
+
solution= laplacian_system_get_solution(a);
if(bbone) {
@@ -723,6 +740,9 @@
/* remove too small vertex weights */
if(bbone && lastsegment) {
for(a=0; a<me->totvert; a++) {
+ if(mask && !mask[a])
+ continue;
+
weight= ED_vgroup_vert_weight(ob,
dgrouplist[j], a);
weight= heat_limit_weight(weight);
if(weight <= 0.0f)
@@ -740,6 +760,7 @@
/* free */
if(vertsflipped) MEM_freeN(vertsflipped);
+ if(mask) MEM_freeN(mask);
heat_system_free(sys);
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs