forked from bartvdbraak/blender
#bugfix #3659
Zero-sized bones in an Armature didn't result in a stable rest position. This caused bones to rotate to random positions on each editmode exit. This commit will automatically remove such bones on exit editmode now, and adds a warning print for it. I've tried to code exception handling for zero-sized bones, but this is just too hard to get stable. Better to define by default that Bones always should have a length. Typically zero-sized bones only get added by accident, for example while ctrl+clicking new bones.
This commit is contained in:
parent
8dbe14b70b
commit
1165cde621
@ -231,7 +231,7 @@ static void fix_bonelist_roll (ListBase *bonelist, ListBase *editbonelist)
|
||||
void editbones_to_armature (ListBase *list, Object *ob)
|
||||
{
|
||||
bArmature *arm;
|
||||
EditBone *eBone;
|
||||
EditBone *eBone, *neBone;
|
||||
Bone *newBone;
|
||||
Object *obt;
|
||||
|
||||
@ -242,8 +242,25 @@ void editbones_to_armature (ListBase *list, Object *ob)
|
||||
/* armature bones */
|
||||
free_bones(arm);
|
||||
|
||||
/* remove zero sized bones, this gives instable restposes */
|
||||
for (eBone=list->first; eBone; eBone= neBone) {
|
||||
float len= VecLenf(eBone->head, eBone->tail);
|
||||
neBone= eBone->next;
|
||||
if(len <= FLT_EPSILON) {
|
||||
EditBone *fBone;
|
||||
|
||||
/* Find any bones that refer to this bone */
|
||||
for (fBone=list->first; fBone; fBone= fBone->next){
|
||||
if (fBone->parent==eBone)
|
||||
fBone->parent= eBone->parent;
|
||||
}
|
||||
printf("Warning; removed zero sized bone: %s\n", eBone->name);
|
||||
BLI_freelinkN (list, eBone);
|
||||
}
|
||||
}
|
||||
|
||||
/* Copy the bones from the editData into the armature */
|
||||
for (eBone=list->first;eBone;eBone=eBone->next){
|
||||
for (eBone=list->first; eBone; eBone=eBone->next){
|
||||
newBone= MEM_callocN (sizeof(Bone), "bone");
|
||||
eBone->temp= newBone; /* Associate the real Bones with the EditBones */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user