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>2011-06-02 12:29:16 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-06-02 12:29:16 +0400
commitd46da5a09d972926e6b4ab5d9fde49ffad16a48f (patch)
tree3b97cd8a4972247362b0d0ae6ae696d0055a4988
parent211cd99cbc0d894c2e586bd08ae723bf18b3cdd3 (diff)
mathutils support for color arithmetic, also some minor whitespace edits.
-rw-r--r--source/blender/python/BPY_extern.h14
-rw-r--r--source/blender/python/generic/bgl.c24
-rw-r--r--source/blender/python/generic/bgl.h2
-rw-r--r--source/blender/python/generic/bpy_internal_import.c4
-rw-r--r--source/blender/python/generic/mathutils_Color.c278
-rw-r--r--source/blender/python/generic/mathutils_Euler.c2
-rw-r--r--source/blender/python/generic/mathutils_Matrix.c2
-rw-r--r--source/blender/python/generic/mathutils_Vector.c29
-rw-r--r--source/blender/python/generic/mathutils_geometry.c4
-rw-r--r--source/blender/python/intern/bpy.c12
-rw-r--r--source/blender/python/intern/bpy.h2
-rw-r--r--source/blender/python/intern/bpy_app.h2
-rw-r--r--source/blender/python/intern/bpy_driver.c2
-rw-r--r--source/blender/python/intern/bpy_interface.c3
-rw-r--r--source/blender/python/intern/bpy_library.c2
-rw-r--r--source/blender/python/intern/bpy_props.c2
-rw-r--r--source/blender/python/intern/bpy_props.h2
-rw-r--r--source/blender/python/intern/bpy_rna.c4
-rw-r--r--source/blender/python/intern/bpy_rna.h16
19 files changed, 337 insertions, 69 deletions
diff --git a/source/blender/python/BPY_extern.h b/source/blender/python/BPY_extern.h
index e8796a6f8dd..ae5253d07a0 100644
--- a/source/blender/python/BPY_extern.h
+++ b/source/blender/python/BPY_extern.h
@@ -67,14 +67,14 @@ int BPY_is_pyconstraint(struct Text *text);
// void BPY_free_pyconstraint_links(struct Text *text);
//
void BPY_python_start(int argc, const char **argv);
-void BPY_python_end( void );
-// void init_syspath( int first_time );
-// void syspath_append( char *dir );
-// void BPY_rebuild_syspath( void );
-// int BPY_path_update( void );
+void BPY_python_end(void);
+// void init_syspath(int first_time);
+// void syspath_append(char *dir);
+// void BPY_rebuild_syspath(void);
+// int BPY_path_update(void);
//
-// int BPY_Err_getLinenumber( void );
-// const char *BPY_Err_getFilename( void );
+// int BPY_Err_getLinenumber(void);
+// const char *BPY_Err_getFilename(void);
/* 2.5 UI Scripts */
int BPY_filepath_exec(struct bContext *C, const char *filepath, struct ReportList *reports);
diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c
index 4eb6d78bd7b..b5a693c397c 100644
--- a/source/blender/python/generic/bgl.c
+++ b/source/blender/python/generic/bgl.c
@@ -62,16 +62,16 @@ square buffer. Passing [16, 16, 32] will create a 3 dimensional\n\
buffer which is twice as deep as it is wide or high."
);
-static PyObject *Method_Buffer( PyObject * self, PyObject *args );
+static PyObject *Method_Buffer(PyObject *self, PyObject *args);
/* Buffer sequence methods */
-static int Buffer_len( PyObject * self );
-static PyObject *Buffer_item( PyObject * self, int i );
-static PyObject *Buffer_slice( PyObject * self, int begin, int end );
-static int Buffer_ass_item( PyObject * self, int i, PyObject * v );
-static int Buffer_ass_slice( PyObject * self, int begin, int end,
- PyObject * seq );
+static int Buffer_len(PyObject *self);
+static PyObject *Buffer_item(PyObject *self, int i);
+static PyObject *Buffer_slice(PyObject *self, int begin, int end);
+static int Buffer_ass_item(PyObject *self, int i, PyObject *v);
+static int Buffer_ass_slice(PyObject *self, int begin, int end,
+ PyObject *seq);
static PySequenceMethods Buffer_SeqMethods = {
( lenfunc ) Buffer_len, /*sq_length */
@@ -86,11 +86,11 @@ static PySequenceMethods Buffer_SeqMethods = {
(ssizeargfunc) NULL, /* sq_inplace_repeat */
};
-static void Buffer_dealloc( PyObject * self );
-static PyObject *Buffer_tolist( PyObject * self );
-static PyObject *Buffer_dimensions( PyObject * self );
-static PyObject *Buffer_getattr( PyObject * self, char *name );
-static PyObject *Buffer_repr( PyObject * self );
+static void Buffer_dealloc(PyObject *self);
+static PyObject *Buffer_tolist(PyObject *self);
+static PyObject *Buffer_dimensions(PyObject *self);
+static PyObject *Buffer_getattr(PyObject *self, char *name);
+static PyObject *Buffer_repr(PyObject *self);
PyTypeObject BGL_bufferType = {
PyVarObject_HEAD_INIT(NULL, 0)
diff --git a/source/blender/python/generic/bgl.h b/source/blender/python/generic/bgl.h
index a870e82d4fd..81b570c8505 100644
--- a/source/blender/python/generic/bgl.h
+++ b/source/blender/python/generic/bgl.h
@@ -55,7 +55,7 @@ int BGL_typeSize( int type );
/*@ For Python access to OpenGL functions requiring a pointer. */
typedef struct _Buffer {
PyObject_VAR_HEAD
- PyObject * parent;
+ PyObject *parent;
int type; /* GL_BYTE, GL_SHORT, GL_INT, GL_FLOAT */
int ndimensions;
diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c
index cb145cc453b..f0158fe72c3 100644
--- a/source/blender/python/generic/bpy_internal_import.c
+++ b/source/blender/python/generic/bpy_internal_import.c
@@ -217,7 +217,7 @@ PyObject *bpy_text_reimport(PyObject *module, int *found)
}
-static PyObject *blender_import(PyObject *UNUSED(self), PyObject *args, PyObject * kw)
+static PyObject *blender_import(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
{
PyObject *exception, *err, *tb;
char *name;
@@ -270,7 +270,7 @@ static PyObject *blender_import(PyObject *UNUSED(self), PyObject *args, PyObject
* our reload() module, to handle reloading in-memory scripts
*/
-static PyObject *blender_reload(PyObject *UNUSED(self), PyObject * module)
+static PyObject *blender_reload(PyObject *UNUSED(self), PyObject *module)
{
PyObject *exception, *err, *tb;
PyObject *newmodule= NULL;
diff --git a/source/blender/python/generic/mathutils_Color.c b/source/blender/python/generic/mathutils_Color.c
index 09e3493cd09..c59cb501d86 100644
--- a/source/blender/python/generic/mathutils_Color.c
+++ b/source/blender/python/generic/mathutils_Color.c
@@ -186,7 +186,7 @@ static PyObject *Color_item(ColorObject * self, int i)
}
//----------------------------object[]-------------------------
//sequence accessor (set)
-static int Color_ass_item(ColorObject * self, int i, PyObject * value)
+static int Color_ass_item(ColorObject * self, int i, PyObject *value)
{
float f = PyFloat_AsDouble(value);
@@ -233,7 +233,7 @@ static PyObject *Color_slice(ColorObject * self, int begin, int end)
}
//----------------------------object[z:y]------------------------
//sequence slice (set)
-static int Color_ass_slice(ColorObject * self, int begin, int end, PyObject * seq)
+static int Color_ass_slice(ColorObject *self, int begin, int end, PyObject *seq)
{
int i, size;
float col[COLOR_SIZE];
@@ -344,13 +344,279 @@ static PyMappingMethods Color_AsMapping = {
(objobjargproc)Color_ass_subscript
};
+/* numeric */
+
+
+/* addition: obj + obj */
+static PyObject *Color_add(PyObject *v1, PyObject *v2)
+{
+ ColorObject *color1 = NULL, *color2 = NULL;
+ float col[COLOR_SIZE];
+
+ if (!ColorObject_Check(v1) || !ColorObject_Check(v2)) {
+ PyErr_SetString(PyExc_AttributeError, "Color addition: arguments not valid for this operation");
+ return NULL;
+ }
+ color1 = (ColorObject*)v1;
+ color2 = (ColorObject*)v2;
+
+ if(BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1)
+ return NULL;
+
+ add_vn_vnvn(col, color1->col, color2->col, COLOR_SIZE);
+
+ return newColorObject(col, Py_NEW, Py_TYPE(v1));
+}
+
+/* addition in-place: obj += obj */
+static PyObject *Color_iadd(PyObject *v1, PyObject *v2)
+{
+ ColorObject *color1 = NULL, *color2 = NULL;
+
+ if (!ColorObject_Check(v1) || !ColorObject_Check(v2)) {
+ PyErr_SetString(PyExc_AttributeError, "Color addition: arguments not valid for this operation");
+ return NULL;
+ }
+ color1 = (ColorObject*)v1;
+ color2 = (ColorObject*)v2;
+
+ if(BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1)
+ return NULL;
+
+ add_vn_vn(color1->col, color2->col, COLOR_SIZE);
+
+ (void)BaseMath_WriteCallback(color1);
+ Py_INCREF(v1);
+ return v1;
+}
+
+/* subtraction: obj - obj */
+static PyObject *Color_sub(PyObject *v1, PyObject *v2)
+{
+ ColorObject *color1 = NULL, *color2 = NULL;
+ float col[COLOR_SIZE];
+
+ if (!ColorObject_Check(v1) || !ColorObject_Check(v2)) {
+ PyErr_SetString(PyExc_AttributeError, "Color subtraction: arguments not valid for this operation");
+ return NULL;
+ }
+ color1 = (ColorObject*)v1;
+ color2 = (ColorObject*)v2;
+
+ if(BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1)
+ return NULL;
+
+ sub_vn_vnvn(col, color1->col, color2->col, COLOR_SIZE);
+
+ return newColorObject(col, Py_NEW, Py_TYPE(v1));
+}
+
+/* subtraction in-place: obj -= obj */
+static PyObject *Color_isub(PyObject *v1, PyObject *v2)
+{
+ ColorObject *color1= NULL, *color2= NULL;
+
+ if (!ColorObject_Check(v1) || !ColorObject_Check(v2)) {
+ PyErr_SetString(PyExc_AttributeError, "Color subtraction: arguments not valid for this operation");
+ return NULL;
+ }
+ color1 = (ColorObject*)v1;
+ color2 = (ColorObject*)v2;
+
+ if(BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1)
+ return NULL;
+
+ sub_vn_vn(color1->col, color2->col, COLOR_SIZE);
+
+ (void)BaseMath_WriteCallback(color1);
+ Py_INCREF(v1);
+ return v1;
+}
+
+static PyObject *color_mul_float(ColorObject *color, const float scalar)
+{
+ float tcol[COLOR_SIZE];
+ mul_vn_vn_fl(tcol, color->col, COLOR_SIZE, scalar);
+ return newColorObject(tcol, Py_NEW, Py_TYPE(color));
+}
+
+
+static PyObject *Color_mul(PyObject *v1, PyObject *v2)
+{
+ ColorObject *color1 = NULL, *color2 = NULL;
+ float scalar;
+
+ if ColorObject_Check(v1) {
+ color1= (ColorObject *)v1;
+ if(BaseMath_ReadCallback(color1) == -1)
+ return NULL;
+ }
+ if ColorObject_Check(v2) {
+ color2= (ColorObject *)v2;
+ if(BaseMath_ReadCallback(color2) == -1)
+ return NULL;
+ }
+
+
+ /* make sure v1 is always the vector */
+ if (color1 && color2) {
+ /* col * col, dont support yet! */
+ }
+ else if (color1) {
+ if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* COLOR * FLOAT */
+ return color_mul_float(color1, scalar);
+ }
+ }
+ else if (color2) {
+ if (((scalar= PyFloat_AsDouble(v1)) == -1.0f && PyErr_Occurred())==0) { /* FLOAT * COLOR */
+ return color_mul_float(color2, scalar);
+ }
+ }
+ else {
+ BLI_assert(!"internal error");
+ }
+
+ PyErr_Format(PyExc_TypeError, "Color multiplication: not supported between '%.200s' and '%.200s' types", Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name);
+ return NULL;
+}
+
+static PyObject *Color_div(PyObject *v1, PyObject *v2)
+{
+ ColorObject *color1 = NULL;
+ float scalar;
+
+ if ColorObject_Check(v1) {
+ color1= (ColorObject *)v1;
+ if(BaseMath_ReadCallback(color1) == -1)
+ return NULL;
+ }
+ else {
+ PyErr_SetString(PyExc_TypeError, "Color division not supported in this order");
+ return NULL;
+ }
+
+ /* make sure v1 is always the vector */
+ if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* COLOR * FLOAT */
+ if(scalar==0.0f) {
+ PyErr_SetString(PyExc_ZeroDivisionError, "Color division: divide by zero error");
+ return NULL;
+ }
+ return color_mul_float(color1, 1.0f / scalar);
+ }
+
+ PyErr_Format(PyExc_TypeError, "Color multiplication: not supported between '%.200s' and '%.200s' types", Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name);
+ return NULL;
+}
+
+/* mulplication in-place: obj *= obj */
+static PyObject *Color_imul(PyObject *v1, PyObject *v2)
+{
+ ColorObject *color = (ColorObject *)v1;
+ float scalar;
+
+ if(BaseMath_ReadCallback(color) == -1)
+ return NULL;
+
+ /* only support color *= float */
+ if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* COLOR *= FLOAT */
+ mul_vn_fl(color->col, COLOR_SIZE, scalar);
+ }
+ else {
+ PyErr_SetString(PyExc_TypeError, "Color multiplication: arguments not acceptable for this operation");
+ return NULL;
+ }
+
+ (void)BaseMath_WriteCallback(color);
+ Py_INCREF(v1);
+ return v1;
+}
+
+/* mulplication in-place: obj *= obj */
+static PyObject *Color_idiv(PyObject *v1, PyObject *v2)
+{
+ ColorObject *color = (ColorObject *)v1;
+ float scalar;
+
+ if(BaseMath_ReadCallback(color) == -1)
+ return NULL;
+
+ /* only support color /= float */
+ if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* COLOR /= FLOAT */
+ if(scalar==0.0f) {
+ PyErr_SetString(PyExc_ZeroDivisionError, "Color division: divide by zero error");
+ return NULL;
+ }
+
+ mul_vn_fl(color->col, COLOR_SIZE, 1.0f / scalar);
+ }
+ else {
+ PyErr_SetString(PyExc_TypeError, "Color multiplication: arguments not acceptable for this operation");
+ return NULL;
+ }
+
+ (void)BaseMath_WriteCallback(color);
+ Py_INCREF(v1);
+ return v1;
+}
+
+/* -obj
+ returns the negative of this object*/
+static PyObject *Color_neg(ColorObject *self)
+{
+ float tcol[COLOR_SIZE];
+
+ if(BaseMath_ReadCallback(self) == -1)
+ return NULL;
+
+ negate_vn_vn(tcol, self->col, COLOR_SIZE);
+ return newColorObject(tcol, Py_NEW, Py_TYPE(self));
+}
+
+
+static PyNumberMethods Color_NumMethods = {
+ (binaryfunc) Color_add, /*nb_add*/
+ (binaryfunc) Color_sub, /*nb_subtract*/
+ (binaryfunc) Color_mul, /*nb_multiply*/
+ NULL, /*nb_remainder*/
+ NULL, /*nb_divmod*/
+ NULL, /*nb_power*/
+ (unaryfunc) Color_neg, /*nb_negative*/
+ (unaryfunc) NULL, /*tp_positive*/
+ (unaryfunc) NULL, /*tp_absolute*/
+ (inquiry) NULL, /*tp_bool*/
+ (unaryfunc) NULL, /*nb_invert*/
+ NULL, /*nb_lshift*/
+ (binaryfunc)NULL, /*nb_rshift*/
+ NULL, /*nb_and*/
+ NULL, /*nb_xor*/
+ NULL, /*nb_or*/
+ NULL, /*nb_int*/
+ NULL, /*nb_reserved*/
+ NULL, /*nb_float*/
+ Color_iadd, /* nb_inplace_add */
+ Color_isub, /* nb_inplace_subtract */
+ Color_imul, /* nb_inplace_multiply */
+ NULL, /* nb_inplace_remainder */
+ NULL, /* nb_inplace_power */
+ NULL, /* nb_inplace_lshift */
+ NULL, /* nb_inplace_rshift */
+ NULL, /* nb_inplace_and */
+ NULL, /* nb_inplace_xor */
+ NULL, /* nb_inplace_or */
+ NULL, /* nb_floor_divide */
+ Color_div, /* nb_true_divide */
+ NULL, /* nb_inplace_floor_divide */
+ Color_idiv, /* nb_inplace_true_divide */
+ NULL, /* nb_index */
+};
+
/* color channel, vector.r/g/b */
static PyObject *Color_getChannel(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_setChannel(ColorObject * self, PyObject *value, void * type)
{
return Color_ass_item(self, GET_INT_FROM_POINTER(type), value);
}
@@ -369,7 +635,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_setChannelHSV(ColorObject * self, PyObject *value, void * type)
{
float hsv[3];
int i= GET_INT_FROM_POINTER(type);
@@ -412,7 +678,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_setHSV(ColorObject * self, PyObject *value, void *UNUSED(closure))
{
float hsv[3];
@@ -473,7 +739,7 @@ PyTypeObject color_Type = {
NULL, //tp_setattr
NULL, //tp_compare
(reprfunc) Color_repr, //tp_repr
- NULL, //tp_as_number
+ &Color_NumMethods, //tp_as_number
&Color_SeqMethods, //tp_as_sequence
&Color_AsMapping, //tp_as_mapping
NULL, //tp_hash
diff --git a/source/blender/python/generic/mathutils_Euler.c b/source/blender/python/generic/mathutils_Euler.c
index 9adf0ee905b..4281c7bf6c5 100644
--- a/source/blender/python/generic/mathutils_Euler.c
+++ b/source/blender/python/generic/mathutils_Euler.c
@@ -419,7 +419,7 @@ static PyObject *Euler_slice(EulerObject * self, int begin, int end)
}
//----------------------------object[z:y]------------------------
//sequence slice (set)
-static int Euler_ass_slice(EulerObject * self, int begin, int end, PyObject * seq)
+static int Euler_ass_slice(EulerObject *self, int begin, int end, PyObject *seq)
{
int i, size;
float eul[EULER_SIZE];
diff --git a/source/blender/python/generic/mathutils_Matrix.c b/source/blender/python/generic/mathutils_Matrix.c
index 982a8e63282..4b7f9dc0d97 100644
--- a/source/blender/python/generic/mathutils_Matrix.c
+++ b/source/blender/python/generic/mathutils_Matrix.c
@@ -1485,7 +1485,7 @@ static PyObject *matrix_mul_float(MatrixObject *mat, const float scalar)
return newMatrixObject(tmat, mat->row_size, mat->col_size, Py_NEW, Py_TYPE(mat));
}
-static PyObject *Matrix_mul(PyObject * m1, PyObject * m2)
+static PyObject *Matrix_mul(PyObject *m1, PyObject *m2)
{
float scalar;
diff --git a/source/blender/python/generic/mathutils_Vector.c b/source/blender/python/generic/mathutils_Vector.c
index fd8d1b5f481..d0ba94474d4 100644
--- a/source/blender/python/generic/mathutils_Vector.c
+++ b/source/blender/python/generic/mathutils_Vector.c
@@ -869,8 +869,7 @@ static PyObject *Vector_slice(VectorObject *self, int begin, int end)
return tuple;
}
/* sequence slice (set): vector[a:b] = value */
-static int Vector_ass_slice(VectorObject *self, int begin, int end,
- PyObject * seq)
+static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *seq)
{
int y, size = 0;
float vec[MAX_DIMENSIONS];
@@ -899,7 +898,7 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end,
/* Numeric Protocols */
/* addition: obj + obj */
-static PyObject *Vector_add(PyObject * v1, PyObject * v2)
+static PyObject *Vector_add(PyObject *v1, PyObject *v2)
{
VectorObject *vec1 = NULL, *vec2 = NULL;
float vec[MAX_DIMENSIONS];
@@ -926,7 +925,7 @@ static PyObject *Vector_add(PyObject * v1, PyObject * v2)
}
/* addition in-place: obj += obj */
-static PyObject *Vector_iadd(PyObject * v1, PyObject * v2)
+static PyObject *Vector_iadd(PyObject *v1, PyObject *v2)
{
VectorObject *vec1 = NULL, *vec2 = NULL;
@@ -953,7 +952,7 @@ static PyObject *Vector_iadd(PyObject * v1, PyObject * v2)
}
/* subtraction: obj - obj */
-static PyObject *Vector_sub(PyObject * v1, PyObject * v2)
+static PyObject *Vector_sub(PyObject *v1, PyObject *v2)
{
VectorObject *vec1 = NULL, *vec2 = NULL;
float vec[MAX_DIMENSIONS];
@@ -979,7 +978,7 @@ static PyObject *Vector_sub(PyObject * v1, PyObject * v2)
}
/* subtraction in-place: obj -= obj */
-static PyObject *Vector_isub(PyObject * v1, PyObject * v2)
+static PyObject *Vector_isub(PyObject *v1, PyObject *v2)
{
VectorObject *vec1= NULL, *vec2= NULL;
@@ -1055,7 +1054,7 @@ static PyObject *vector_mul_float(VectorObject *vec, const float scalar)
return newVectorObject(tvec, vec->size, Py_NEW, Py_TYPE(vec));
}
-static PyObject *Vector_mul(PyObject * v1, PyObject * v2)
+static PyObject *Vector_mul(PyObject *v1, PyObject *v2)
{
VectorObject *vec1 = NULL, *vec2 = NULL;
float scalar;
@@ -1116,12 +1115,12 @@ static PyObject *Vector_mul(PyObject * v1, PyObject * v2)
mul_qt_v3(quat2->quat, tvec);
return newVectorObject(tvec, 3, Py_NEW, Py_TYPE(vec1));
}
- else if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* VEC*FLOAT */
+ else if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* VEC * FLOAT */
return vector_mul_float(vec1, scalar);
}
}
else if (vec2) {
- if (((scalar= PyFloat_AsDouble(v1)) == -1.0f && PyErr_Occurred())==0) { /* VEC*FLOAT */
+ if (((scalar= PyFloat_AsDouble(v1)) == -1.0f && PyErr_Occurred())==0) { /* FLOAT * VEC */
return vector_mul_float(vec2, scalar);
}
}
@@ -1134,7 +1133,7 @@ static PyObject *Vector_mul(PyObject * v1, PyObject * v2)
}
/* mulplication in-place: obj *= obj */
-static PyObject *Vector_imul(PyObject * v1, PyObject * v2)
+static PyObject *Vector_imul(PyObject *v1, PyObject *v2)
{
VectorObject *vec = (VectorObject *)v1;
float scalar;
@@ -1168,7 +1167,7 @@ static PyObject *Vector_imul(PyObject * v1, PyObject * v2)
}
mul_qt_v3(quat2->quat, vec->vec);
}
- else if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* VEC*=FLOAT */
+ else if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* VEC *= FLOAT */
mul_vn_fl(vec->vec, vec->size, scalar);
}
else {
@@ -1182,7 +1181,7 @@ static PyObject *Vector_imul(PyObject * v1, PyObject * v2)
}
/* divid: obj / obj */
-static PyObject *Vector_div(PyObject * v1, PyObject * v2)
+static PyObject *Vector_div(PyObject *v1, PyObject *v2)
{
int i;
float vec[4], scalar;
@@ -1214,7 +1213,7 @@ static PyObject *Vector_div(PyObject * v1, PyObject * v2)
}
/* divide in-place: obj /= obj */
-static PyObject *Vector_idiv(PyObject * v1, PyObject * v2)
+static PyObject *Vector_idiv(PyObject *v1, PyObject *v2)
{
int i;
float scalar;
@@ -1489,7 +1488,7 @@ static PyObject *Vector_getAxis(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_setAxis(VectorObject *self, PyObject *value, void *type)
{
return vector_ass_item_internal(self, GET_INT_FROM_POINTER(type), value, TRUE);
}
@@ -1596,7 +1595,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_setSwizzle(VectorObject *self, PyObject *value, void *closure)
{
size_t size_from;
float scalarVal;
diff --git a/source/blender/python/generic/mathutils_geometry.c b/source/blender/python/generic/mathutils_geometry.c
index c4917199e59..53c066d1a85 100644
--- a/source/blender/python/generic/mathutils_geometry.c
+++ b/source/blender/python/generic/mathutils_geometry.c
@@ -169,7 +169,7 @@ PyDoc_STRVAR(M_Geometry_intersect_line_line_doc,
);
static PyObject *M_Geometry_intersect_line_line(PyObject *UNUSED(self), PyObject *args)
{
- PyObject * tuple;
+ PyObject *tuple;
VectorObject *vec1, *vec2, *vec3, *vec4;
float v1[3], v2[3], v3[3], v4[3], i1[3], i2[3];
@@ -720,7 +720,7 @@ static int boxPack_FromPyObject(PyObject *value, boxPack **boxarray)
return 0;
}
-static void boxPack_ToPyObject(PyObject * value, boxPack **boxarray)
+static void boxPack_ToPyObject(PyObject *value, boxPack **boxarray)
{
int len, i;
PyObject *list_item;
diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c
index 450151ee870..cb11b53c83c 100644
--- a/source/blender/python/intern/bpy.c
+++ b/source/blender/python/intern/bpy.c
@@ -231,7 +231,7 @@ static PyObject *bpy_import_test(const char *modname)
/*****************************************************************************
* Description: Creates the bpy module and adds it to sys.modules for importing
*****************************************************************************/
-void BPy_init_modules( void )
+void BPy_init_modules(void)
{
extern BPy_StructRNA *bpy_context_module;
extern int bpy_lib_init(PyObject *);
@@ -262,17 +262,17 @@ void BPy_init_modules( void )
/* run first, initializes rna types */
BPY_rna_init();
- PyModule_AddObject( mod, "types", BPY_rna_types() ); /* needs to be first so bpy_types can run */
+ PyModule_AddObject(mod, "types", BPY_rna_types()); /* needs to be first so bpy_types can run */
PyModule_AddObject(mod, "StructMetaPropGroup", (PyObject *)&pyrna_struct_meta_idprop_Type); /* metaclass for idprop types, bpy_types.py needs access */
bpy_lib_init(mod); /* adds '_bpy._library_load', must be called before 'bpy_types' which uses it */
bpy_import_test("bpy_types");
- PyModule_AddObject( mod, "data", BPY_rna_module() ); /* imports bpy_types by running this */
+ PyModule_AddObject(mod, "data", BPY_rna_module()); /* imports bpy_types by running this */
bpy_import_test("bpy_types");
- PyModule_AddObject( mod, "props", BPY_rna_props() );
- PyModule_AddObject( mod, "ops", BPY_operator_module() ); /* ops is now a python module that does the conversion from SOME_OT_foo -> some.foo */
- PyModule_AddObject( mod, "app", BPY_app_struct() );
+ PyModule_AddObject(mod, "props", BPY_rna_props());
+ PyModule_AddObject(mod, "ops", BPY_operator_module()); /* ops is now a python module that does the conversion from SOME_OT_foo -> some.foo */
+ PyModule_AddObject(mod, "app", BPY_app_struct());
/* bpy context */
RNA_pointer_create(NULL, &RNA_Context, (void *)BPy_GetContext(), &ctx_ptr);
diff --git a/source/blender/python/intern/bpy.h b/source/blender/python/intern/bpy.h
index 0f298c1daf1..0ebc6bb2438 100644
--- a/source/blender/python/intern/bpy.h
+++ b/source/blender/python/intern/bpy.h
@@ -26,5 +26,5 @@
*/
-void BPy_init_modules( void );
+void BPy_init_modules(void);
extern PyObject *bpy_package_py;
diff --git a/source/blender/python/intern/bpy_app.h b/source/blender/python/intern/bpy_app.h
index d57e4688f46..fbc5696875a 100644
--- a/source/blender/python/intern/bpy_app.h
+++ b/source/blender/python/intern/bpy_app.h
@@ -29,6 +29,6 @@
#ifndef BPY_APP_H
#define BPY_APP_H
-PyObject *BPY_app_struct( void );
+PyObject *BPY_app_struct(void);
#endif // BPY_APP_H
diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c
index df31fab6bde..6f124d959cb 100644
--- a/source/blender/python/intern/bpy_driver.c
+++ b/source/blender/python/intern/bpy_driver.c
@@ -60,7 +60,7 @@ int bpy_pydriver_create_dict(void)
else
bpy_pydriver_Dict= d;
- /* import some modules: builtins, bpy, math, (Blender.noise )*/
+ /* import some modules: builtins, bpy, math, (Blender.noise)*/
PyDict_SetItemString(d, "__builtins__", PyEval_GetBuiltins());
mod= PyImport_ImportModule("math");
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index e6f4c5713a1..089c9b37788 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -171,6 +171,8 @@ void BPY_context_set(bContext *C)
/* defined in AUD_C-API.cpp */
extern PyObject *AUD_initPython(void);
+/* defined in gpu_python.c */
+extern PyObject *GPU_initPython(void);
static struct _inittab bpy_internal_modules[]= {
{(char *)"noise", BPyInit_noise},
@@ -179,6 +181,7 @@ static struct _inittab bpy_internal_modules[]= {
{(char *)"bgl", BPyInit_bgl},
{(char *)"blf", BPyInit_blf},
{(char *)"aud", AUD_initPython},
+ {(char *)"gpu", GPU_initPython},
{NULL, NULL}
};
diff --git a/source/blender/python/intern/bpy_library.c b/source/blender/python/intern/bpy_library.c
index 10e97573447..85bffb5a8cc 100644
--- a/source/blender/python/intern/bpy_library.c
+++ b/source/blender/python/intern/bpy_library.c
@@ -213,7 +213,7 @@ static PyObject *_bpy_names(BPy_Library *self, int blocktype)
int counter= 0;
list= PyList_New(totnames);
for(l= names; l; l= l->next) {
- PyList_SET_ITEM(list, counter, PyUnicode_FromString((char * )l->link));
+ PyList_SET_ITEM(list, counter, PyUnicode_FromString((char *)l->link));
counter++;
}
BLI_linklist_free(names, free); /* free linklist *and* each node's data */
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c
index 0ee9d7e5bd5..352f7408961 100644
--- a/source/blender/python/intern/bpy_props.c
+++ b/source/blender/python/intern/bpy_props.c
@@ -1156,7 +1156,7 @@ static struct PyModuleDef props_module= {
NULL, NULL, NULL, NULL
};
-PyObject *BPY_rna_props( void )
+PyObject *BPY_rna_props(void)
{
PyObject *submodule;
PyObject *submodule_dict;
diff --git a/source/blender/python/intern/bpy_props.h b/source/blender/python/intern/bpy_props.h
index f306d6898d1..8b64d04e092 100644
--- a/source/blender/python/intern/bpy_props.h
+++ b/source/blender/python/intern/bpy_props.h
@@ -30,7 +30,7 @@
#ifndef BPY_PROPS_H
#define BPY_PROPS_H
-PyObject *BPY_rna_props( void );
+PyObject *BPY_rna_props(void);
#define PYRNA_STACK_ARRAY 32
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 72d391fed32..4fe13bc6818 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -1200,7 +1200,7 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
return ret;
}
-PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
+PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
{
PyObject *ret;
int type= RNA_property_type(prop);
@@ -1334,7 +1334,7 @@ int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, int all_args, const cha
return error_val;
}
-static PyObject * pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw);
+static PyObject *pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw);
static PyObject *pyrna_func_to_py(BPy_DummyPointerRNA *pyrna, FunctionRNA *func)
{
diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h
index ea8af61c9bf..dbb5fc2feb7 100644
--- a/source/blender/python/intern/bpy_rna.h
+++ b/source/blender/python/intern/bpy_rna.h
@@ -148,18 +148,18 @@ typedef struct {
StructRNA *srna_from_self(PyObject *self, const char *error_prefix);
StructRNA *pyrna_struct_as_srna(PyObject *self, int parent, const char *error_prefix);
-void BPY_rna_init( void );
-PyObject *BPY_rna_module( void );
-void BPY_update_rna_module( void );
-/*PyObject *BPY_rna_doc( void );*/
-PyObject *BPY_rna_types( void );
+void BPY_rna_init(void);
+PyObject *BPY_rna_module(void);
+void BPY_update_rna_module(void);
+/*PyObject *BPY_rna_doc(void);*/
+PyObject *BPY_rna_types(void);
-PyObject *pyrna_struct_CreatePyObject( PointerRNA *ptr );
-PyObject *pyrna_prop_CreatePyObject( PointerRNA *ptr, PropertyRNA *prop );
+PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr);
+PyObject *pyrna_prop_CreatePyObject(PointerRNA *ptr, PropertyRNA *prop);
/* operators also need this to set args */
int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, int all_args, const char *error_prefix);
-PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop);
+PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop);
PyObject *pyrna_enum_bitfield_to_py(struct EnumPropertyItem *items, int value);
int pyrna_set_to_enum_bitfield(EnumPropertyItem *items, PyObject *value, int *r_value, const char *error_prefix);