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.
This commit is contained in:
parent
add2e9bfa2
commit
e2944936ac
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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, "");
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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++){
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue