- getBones() fixed - returns all armature bones including children

This commit is contained in:
2004-04-05 04:17:01 +00:00
parent 09b19aead2
commit 136b66c19f
2 changed files with 39 additions and 36 deletions

View File

@@ -314,28 +314,36 @@ Armature_getName (BPy_Armature * self)
}
/** Create and return a list of the root bones for this armature. */
static void
append_childrenToList(Bone *parent, PyObject *listbones)
{
Bone *child = NULL;
//append children
for(child = parent->childbase.first; child; child = child->next){
PyList_Append (listbones, Bone_CreatePyObject (child));
if(child->childbase.first){ //has children?
append_childrenToList(child, listbones);
}
}
}
static PyObject *
Armature_getBones (BPy_Armature * self)
{
int totbones = 0;
PyObject *listbones = NULL;
Bone *current = NULL;
int i;
Bone *parent = NULL;
/* Count the number of bones to create the list */
current = self->armature->bonebase.first;
for (; current; current = current->next)
totbones++;
listbones = PyList_New(0);
/* Create a list with a bone wrapper for each bone */
current = self->armature->bonebase.first;
listbones = PyList_New (totbones);
for (i = 0; i < totbones; i++)
{
/* Wrap and set to corresponding element of the list. */
PyList_SetItem (listbones, i, Bone_CreatePyObject (current));
current = current->next;
//append root bones
for (parent = self->armature->bonebase.first; parent; parent = parent->next){
PyList_Append (listbones, Bone_CreatePyObject (parent));
if(parent->childbase.first){ //has children?
append_childrenToList(parent, listbones);
}
}
return listbones;
@@ -525,8 +533,6 @@ Armature_setAttr (BPy_Armature * self, char *name, PyObject * value)
if (strcmp (name, "name") == 0)
error = Armature_setName (self, valtuple);
/* if (strcmp (name, "bones") == 0)
error = Armature_setBones (self, valtuple); */
else
{ /* Error */
Py_DECREF (valtuple);

View File

@@ -777,9 +777,6 @@ Bone_compare (BPy_Bone * a, BPy_Bone * b)
return (pa == pb) ? 0 : -1;
}
/*****************************************************************************/
/* Function: Bone_CreatePyObject */
/* Description: This function will create a new BlenBone from an existing */