diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c index 1147930ff65..5ff163379a7 100644 --- a/source/blender/python/mathutils/mathutils.c +++ b/source/blender/python/mathutils/mathutils.c @@ -358,16 +358,16 @@ int _BaseMathObject_WriteIndexCallback(BaseMathObject *self, int index) } /* BaseMathObject generic functions for all mathutils types */ -char BaseMathObject_Owner_doc[] = "The item this is wrapping or None (readonly)."; -PyObject *BaseMathObject_getOwner(BaseMathObject *self, void *UNUSED(closure)) +char BaseMathObject_owner_doc[] = "The item this is wrapping or None (readonly)."; +PyObject *BaseMathObject_owner_get(BaseMathObject *self, void *UNUSED(closure)) { PyObject *ret= self->cb_user ? self->cb_user : Py_None; Py_INCREF(ret); return ret; } -char BaseMathObject_Wrapped_doc[] = "True when this object wraps external data (readonly).\n\n:type: boolean"; -PyObject *BaseMathObject_getWrapped(BaseMathObject *self, void *UNUSED(closure)) +char BaseMathObject_is_wrapped_doc[] = "True when this object wraps external data (readonly).\n\n:type: boolean"; +PyObject *BaseMathObject_is_wrapped_get(BaseMathObject *self, void *UNUSED(closure)) { return PyBool_FromLong((self->wrapped == Py_WRAP) ? 1:0); } diff --git a/source/blender/python/mathutils/mathutils.h b/source/blender/python/mathutils/mathutils.h index 2454e953949..220ae61f47d 100644 --- a/source/blender/python/mathutils/mathutils.h +++ b/source/blender/python/mathutils/mathutils.h @@ -39,8 +39,8 @@ struct DynStr; -extern char BaseMathObject_Wrapped_doc[]; -extern char BaseMathObject_Owner_doc[]; +extern char BaseMathObject_is_wrapped_doc[]; +extern char BaseMathObject_owner_doc[]; #define BASE_MATH_MEMBERS(_data) \ PyObject_VAR_HEAD \ @@ -67,8 +67,8 @@ typedef struct { #include "mathutils_geometry.h" #include "mathutils_noise.h" -PyObject *BaseMathObject_getOwner( BaseMathObject * self, void * ); -PyObject *BaseMathObject_getWrapped( BaseMathObject *self, void * ); +PyObject *BaseMathObject_owner_get( BaseMathObject * self, void * ); +PyObject *BaseMathObject_is_wrapped_get( BaseMathObject *self, void * ); int BaseMathObject_traverse(BaseMathObject *self, visitproc visit, void *arg); int BaseMathObject_clear(BaseMathObject *self); diff --git a/source/blender/python/mathutils/mathutils_Color.c b/source/blender/python/mathutils/mathutils_Color.c index e0a0deb9a0e..59fc656a380 100644 --- a/source/blender/python/mathutils/mathutils_Color.c +++ b/source/blender/python/mathutils/mathutils_Color.c @@ -670,18 +670,18 @@ static PyNumberMethods Color_NumMethods = { }; /* color channel, vector.r/g/b */ -static PyObject *Color_getChannel(ColorObject * self, void *type) +static PyObject *Color_channel_get(ColorObject * self, void *type) { return Color_item(self, GET_INT_FROM_POINTER(type)); } -static int Color_setChannel(ColorObject * self, PyObject *value, void * type) +static int Color_channel_set(ColorObject * self, PyObject *value, void * type) { return Color_ass_item(self, GET_INT_FROM_POINTER(type), value); } /* color channel (HSV), color.h/s/v */ -static PyObject *Color_getChannelHSV(ColorObject * self, void *type) +static PyObject *Color_channel_hsv_get(ColorObject * self, void *type) { float hsv[3]; int i= GET_INT_FROM_POINTER(type); @@ -694,7 +694,7 @@ static PyObject *Color_getChannelHSV(ColorObject * self, void *type) return PyFloat_FromDouble(hsv[i]); } -static int Color_setChannelHSV(ColorObject * self, PyObject *value, void * type) +static int Color_channel_hsv_set(ColorObject * self, PyObject *value, void * type) { float hsv[3]; int i= GET_INT_FROM_POINTER(type); @@ -722,7 +722,7 @@ static int Color_setChannelHSV(ColorObject * self, PyObject *value, void * type) } /* color channel (HSV), color.h/s/v */ -static PyObject *Color_getHSV(ColorObject * self, void *UNUSED(closure)) +static PyObject *Color_hsv_get(ColorObject * self, void *UNUSED(closure)) { float hsv[3]; PyObject *ret; @@ -739,7 +739,7 @@ static PyObject *Color_getHSV(ColorObject * self, void *UNUSED(closure)) return ret; } -static int Color_setHSV(ColorObject * self, PyObject *value, void *UNUSED(closure)) +static int Color_hsv_set(ColorObject * self, PyObject *value, void *UNUSED(closure)) { float hsv[3]; @@ -762,18 +762,18 @@ static int Color_setHSV(ColorObject * self, PyObject *value, void *UNUSED(closur /* Python attributes get/set structure: */ /*****************************************************************************/ static PyGetSetDef Color_getseters[] = { - {(char *)"r", (getter)Color_getChannel, (setter)Color_setChannel, (char *)"Red color channel.\n\n:type: float", (void *)0}, - {(char *)"g", (getter)Color_getChannel, (setter)Color_setChannel, (char *)"Green color channel.\n\n:type: float", (void *)1}, - {(char *)"b", (getter)Color_getChannel, (setter)Color_setChannel, (char *)"Blue color channel.\n\n:type: float", (void *)2}, + {(char *)"r", (getter)Color_channel_get, (setter)Color_channel_set, (char *)"Red color channel.\n\n:type: float", (void *)0}, + {(char *)"g", (getter)Color_channel_get, (setter)Color_channel_set, (char *)"Green color channel.\n\n:type: float", (void *)1}, + {(char *)"b", (getter)Color_channel_get, (setter)Color_channel_set, (char *)"Blue color channel.\n\n:type: float", (void *)2}, - {(char *)"h", (getter)Color_getChannelHSV, (setter)Color_setChannelHSV, (char *)"HSV Hue component in [0, 1].\n\n:type: float", (void *)0}, - {(char *)"s", (getter)Color_getChannelHSV, (setter)Color_setChannelHSV, (char *)"HSV Saturation component in [0, 1].\n\n:type: float", (void *)1}, - {(char *)"v", (getter)Color_getChannelHSV, (setter)Color_setChannelHSV, (char *)"HSV Value component in [0, 1].\n\n:type: float", (void *)2}, + {(char *)"h", (getter)Color_channel_hsv_get, (setter)Color_channel_hsv_set, (char *)"HSV Hue component in [0, 1].\n\n:type: float", (void *)0}, + {(char *)"s", (getter)Color_channel_hsv_get, (setter)Color_channel_hsv_set, (char *)"HSV Saturation component in [0, 1].\n\n:type: float", (void *)1}, + {(char *)"v", (getter)Color_channel_hsv_get, (setter)Color_channel_hsv_set, (char *)"HSV Value component in [0, 1].\n\n:type: float", (void *)2}, - {(char *)"hsv", (getter)Color_getHSV, (setter)Color_setHSV, (char *)"HSV Values in [0, 1].\n\n:type: float triplet", (void *)0}, + {(char *)"hsv", (getter)Color_hsv_get, (setter)Color_hsv_set, (char *)"HSV Values in [0, 1].\n\n:type: float triplet", (void *)0}, - {(char *)"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, BaseMathObject_Wrapped_doc, NULL}, - {(char *)"owner", (getter)BaseMathObject_getOwner, (setter)NULL, BaseMathObject_Owner_doc, NULL}, + {(char *)"is_wrapped", (getter)BaseMathObject_is_wrapped_get, (setter)NULL, BaseMathObject_is_wrapped_doc, NULL}, + {(char *)"owner", (getter)BaseMathObject_owner_get, (setter)NULL, BaseMathObject_owner_doc, NULL}, {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; diff --git a/source/blender/python/mathutils/mathutils_Euler.c b/source/blender/python/mathutils/mathutils_Euler.c index 443e77c3798..08e5018b789 100644 --- a/source/blender/python/mathutils/mathutils_Euler.c +++ b/source/blender/python/mathutils/mathutils_Euler.c @@ -571,18 +571,18 @@ static PyMappingMethods Euler_AsMapping = { /* * euler axis, euler.x/y/z */ -static PyObject *Euler_getAxis(EulerObject *self, void *type) +static PyObject *Euler_axis_get(EulerObject *self, void *type) { return Euler_item(self, GET_INT_FROM_POINTER(type)); } -static int Euler_setAxis(EulerObject *self, PyObject *value, void *type) +static int Euler_axis_set(EulerObject *self, PyObject *value, void *type) { return Euler_ass_item(self, GET_INT_FROM_POINTER(type), value); } /* rotation order */ -static PyObject *Euler_getOrder(EulerObject *self, void *UNUSED(closure)) +static PyObject *Euler_order_get(EulerObject *self, void *UNUSED(closure)) { if (BaseMath_ReadCallback(self) == -1) /* can read order too */ return NULL; @@ -590,7 +590,7 @@ static PyObject *Euler_getOrder(EulerObject *self, void *UNUSED(closure)) return PyUnicode_FromString(euler_order_str(self)); } -static int Euler_setOrder(EulerObject *self, PyObject *value, void *UNUSED(closure)) +static int Euler_order_set(EulerObject *self, PyObject *value, void *UNUSED(closure)) { const char *order_str= _PyUnicode_AsString(value); short order= euler_order_from_string(order_str, "euler.order"); @@ -607,13 +607,13 @@ static int Euler_setOrder(EulerObject *self, PyObject *value, void *UNUSED(closu /* Python attributes get/set structure: */ /*****************************************************************************/ static PyGetSetDef Euler_getseters[] = { - {(char *)"x", (getter)Euler_getAxis, (setter)Euler_setAxis, (char *)"Euler X axis in radians.\n\n:type: float", (void *)0}, - {(char *)"y", (getter)Euler_getAxis, (setter)Euler_setAxis, (char *)"Euler Y axis in radians.\n\n:type: float", (void *)1}, - {(char *)"z", (getter)Euler_getAxis, (setter)Euler_setAxis, (char *)"Euler Z axis in radians.\n\n:type: float", (void *)2}, - {(char *)"order", (getter)Euler_getOrder, (setter)Euler_setOrder, (char *)"Euler rotation order.\n\n:type: string in ['XYZ', 'XZY', 'YXZ', 'YZX', 'ZXY', 'ZYX']", (void *)NULL}, + {(char *)"x", (getter)Euler_axis_get, (setter)Euler_axis_set, (char *)"Euler X axis in radians.\n\n:type: float", (void *)0}, + {(char *)"y", (getter)Euler_axis_get, (setter)Euler_axis_set, (char *)"Euler Y axis in radians.\n\n:type: float", (void *)1}, + {(char *)"z", (getter)Euler_axis_get, (setter)Euler_axis_set, (char *)"Euler Z axis in radians.\n\n:type: float", (void *)2}, + {(char *)"order", (getter)Euler_order_get, (setter)Euler_order_set, (char *)"Euler rotation order.\n\n:type: string in ['XYZ', 'XZY', 'YXZ', 'YZX', 'ZXY', 'ZYX']", (void *)NULL}, - {(char *)"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, (char *)BaseMathObject_Wrapped_doc, NULL}, - {(char *)"owner", (getter)BaseMathObject_getOwner, (setter)NULL, (char *)BaseMathObject_Owner_doc, NULL}, + {(char *)"is_wrapped", (getter)BaseMathObject_is_wrapped_get, (setter)NULL, (char *)BaseMathObject_is_wrapped_doc, NULL}, + {(char *)"owner", (getter)BaseMathObject_owner_get, (setter)NULL, (char *)BaseMathObject_owner_doc, NULL}, {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index de098ce8bd8..690a8d1b616 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -389,15 +389,12 @@ PyDoc_STRVAR(C_Matrix_Translation_doc, ); static PyObject *C_Matrix_Translation(PyObject *cls, PyObject *value) { - float mat[16], tvec[3]; + float mat[4][4]= MAT4_UNITY; - if (mathutils_array_parse(tvec, 3, 4, value, "mathutils.Matrix.Translation(vector), invalid vector arg") == -1) + if (mathutils_array_parse(mat[3], 3, 4, value, "mathutils.Matrix.Translation(vector), invalid vector arg") == -1) return NULL; - /* create a identity matrix and add translation */ - unit_m4((float(*)[4]) mat); - copy_v3_v3(mat + 12, tvec); /* 12, 13, 14 */ - return Matrix_CreatePyObject(mat, 4, 4, Py_NEW, (PyTypeObject *)cls); + return Matrix_CreatePyObject(&mat[0][0], 4, 4, Py_NEW, (PyTypeObject *)cls); } //----------------------------------mathutils.Matrix.Scale() ------------- //mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc. @@ -583,19 +580,19 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args) } if (matSize == 2) { mat[0] = 1 - (tvec[0] * tvec[0]); - mat[1] = -(tvec[0] * tvec[1]); - mat[2] = -(tvec[0] * tvec[1]); + mat[1] = - (tvec[0] * tvec[1]); + mat[2] = - (tvec[0] * tvec[1]); mat[3] = 1 - (tvec[1] * tvec[1]); } else if (matSize > 2) { mat[0] = 1 - (tvec[0] * tvec[0]); - mat[1] = -(tvec[0] * tvec[1]); - mat[2] = -(tvec[0] * tvec[2]); - mat[3] = -(tvec[0] * tvec[1]); + mat[1] = - (tvec[0] * tvec[1]); + mat[2] = - (tvec[0] * tvec[2]); + mat[3] = - (tvec[0] * tvec[1]); mat[4] = 1 - (tvec[1] * tvec[1]); - mat[5] = -(tvec[1] * tvec[2]); - mat[6] = -(tvec[0] * tvec[2]); - mat[7] = -(tvec[1] * tvec[2]); + mat[5] = - (tvec[1] * tvec[2]); + mat[6] = - (tvec[0] * tvec[2]); + mat[7] = - (tvec[1] * tvec[2]); mat[8] = 1 - (tvec[2] * tvec[2]); } } @@ -846,7 +843,7 @@ PyDoc_STRVAR(Matrix_resize_4x4_doc, ); static PyObject *Matrix_resize_4x4(MatrixObject *self) { - float mat[16]; + float mat[4][4]= MAT4_UNITY; int col; if (self->wrapped==Py_WRAP) { @@ -870,10 +867,8 @@ static PyObject *Matrix_resize_4x4(MatrixObject *self) return NULL; } - unit_m4((float (*)[4])mat); - for (col = 0; col < self->num_col; col++) { - memcpy(mat + (4 * col), MATRIX_COL_PTR(self, col), self->num_row * sizeof(float)); + memcpy(mat[col], MATRIX_COL_PTR(self, col), self->num_row * sizeof(float)); } copy_m4_m4((float (*)[4])self->matrix, (float (*)[4])mat); @@ -1896,12 +1891,12 @@ static PyNumberMethods Matrix_NumMethods = { NULL, /* nb_index */ }; -static PyObject *Matrix_getRowSize(MatrixObject *self, void *UNUSED(closure)) +static PyObject *Matrix_row_size_get(MatrixObject *self, void *UNUSED(closure)) { return PyLong_FromLong((long) self->num_col); } -static PyObject *Matrix_getColSize(MatrixObject *self, void *UNUSED(closure)) +static PyObject *Matrix_col_size_get(MatrixObject *self, void *UNUSED(closure)) { return PyLong_FromLong((long) self->num_row); } @@ -2011,14 +2006,14 @@ static PyObject *Matrix_is_orthogonal_get(MatrixObject *self, void *UNUSED(closu /* Python attributes get/set structure: */ /*****************************************************************************/ static PyGetSetDef Matrix_getseters[] = { - {(char *)"row_size", (getter)Matrix_getRowSize, (setter)NULL, (char *)"The row size of the matrix (readonly).\n\n:type: int", NULL}, - {(char *)"col_size", (getter)Matrix_getColSize, (setter)NULL, (char *)"The column size of the matrix (readonly).\n\n:type: int", NULL}, + {(char *)"row_size", (getter)Matrix_row_size_get, (setter)NULL, (char *)"The row size of the matrix (readonly).\n\n:type: int", NULL}, + {(char *)"col_size", (getter)Matrix_col_size_get, (setter)NULL, (char *)"The column size of the matrix (readonly).\n\n:type: int", NULL}, {(char *)"median_scale", (getter)Matrix_median_scale_get, (setter)NULL, (char *)"The average scale applied to each axis (readonly).\n\n:type: float", NULL}, {(char *)"translation", (getter)Matrix_translation_get, (setter)Matrix_translation_set, (char *)"The translation component of the matrix.\n\n:type: Vector", NULL}, {(char *)"is_negative", (getter)Matrix_is_negative_get, (setter)NULL, (char *)"True if this matrix results in a negative scale, 3x3 and 4x4 only, (readonly).\n\n:type: bool", NULL}, {(char *)"is_orthogonal", (getter)Matrix_is_orthogonal_get, (setter)NULL, (char *)"True if this matrix is orthogonal, 3x3 and 4x4 only, (readonly).\n\n:type: bool", NULL}, - {(char *)"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, (char *)BaseMathObject_Wrapped_doc, NULL}, - {(char *)"owner",(getter)BaseMathObject_getOwner, (setter)NULL, (char *)BaseMathObject_Owner_doc, NULL}, + {(char *)"is_wrapped", (getter)BaseMathObject_is_wrapped_get, (setter)NULL, (char *)BaseMathObject_is_wrapped_doc, NULL}, + {(char *)"owner",(getter)BaseMathObject_owner_get, (setter)NULL, (char *)BaseMathObject_owner_doc, NULL}, {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; @@ -2180,9 +2175,11 @@ PyObject *Matrix_CreatePyObject(float *mat, return (PyObject *) self; } -PyObject *Matrix_CreatePyObject_cb(PyObject *cb_user, int rowSize, int colSize, int cb_type, int cb_subtype) +PyObject *Matrix_CreatePyObject_cb(PyObject *cb_user, + const unsigned short num_col, const unsigned short num_row, + int cb_type, int cb_subtype) { - MatrixObject *self= (MatrixObject *)Matrix_CreatePyObject(NULL, rowSize, colSize, Py_NEW, NULL); + MatrixObject *self= (MatrixObject *)Matrix_CreatePyObject(NULL, num_col, num_row, Py_NEW, NULL); if (self) { Py_INCREF(cb_user); self->cb_user= cb_user; diff --git a/source/blender/python/mathutils/mathutils_Matrix.h b/source/blender/python/mathutils/mathutils_Matrix.h index e7bfc06b98b..05c822b0330 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.h +++ b/source/blender/python/mathutils/mathutils_Matrix.h @@ -68,7 +68,9 @@ typedef struct { PyObject *Matrix_CreatePyObject(float *mat, const unsigned short num_col, const unsigned short num_row, int type, PyTypeObject *base_type); -PyObject *Matrix_CreatePyObject_cb(PyObject *user, int num_col, int num_row, int cb_type, int cb_subtype); +PyObject *Matrix_CreatePyObject_cb(PyObject *user, + const unsigned short num_col, const unsigned short num_row, + int cb_type, int cb_subtype); extern int mathutils_matrix_vector_cb_index; extern int mathutils_matrix_column_cb_index; diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c index 7c339807ee9..2dd266d83fb 100644 --- a/source/blender/python/mathutils/mathutils_Quaternion.c +++ b/source/blender/python/mathutils/mathutils_Quaternion.c @@ -922,17 +922,17 @@ static PyNumberMethods Quaternion_NumMethods = { NULL, /* nb_index */ }; -static PyObject *Quaternion_getAxis(QuaternionObject *self, void *type) +static PyObject *Quaternion_axis_get(QuaternionObject *self, void *type) { return Quaternion_item(self, GET_INT_FROM_POINTER(type)); } -static int Quaternion_setAxis(QuaternionObject *self, PyObject *value, void *type) +static int Quaternion_axis_set(QuaternionObject *self, PyObject *value, void *type) { return Quaternion_ass_item(self, GET_INT_FROM_POINTER(type), value); } -static PyObject *Quaternion_getMagnitude(QuaternionObject *self, void *UNUSED(closure)) +static PyObject *Quaternion_magnitude_get(QuaternionObject *self, void *UNUSED(closure)) { if (BaseMath_ReadCallback(self) == -1) return NULL; @@ -940,7 +940,7 @@ static PyObject *Quaternion_getMagnitude(QuaternionObject *self, void *UNUSED(cl return PyFloat_FromDouble(sqrt(dot_qtqt(self->quat, self->quat))); } -static PyObject *Quaternion_getAngle(QuaternionObject *self, void *UNUSED(closure)) +static PyObject *Quaternion_angle_get(QuaternionObject *self, void *UNUSED(closure)) { float tquat[4]; float angle; @@ -957,7 +957,7 @@ static PyObject *Quaternion_getAngle(QuaternionObject *self, void *UNUSED(closur return PyFloat_FromDouble(angle); } -static int Quaternion_setAngle(QuaternionObject *self, PyObject *value, void *UNUSED(closure)) +static int Quaternion_angle_set(QuaternionObject *self, PyObject *value, void *UNUSED(closure)) { float tquat[4]; float len; @@ -992,7 +992,7 @@ static int Quaternion_setAngle(QuaternionObject *self, PyObject *value, void *UN return 0; } -static PyObject *Quaternion_getAxisVec(QuaternionObject *self, void *UNUSED(closure)) +static PyObject *Quaternion_axis_vector_get(QuaternionObject *self, void *UNUSED(closure)) { float tquat[4]; @@ -1010,7 +1010,7 @@ static PyObject *Quaternion_getAxisVec(QuaternionObject *self, void *UNUSED(clos return Vector_CreatePyObject(axis, 3, Py_NEW, NULL); } -static int Quaternion_setAxisVec(QuaternionObject *self, PyObject *value, void *UNUSED(closure)) +static int Quaternion_axis_vector_set(QuaternionObject *self, PyObject *value, void *UNUSED(closure)) { float tquat[4]; float len; @@ -1151,15 +1151,15 @@ static struct PyMethodDef Quaternion_methods[] = { /* Python attributes get/set structure: */ /*****************************************************************************/ static PyGetSetDef Quaternion_getseters[] = { - {(char *)"w", (getter)Quaternion_getAxis, (setter)Quaternion_setAxis, (char *)"Quaternion W value.\n\n:type: float", (void *)0}, - {(char *)"x", (getter)Quaternion_getAxis, (setter)Quaternion_setAxis, (char *)"Quaternion X axis.\n\n:type: float", (void *)1}, - {(char *)"y", (getter)Quaternion_getAxis, (setter)Quaternion_setAxis, (char *)"Quaternion Y axis.\n\n:type: float", (void *)2}, - {(char *)"z", (getter)Quaternion_getAxis, (setter)Quaternion_setAxis, (char *)"Quaternion Z axis.\n\n:type: float", (void *)3}, - {(char *)"magnitude", (getter)Quaternion_getMagnitude, (setter)NULL, (char *)"Size of the quaternion (readonly).\n\n:type: float", NULL}, - {(char *)"angle", (getter)Quaternion_getAngle, (setter)Quaternion_setAngle, (char *)"angle of the quaternion.\n\n:type: float", NULL}, - {(char *)"axis",(getter)Quaternion_getAxisVec, (setter)Quaternion_setAxisVec, (char *)"quaternion axis as a vector.\n\n:type: :class:`Vector`", NULL}, - {(char *)"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, (char *)BaseMathObject_Wrapped_doc, NULL}, - {(char *)"owner", (getter)BaseMathObject_getOwner, (setter)NULL, (char *)BaseMathObject_Owner_doc, NULL}, + {(char *)"w", (getter)Quaternion_axis_get, (setter)Quaternion_axis_set, (char *)"Quaternion W value.\n\n:type: float", (void *)0}, + {(char *)"x", (getter)Quaternion_axis_get, (setter)Quaternion_axis_set, (char *)"Quaternion X axis.\n\n:type: float", (void *)1}, + {(char *)"y", (getter)Quaternion_axis_get, (setter)Quaternion_axis_set, (char *)"Quaternion Y axis.\n\n:type: float", (void *)2}, + {(char *)"z", (getter)Quaternion_axis_get, (setter)Quaternion_axis_set, (char *)"Quaternion Z axis.\n\n:type: float", (void *)3}, + {(char *)"magnitude", (getter)Quaternion_magnitude_get, (setter)NULL, (char *)"Size of the quaternion (readonly).\n\n:type: float", NULL}, + {(char *)"angle", (getter)Quaternion_angle_get, (setter)Quaternion_angle_set, (char *)"angle of the quaternion.\n\n:type: float", NULL}, + {(char *)"axis",(getter)Quaternion_axis_vector_get, (setter)Quaternion_axis_vector_set, (char *)"quaternion axis as a vector.\n\n:type: :class:`Vector`", NULL}, + {(char *)"is_wrapped", (getter)BaseMathObject_is_wrapped_get, (setter)NULL, (char *)BaseMathObject_is_wrapped_doc, NULL}, + {(char *)"owner", (getter)BaseMathObject_owner_get, (setter)NULL, (char *)BaseMathObject_owner_doc, NULL}, {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index c31835cf7b5..69e51832bda 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -2028,18 +2028,18 @@ static PyNumberMethods Vector_NumMethods = { * vector axis, vector.x/y/z/w */ -static PyObject *Vector_getAxis(VectorObject *self, void *type) +static PyObject *Vector_axis_get(VectorObject *self, void *type) { return vector_item_internal(self, GET_INT_FROM_POINTER(type), TRUE); } -static int Vector_setAxis(VectorObject *self, PyObject *value, void *type) +static int Vector_axis_set(VectorObject *self, PyObject *value, void *type) { return vector_ass_item_internal(self, GET_INT_FROM_POINTER(type), value, TRUE); } /* vector.length */ -static PyObject *Vector_getLength(VectorObject *self, void *UNUSED(closure)) +static PyObject *Vector_length_get(VectorObject *self, void *UNUSED(closure)) { if (BaseMath_ReadCallback(self) == -1) return NULL; @@ -2047,7 +2047,7 @@ static PyObject *Vector_getLength(VectorObject *self, void *UNUSED(closure)) return PyFloat_FromDouble(sqrt(dot_vn_vn(self->vec, self->vec, self->size))); } -static int Vector_setLength(VectorObject *self, PyObject *value) +static int Vector_length_set(VectorObject *self, PyObject *value) { double dot = 0.0f, param; @@ -2090,7 +2090,7 @@ static int Vector_setLength(VectorObject *self, PyObject *value) } /* vector.length_squared */ -static PyObject *Vector_getLengthSquared(VectorObject *self, void *UNUSED(closure)) +static PyObject *Vector_length_squared_get(VectorObject *self, void *UNUSED(closure)) { if (BaseMath_ReadCallback(self) == -1) return NULL; @@ -2101,7 +2101,7 @@ static PyObject *Vector_getLengthSquared(VectorObject *self, void *UNUSED(closur /* Get a new Vector according to the provided swizzle. This function has little error checking, as we are in control of the inputs: the closure is set by us in Vector_createSwizzleGetSeter. */ -static PyObject *Vector_getSwizzle(VectorObject *self, void *closure) +static PyObject *Vector_swizzle_get(VectorObject *self, void *closure) { size_t axis_to; size_t axis_from; @@ -2142,7 +2142,7 @@ static PyObject *Vector_getSwizzle(VectorObject *self, void *closure) Returns 0 on success and -1 on failure. On failure, the vector will be unchanged. */ -static int Vector_setSwizzle(VectorObject *self, PyObject *value, void *closure) +static int Vector_swizzle_set(VectorObject *self, PyObject *value, void *closure) { size_t size_from; float scalarVal; @@ -2219,353 +2219,353 @@ static int Vector_setSwizzle(VectorObject *self, PyObject *value, void *closure) /* Python attributes get/set structure: */ /*****************************************************************************/ static PyGetSetDef Vector_getseters[] = { - {(char *)"x", (getter)Vector_getAxis, (setter)Vector_setAxis, (char *)"Vector X axis.\n\n:type: float", (void *)0}, - {(char *)"y", (getter)Vector_getAxis, (setter)Vector_setAxis, (char *)"Vector Y axis.\n\n:type: float", (void *)1}, - {(char *)"z", (getter)Vector_getAxis, (setter)Vector_setAxis, (char *)"Vector Z axis (3D Vectors only).\n\n:type: float", (void *)2}, - {(char *)"w", (getter)Vector_getAxis, (setter)Vector_setAxis, (char *)"Vector W axis (4D Vectors only).\n\n:type: float", (void *)3}, - {(char *)"length", (getter)Vector_getLength, (setter)Vector_setLength, (char *)"Vector Length.\n\n:type: float", NULL}, - {(char *)"length_squared", (getter)Vector_getLengthSquared, (setter)NULL, (char *)"Vector length squared (v.dot(v)).\n\n:type: float", NULL}, - {(char *)"magnitude", (getter)Vector_getLength, (setter)Vector_setLength, (char *)"Vector Length.\n\n:type: float", NULL}, - {(char *)"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, (char *)BaseMathObject_Wrapped_doc, NULL}, - {(char *)"owner", (getter)BaseMathObject_getOwner, (setter)NULL, (char *)BaseMathObject_Owner_doc, NULL}, + {(char *)"x", (getter)Vector_axis_get, (setter)Vector_axis_set, (char *)"Vector X axis.\n\n:type: float", (void *)0}, + {(char *)"y", (getter)Vector_axis_get, (setter)Vector_axis_set, (char *)"Vector Y axis.\n\n:type: float", (void *)1}, + {(char *)"z", (getter)Vector_axis_get, (setter)Vector_axis_set, (char *)"Vector Z axis (3D Vectors only).\n\n:type: float", (void *)2}, + {(char *)"w", (getter)Vector_axis_get, (setter)Vector_axis_set, (char *)"Vector W axis (4D Vectors only).\n\n:type: float", (void *)3}, + {(char *)"length", (getter)Vector_length_get, (setter)Vector_length_set, (char *)"Vector Length.\n\n:type: float", NULL}, + {(char *)"length_squared", (getter)Vector_length_squared_get, (setter)NULL, (char *)"Vector length squared (v.dot(v)).\n\n:type: float", NULL}, + {(char *)"magnitude", (getter)Vector_length_get, (setter)Vector_length_set, (char *)"Vector Length.\n\n:type: float", NULL}, + {(char *)"is_wrapped", (getter)BaseMathObject_is_wrapped_get, (setter)NULL, (char *)BaseMathObject_is_wrapped_doc, NULL}, + {(char *)"owner", (getter)BaseMathObject_owner_get, (setter)NULL, (char *)BaseMathObject_owner_doc, NULL}, /* autogenerated swizzle attrs, see python script below */ - {(char *)"xx", (getter)Vector_getSwizzle, (setter)NULL, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<