diff options
author | Ton Roosendaal <ton@blender.org> | 2005-09-07 22:07:24 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2005-09-07 22:07:24 +0400 |
commit | e2944936ac33771996898063c3b719f9fc26b4ef (patch) | |
tree | 38042549e488c6f1039a9cde9070eb801aa8c222 /source/blender | |
parent | add2e9bfa2d6f6cc8ab50566d1d2966d1a83c6bd (diff) |
Fix for weight painting errors, as reported by Bassam.
- Undo/Redo didn't work
- Crash on using weightpaint with Armature-modifier (instead of parent).
Note: checking if an object is being deformed cannot be simply done with
checking for a parent anymore... for this a call in modifier.c has been
added; modifiers_isDeformedByArmature(Object *). It even returns the
Armature object pointer.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_modifier.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/armature.c | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/modifier.c | 12 | ||||
-rw-r--r-- | source/blender/src/buttons_object.c | 2 | ||||
-rw-r--r-- | source/blender/src/editarmature.c | 18 | ||||
-rw-r--r-- | source/blender/src/editdeform.c | 2 | ||||
-rw-r--r-- | source/blender/src/vpaint.c | 11 |
7 files changed, 32 insertions, 21 deletions
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index e600c0752fb..55a09fcd158 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -201,7 +201,7 @@ void modifiers_clearErrors (struct Object *ob); int modifiers_getCageIndex (struct Object *ob, int *lastPossibleCageIndex_r); int modifiers_isSoftbodyEnabled (struct Object *ob); -int modifiers_isDeformedByArmature(struct Object *ob, struct Object *armOb); +struct Object* modifiers_isDeformedByArmature(struct Object *ob); ModifierData* modifiers_getVirtualModifierList (struct Object *ob); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 7c6f6a67be7..fb36cfdf020 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -728,8 +728,10 @@ void armature_deform_verts(Object *armOb, Object *target, float (*vertexCos)[3], pchan = defnrToPC[dvert->dw[j].def_nr]; if (pchan) { float weight= dvert->dw[j].weight; - if(pchan->bone->flag & BONE_MULT_VG_ENV) { - Bone *bone= pchan->bone; + Bone *bone= pchan->bone; + + if(bone && bone->flag & BONE_MULT_VG_ENV) { + weight*= distfactor_to_bone(co, bone->arm_head, bone->arm_tail, bone->rad_head, bone->rad_tail, bone->dist); } pchan_bone_deform(pchan, weight, vec, co, &contrib); diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index cc24f420098..f5fe534c0b3 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -1494,18 +1494,20 @@ ModifierData *modifiers_getVirtualModifierList(Object *ob) return ob->modifiers.first; } -int modifiers_isDeformedByArmature(Object *ob, Object *armOb) +Object *modifiers_isDeformedByArmature(Object *ob) { ModifierData *md = modifiers_getVirtualModifierList(ob); for (; md; md=md->next) { if (md->type==eModifierType_Armature) { ArmatureModifierData *amd = (ArmatureModifierData*) md; - - if (amd->object==armOb) - return 1; + return amd->object; } } + + if(ob->parent && ob->parent->type==OB_ARMATURE) + if(ob->partype==PARSKEL) + return ob->parent; - return 0; + return NULL; }
\ No newline at end of file diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index 63916adc431..d1455afc879 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -685,7 +685,7 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s strcpy (data->subtarget, ""); uiBlockEndAlign(block); - but=uiDefButBitI(block, TOG, 1, B_CONSTRAINT_TEST, "Sticky", *xco, *yco-24, 54, 18, &data->sticky, 0, 24, 0, 0, "Immobilize object while constrained"); + but=uiDefButBitS(block, TOG, 1, B_CONSTRAINT_TEST, "Sticky", *xco, *yco-24, 54, 18, &data->sticky, 0, 24, 0, 0, "Immobilize object while constrained"); uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Max/Min:", *xco-8, *yco-64, 54, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); diff --git a/source/blender/src/editarmature.c b/source/blender/src/editarmature.c index ec992db6531..8c7e386ba25 100644 --- a/source/blender/src/editarmature.c +++ b/source/blender/src/editarmature.c @@ -2400,7 +2400,7 @@ static void constraint_bone_name_fix(Object *ob, ListBase *conlist, char *oldnam /* seems messy, but thats what you get with not using pointers but channel names :) */ void armature_bone_rename(bArmature *arm, char *oldnamep, char *newnamep) { - Object *ob; + Object *ob, *modob; char newname[MAXBONENAME]; char oldname[MAXBONENAME]; @@ -2481,13 +2481,15 @@ void armature_bone_rename(bArmature *arm, char *oldnamep, char *newnamep) if (!strcmp(ob->parsubstr, oldname)) BLI_strncpy(ob->parsubstr, newname, MAXBONENAME); } - else if(ob->partype==PARSKEL) { - bDeformGroup *dg; - /* bone name in defgroup */ - for (dg=ob->defbase.first; dg; dg=dg->next) { - if(!strcmp(dg->name, oldname)) - BLI_strncpy(dg->name, newname, MAXBONENAME); - } + } + /* or is there an armature deforming object */ + modob = modifiers_isDeformedByArmature(ob); + if(modob) { + bDeformGroup *dg; + /* bone name in defgroup */ + for (dg=ob->defbase.first; dg; dg=dg->next) { + if(!strcmp(dg->name, oldname)) + BLI_strncpy(dg->name, newname, MAXBONENAME); } } } diff --git a/source/blender/src/editdeform.c b/source/blender/src/editdeform.c index 97988a5c47c..36709948be9 100644 --- a/source/blender/src/editdeform.c +++ b/source/blender/src/editdeform.c @@ -109,7 +109,7 @@ the specified defweight group */ int i; MDeformWeight *newdw; - if (!dv) + if (!dv || defgroup<0) return NULL; for (i=0; i<dv->totweight; i++){ diff --git a/source/blender/src/vpaint.c b/source/blender/src/vpaint.c index 8b9f2be1867..77a839f0869 100644 --- a/source/blender/src/vpaint.c +++ b/source/blender/src/vpaint.c @@ -55,6 +55,7 @@ #include "DNA_armature_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" +#include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_object_force.h" #include "DNA_screen_types.h" @@ -68,6 +69,7 @@ #include "BKE_displist.h" #include "BKE_global.h" #include "BKE_mesh.h" +#include "BKE_modifier.h" #include "BKE_object.h" #include "BKE_utildefines.h" @@ -734,7 +736,8 @@ void wpaint_undo (void) /* now free previous mesh dverts */ free_dverts(swapbuf, me->totvert); - DAG_object_flush_update(G.scene, ob->parent, OB_RECALC_DATA); + DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); + DAG_object_flush_update(G.scene, modifiers_isDeformedByArmature(ob), OB_RECALC_DATA); scrarea_do_windraw(curarea); } @@ -911,11 +914,13 @@ void weight_paint(void) /* if nothing was added yet, we make dverts and a vertex deform group */ if (!me->dvert) create_dverts(me); + /* this happens on a Bone select, when no vgroup existed yet */ if(ob->actdef==0) { - if(ob->parent && (ob->parent->flag & OB_POSEMODE)) { + Object *modob; + if(modob = modifiers_isDeformedByArmature(ob)) { bPoseChannel *pchan; - for(pchan= ob->parent->pose->chanbase.first; pchan; pchan= pchan->next) + for(pchan= modob->pose->chanbase.first; pchan; pchan= pchan->next) if(pchan->bone->flag & SELECT) break; if(pchan) { |