From ad9099ea5d7700d53bf9595118ad6fc59b04872a Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Tue, 23 Aug 2005 20:19:01 +0000 Subject: [PATCH] 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. --- source/blender/blenkernel/intern/armature.c | 11 ++++++----- source/blender/makesdna/DNA_armature_types.h | 5 +---- source/blender/src/buttons_editing.c | 8 ++++---- source/blender/src/drawarmature.c | 14 ++++++-------- source/blender/src/editarmature.c | 7 +++---- 5 files changed, 20 insertions(+), 25 deletions(-) diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 85c68bab1a1..dabc4fcf359 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -678,7 +678,7 @@ void armature_deform_verts(Object *armOb, Object *target, float (*vertexCos)[3], /* initialize B_bone matrices */ 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) pchan_b_bone_defmats(pchan); } @@ -694,10 +694,11 @@ void armature_deform_verts(Object *armOb, Object *target, float (*vertexCos)[3], defnrToPC = MEM_callocN(sizeof(*defnrToPC)*numGroups, "defnrToBone"); for (i=0,dg=target->defbase.first; dg; i++,dg=dg->next) { defnrToPC[i] = get_pose_channel(armOb->pose, dg->name); - /* exclude non-skinnable bones */ - if(defnrToPC[i]) - if(defnrToPC[i]->bone->boneclass!=BONE_SKINNABLE) + /* exclude non-deforming bones */ + if(defnrToPC[i]) { + if(defnrToPC[i]->bone->flag & BONE_NO_DEFORM) defnrToPC[i]= NULL; + } } } } @@ -736,7 +737,7 @@ void armature_deform_verts(Object *armOb, Object *target, float (*vertexCos)[3], } else if(use_envelope) { 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); } } diff --git a/source/blender/makesdna/DNA_armature_types.h b/source/blender/makesdna/DNA_armature_types.h index 59e68ebe44b..cb790b816cb 100644 --- a/source/blender/makesdna/DNA_armature_types.h +++ b/source/blender/makesdna/DNA_armature_types.h @@ -126,10 +126,7 @@ typedef struct bArmature { #define BONE_HIDDEN_A 1024 /* multiplies vgroup with envelope */ #define BONE_MULT_VG_ENV 2048 - -/* bone->flag bits */ -#define BONE_IK_TOPARENTBIT 4 -#define BONE_HIDDENBIT 6 +#define BONE_NO_DEFORM 4096 enum { diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 822ca7d5709..380af983fe4 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -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"); 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"); - + printf("bone name %s class %d\n", curBone->name, curBone->boneclass); /* 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"); - 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, 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, 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_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 */ 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_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); diff --git a/source/blender/src/drawarmature.c b/source/blender/src/drawarmature.c index b7521b23138..a16b4481865 100644 --- a/source/blender/src/drawarmature.c +++ b/source/blender/src/drawarmature.c @@ -1098,10 +1098,9 @@ static void draw_pose_channels(Base *base, int dt) for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { bone= pchan->bone; - if(bone && !(bone->flag & BONE_HIDDEN_P)) { - if(bone->boneclass==BONE_SKINNABLE) - if(bone->flag & (BONE_SELECTED)) - draw_sphere_bone_dist(smat, imat, bone->flag, pchan, NULL); + if(bone && !(bone->flag & (BONE_HIDDEN_P|BONE_NO_DEFORM))) { + if(bone->flag & (BONE_SELECTED)) + draw_sphere_bone_dist(smat, imat, bone->flag, pchan, NULL); } } @@ -1301,10 +1300,9 @@ static void draw_ebones(Object *ob, int dt) if(G.vd->zbuf) glDisable(GL_DEPTH_TEST); for (eBone=G.edbo.first, index=0; eBone; eBone=eBone->next, index++){ - if(!(eBone->flag & BONE_HIDDEN_A)) - if(eBone->boneclass==BONE_SKINNABLE) - if(eBone->flag & (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL)) - draw_sphere_bone_dist(smat, imat, eBone->flag, NULL, eBone); + if(!(eBone->flag & (BONE_HIDDEN_A|BONE_NO_DEFORM))) + if(eBone->flag & (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL)) + draw_sphere_bone_dist(smat, imat, eBone->flag, NULL, eBone); } if(G.vd->zbuf) glEnable(GL_DEPTH_TEST); diff --git a/source/blender/src/editarmature.c b/source/blender/src/editarmature.c index 511a49b37e3..5980ffcee48 100644 --- a/source/blender/src/editarmature.c +++ b/source/blender/src/editarmature.c @@ -1181,7 +1181,6 @@ static EditBone *add_editbone(void) bone->rad_head= 0.25; bone->rad_tail= 0.1; bone->segments= 1; - bone->boneclass = BONE_SKINNABLE; 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) { - /* Bones that are not of boneclass BONE_UNSKINNABLE + /* Bones that are deforming * are regarded to be "skinnable" and are eligible for * auto-skinning. * @@ -2041,7 +2040,7 @@ static int bone_skinnable(Object *ob, Bone *bone, void *data) */ Bone ***hbone; - if ( bone->boneclass != BONE_UNSKINNABLE ) { + if (!(bone->flag & BONE_NO_DEFORM)) { if (data != NULL) { hbone = (Bone ***) data; **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). * 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)) { add_defgroup_name(ob, bone->name); return 1;