forked from bartvdbraak/blender
Nice time saver for Armatures: Introduced Bone type "Hinge", which doesn't
inherit pose rotation/scale from its parent pose-channel. Button is available in Editing Buttons for PoseMode as well as EditMode. Aim is to reduce overhead of Constraint usage (copy location). (in object.c I removed old code for IK)
This commit is contained in:
parent
a2c4044b27
commit
4cc96528b8
@ -1007,6 +1007,20 @@ static void where_is_pose_bone(Object *ob, bPoseChannel *pchan)
|
||||
offs_bone[3][1]+= parbone->length;
|
||||
|
||||
/* Compose the matrix for this bone */
|
||||
if(bone->flag & BONE_HINGE) { // uses restposition rotation, but actual position
|
||||
float tmat[4][4];
|
||||
|
||||
/* the rotation of the parent restposition */
|
||||
Mat4CpyMat4(tmat, parbone->arm_mat);
|
||||
|
||||
/* the location of actual parent transform */
|
||||
VECCOPY(tmat[3], offs_bone[3]);
|
||||
offs_bone[3][0]= offs_bone[3][1]= offs_bone[3][2]= 0.0f;
|
||||
Mat4MulVecfl(parchan->pose_mat, tmat[3]);
|
||||
|
||||
Mat4MulSerie(pchan->pose_mat, tmat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL);
|
||||
}
|
||||
else
|
||||
Mat4MulSerie(pchan->pose_mat, parchan->pose_mat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL);
|
||||
}
|
||||
else
|
||||
@ -1017,7 +1031,6 @@ static void where_is_pose_bone(Object *ob, bPoseChannel *pchan)
|
||||
if(pchan->constraints.first) {
|
||||
static Object conOb;
|
||||
static int initialized= 0;
|
||||
float vec[3];
|
||||
|
||||
VECCOPY(vec, pchan->pose_mat[3]);
|
||||
|
||||
@ -1067,7 +1080,7 @@ void where_is_pose (Object *ob)
|
||||
{
|
||||
bArmature *arm;
|
||||
Bone *bone;
|
||||
bPoseChannel *pchan, *next;
|
||||
bPoseChannel *pchan;
|
||||
float imat[4][4];
|
||||
|
||||
arm = get_armature(ob);
|
||||
@ -1132,9 +1145,7 @@ void where_is_pose (Object *ob)
|
||||
}
|
||||
|
||||
/* calculating deform matrices */
|
||||
for(pchan= ob->pose->chanbase.first; pchan; pchan= next) {
|
||||
next= pchan->next;
|
||||
|
||||
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
|
||||
if(pchan->bone) {
|
||||
Mat4Invert(imat, pchan->bone->arm_mat);
|
||||
Mat4MulMat4(pchan->chan_mat, imat, pchan->pose_mat);
|
||||
|
@ -1645,7 +1645,6 @@ void solve_constraints (Object *ob, short obtype, void *obdata, float ctime)
|
||||
float delta[4][4];
|
||||
float imat[4][4];
|
||||
float identity[4][4];
|
||||
float worldmat[4][4];
|
||||
|
||||
if (con->type!=CONSTRAINT_TYPE_KINEMATIC) {
|
||||
/* If we're not an IK constraint, solve the constraint then blend it to the previous one */
|
||||
@ -1664,18 +1663,6 @@ void solve_constraints (Object *ob, short obtype, void *obdata, float ctime)
|
||||
Mat4MulMat4 (ob->obmat, delta, oldmat);
|
||||
|
||||
}
|
||||
else{
|
||||
/* Interpolate the target between the chain's unconstrained endpoint and the effector loc */
|
||||
if (obtype==TARGET_BONE) {
|
||||
get_objectspace_bone_matrix(obdata, oldmat, 1, 1);
|
||||
|
||||
Mat4MulMat4(worldmat, oldmat, ob->parent->obmat);
|
||||
|
||||
Mat4BlendMat4(focusmat, worldmat, lastmat, a);
|
||||
|
||||
evaluate_constraint(con, ob, obtype, obdata, focusmat);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -120,6 +120,8 @@ typedef struct bArmature {
|
||||
#define BONE_DONE 128
|
||||
/* active is on mouse clicks only */
|
||||
#define BONE_ACTIVE 256
|
||||
/* No parent rotation or scale */
|
||||
#define BONE_HINGE 512
|
||||
|
||||
/* bone->flag bits */
|
||||
#define BONE_IK_TOPARENTBIT 4
|
||||
|
@ -1527,9 +1527,9 @@ static void validate_posebonebutton_cb(void *bonev, void *namev)
|
||||
allqueue(REDRAWALL, 0);
|
||||
}
|
||||
|
||||
static void armature_rest_pos_func(void *pointer1, void *pointer2)
|
||||
static void armature_recalc_func(void *obp, void *pointer2)
|
||||
{
|
||||
Object *ob= pointer1;
|
||||
Object *ob= obp;
|
||||
|
||||
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
|
||||
}
|
||||
@ -1545,7 +1545,7 @@ static void editing_panel_armature_type(Object *ob, bArmature *arm)
|
||||
uiBlockBeginAlign(block);
|
||||
but = uiDefButI(block, TOG|BIT|ARM_RESTPOSBIT,REDRAWVIEW3D,
|
||||
"Rest Position", 10,180,150,20, &arm->flag, 0, 0, 0, 0, "Disable all animation for this object");
|
||||
uiButSetFunc(but, armature_rest_pos_func, ob, arm);
|
||||
uiButSetFunc(but, armature_recalc_func, ob, NULL);
|
||||
uiDefButI(block, TOG|BIT|ARM_DELAYBIT,REDRAWVIEW3D, "Delay Deform", 160, 180,150,20, &arm->flag, 0, 0, 0, 0, "Don't deform children when manipulating bones in pose mode");
|
||||
|
||||
uiBlockBeginAlign(block);
|
||||
@ -1583,9 +1583,6 @@ static void editing_panel_armature_bones(Object *ob, bArmature *arm)
|
||||
for (curBone=G.edbo.first, index=0; curBone; curBone=curBone->next, index++){
|
||||
if (curBone->flag & (BONE_SELECTED)) {
|
||||
|
||||
/* Hide in posemode flag */
|
||||
uiDefButI(block, TOG|BIT|BONE_HIDDENBIT, REDRAWVIEW3D, "Hide", bx-55,by,45,18, &curBone->flag, 0, 0, 0, 0, "Toggles display of this bone in posemode");
|
||||
|
||||
/* Bone naming button */
|
||||
but=uiDefBut(block, TEX, REDRAWVIEW3D, "BO:", bx-10,by,117,18, &curBone->name, 0, 24, 0, 0, "Change the bone name");
|
||||
uiButSetFunc(but, validate_editbonebutton_cb, curBone, NULL);
|
||||
@ -1604,26 +1601,24 @@ static void editing_panel_armature_bones(Object *ob, bArmature *arm)
|
||||
|
||||
/* IK to parent flag */
|
||||
if (curBone->parent){
|
||||
but=uiDefButI(block, TOG|BIT|BONE_IK_TOPARENTBIT, REDRAWVIEW3D, "IK", bx+300,by,32,18, &curBone->flag, 0.0, 0.0, 0.0, 0.0, "IK link to parent");
|
||||
but=uiDefButBitI(block, TOG, BONE_IK_TOPARENT, REDRAWVIEW3D, "IK", bx+300,by,32,18, &curBone->flag, 0.0, 0.0, 0.0, 0.0, "IK link to parent");
|
||||
uiButSetFunc(but, attach_bone_to_parent_cb, curBone, NULL);
|
||||
}
|
||||
|
||||
/* Dist and weight buttons */
|
||||
/* Segment, dist and weight buttons */
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefButS(block, NUM, REDRAWVIEW3D, "Segm: ",
|
||||
bx-10,by-19,117,18, &curBone->segments, 1.0, 32.0, 0.0, 0.0,
|
||||
"Subdivisions for B-bones");
|
||||
uiDefButS(block, NUM, REDRAWVIEW3D, "Segm: ", bx-10,by-19,117,18, &curBone->segments, 1.0, 32.0, 0.0, 0.0, "Subdivisions for B-bones");
|
||||
uiDefButF(block, NUM,REDRAWVIEW3D, "Dist:", bx+110, by-19, 105, 18, &curBone->dist, 0.0, 1000.0, 10.0, 0.0, "Bone deformation distance");
|
||||
uiDefButF(block, NUM,REDRAWVIEW3D, "Weight:", bx+223, by-19,110, 18, &curBone->weight, 0.0F, 1000.0F, 10.0F, 0.0F, "Bone deformation weight");
|
||||
|
||||
/* Dist and weight buttons */
|
||||
uiDefButF(block, NUM,REDRAWVIEW3D, "Dist:", bx+110, by-19,
|
||||
105, 18, &curBone->dist, 0.0, 1000.0, 10.0, 0.0,
|
||||
"Bone deformation distance");
|
||||
uiDefButF(block, NUM,REDRAWVIEW3D, "Weight:", bx+223, by-19,
|
||||
110, 18, &curBone->weight, 0.0F, 1000.0F,
|
||||
10.0F, 0.0F, "Bone deformation weight");
|
||||
/* bone types */
|
||||
uiDefButBitI(block, TOG, BONE_HINGE, REDRAWVIEW3D, "Hinge", bx-10,by-38,117,18, &curBone->flag, 1.0, 32.0, 0.0, 0.0, "Don't inherit rotation or scale from parent Bone");
|
||||
uiDefButS(block, TOGN|BIT|0,REDRAWVIEW3D, "Skinnable", bx+110, by-38, 105, 18, &curBone->boneclass, 0.0, 0.0, 0.0, 0.0, "Indicate if Bone is included in automatic creation of vertex groups");
|
||||
/* Hide in posemode flag */
|
||||
uiDefButBitI(block, TOG, BONE_HIDDEN, REDRAWVIEW3D, "Hide", bx+223,by-38,110,18, &curBone->flag, 0, 0, 0, 0, "Toggles display of this bone in posemode");
|
||||
|
||||
uiBlockEndAlign(block);
|
||||
by-=42;
|
||||
by-=60;
|
||||
|
||||
if(by < -200) break; // for time being... extreme long panels are very slow
|
||||
}
|
||||
@ -1659,31 +1654,28 @@ static void editing_panel_pose_bones(Object *ob, bArmature *arm)
|
||||
curBone= pchan->bone;
|
||||
if (curBone->flag & (BONE_SELECTED)) {
|
||||
|
||||
/* Hide in posemode flag */
|
||||
uiDefButI(block, TOG|BIT|BONE_HIDDENBIT, REDRAWVIEW3D, "Hide", bx-55,by,45,18, &curBone->flag, 0, 0, 0, 0, "Toggles display of this bone in posemode");
|
||||
|
||||
/* Bone naming button */
|
||||
uiBlockBeginAlign(block);
|
||||
but=uiDefBut(block, TEX, REDRAWVIEW3D, "BO:", bx-10,by,117,18, &curBone->name, 0, 24, 0, 0, "Change the bone name");
|
||||
uiButSetFunc(but, validate_posebonebutton_cb, curBone, NULL);
|
||||
|
||||
/* Dist and weight buttons */
|
||||
uiDefButF(block, NUM,REDRAWVIEW3D, "Dist:", bx+107, by,
|
||||
105, 18, &curBone->dist, 0.0, 1000.0, 10.0, 0.0,
|
||||
"Bone deformation distance");
|
||||
uiDefButF(block, NUM,REDRAWVIEW3D, "Weight:", bx+220, by,
|
||||
110, 18, &curBone->weight, 0.0F, 1000.0F,
|
||||
10.0F, 0.0F, "Bone deformation weight");
|
||||
uiDefButF(block, NUM,REDRAWVIEW3D, "Dist:", bx+107, by, 105, 18, &curBone->dist, 0.0, 1000.0, 10.0, 0.0, "Bone deformation distance");
|
||||
uiDefButF(block, NUM,REDRAWVIEW3D, "Weight:", bx+220, by, 110, 18, &curBone->weight, 0.0F, 1000.0F, 10.0F, 0.0F, "Bone deformation weight");
|
||||
|
||||
|
||||
/* Segment, ease in/out buttons */
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefButS(block, NUM, REDRAWVIEW3D, "Segm: ",
|
||||
bx-10,by-19,117,19, &curBone->segments, 1.0, 32.0, 0.0, 0.0, "Subdivisions for B-bones");
|
||||
uiDefButF(block, NUM,REDRAWVIEW3D, "In:",
|
||||
bx+107, by-19,105, 19, &curBone->ease1, 0.0, 2.0, 10.0, 0.0, "First length of Bezier handle");
|
||||
uiDefButF(block, NUM,REDRAWVIEW3D, "Out:",
|
||||
bx+220, by-19, 110, 19, &curBone->ease2, 0.0, 2.0, 10.0, 0.0, "Second length of Bezier handle");
|
||||
uiDefButS(block, NUM, REDRAWVIEW3D, "Segm: ", bx-10,by-19,117,19, &curBone->segments, 1.0, 32.0, 0.0, 0.0, "Subdivisions for B-bones");
|
||||
uiDefButF(block, NUM,REDRAWVIEW3D, "In:", bx+107, by-19,105, 19, &curBone->ease1, 0.0, 2.0, 10.0, 0.0, "First length of Bezier handle");
|
||||
uiDefButF(block, NUM,REDRAWVIEW3D, "Out:", bx+220, by-19, 110, 19, &curBone->ease2, 0.0, 2.0, 10.0, 0.0, "Second length of Bezier handle");
|
||||
|
||||
/* bone types */
|
||||
but= uiDefButBitI(block, TOG, BONE_HINGE, REDRAWVIEW3D, "Hinge", bx-10,by-38,117,18, &curBone->flag, 1.0, 32.0, 0.0, 0.0, "Don't inherit rotation or scale from parent Bone");
|
||||
uiButSetFunc(but, armature_recalc_func, ob, NULL);
|
||||
uiDefButS(block, TOGN|BIT|0,REDRAWVIEW3D, "Skinnable", bx+110, by-38, 105, 18, &curBone->boneclass, 0.0, 0.0, 0.0, 0.0, "Indicate if Bone is included in automatic creation of vertex groups");
|
||||
/* Hide in posemode flag */
|
||||
uiDefButBitI(block, TOG, BONE_HIDDEN, REDRAWVIEW3D, "Hide", bx+223,by-38,110,18, &curBone->flag, 0, 0, 0, 0, "Toggles display of this bone in posemode");
|
||||
|
||||
uiBlockEndAlign(block);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user