Armatures; the bones menu used for "Make Parent" (CTRL+P) used wrong

indices still.
Cleaned the code, moved to editobject.c
This commit is contained in:
Ton Roosendaal
2005-07-09 16:16:45 +00:00
parent 30f89a6db7
commit a4f907d2e0
4 changed files with 70 additions and 79 deletions

View File

@@ -86,7 +86,7 @@ void extrude_armature(void);
void free_editArmature(void);
void join_armature(void);
void load_editArmature(void);
char* make_bone_menu(struct bArmature *arm);
void make_bone_parent(void);
void clear_bone_parent(void);

View File

@@ -684,40 +684,6 @@ static int count_bones (bArmature *arm, int flagmask, int allbones)
}
static void make_bone_menu_children (Bone *bone, char *str, int *index)
{
Bone *curBone;
sprintf (str, "%s|%s%%x%d", str, bone->name, *index);
(*index) ++;
for (curBone=bone->childbase.first; curBone; curBone=curBone->next)
make_bone_menu_children (curBone, str, index);
}
/* called in editobject.c */
char *make_bone_menu (bArmature *arm)
{
char *menustr=NULL;
Bone *curBone;
int size;
int index=0;
// Count the bones
size = (count_bones (arm, 0xFFFFFFFF, 1)*48) + 256;
menustr = MEM_callocN(size, "bonemenu");
sprintf (menustr, "Select Bone%%t");
for (curBone=arm->bonebase.first; curBone; curBone=curBone->next){
make_bone_menu_children (curBone, menustr, &index);
}
return menustr;
}
/* **************** END Posemode stuff ********************** */
/* **************** EditMode stuff ********************** */

View File

@@ -1093,6 +1093,29 @@ int test_parent_loop(Object *par, Object *ob)
}
static char *make_bone_menu (Object *ob)
{
char *menustr=NULL;
bPoseChannel *pchan;
int size;
int index=0;
// Count the bones
for(size=0, pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next, size++);
size = size*48 + 256;
menustr = MEM_callocN(size, "bonemenu");
sprintf (menustr, "Select Bone%%t");
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next, index++) {
sprintf (menustr, "%s|%s%%x%d", menustr, pchan->bone->name, index);
}
return menustr;
}
void make_parent(void)
{
Base *base;
@@ -1194,8 +1217,7 @@ void make_parent(void)
mode=PARBONE;
/* Make bone popup menu */
bonestr = make_bone_menu(get_armature(par));
// if(mbutton(&bone, bonestr, 1, 24, "Bone: ")==0) {
bonestr = make_bone_menu(par);
bonenr= pupmenu_col(bonestr, 20);
if (bonestr)

View File

@@ -442,58 +442,61 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
/* possible add all other types links? */
}
}
if(ob->pose && ob!=G.obedit) {
if(ob->pose) {
bPoseChannel *pchan;
TreeElement *ten;
TreeElement *tenla= outliner_add_element(soops, &te->subtree, ob, te, TSE_POSE_BASE, 0);
int a= 0;
tenla->name= "Pose";
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next, a++) {
ten= outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_POSE_CHANNEL, a);
ten->name= pchan->name;
ten->directdata= pchan;
pchan->prev= (bPoseChannel *)ten;
if(pchan->constraints.first) {
Object *target;
bConstraint *con;
TreeElement *ten1;
TreeElement *tenla1= outliner_add_element(soops, &ten->subtree, ob, ten, TSE_CONSTRAINT_BASE, 0);
int a= 0;
char *str;
if(ob!=G.obedit) { // channels undefined in editmode, but we want the 'tenla' pose icon itself
int a= 0;
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next, a++) {
ten= outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_POSE_CHANNEL, a);
ten->name= pchan->name;
ten->directdata= pchan;
pchan->prev= (bPoseChannel *)ten;
tenla1->name= "Constraints";
for(con= pchan->constraints.first; con; con= con->next, a++) {
ten1= outliner_add_element(soops, &tenla1->subtree, ob, tenla1, TSE_CONSTRAINT, a);
target= get_constraint_target(con, &str);
if(str && str[0]) ten1->name= str;
else if(target) ten1->name= target->id.name+2;
else ten1->name= con->name;
ten1->directdata= con;
/* possible add all other types links? */
if(pchan->constraints.first) {
Object *target;
bConstraint *con;
TreeElement *ten1;
TreeElement *tenla1= outliner_add_element(soops, &ten->subtree, ob, ten, TSE_CONSTRAINT_BASE, 0);
int a= 0;
char *str;
tenla1->name= "Constraints";
for(con= pchan->constraints.first; con; con= con->next, a++) {
ten1= outliner_add_element(soops, &tenla1->subtree, ob, tenla1, TSE_CONSTRAINT, a);
target= get_constraint_target(con, &str);
if(str && str[0]) ten1->name= str;
else if(target) ten1->name= target->id.name+2;
else ten1->name= con->name;
ten1->directdata= con;
/* possible add all other types links? */
}
}
}
}
/* make hierarchy */
ten= tenla->subtree.first;
while(ten) {
TreeElement *nten= ten->next, *par;
tselem= TREESTORE(ten);
if(tselem->type==TSE_POSE_CHANNEL) {
pchan= (bPoseChannel *)ten->directdata;
if(pchan->parent) {
BLI_remlink(&tenla->subtree, ten);
par= (TreeElement *)pchan->parent->prev;
BLI_addtail(&par->subtree, ten);
/* make hierarchy */
ten= tenla->subtree.first;
while(ten) {
TreeElement *nten= ten->next, *par;
tselem= TREESTORE(ten);
if(tselem->type==TSE_POSE_CHANNEL) {
pchan= (bPoseChannel *)ten->directdata;
if(pchan->parent) {
BLI_remlink(&tenla->subtree, ten);
par= (TreeElement *)pchan->parent->prev;
BLI_addtail(&par->subtree, ten);
}
}
ten= nten;
}
/* restore prev pointers */
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
if(pchan->next) pchan->next->prev= pchan;
else if(pchan==ob->pose->chanbase.first) pchan->prev= NULL;
}
ten= nten;
}
/* restore prev pointers */
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
if(pchan->next) pchan->next->prev= pchan;
else if(pchan==ob->pose->chanbase.first) pchan->prev= NULL;
}
}