added .sel to pose bones as well as read only .parent property

This commit is contained in:
2006-08-31 09:26:49 +00:00
parent ab5cc740d6
commit e2e6bce283
3 changed files with 44 additions and 1 deletions

View File

@@ -54,6 +54,8 @@
#include "NLA.h"
#include "gen_utils.h"
#include "DNA_armature_types.h" /*used for pose bone select*/
extern void chan_calc_mat(bPoseChannel *chan);
//------------------------ERROR CODES---------------------------------
@@ -908,6 +910,38 @@ static int PoseBone_setTail(BPy_PoseBone *self, PyObject *value, void *closure)
return EXPP_intError(PyExc_AttributeError, "%s%s%s",
sPoseBoneError, ".tail: ", "not able to set this property");
}
//------------------------PoseBone.sel (getter)
//Gets the pose bones selection
static PyObject *PoseBone_getSelect(BPy_PoseBone *self, void *closure)
{
if (self->posechannel->bone->flag & BONE_SELECTED)
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
}
//------------------------PoseBone.sel (setter)
//Sets the pose bones selection
static int PoseBone_setSelect(BPy_PoseBone *self, PyObject *value, void *closure)
{
if (PyObject_IsTrue( value ))
self->posechannel->bone->flag |= BONE_SELECTED;
else
self->posechannel->bone->flag &= ~(BONE_SELECTED | BONE_ACTIVE);
return 0;
}
//------------------------PoseBone.parent (getter)
//Gets the pose bones selection
static PyObject *PoseBone_getParent(BPy_PoseBone *self, void *closure)
{
if (self->posechannel->parent) {
return PyPoseBone_FromPosechannel(self->posechannel->parent);
} else {
return EXPP_incr_ret(Py_None);
}
}
//------------------TYPE_OBECT IMPLEMENTATION---------------------------
//------------------------tp_getset
//This contains methods for attributes that require checking
@@ -928,12 +962,16 @@ static PyGetSetDef BPy_PoseBone_getset[] = {
"The pose bone's head positon", NULL},
{"tail", (getter)PoseBone_getTail, (setter)PoseBone_setTail,
"The pose bone's tail positon", NULL},
{"sel", (getter)PoseBone_getSelect, (setter)PoseBone_setSelect,
"The pose selection state", NULL},
{"limitMin", (getter)PoseBone_getLimitMin, (setter)PoseBone_setLimitMin,
"The pose bone dof min", NULL},
{"limitMax", (getter)PoseBone_getLimitMax, (setter)PoseBone_setLimitMax,
"The pose bone dof max", NULL},
{"constraints", (getter)PoseBone_getConstraints, (setter)NULL,
"The list of contraints that pertain to this pose bone", NULL},
{"parent", (getter)PoseBone_getParent, (setter)NULL,
"The bones parent (read only for posebones)", NULL},
{NULL, NULL, NULL, NULL, NULL}
};
//------------------------tp_dealloc

View File

@@ -46,7 +46,7 @@ extern PyTypeObject PoseBonesDict_Type;
//-------------------STRUCT DEFINITION----------------------------
typedef struct {
PyObject_HEAD
PyObject *bonesMap;
PyObject *bonesMap;
ListBase *bones;
} BPy_PoseBonesDict;
@@ -60,6 +60,7 @@ typedef struct {
typedef struct {
PyObject_HEAD
bPoseChannel *posechannel;
} BPy_PoseBone;
//-------------------VISIBLE PROTOTYPES-------------------------

View File

@@ -81,6 +81,10 @@ class PoseBone:
@type head: Vector object
@ivar tail: The final tail location for this PoseBone. (not settable)
@type tail: Vector object
@ivar sel: The selection state of this bone
@type sel: Boolean
@ivar parent: The parent of this posebone (not settable)
@type parent: posebone or None
@ivar localMatrix: The matrix combination of rot/quat/loc.
@type localMatrix: Matrix object
@ivar poseMatrix: The total transformation of this PoseBone including constraints.