py/rna, euler objects order is now wrapped correctly...
eg: eul = bpy.context.object.rotation_euler eul.order = 'XZY' # will update the objects setting.
This commit is contained in:
@@ -646,7 +646,7 @@ int Mathutils_RegisterCallback(Mathutils_Callback *cb)
|
||||
int _BaseMathObject_ReadCallback(BaseMathObject *self)
|
||||
{
|
||||
Mathutils_Callback *cb= mathutils_callbacks[self->cb_type];
|
||||
if(cb->get(self->cb_user, self->cb_subtype, self->data))
|
||||
if(cb->get(self, self->cb_subtype, self->data))
|
||||
return 1;
|
||||
|
||||
PyErr_Format(PyExc_SystemError, "%s user has become invalid", Py_TYPE(self)->tp_name);
|
||||
@@ -656,7 +656,7 @@ int _BaseMathObject_ReadCallback(BaseMathObject *self)
|
||||
int _BaseMathObject_WriteCallback(BaseMathObject *self)
|
||||
{
|
||||
Mathutils_Callback *cb= mathutils_callbacks[self->cb_type];
|
||||
if(cb->set(self->cb_user, self->cb_subtype, self->data))
|
||||
if(cb->set(self, self->cb_subtype, self->data))
|
||||
return 1;
|
||||
|
||||
PyErr_Format(PyExc_SystemError, "%s user has become invalid", Py_TYPE(self)->tp_name);
|
||||
@@ -666,7 +666,7 @@ int _BaseMathObject_WriteCallback(BaseMathObject *self)
|
||||
int _BaseMathObject_ReadIndexCallback(BaseMathObject *self, int index)
|
||||
{
|
||||
Mathutils_Callback *cb= mathutils_callbacks[self->cb_type];
|
||||
if(cb->get_index(self->cb_user, self->cb_subtype, self->data, index))
|
||||
if(cb->get_index(self, self->cb_subtype, self->data, index))
|
||||
return 1;
|
||||
|
||||
PyErr_Format(PyExc_SystemError, "%s user has become invalid", Py_TYPE(self)->tp_name);
|
||||
@@ -676,7 +676,7 @@ int _BaseMathObject_ReadIndexCallback(BaseMathObject *self, int index)
|
||||
int _BaseMathObject_WriteIndexCallback(BaseMathObject *self, int index)
|
||||
{
|
||||
Mathutils_Callback *cb= mathutils_callbacks[self->cb_type];
|
||||
if(cb->set_index(self->cb_user, self->cb_subtype, self->data, index))
|
||||
if(cb->set_index(self, self->cb_subtype, self->data, index))
|
||||
return 1;
|
||||
|
||||
PyErr_Format(PyExc_SystemError, "%s user has become invalid", Py_TYPE(self)->tp_name);
|
||||
|
||||
@@ -88,18 +88,18 @@ int EXPP_VectorsAreEqual(float *vecA, float *vecB, int size, int floatSteps);
|
||||
|
||||
typedef struct Mathutils_Callback Mathutils_Callback;
|
||||
|
||||
typedef int (*BaseMathCheckFunc)(PyObject *);
|
||||
typedef int (*BaseMathGetFunc)(PyObject *, int, float *);
|
||||
typedef int (*BaseMathSetFunc)(PyObject *, int, float *);
|
||||
typedef int (*BaseMathGetIndexFunc)(PyObject *, int, float *, int);
|
||||
typedef int (*BaseMathSetIndexFunc)(PyObject *, int, float *, int);
|
||||
typedef int (*BaseMathCheckFunc)(BaseMathObject *); /* checks the user is still valid */
|
||||
typedef int (*BaseMathGetFunc)(BaseMathObject *, int, float *); /* gets the vector from the user */
|
||||
typedef int (*BaseMathSetFunc)(BaseMathObject *, int, float *); /* sets the users vector values once the vector is modified */
|
||||
typedef int (*BaseMathGetIndexFunc)(BaseMathObject *, int, float *, int); /* same as above but only for an index */
|
||||
typedef int (*BaseMathSetIndexFunc)(BaseMathObject *, int, float *, int); /* same as above but only for an index */
|
||||
|
||||
struct Mathutils_Callback {
|
||||
int (*check)(PyObject *user); /* checks the user is still valid */
|
||||
int (*get)(PyObject *user, int subtype, float *from); /* gets the vector from the user */
|
||||
int (*set)(PyObject *user, int subtype, float *to); /* sets the users vector values once the vector is modified */
|
||||
int (*get_index)(PyObject *user, int subtype, float *from,int index); /* same as above but only for an index */
|
||||
int (*set_index)(PyObject *user, int subtype, float *to, int index); /* same as above but only for an index */
|
||||
BaseMathCheckFunc check;
|
||||
BaseMathGetFunc get;
|
||||
BaseMathSetFunc set;
|
||||
BaseMathGetIndexFunc get_index;
|
||||
BaseMathSetIndexFunc set_index;
|
||||
};
|
||||
|
||||
int Mathutils_RegisterCallback(Mathutils_Callback *cb);
|
||||
|
||||
@@ -280,13 +280,13 @@ static PyObject *Color_subscript(ColorObject *self, PyObject *item)
|
||||
return Color_slice(self, start, stop);
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_TypeError, "slice steps not supported with eulers");
|
||||
PyErr_SetString(PyExc_TypeError, "slice steps not supported with color");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"euler indices must be integers, not %.200s",
|
||||
"color indices must be integers, not %.200s",
|
||||
item->ob_type->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
@@ -311,13 +311,13 @@ static int Color_ass_subscript(ColorObject *self, PyObject *item, PyObject *valu
|
||||
if (step == 1)
|
||||
return Color_ass_slice(self, start, stop, value);
|
||||
else {
|
||||
PyErr_SetString(PyExc_TypeError, "slice steps not supported with euler");
|
||||
PyErr_SetString(PyExc_TypeError, "slice steps not supported with color");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"euler indices must be integers, not %.200s",
|
||||
"color indices must be integers, not %.200s",
|
||||
item->ob_type->tp_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -587,7 +587,11 @@ static int Euler_setAxis( EulerObject * self, PyObject * value, void * type )
|
||||
/* rotation order */
|
||||
static PyObject *Euler_getOrder(EulerObject *self, void *type)
|
||||
{
|
||||
static char order[][4] = {"XYZ", "XZY", "YXZ", "YZX", "ZXY", "ZYX"};
|
||||
const char order[][4] = {"XYZ", "XZY", "YXZ", "YZX", "ZXY", "ZYX"};
|
||||
|
||||
if(!BaseMath_ReadCallback(self)) /* can read order too */
|
||||
return NULL;
|
||||
|
||||
return PyUnicode_FromString(order[self->order-EULER_ORDER_XYZ]);
|
||||
}
|
||||
|
||||
@@ -599,12 +603,8 @@ static int Euler_setOrder( EulerObject * self, PyObject * value, void * type )
|
||||
if(order == -1)
|
||||
return -1;
|
||||
|
||||
if(self->cb_user) {
|
||||
PyErr_SetString(PyExc_TypeError, "euler.order: assignment is not allowed on eulers with an owner");
|
||||
return -1;
|
||||
}
|
||||
|
||||
self->order= order;
|
||||
BaseMath_WriteCallback(self); /* order can be written back */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,15 +37,15 @@ static PyObject *column_vector_multiplication(MatrixObject * mat, VectorObject*
|
||||
/* matrix vector callbacks */
|
||||
int mathutils_matrix_vector_cb_index= -1;
|
||||
|
||||
static int mathutils_matrix_vector_check(PyObject *self_p)
|
||||
static int mathutils_matrix_vector_check(BaseMathObject *self_p)
|
||||
{
|
||||
MatrixObject *self= (MatrixObject*)self_p;
|
||||
MatrixObject *self= (MatrixObject *)self_p;
|
||||
return BaseMath_ReadCallback(self);
|
||||
}
|
||||
|
||||
static int mathutils_matrix_vector_get(PyObject *self_p, int subtype, float *vec_from)
|
||||
static int mathutils_matrix_vector_get(BaseMathObject *self_p, int subtype, float *vec_from)
|
||||
{
|
||||
MatrixObject *self= (MatrixObject*)self_p;
|
||||
MatrixObject *self= (MatrixObject *)self_p;
|
||||
int i;
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
@@ -57,9 +57,9 @@ static int mathutils_matrix_vector_get(PyObject *self_p, int subtype, float *vec
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int mathutils_matrix_vector_set(PyObject *self_p, int subtype, float *vec_to)
|
||||
static int mathutils_matrix_vector_set(BaseMathObject *self_p, int subtype, float *vec_to)
|
||||
{
|
||||
MatrixObject *self= (MatrixObject*)self_p;
|
||||
MatrixObject *self= (MatrixObject *)self_p;
|
||||
int i;
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
@@ -72,9 +72,9 @@ static int mathutils_matrix_vector_set(PyObject *self_p, int subtype, float *vec
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int mathutils_matrix_vector_get_index(PyObject *self_p, int subtype, float *vec_from, int index)
|
||||
static int mathutils_matrix_vector_get_index(BaseMathObject *self_p, int subtype, float *vec_from, int index)
|
||||
{
|
||||
MatrixObject *self= (MatrixObject*)self_p;
|
||||
MatrixObject *self= (MatrixObject *)self_p;
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return 0;
|
||||
@@ -83,7 +83,7 @@ static int mathutils_matrix_vector_get_index(PyObject *self_p, int subtype, floa
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int mathutils_matrix_vector_set_index(PyObject *self_p, int subtype, float *vec_to, int index)
|
||||
static int mathutils_matrix_vector_set_index(BaseMathObject *self_p, int subtype, float *vec_to, int index)
|
||||
{
|
||||
MatrixObject *self= (MatrixObject*)self_p;
|
||||
|
||||
|
||||
@@ -68,22 +68,34 @@ static int mathutils_rna_array_cb_index= -1; /* index for our callbacks */
|
||||
#define MATHUTILS_CB_SUBTYPE_QUAT 2
|
||||
#define MATHUTILS_CB_SUBTYPE_COLOR 0
|
||||
|
||||
static int mathutils_rna_generic_check(BPy_PropertyRNA *self)
|
||||
static int mathutils_rna_generic_check(BaseMathObject *bmo)
|
||||
{
|
||||
return self->prop?1:0;
|
||||
BPy_PropertyRNA *self= (BPy_PropertyRNA *)bmo->cb_user;
|
||||
return self->prop ? 1:0;
|
||||
}
|
||||
|
||||
static int mathutils_rna_vector_get(BPy_PropertyRNA *self, int subtype, float *vec_from)
|
||||
static int mathutils_rna_vector_get(BaseMathObject *bmo, int subtype, float *vec_from)
|
||||
{
|
||||
BPy_PropertyRNA *self= (BPy_PropertyRNA *)bmo->cb_user;
|
||||
if(self->prop==NULL)
|
||||
return 0;
|
||||
|
||||
RNA_property_float_get_array(&self->ptr, self->prop, vec_from);
|
||||
|
||||
/* Euler order exception */
|
||||
if(subtype==MATHUTILS_CB_SUBTYPE_EUL) {
|
||||
PropertyRNA *prop_eul_order= RNA_struct_find_property(&self->ptr, "rotation_mode");
|
||||
if(prop_eul_order) {
|
||||
((EulerObject *)bmo)->order= RNA_property_enum_get(&self->ptr, prop_eul_order);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int mathutils_rna_vector_set(BPy_PropertyRNA *self, int subtype, float *vec_to)
|
||||
static int mathutils_rna_vector_set(BaseMathObject *bmo, int subtype, float *vec_to)
|
||||
{
|
||||
BPy_PropertyRNA *self= (BPy_PropertyRNA *)bmo->cb_user;
|
||||
float min, max;
|
||||
if(self->prop==NULL)
|
||||
return 0;
|
||||
@@ -98,12 +110,24 @@ static int mathutils_rna_vector_set(BPy_PropertyRNA *self, int subtype, float *v
|
||||
}
|
||||
|
||||
RNA_property_float_set_array(&self->ptr, self->prop, vec_to);
|
||||
|
||||
/* Euler order exception */
|
||||
if(subtype==MATHUTILS_CB_SUBTYPE_EUL) {
|
||||
PropertyRNA *prop_eul_order= RNA_struct_find_property(&self->ptr, "rotation_mode");
|
||||
if(prop_eul_order) {
|
||||
RNA_property_enum_set(&self->ptr, prop_eul_order, ((EulerObject *)bmo)->order);
|
||||
RNA_property_update(BPy_GetContext(), &self->ptr, prop_eul_order);
|
||||
}
|
||||
}
|
||||
|
||||
RNA_property_update(BPy_GetContext(), &self->ptr, self->prop);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int mathutils_rna_vector_get_index(BPy_PropertyRNA *self, int subtype, float *vec_from, int index)
|
||||
static int mathutils_rna_vector_get_index(BaseMathObject *bmo, int subtype, float *vec_from, int index)
|
||||
{
|
||||
BPy_PropertyRNA *self= (BPy_PropertyRNA *)bmo->cb_user;
|
||||
|
||||
if(self->prop==NULL)
|
||||
return 0;
|
||||
|
||||
@@ -111,8 +135,10 @@ static int mathutils_rna_vector_get_index(BPy_PropertyRNA *self, int subtype, fl
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int mathutils_rna_vector_set_index(BPy_PropertyRNA *self, int subtype, float *vec_to, int index)
|
||||
static int mathutils_rna_vector_set_index(BaseMathObject *bmo, int subtype, float *vec_to, int index)
|
||||
{
|
||||
BPy_PropertyRNA *self= (BPy_PropertyRNA *)bmo->cb_user;
|
||||
|
||||
if(self->prop==NULL)
|
||||
return 0;
|
||||
|
||||
@@ -134,8 +160,10 @@ Mathutils_Callback mathutils_rna_array_cb = {
|
||||
/* bpyrna matrix callbacks */
|
||||
static int mathutils_rna_matrix_cb_index= -1; /* index for our callbacks */
|
||||
|
||||
static int mathutils_rna_matrix_get(BPy_PropertyRNA *self, int subtype, float *mat_from)
|
||||
static int mathutils_rna_matrix_get(BaseMathObject *bmo, int subtype, float *mat_from)
|
||||
{
|
||||
BPy_PropertyRNA *self= (BPy_PropertyRNA *)bmo->cb_user;
|
||||
|
||||
if(self->prop==NULL)
|
||||
return 0;
|
||||
|
||||
@@ -143,8 +171,10 @@ static int mathutils_rna_matrix_get(BPy_PropertyRNA *self, int subtype, float *m
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int mathutils_rna_matrix_set(BPy_PropertyRNA *self, int subtype, float *mat_to)
|
||||
static int mathutils_rna_matrix_set(BaseMathObject *bmo, int subtype, float *mat_to)
|
||||
{
|
||||
BPy_PropertyRNA *self= (BPy_PropertyRNA *)bmo->cb_user;
|
||||
|
||||
if(self->prop==NULL)
|
||||
return 0;
|
||||
/* can ignore clamping here */
|
||||
|
||||
Reference in New Issue
Block a user