Fix for reading older files... it didn't always convert OK for the new

deformation options of Armatures, causing bones not to deform.

It was caused by using the old "boneclass" variable and SKINNABLE.
Apparently the boneclass can have any value in older files. Will be killed.

Please note; in files created after last sunday, with setting "No deform" on a
Bone, that setting has to be done again.
This commit is contained in:
Ton Roosendaal 2005-08-23 20:19:01 +00:00
parent 7396075ef1
commit ad9099ea5d
5 changed files with 20 additions and 25 deletions

@ -678,7 +678,7 @@ void armature_deform_verts(Object *armOb, Object *target, float (*vertexCos)[3],
/* initialize B_bone matrices */ /* initialize B_bone matrices */
for(pchan= armOb->pose->chanbase.first; pchan; pchan= pchan->next) { for(pchan= armOb->pose->chanbase.first; pchan; pchan= pchan->next) {
if(pchan->bone->boneclass==BONE_SKINNABLE) if(!(pchan->bone->flag & BONE_NO_DEFORM))
if(pchan->bone->segments>1) if(pchan->bone->segments>1)
pchan_b_bone_defmats(pchan); pchan_b_bone_defmats(pchan);
} }
@ -694,14 +694,15 @@ void armature_deform_verts(Object *armOb, Object *target, float (*vertexCos)[3],
defnrToPC = MEM_callocN(sizeof(*defnrToPC)*numGroups, "defnrToBone"); defnrToPC = MEM_callocN(sizeof(*defnrToPC)*numGroups, "defnrToBone");
for (i=0,dg=target->defbase.first; dg; i++,dg=dg->next) { for (i=0,dg=target->defbase.first; dg; i++,dg=dg->next) {
defnrToPC[i] = get_pose_channel(armOb->pose, dg->name); defnrToPC[i] = get_pose_channel(armOb->pose, dg->name);
/* exclude non-skinnable bones */ /* exclude non-deforming bones */
if(defnrToPC[i]) if(defnrToPC[i]) {
if(defnrToPC[i]->bone->boneclass!=BONE_SKINNABLE) if(defnrToPC[i]->bone->flag & BONE_NO_DEFORM)
defnrToPC[i]= NULL; defnrToPC[i]= NULL;
} }
} }
} }
} }
}
for(i=0; i<numVerts; i++) { for(i=0; i<numVerts; i++) {
MDeformVert *dvert; MDeformVert *dvert;
@ -736,7 +737,7 @@ void armature_deform_verts(Object *armOb, Object *target, float (*vertexCos)[3],
} }
else if(use_envelope) { else if(use_envelope) {
for(pchan= armOb->pose->chanbase.first; pchan; pchan= pchan->next) { for(pchan= armOb->pose->chanbase.first; pchan; pchan= pchan->next) {
if(pchan->bone->boneclass==BONE_SKINNABLE) if(!(pchan->bone->flag & BONE_NO_DEFORM))
contrib+= dist_bone_deform(pchan, vec, co); contrib+= dist_bone_deform(pchan, vec, co);
} }
} }

@ -126,10 +126,7 @@ typedef struct bArmature {
#define BONE_HIDDEN_A 1024 #define BONE_HIDDEN_A 1024
/* multiplies vgroup with envelope */ /* multiplies vgroup with envelope */
#define BONE_MULT_VG_ENV 2048 #define BONE_MULT_VG_ENV 2048
#define BONE_NO_DEFORM 4096
/* bone->flag bits */
#define BONE_IK_TOPARENTBIT 4
#define BONE_HIDDENBIT 6
enum { enum {

@ -2253,10 +2253,10 @@ static void editing_panel_armature_bones(Object *ob, bArmature *arm)
uiDefButS(block, NUM, B_ARM_RECALCDATA, "Segm: ", bx-10,by-19,117,18, &curBone->segments, 1.0, 32.0, 0.0, 0.0, "Subdivisions for B-bones"); uiDefButS(block, NUM, B_ARM_RECALCDATA, "Segm: ", bx-10,by-19,117,18, &curBone->segments, 1.0, 32.0, 0.0, 0.0, "Subdivisions for B-bones");
uiDefButF(block, NUM,B_ARM_RECALCDATA, "Dist:", bx+110, by-19, 105, 18, &curBone->dist, 0.0, 1000.0, 10.0, 0.0, "Bone deformation distance"); uiDefButF(block, NUM,B_ARM_RECALCDATA, "Dist:", bx+110, by-19, 105, 18, &curBone->dist, 0.0, 1000.0, 10.0, 0.0, "Bone deformation distance");
uiDefButF(block, NUM,B_ARM_RECALCDATA, "Weight:", bx+223, by-19,110, 18, &curBone->weight, 0.0F, 1000.0F, 10.0F, 0.0F, "Bone deformation weight"); uiDefButF(block, NUM,B_ARM_RECALCDATA, "Weight:", bx+223, by-19,110, 18, &curBone->weight, 0.0F, 1000.0F, 10.0F, 0.0F, "Bone deformation weight");
printf("bone name %s class %d\n", curBone->name, curBone->boneclass);
/* bone types */ /* bone types */
uiDefButBitI(block, TOG, BONE_HINGE, B_ARM_RECALCDATA, "Hinge", bx-10,by-38,85,18, &curBone->flag, 1.0, 32.0, 0.0, 0.0, "Don't inherit rotation or scale from parent Bone"); uiDefButBitI(block, TOG, BONE_HINGE, B_ARM_RECALCDATA, "Hinge", bx-10,by-38,85,18, &curBone->flag, 1.0, 32.0, 0.0, 0.0, "Don't inherit rotation or scale from parent Bone");
uiDefButBitS(block, TOGN, 1, B_ARM_RECALCDATA, "Deform", bx+75, by-38, 85, 18, &curBone->boneclass, 0.0, 0.0, 0.0, 0.0, "Indicate if Bone deforms geometry"); uiDefButBitI(block, TOGN, BONE_NO_DEFORM, B_ARM_RECALCDATA, "Deform", bx+75, by-38, 85, 18, &curBone->flag, 0.0, 0.0, 0.0, 0.0, "Indicate if Bone deforms geometry");
uiDefButBitI(block, TOG, BONE_MULT_VG_ENV, B_ARM_RECALCDATA, "Mult", bx+160,by-38,85,18, &curBone->flag, 1.0, 32.0, 0.0, 0.0, "Multiply Bone Envelope with VertexGroup"); uiDefButBitI(block, TOG, BONE_MULT_VG_ENV, B_ARM_RECALCDATA, "Mult", bx+160,by-38,85,18, &curBone->flag, 1.0, 32.0, 0.0, 0.0, "Multiply Bone Envelope with VertexGroup");
uiDefButBitI(block, TOG, BONE_HIDDEN_A, REDRAWVIEW3D, "Hide", bx+245,by-38,88,18, &curBone->flag, 0, 0, 0, 0, "Toggles display of this bone in Edit Mode"); uiDefButBitI(block, TOG, BONE_HIDDEN_A, REDRAWVIEW3D, "Hide", bx+245,by-38,88,18, &curBone->flag, 0, 0, 0, 0, "Toggles display of this bone in Edit Mode");
@ -2315,7 +2315,7 @@ static void editing_panel_pose_bones(Object *ob, bArmature *arm)
/* bone types */ /* bone types */
uiDefButBitI(block, TOG, BONE_HINGE, B_ARM_RECALCDATA, "Hinge", bx-10,by-38,85,18, &curBone->flag, 1.0, 32.0, 0.0, 0.0, "Don't inherit rotation or scale from parent Bone"); uiDefButBitI(block, TOG, BONE_HINGE, B_ARM_RECALCDATA, "Hinge", bx-10,by-38,85,18, &curBone->flag, 1.0, 32.0, 0.0, 0.0, "Don't inherit rotation or scale from parent Bone");
uiDefButBitS(block, TOGN, 1, B_ARM_RECALCDATA, "Deform", bx+75, by-38, 85, 18, &curBone->boneclass, 0.0, 0.0, 0.0, 0.0, "Indicate if Bone deforms geometry"); uiDefButBitI(block, TOGN, BONE_NO_DEFORM, B_ARM_RECALCDATA, "Deform", bx+75, by-38, 85, 18, &curBone->flag, 0.0, 0.0, 0.0, 0.0, "Indicate if Bone deforms geometry");
uiDefButBitI(block, TOG, BONE_MULT_VG_ENV, B_ARM_RECALCDATA, "Mult", bx+160,by-38,85,18, &curBone->flag, 1.0, 32.0, 0.0, 0.0, "Multiply Bone Envelope with VertexGroup"); uiDefButBitI(block, TOG, BONE_MULT_VG_ENV, B_ARM_RECALCDATA, "Mult", bx+160,by-38,85,18, &curBone->flag, 1.0, 32.0, 0.0, 0.0, "Multiply Bone Envelope with VertexGroup");
uiDefButBitI(block, TOG, BONE_HIDDEN_P, REDRAWVIEW3D, "Hide", bx+245,by-38,88,18, &curBone->flag, 0, 0, 0, 0, "Toggles display of this bone in Pose Mode"); uiDefButBitI(block, TOG, BONE_HIDDEN_P, REDRAWVIEW3D, "Hide", bx+245,by-38,88,18, &curBone->flag, 0, 0, 0, 0, "Toggles display of this bone in Pose Mode");
uiBlockEndAlign(block); uiBlockEndAlign(block);

@ -1098,8 +1098,7 @@ static void draw_pose_channels(Base *base, int dt)
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
bone= pchan->bone; bone= pchan->bone;
if(bone && !(bone->flag & BONE_HIDDEN_P)) { if(bone && !(bone->flag & (BONE_HIDDEN_P|BONE_NO_DEFORM))) {
if(bone->boneclass==BONE_SKINNABLE)
if(bone->flag & (BONE_SELECTED)) if(bone->flag & (BONE_SELECTED))
draw_sphere_bone_dist(smat, imat, bone->flag, pchan, NULL); draw_sphere_bone_dist(smat, imat, bone->flag, pchan, NULL);
} }
@ -1301,8 +1300,7 @@ static void draw_ebones(Object *ob, int dt)
if(G.vd->zbuf) glDisable(GL_DEPTH_TEST); if(G.vd->zbuf) glDisable(GL_DEPTH_TEST);
for (eBone=G.edbo.first, index=0; eBone; eBone=eBone->next, index++){ for (eBone=G.edbo.first, index=0; eBone; eBone=eBone->next, index++){
if(!(eBone->flag & BONE_HIDDEN_A)) if(!(eBone->flag & (BONE_HIDDEN_A|BONE_NO_DEFORM)))
if(eBone->boneclass==BONE_SKINNABLE)
if(eBone->flag & (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL)) if(eBone->flag & (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL))
draw_sphere_bone_dist(smat, imat, eBone->flag, NULL, eBone); draw_sphere_bone_dist(smat, imat, eBone->flag, NULL, eBone);
} }

@ -1181,7 +1181,6 @@ static EditBone *add_editbone(void)
bone->rad_head= 0.25; bone->rad_head= 0.25;
bone->rad_tail= 0.1; bone->rad_tail= 0.1;
bone->segments= 1; bone->segments= 1;
bone->boneclass = BONE_SKINNABLE;
return bone; return bone;
} }
@ -2017,7 +2016,7 @@ int ik_chain_looper(Object *ob, Bone *bone, void *data,
static int bone_skinnable(Object *ob, Bone *bone, void *data) static int bone_skinnable(Object *ob, Bone *bone, void *data)
{ {
/* Bones that are not of boneclass BONE_UNSKINNABLE /* Bones that are deforming
* are regarded to be "skinnable" and are eligible for * are regarded to be "skinnable" and are eligible for
* auto-skinning. * auto-skinning.
* *
@ -2041,7 +2040,7 @@ static int bone_skinnable(Object *ob, Bone *bone, void *data)
*/ */
Bone ***hbone; Bone ***hbone;
if ( bone->boneclass != BONE_UNSKINNABLE ) { if (!(bone->flag & BONE_NO_DEFORM)) {
if (data != NULL) { if (data != NULL) {
hbone = (Bone ***) data; hbone = (Bone ***) data;
**hbone = bone; **hbone = bone;
@ -2058,7 +2057,7 @@ static int add_defgroup_unique_bone(Object *ob, Bone *bone, void *data)
* same name as bone (provided the bone is skinnable). * same name as bone (provided the bone is skinnable).
* If such a vertex group aleady exist the routine exits. * If such a vertex group aleady exist the routine exits.
*/ */
if ( bone_skinnable(ob, bone, NULL) ) { if (!(bone->flag & BONE_NO_DEFORM)) {
if (!get_named_vertexgroup(ob,bone->name)) { if (!get_named_vertexgroup(ob,bone->name)) {
add_defgroup_name(ob, bone->name); add_defgroup_name(ob, bone->name);
return 1; return 1;