Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2006-08-26 09:40:58 +0400
committerCampbell Barton <ideasman42@gmail.com>2006-08-26 09:40:58 +0400
commitf479235f8e2086695d527ce3c851aae1efc06280 (patch)
tree6406caa4f6320029f75224c99022a31fc3c6fa77
parentb56047a65ac17e04832438f85fd4a7f6b95b8234 (diff)
added tipRadius and headRadius bone properties
-rw-r--r--source/blender/python/api2_2x/Bone.c128
-rw-r--r--source/blender/python/api2_2x/Bone.h8
-rw-r--r--source/blender/python/api2_2x/doc/Armature.py8
3 files changed, 140 insertions, 4 deletions
diff --git a/source/blender/python/api2_2x/Bone.c b/source/blender/python/api2_2x/Bone.c
index c18beb17b08..bed859a5a78 100644
--- a/source/blender/python/api2_2x/Bone.c
+++ b/source/blender/python/api2_2x/Bone.c
@@ -639,6 +639,76 @@ static int EditBone_setLength(BPy_EditBone *self, PyObject *value, void *closure
printf("Sorry this isn't implemented yet.... :/");
return 1;
}
+
+
+//------------------------Bone.headRadius (get)
+static PyObject *EditBone_getHeadRadius(BPy_EditBone *self, void *closure)
+{
+ if (self->editbone)
+ if (self->editbone->parent && self->editbone->flag & BONE_CONNECTED)
+ return PyFloat_FromDouble(self->editbone->parent->rad_tail);
+ else
+ return PyFloat_FromDouble(self->editbone->rad_head);
+ else
+ if (self->parent && self->flag & BONE_CONNECTED)
+ return PyFloat_FromDouble(self->parent->rad_tail);
+ else
+ return PyFloat_FromDouble(self->rad_head);
+}
+//------------------------Bone.headRadius (set)
+static int EditBone_setHeadRadius(BPy_EditBone *self, PyObject *value, void *closure)
+{
+ float radius;
+ if (!PyArg_Parse(value, "f", &radius))
+ goto AttributeError;
+ CLAMP(radius, 0.0f, 10000.0f);
+
+ if (self->editbone)
+ if (self->editbone->parent && self->editbone->flag & BONE_CONNECTED)
+ self->editbone->parent->rad_tail= radius;
+ else
+ self->editbone->rad_head= radius;
+ else
+ if (self->parent && self->flag & BONE_CONNECTED)
+ self->parent->rad_tail= radius;
+ else
+ self->rad_head= radius;
+ return 0;
+
+AttributeError:
+ return EXPP_intError(PyExc_AttributeError, "%s%s%s",
+ sEditBoneError, ".headRadius: ", "expects a float");
+}
+
+
+//------------------------Bone.tailRadius (get)
+static PyObject *EditBone_getTailRadius(BPy_EditBone *self, void *closure)
+{
+ if (self->editbone)
+ return PyFloat_FromDouble(self->editbone->rad_tail);
+ else
+ return PyFloat_FromDouble(self->rad_tail);
+}
+//------------------------Bone.tailRadius (set)
+static int EditBone_setTailRadius(BPy_EditBone *self, PyObject *value, void *closure)
+{
+ float radius;
+ if (!PyArg_Parse(value, "f", &radius))
+ goto AttributeError;
+ CLAMP(radius, 0.0f, 10000.0f);
+
+ if (self->editbone)
+ self->editbone->rad_tail = radius;
+ else
+ self->rad_tail = radius;
+ return 0;
+
+AttributeError:
+ return EXPP_intError(PyExc_AttributeError, "%s%s%s",
+ sEditBoneError, ".tailRadius: ", "expects a float");
+}
+
+
//------------------TYPE_OBECT IMPLEMENTATION--------------------------
//------------------------tp_methods
//This contains a list of all methods the object contains
@@ -674,6 +744,10 @@ static PyGetSetDef BPy_EditBone_getset[] = {
"The parent bone of this bone", NULL},
{"length", (getter)EditBone_getLength, (setter)EditBone_setLength,
"The length of this bone", NULL},
+ {"tailRadius", (getter)EditBone_getTailRadius, (setter)EditBone_setTailRadius,
+ "Set the radius of this bones tip", NULL},
+ {"headRadius", (getter)EditBone_getHeadRadius, (setter)EditBone_setHeadRadius,
+ "Set the radius of this bones head", NULL},
{NULL, NULL, NULL, NULL,NULL}
};
@@ -1056,6 +1130,56 @@ static int Bone_setLength(BPy_Bone *self, PyObject *value, void *closure)
return EXPP_intError(PyExc_ValueError, "%s%s",
sBoneError, "You must first call .makeEditable() to edit the armature");
}
+
+//------------------------Bone.headRadius (get)
+static PyObject *Bone_getHeadRadius(BPy_Bone *self, void *closure)
+{
+
+ if (self->bone->parent && self->bone->flag & BONE_CONNECTED)
+ return PyFloat_FromDouble(self->bone->parent->rad_tail);
+ else
+ return PyFloat_FromDouble(self->bone->rad_head);
+}
+//------------------------Bone.headRadius (set)
+static int Bone_setHeadRadius(BPy_Bone *self, PyObject *value, void *closure)
+{
+ float radius;
+ if (!PyArg_Parse(value, "f", &radius))
+ goto AttributeError;
+ CLAMP(radius, 0.0f, 10000.0f);
+
+ if (self->bone->parent && self->bone->flag & BONE_CONNECTED)
+ self->bone->parent->rad_tail= radius;
+ else
+ self->bone->rad_head= radius;
+ return 0;
+
+AttributeError:
+ return EXPP_intError(PyExc_AttributeError, "%s%s%s",
+ sEditBoneError, ".headRadius: ", "expects a float");
+}
+
+//------------------------Bone.tailRadius (get)
+static PyObject *Bone_getTailRadius(BPy_Bone *self, void *closure)
+{
+ return PyFloat_FromDouble(self->bone->rad_tail);
+}
+
+//------------------------Bone.headRadius (set)
+static int Bone_setTailRadius(BPy_Bone *self, PyObject *value, void *closure)
+{
+ float radius;
+ if (!PyArg_Parse(value, "f", &radius))
+ goto AttributeError;
+ CLAMP(radius, 0.0f, 10000.0f);
+ self->bone->rad_tail= radius;
+ return 0;
+
+AttributeError:
+ return EXPP_intError(PyExc_AttributeError, "%s%s%s",
+ sEditBoneError, ".headRadius: ", "expects a float");
+}
+
//------------------TYPE_OBECT IMPLEMENTATION--------------------------
//------------------------tp_methods
//This contains a list of all methods the object contains
@@ -1095,6 +1219,10 @@ static PyGetSetDef BPy_Bone_getset[] = {
"The child bones of this bone", NULL},
{"length", (getter)Bone_getLength, (setter)Bone_setLength,
"The length of this bone", NULL},
+ {"tailRadius", (getter)Bone_getTailRadius, (setter)Bone_setTailRadius,
+ "Set the radius of this bones tip", NULL},
+ {"headRadius", (getter)Bone_getHeadRadius, (setter)Bone_setHeadRadius,
+ "Set the radius of this bones head", NULL},
{NULL, NULL, NULL, NULL,NULL}
};
//------------------------tp_repr
diff --git a/source/blender/python/api2_2x/Bone.h b/source/blender/python/api2_2x/Bone.h
index 8c10aeb3075..c3f5de81714 100644
--- a/source/blender/python/api2_2x/Bone.h
+++ b/source/blender/python/api2_2x/Bone.h
@@ -34,13 +34,13 @@
#include <Python.h>
#include "DNA_armature_types.h"
-//-------------------TYPE CHECKS---------------------------------
+/*-------------------TYPE CHECKS---------------------------------*/
#define BoneObject_Check(v) ((v)->ob_type == &Bone_Type)
#define EditBoneObject_Check(v) ((v)->ob_type == &EditBone_Type)
-//-------------------TYPEOBJECT----------------------------------
+/*-------------------TYPEOBJECT----------------------------------*/
extern PyTypeObject EditBone_Type;
extern PyTypeObject Bone_Type;
-//-------------------STRUCT DEFINITION----------------------------
+/*-------------------STRUCT DEFINITION----------------------------*/
typedef struct {
PyObject_HEAD
@@ -66,7 +66,7 @@ typedef struct {
float rad_tail;
short segments;
} BPy_EditBone;
-//-------------------VISIBLE PROTOTYPES-------------------------
+/*-------------------VISIBLE PROTOTYPES-------------------------*/
PyObject *PyBone_FromBone(struct Bone *bone);
struct Bone *PyBone_AsBone(BPy_Bone *py_Bone);
PyObject *PyEditBone_FromBone(Bone *bone);
diff --git a/source/blender/python/api2_2x/doc/Armature.py b/source/blender/python/api2_2x/doc/Armature.py
index 587cadd74ad..791d18e2566 100644
--- a/source/blender/python/api2_2x/doc/Armature.py
+++ b/source/blender/python/api2_2x/doc/Armature.py
@@ -277,6 +277,10 @@ class Bone:
@type deformDist: Float
@ivar length: The length of the bone. This cannot be set.
@type length: Float
+ @ivar headRadius: The radius of this bones head (used for envalope bones)
+ @type headRadius: Float
+ @ivar tailRadius: The radius of this bones head (used for envalope bones)
+ @type tailRadius: Float
"""
def hasParent():
@@ -334,6 +338,10 @@ class Editbone:
@type deformDist: Float
@ivar length: The length of the bone. This cannot be set.
@type length: Float
+ @ivar headRadius: The radius of this bones head (used for envalope bones)
+ @type headRadius: Float
+ @ivar tailRadius: The radius of this bones head (used for envalope bones)
+ @type tailRadius: Float
"""
def hasParent():