style cleanup: python api

This commit is contained in:
2012-03-26 06:55:09 +00:00
parent 7c8c1a0718
commit 11d12d945e
12 changed files with 1092 additions and 1092 deletions

View File

@@ -56,16 +56,16 @@ static PyObject *Buffer_subscript(Buffer *self, PyObject *item);
static int Buffer_ass_subscript(Buffer *self, PyObject *item, PyObject *value); static int Buffer_ass_subscript(Buffer *self, PyObject *item, PyObject *value);
static PySequenceMethods Buffer_SeqMethods = { static PySequenceMethods Buffer_SeqMethods = {
(lenfunc) Buffer_len, /*sq_length */ (lenfunc) Buffer_len, /*sq_length */
(binaryfunc) NULL, /*sq_concat */ (binaryfunc) NULL, /*sq_concat */
(ssizeargfunc) NULL, /*sq_repeat */ (ssizeargfunc) NULL, /*sq_repeat */
(ssizeargfunc) Buffer_item, /*sq_item */ (ssizeargfunc) Buffer_item, /*sq_item */
(ssizessizeargfunc) NULL, /*sq_slice, deprecated, handled in Buffer_item */ (ssizessizeargfunc) NULL, /*sq_slice, deprecated, handled in Buffer_item */
(ssizeobjargproc) Buffer_ass_item, /*sq_ass_item */ (ssizeobjargproc) Buffer_ass_item, /*sq_ass_item */
(ssizessizeobjargproc) NULL, /*sq_ass_slice, deprecated handled in Buffer_ass_item */ (ssizessizeobjargproc) NULL, /*sq_ass_slice, deprecated handled in Buffer_ass_item */
(objobjproc) NULL, /* sq_contains */ (objobjproc) NULL, /* sq_contains */
(binaryfunc) NULL, /* sq_inplace_concat */ (binaryfunc) NULL, /* sq_inplace_concat */
(ssizeargfunc) NULL, /* sq_inplace_repeat */ (ssizeargfunc) NULL, /* sq_inplace_repeat */
}; };
@@ -125,13 +125,13 @@ static PyObject *Buffer_dimensions(Buffer *self, void *UNUSED(arg))
static PyMethodDef Buffer_methods[] = { static PyMethodDef Buffer_methods[] = {
{"to_list", (PyCFunction)Buffer_to_list_recursive, METH_NOARGS, {"to_list", (PyCFunction)Buffer_to_list_recursive, METH_NOARGS,
"return the buffer as a list"}, "return the buffer as a list"},
{NULL, NULL, 0, NULL} {NULL, NULL, 0, NULL}
}; };
static PyGetSetDef Buffer_getseters[] = { static PyGetSetDef Buffer_getseters[] = {
{(char *)"dimensions", (getter)Buffer_dimensions, NULL, NULL, NULL}, {(char *)"dimensions", (getter)Buffer_dimensions, NULL, NULL, NULL},
{NULL, NULL, NULL, NULL, NULL} {NULL, NULL, NULL, NULL, NULL}
}; };
@@ -144,11 +144,11 @@ PyTypeObject BGL_bufferType = {
(printfunc)NULL, /*tp_print */ (printfunc)NULL, /*tp_print */
NULL, /*tp_getattr */ NULL, /*tp_getattr */
NULL, /*tp_setattr */ NULL, /*tp_setattr */
NULL, /*tp_compare */ NULL, /*tp_compare */
(reprfunc) Buffer_repr, /*tp_repr */ (reprfunc) Buffer_repr, /*tp_repr */
NULL, /*tp_as_number */ NULL, /*tp_as_number */
&Buffer_SeqMethods, /*tp_as_sequence */ &Buffer_SeqMethods, /*tp_as_sequence */
&Buffer_AsMapping, /* PyMappingMethods *tp_as_mapping; */ &Buffer_AsMapping, /* PyMappingMethods *tp_as_mapping; */
/* More standard operations (here for binary compatibility) */ /* More standard operations (here for binary compatibility) */
@@ -187,22 +187,22 @@ PyTypeObject BGL_bufferType = {
Buffer_methods, /* struct PyMethodDef *tp_methods; */ Buffer_methods, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */ NULL, /* struct PyMemberDef *tp_members; */
Buffer_getseters, /* struct PyGetSetDef *tp_getset; */ Buffer_getseters, /* struct PyGetSetDef *tp_getset; */
NULL, /*tp_base*/ NULL, /*tp_base*/
NULL, /*tp_dict*/ NULL, /*tp_dict*/
NULL, /*tp_descr_get*/ NULL, /*tp_descr_get*/
NULL, /*tp_descr_set*/ NULL, /*tp_descr_set*/
0, /*tp_dictoffset*/ 0, /*tp_dictoffset*/
NULL, /*tp_init*/ NULL, /*tp_init*/
NULL, /*tp_alloc*/ NULL, /*tp_alloc*/
Buffer_new, /*tp_new*/ Buffer_new, /*tp_new*/
NULL, /*tp_free*/ NULL, /*tp_free*/
NULL, /*tp_is_gc*/ NULL, /*tp_is_gc*/
NULL, /*tp_bases*/ NULL, /*tp_bases*/
NULL, /*tp_mro*/ NULL, /*tp_mro*/
NULL, /*tp_cache*/ NULL, /*tp_cache*/
NULL, /*tp_subclasses*/ NULL, /*tp_subclasses*/
NULL, /*tp_weaklist*/ NULL, /*tp_weaklist*/
NULL /*tp_del*/ NULL /*tp_del*/
}; };
#define BGL_Wrap(nargs, funcname, ret, arg_list) \ #define BGL_Wrap(nargs, funcname, ret, arg_list) \
@@ -286,7 +286,7 @@ Buffer *BGL_MakeBuffer(int type, int ndimensions, int *dimensions, void *initbuf
} }
#define MAX_DIMENSIONS 256 #define MAX_DIMENSIONS 256
static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds) static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
{ {
PyObject *length_ob = NULL, *init = NULL; PyObject *length_ob = NULL, *init = NULL;
@@ -428,7 +428,7 @@ static PyObject *Buffer_slice(Buffer *self, int begin, int end)
list = PyList_New(end - begin); list = PyList_New(end - begin);
for (count = begin; count < end; count++) { for (count = begin; count < end; count++) {
PyList_SET_ITEM(list, count-begin, Buffer_item(self, count)); PyList_SET_ITEM(list, count - begin, Buffer_item(self, count));
} }
return list; return list;
} }
@@ -618,7 +618,7 @@ BGL_Wrap(3, AreTexturesResident, GLboolean, (GLsizei, GLuintP, GLbooleanP))
BGL_Wrap(1, Begin, void, (GLenum)) BGL_Wrap(1, Begin, void, (GLenum))
BGL_Wrap(2, BindTexture, void, (GLenum, GLuint)) BGL_Wrap(2, BindTexture, void, (GLenum, GLuint))
BGL_Wrap(7, Bitmap, void, (GLsizei, GLsizei, GLfloat, BGL_Wrap(7, Bitmap, void, (GLsizei, GLsizei, GLfloat,
GLfloat, GLfloat, GLfloat, GLubyteP)) GLfloat, GLfloat, GLfloat, GLubyteP))
BGL_Wrap(2, BlendFunc, void, (GLenum, GLenum)) BGL_Wrap(2, BlendFunc, void, (GLenum, GLenum))
BGL_Wrap(1, CallList, void, (GLuint)) BGL_Wrap(1, CallList, void, (GLuint))
BGL_Wrap(3, CallLists, void, (GLsizei, GLenum, GLvoidP)) BGL_Wrap(3, CallLists, void, (GLsizei, GLenum, GLvoidP))
@@ -700,7 +700,7 @@ BGL_Wrap(2, Fogi, void, (GLenum, GLint))
BGL_Wrap(2, Fogiv, void, (GLenum, GLintP)) BGL_Wrap(2, Fogiv, void, (GLenum, GLintP))
BGL_Wrap(1, FrontFace, void, (GLenum)) BGL_Wrap(1, FrontFace, void, (GLenum))
BGL_Wrap(6, Frustum, void, (GLdouble, GLdouble, BGL_Wrap(6, Frustum, void, (GLdouble, GLdouble,
GLdouble, GLdouble, GLdouble, GLdouble)) GLdouble, GLdouble, GLdouble, GLdouble))
BGL_Wrap(1, GenLists, GLuint, (GLsizei)) BGL_Wrap(1, GenLists, GLuint, (GLsizei))
BGL_Wrap(2, GenTextures, void, (GLsizei, GLuintP)) BGL_Wrap(2, GenTextures, void, (GLsizei, GLuintP))
BGL_Wrap(2, GetBooleanv, void, (GLenum, GLbooleanP)) BGL_Wrap(2, GetBooleanv, void, (GLenum, GLbooleanP))
@@ -719,7 +719,7 @@ BGL_Wrap(3, GetMaterialiv, void, (GLenum, GLenum, GLintP))
BGL_Wrap(2, GetPixelMapfv, void, (GLenum, GLfloatP)) BGL_Wrap(2, GetPixelMapfv, void, (GLenum, GLfloatP))
BGL_Wrap(2, GetPixelMapuiv, void, (GLenum, GLuintP)) BGL_Wrap(2, GetPixelMapuiv, void, (GLenum, GLuintP))
BGL_Wrap(2, GetPixelMapusv, void, (GLenum, GLushortP)) BGL_Wrap(2, GetPixelMapusv, void, (GLenum, GLushortP))
BGL_Wrap(1, GetPolygonStipple,void, (GLubyteP)) BGL_Wrap(1, GetPolygonStipple, void, (GLubyteP))
BGL_Wrap(1, GetString, GLstring, (GLenum)) BGL_Wrap(1, GetString, GLstring, (GLenum))
BGL_Wrap(3, GetTexEnvfv, void, (GLenum, GLenum, GLfloatP)) BGL_Wrap(3, GetTexEnvfv, void, (GLenum, GLenum, GLfloatP))
BGL_Wrap(3, GetTexEnviv, void, (GLenum, GLenum, GLintP)) BGL_Wrap(3, GetTexEnviv, void, (GLenum, GLenum, GLintP))
@@ -762,19 +762,19 @@ BGL_Wrap(1, LoadMatrixf, void, (GLfloatP))
BGL_Wrap(1, LoadName, void, (GLuint)) BGL_Wrap(1, LoadName, void, (GLuint))
BGL_Wrap(1, LogicOp, void, (GLenum)) BGL_Wrap(1, LogicOp, void, (GLenum))
BGL_Wrap(6, Map1d, void, (GLenum, GLdouble, GLdouble, BGL_Wrap(6, Map1d, void, (GLenum, GLdouble, GLdouble,
GLint, GLint, GLdoubleP)) GLint, GLint, GLdoubleP))
BGL_Wrap(6, Map1f, void, (GLenum, GLfloat, GLfloat, BGL_Wrap(6, Map1f, void, (GLenum, GLfloat, GLfloat,
GLint, GLint, GLfloatP)) GLint, GLint, GLfloatP))
BGL_Wrap(10, Map2d, void, (GLenum, GLdouble, GLdouble, BGL_Wrap(10, Map2d, void, (GLenum, GLdouble, GLdouble,
GLint, GLint, GLdouble, GLdouble, GLint, GLint, GLdoubleP)) GLint, GLint, GLdouble, GLdouble, GLint, GLint, GLdoubleP))
BGL_Wrap(10, Map2f, void, (GLenum, GLfloat, GLfloat, BGL_Wrap(10, Map2f, void, (GLenum, GLfloat, GLfloat,
GLint, GLint, GLfloat, GLfloat, GLint, GLint, GLfloatP)) GLint, GLint, GLfloat, GLfloat, GLint, GLint, GLfloatP))
BGL_Wrap(3, MapGrid1d, void, (GLint, GLdouble, GLdouble)) BGL_Wrap(3, MapGrid1d, void, (GLint, GLdouble, GLdouble))
BGL_Wrap(3, MapGrid1f, void, (GLint, GLfloat, GLfloat)) BGL_Wrap(3, MapGrid1f, void, (GLint, GLfloat, GLfloat))
BGL_Wrap(6, MapGrid2d, void, (GLint, GLdouble, GLdouble, BGL_Wrap(6, MapGrid2d, void, (GLint, GLdouble, GLdouble,
GLint, GLdouble, GLdouble)) GLint, GLdouble, GLdouble))
BGL_Wrap(6, MapGrid2f, void, (GLint, GLfloat, GLfloat, BGL_Wrap(6, MapGrid2f, void, (GLint, GLfloat, GLfloat,
GLint, GLfloat, GLfloat)) GLint, GLfloat, GLfloat))
BGL_Wrap(3, Materialf, void, (GLenum, GLenum, GLfloat)) BGL_Wrap(3, Materialf, void, (GLenum, GLenum, GLfloat))
BGL_Wrap(3, Materialfv, void, (GLenum, GLenum, GLfloatP)) BGL_Wrap(3, Materialfv, void, (GLenum, GLenum, GLfloatP))
BGL_Wrap(3, Materiali, void, (GLenum, GLenum, GLint)) BGL_Wrap(3, Materiali, void, (GLenum, GLenum, GLint))
@@ -794,7 +794,7 @@ BGL_Wrap(1, Normal3iv, void, (GLintP))
BGL_Wrap(3, Normal3s, void, (GLshort, GLshort, GLshort)) BGL_Wrap(3, Normal3s, void, (GLshort, GLshort, GLshort))
BGL_Wrap(1, Normal3sv, void, (GLshortP)) BGL_Wrap(1, Normal3sv, void, (GLshortP))
BGL_Wrap(6, Ortho, void, (GLdouble, GLdouble, BGL_Wrap(6, Ortho, void, (GLdouble, GLdouble,
GLdouble, GLdouble, GLdouble, GLdouble)) GLdouble, GLdouble, GLdouble, GLdouble))
BGL_Wrap(1, PassThrough, void, (GLfloat)) BGL_Wrap(1, PassThrough, void, (GLfloat))
BGL_Wrap(3, PixelMapfv, void, (GLenum, GLint, GLfloatP)) BGL_Wrap(3, PixelMapfv, void, (GLenum, GLint, GLfloatP))
BGL_Wrap(3, PixelMapuiv, void, (GLenum, GLint, GLuintP)) BGL_Wrap(3, PixelMapuiv, void, (GLenum, GLint, GLuintP))
@@ -843,7 +843,7 @@ BGL_Wrap(4, RasterPos4s, void, (GLshort, GLshort, GLshort, GLshort))
BGL_Wrap(1, RasterPos4sv, void, (GLshortP)) BGL_Wrap(1, RasterPos4sv, void, (GLshortP))
BGL_Wrap(1, ReadBuffer, void, (GLenum)) BGL_Wrap(1, ReadBuffer, void, (GLenum))
BGL_Wrap(7, ReadPixels, void, (GLint, GLint, GLsizei, BGL_Wrap(7, ReadPixels, void, (GLint, GLint, GLsizei,
GLsizei, GLenum, GLenum, GLvoidP)) GLsizei, GLenum, GLenum, GLvoidP))
BGL_Wrap(4, Rectd, void, (GLdouble, GLdouble, GLdouble, GLdouble)) BGL_Wrap(4, Rectd, void, (GLdouble, GLdouble, GLdouble, GLdouble))
BGL_Wrap(2, Rectdv, void, (GLdoubleP, GLdoubleP)) BGL_Wrap(2, Rectdv, void, (GLdoubleP, GLdoubleP))
BGL_Wrap(4, Rectf, void, (GLfloat, GLfloat, GLfloat, GLfloat)) BGL_Wrap(4, Rectf, void, (GLfloat, GLfloat, GLfloat, GLfloat))
@@ -906,9 +906,9 @@ BGL_Wrap(3, TexGenfv, void, (GLenum, GLenum, GLfloatP))
BGL_Wrap(3, TexGeni, void, (GLenum, GLenum, GLint)) BGL_Wrap(3, TexGeni, void, (GLenum, GLenum, GLint))
BGL_Wrap(3, TexGeniv, void, (GLenum, GLenum, GLintP)) BGL_Wrap(3, TexGeniv, void, (GLenum, GLenum, GLintP))
BGL_Wrap(8, TexImage1D, void, (GLenum, GLint, GLint, BGL_Wrap(8, TexImage1D, void, (GLenum, GLint, GLint,
GLsizei, GLint, GLenum, GLenum, GLvoidP)) GLsizei, GLint, GLenum, GLenum, GLvoidP))
BGL_Wrap(9, TexImage2D, void, (GLenum, GLint, GLint, BGL_Wrap(9, TexImage2D, void, (GLenum, GLint, GLint,
GLsizei, GLsizei, GLint, GLenum, GLenum, GLvoidP)) GLsizei, GLsizei, GLint, GLenum, GLenum, GLvoidP))
BGL_Wrap(3, TexParameterf, void, (GLenum, GLenum, GLfloat)) BGL_Wrap(3, TexParameterf, void, (GLenum, GLenum, GLfloat))
BGL_Wrap(3, TexParameterfv, void, (GLenum, GLenum, GLfloatP)) BGL_Wrap(3, TexParameterfv, void, (GLenum, GLenum, GLfloatP))
BGL_Wrap(3, TexParameteri, void, (GLenum, GLenum, GLint)) BGL_Wrap(3, TexParameteri, void, (GLenum, GLenum, GLint))
@@ -940,12 +940,12 @@ BGL_Wrap(1, Vertex4iv, void, (GLintP))
BGL_Wrap(4, Vertex4s, void, (GLshort, GLshort, GLshort, GLshort)) BGL_Wrap(4, Vertex4s, void, (GLshort, GLshort, GLshort, GLshort))
BGL_Wrap(1, Vertex4sv, void, (GLshortP)) BGL_Wrap(1, Vertex4sv, void, (GLshortP))
BGL_Wrap(4, Viewport, void, (GLint, GLint, GLsizei, GLsizei)) BGL_Wrap(4, Viewport, void, (GLint, GLint, GLsizei, GLsizei))
BGLU_Wrap(4, Perspective, void, (GLdouble, GLdouble, GLdouble, GLdouble)) BGLU_Wrap(4, Perspective, void, (GLdouble, GLdouble, GLdouble, GLdouble))
BGLU_Wrap(9, LookAt, void, (GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble)) BGLU_Wrap(9, LookAt, void, (GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble))
BGLU_Wrap(4, Ortho2D, void, (GLdouble, GLdouble, GLdouble, GLdouble)) BGLU_Wrap(4, Ortho2D, void, (GLdouble, GLdouble, GLdouble, GLdouble))
BGLU_Wrap(5, PickMatrix, void, (GLdouble, GLdouble, GLdouble, GLdouble, GLintP)) BGLU_Wrap(5, PickMatrix, void, (GLdouble, GLdouble, GLdouble, GLdouble, GLintP))
BGLU_Wrap(9, Project, GLint, (GLdouble, GLdouble, GLdouble, GLdoubleP, GLdoubleP, GLintP, GLdoubleP, GLdoubleP, GLdoubleP)) BGLU_Wrap(9, Project, GLint, (GLdouble, GLdouble, GLdouble, GLdoubleP, GLdoubleP, GLintP, GLdoubleP, GLdoubleP, GLdoubleP))
BGLU_Wrap(9, UnProject, GLint, (GLdouble, GLdouble, GLdouble, GLdoubleP, GLdoubleP, GLintP, GLdoubleP, GLdoubleP, GLdoubleP)) BGLU_Wrap(9, UnProject, GLint, (GLdouble, GLdouble, GLdouble, GLdoubleP, GLdoubleP, GLintP, GLdoubleP, GLdoubleP, GLdoubleP))
#undef MethodDef #undef MethodDef
#define MethodDef(func) {"gl"#func, Method_##func, METH_VARARGS, "no string"} #define MethodDef(func) {"gl"#func, Method_##func, METH_VARARGS, "no string"}
@@ -1302,7 +1302,7 @@ PyObject *BPyInit_bgl(void)
dict = PyModule_GetDict(submodule); dict = PyModule_GetDict(submodule);
if (PyType_Ready(&BGL_bufferType) < 0) if (PyType_Ready(&BGL_bufferType) < 0)
return NULL; /* should never happen */ return NULL; /* should never happen */
PyModule_AddObject(submodule, "Buffer", (PyObject *)&BGL_bufferType); PyModule_AddObject(submodule, "Buffer", (PyObject *)&BGL_bufferType);
Py_INCREF((PyObject *)&BGL_bufferType); Py_INCREF((PyObject *)&BGL_bufferType);

View File

@@ -47,7 +47,7 @@
#include "BLI_string.h" #include "BLI_string.h"
#include "BLI_utildefines.h" #include "BLI_utildefines.h"
/* UNUSED */ /* UNUSED */
#include "BKE_text.h" /* txt_to_buf */ #include "BKE_text.h" /* txt_to_buf */
#include "BKE_main.h" #include "BKE_main.h"
@@ -244,12 +244,12 @@ static PyObject *blender_import(PyObject *UNUSED(self), PyObject *args, PyObject
if (newmodule) if (newmodule)
return newmodule; return newmodule;
PyErr_Fetch(&exception, &err, &tb); /* get the python error in case we cant import as blender text either */ PyErr_Fetch(&exception, &err, &tb); /* get the python error in case we cant import as blender text either */
/* importing from existing modules failed, see if we have this module as blender text */ /* importing from existing modules failed, see if we have this module as blender text */
newmodule = bpy_text_import_name(name, &found); newmodule = bpy_text_import_name(name, &found);
if (newmodule) {/* found module as blender text, ignore above exception */ if (newmodule) { /* found module as blender text, ignore above exception */
PyErr_Clear(); PyErr_Clear();
Py_XDECREF(exception); Py_XDECREF(exception);
Py_XDECREF(err); Py_XDECREF(err);
@@ -287,10 +287,10 @@ static PyObject *blender_reload(PyObject *UNUSED(self), PyObject *module)
return newmodule; return newmodule;
/* no file, try importing from memory */ /* no file, try importing from memory */
PyErr_Fetch(&exception, &err, &tb); /*restore for probable later use */ PyErr_Fetch(&exception, &err, &tb); /*restore for probable later use */
newmodule = bpy_text_reimport(module, &found); newmodule = bpy_text_reimport(module, &found);
if (newmodule) {/* found module as blender text, ignore above exception */ if (newmodule) { /* found module as blender text, ignore above exception */
PyErr_Clear(); PyErr_Clear();
Py_XDECREF(exception); Py_XDECREF(exception);
Py_XDECREF(err); Py_XDECREF(err);

View File

@@ -88,7 +88,7 @@ static PyObject *idprop_py_from_idp_group(ID *id, IDProperty *prop, IDProperty *
group->id = id; group->id = id;
group->prop = prop; group->prop = prop;
group->parent = parent; /* can be NULL */ group->parent = parent; /* can be NULL */
return (PyObject*)group; return (PyObject *)group;
} }
static PyObject *idprop_py_from_idp_array(ID *id, IDProperty *prop) static PyObject *idprop_py_from_idp_array(ID *id, IDProperty *prop)
@@ -96,7 +96,7 @@ static PyObject *idprop_py_from_idp_array(ID *id, IDProperty *prop)
BPy_IDProperty *array = PyObject_New(BPy_IDProperty, &BPy_IDArray_Type); BPy_IDProperty *array = PyObject_New(BPy_IDProperty, &BPy_IDArray_Type);
array->id = id; array->id = id;
array->prop = prop; array->prop = prop;
return (PyObject*)array; return (PyObject *)array;
} }
static PyObject *idprop_py_from_idp_idparray(ID *id, IDProperty *prop) static PyObject *idprop_py_from_idp_idparray(ID *id, IDProperty *prop)
@@ -178,7 +178,7 @@ static int BPy_IDGroup_SetData(BPy_IDProperty *self, IDProperty *prop, PyObject
} }
#else #else
st = _PyUnicode_AsString(value); st = _PyUnicode_AsString(value);
IDP_ResizeArray(prop, strlen(st)+1); IDP_ResizeArray(prop, strlen(st) + 1);
strcpy(IDP_Array(prop), st); strcpy(IDP_Array(prop), st);
#endif #endif
@@ -258,7 +258,7 @@ static PyObject *BPy_IDGroup_GetType(BPy_IDProperty *self)
static PyGetSetDef BPy_IDGroup_getseters[] = { static PyGetSetDef BPy_IDGroup_getseters[] = {
{(char *)"name", (getter)BPy_IDGroup_GetName, (setter)BPy_IDGroup_SetName, (char *)"The name of this Group.", NULL}, {(char *)"name", (getter)BPy_IDGroup_GetName, (setter)BPy_IDGroup_SetName, (char *)"The name of this Group.", NULL},
{NULL, NULL, NULL, NULL, NULL} {NULL, NULL, NULL, NULL, NULL}
}; };
static Py_ssize_t BPy_IDGroup_Map_Len(BPy_IDProperty *self) static Py_ssize_t BPy_IDGroup_Map_Len(BPy_IDProperty *self)
@@ -530,7 +530,7 @@ static PyObject *BPy_IDGroup_iter(BPy_IDProperty *self)
iter->mode = IDPROP_ITER_KEYS; iter->mode = IDPROP_ITER_KEYS;
iter->cur = self->prop->data.group.first; iter->cur = self->prop->data.group.first;
Py_XINCREF(iter); Py_XINCREF(iter);
return (PyObject*)iter; return (PyObject *)iter;
} }
/* for simple, non nested types this is the same as BPy_IDGroup_WrapData */ /* for simple, non nested types this is the same as BPy_IDGroup_WrapData */
@@ -679,7 +679,7 @@ static PyObject *BPy_IDGroup_IterItems(BPy_IDProperty *self)
iter->mode = IDPROP_ITER_ITEMS; iter->mode = IDPROP_ITER_ITEMS;
iter->cur = self->prop->data.group.first; iter->cur = self->prop->data.group.first;
Py_XINCREF(iter); Py_XINCREF(iter);
return (PyObject*)iter; return (PyObject *)iter;
} }
/* utility function */ /* utility function */
@@ -793,7 +793,7 @@ static int BPy_IDGroup_Contains(BPy_IDProperty *self, PyObject *value)
return -1; return -1;
} }
return IDP_GetPropertyFromGroup(self->prop, name) ? 1:0; return IDP_GetPropertyFromGroup(self->prop, name) ? 1 : 0;
} }
static PyObject *BPy_IDGroup_Update(BPy_IDProperty *self, PyObject *value) static PyObject *BPy_IDGroup_Update(BPy_IDProperty *self, PyObject *value)
@@ -845,64 +845,64 @@ static PyObject *BPy_IDGroup_Get(BPy_IDProperty *self, PyObject *args)
static struct PyMethodDef BPy_IDGroup_methods[] = { static struct PyMethodDef BPy_IDGroup_methods[] = {
{"pop", (PyCFunction)BPy_IDGroup_Pop, METH_O, {"pop", (PyCFunction)BPy_IDGroup_Pop, METH_O,
"pop an item from the group; raises KeyError if the item doesn't exist"}, "pop an item from the group; raises KeyError if the item doesn't exist"},
{"iteritems", (PyCFunction)BPy_IDGroup_IterItems, METH_NOARGS, {"iteritems", (PyCFunction)BPy_IDGroup_IterItems, METH_NOARGS,
"iterate through the items in the dict; behaves like dictionary method iteritems"}, "iterate through the items in the dict; behaves like dictionary method iteritems"},
{"keys", (PyCFunction)BPy_IDGroup_GetKeys, METH_NOARGS, {"keys", (PyCFunction)BPy_IDGroup_GetKeys, METH_NOARGS,
"get the keys associated with this group as a list of strings"}, "get the keys associated with this group as a list of strings"},
{"values", (PyCFunction)BPy_IDGroup_GetValues, METH_NOARGS, {"values", (PyCFunction)BPy_IDGroup_GetValues, METH_NOARGS,
"get the values associated with this group"}, "get the values associated with this group"},
{"items", (PyCFunction)BPy_IDGroup_GetItems, METH_NOARGS, {"items", (PyCFunction)BPy_IDGroup_GetItems, METH_NOARGS,
"get the items associated with this group"}, "get the items associated with this group"},
{"update", (PyCFunction)BPy_IDGroup_Update, METH_O, {"update", (PyCFunction)BPy_IDGroup_Update, METH_O,
"updates the values in the group with the values of another or a dict"}, "updates the values in the group with the values of another or a dict"},
{"get", (PyCFunction)BPy_IDGroup_Get, METH_VARARGS, {"get", (PyCFunction)BPy_IDGroup_Get, METH_VARARGS,
"idprop.get(k[,d]) -> idprop[k] if k in idprop, else d. d defaults to None"}, "idprop.get(k[,d]) -> idprop[k] if k in idprop, else d. d defaults to None"},
{"to_dict", (PyCFunction)BPy_IDGroup_to_dict, METH_NOARGS, {"to_dict", (PyCFunction)BPy_IDGroup_to_dict, METH_NOARGS,
"return a purely python version of the group"}, "return a purely python version of the group"},
{NULL, NULL, 0, NULL} {NULL, NULL, 0, NULL}
}; };
static PySequenceMethods BPy_IDGroup_Seq = { static PySequenceMethods BPy_IDGroup_Seq = {
(lenfunc) BPy_IDGroup_Map_Len, /* lenfunc sq_length */ (lenfunc) BPy_IDGroup_Map_Len, /* lenfunc sq_length */
NULL, /* binaryfunc sq_concat */ NULL, /* binaryfunc sq_concat */
NULL, /* ssizeargfunc sq_repeat */ NULL, /* ssizeargfunc sq_repeat */
NULL, /* ssizeargfunc sq_item */ /* TODO - setting this will allow PySequence_Check to return True */ NULL, /* ssizeargfunc sq_item */ /* TODO - setting this will allow PySequence_Check to return True */
NULL, /* intintargfunc ***was_sq_slice*** */ NULL, /* intintargfunc ***was_sq_slice*** */
NULL, /* intobjargproc sq_ass_item */ NULL, /* intobjargproc sq_ass_item */
NULL, /* ssizeobjargproc ***was_sq_ass_slice*** */ NULL, /* ssizeobjargproc ***was_sq_ass_slice*** */
(objobjproc) BPy_IDGroup_Contains, /* objobjproc sq_contains */ (objobjproc) BPy_IDGroup_Contains, /* objobjproc sq_contains */
NULL, /* binaryfunc sq_inplace_concat */ NULL, /* binaryfunc sq_inplace_concat */
NULL, /* ssizeargfunc sq_inplace_repeat */ NULL, /* ssizeargfunc sq_inplace_repeat */
}; };
static PyMappingMethods BPy_IDGroup_Mapping = { static PyMappingMethods BPy_IDGroup_Mapping = {
(lenfunc)BPy_IDGroup_Map_Len, /*inquiry mp_length */ (lenfunc)BPy_IDGroup_Map_Len, /*inquiry mp_length */
(binaryfunc)BPy_IDGroup_Map_GetItem,/*binaryfunc mp_subscript */ (binaryfunc)BPy_IDGroup_Map_GetItem, /*binaryfunc mp_subscript */
(objobjargproc)BPy_IDGroup_Map_SetItem, /*objobjargproc mp_ass_subscript */ (objobjargproc)BPy_IDGroup_Map_SetItem, /*objobjargproc mp_ass_subscript */
}; };
PyTypeObject BPy_IDGroup_Type = { PyTypeObject BPy_IDGroup_Type = {
PyVarObject_HEAD_INIT(NULL, 0) PyVarObject_HEAD_INIT(NULL, 0)
/* For printing, in format "<module>.<name>" */ /* For printing, in format "<module>.<name>" */
"Blender IDProperty", /* char *tp_name; */ "Blender IDProperty", /* char *tp_name; */
sizeof(BPy_IDProperty), /* int tp_basicsize; */ sizeof(BPy_IDProperty), /* int tp_basicsize; */
0, /* tp_itemsize; For allocation */ 0, /* tp_itemsize; For allocation */
/* Methods to implement standard operations */ /* Methods to implement standard operations */
NULL, /* destructor tp_dealloc; */ NULL, /* destructor tp_dealloc; */
NULL, /* printfunc tp_print; */ NULL, /* printfunc tp_print; */
NULL, /* getattrfunc tp_getattr; */ NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */ NULL, /* setattrfunc tp_setattr; */
NULL, /* cmpfunc tp_compare; */ NULL, /* cmpfunc tp_compare; */
(reprfunc)BPy_IDGroup_repr, /* reprfunc tp_repr; */ (reprfunc)BPy_IDGroup_repr, /* reprfunc tp_repr; */
/* Method suites for standard classes */ /* Method suites for standard classes */
NULL, /* PyNumberMethods *tp_as_number; */ NULL, /* PyNumberMethods *tp_as_number; */
&BPy_IDGroup_Seq, /* PySequenceMethods *tp_as_sequence; */ &BPy_IDGroup_Seq, /* PySequenceMethods *tp_as_sequence; */
&BPy_IDGroup_Mapping, /* PyMappingMethods *tp_as_mapping; */ &BPy_IDGroup_Mapping, /* PyMappingMethods *tp_as_mapping; */
/* More standard operations (here for binary compatibility) */ /* More standard operations (here for binary compatibility) */
@@ -915,29 +915,29 @@ PyTypeObject BPy_IDGroup_Type = {
/* Functions to access object as input/output buffer */ /* Functions to access object as input/output buffer */
NULL, /* PyBufferProcs *tp_as_buffer; */ NULL, /* PyBufferProcs *tp_as_buffer; */
/*** Flags to define presence of optional/expanded features ***/ /*** Flags to define presence of optional/expanded features ***/
Py_TPFLAGS_DEFAULT, /* long tp_flags; */ Py_TPFLAGS_DEFAULT, /* long tp_flags; */
NULL, /* char *tp_doc; Documentation string */ NULL, /* char *tp_doc; Documentation string */
/*** Assigned meaning in release 2.0 ***/ /*** Assigned meaning in release 2.0 ***/
/* call function for all accessible objects */ /* call function for all accessible objects */
NULL, /* traverseproc tp_traverse; */ NULL, /* traverseproc tp_traverse; */
/* delete references to contained objects */ /* delete references to contained objects */
NULL, /* inquiry tp_clear; */ NULL, /* inquiry tp_clear; */
/*** Assigned meaning in release 2.1 ***/ /*** Assigned meaning in release 2.1 ***/
/*** rich comparisons ***/ /*** rich comparisons ***/
NULL, /* richcmpfunc tp_richcompare; */ NULL, /* richcmpfunc tp_richcompare; */
/*** weak reference enabler ***/ /*** weak reference enabler ***/
0, /* long tp_weaklistoffset; */ 0, /* long tp_weaklistoffset; */
/*** Added in release 2.2 ***/ /*** Added in release 2.2 ***/
/* Iterators */ /* Iterators */
(getiterfunc)BPy_IDGroup_iter, /* getiterfunc tp_iter; */ (getiterfunc)BPy_IDGroup_iter, /* getiterfunc tp_iter; */
NULL, /* iternextfunc tp_iternext; */ NULL, /* iternextfunc tp_iternext; */
/*** Attribute descriptor and subclassing stuff ***/ /*** Attribute descriptor and subclassing stuff ***/
BPy_IDGroup_methods, /* struct PyMethodDef *tp_methods; */ BPy_IDGroup_methods, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */ NULL, /* struct PyMemberDef *tp_members; */
BPy_IDGroup_getseters, /* struct PyGetSetDef *tp_getset; */ BPy_IDGroup_getseters, /* struct PyGetSetDef *tp_getset; */
@@ -984,7 +984,7 @@ static PyObject *BPy_IDArray_GetType(BPy_IDArray *self)
} }
static PyGetSetDef BPy_IDArray_getseters[] = { static PyGetSetDef BPy_IDArray_getseters[] = {
/* matches pythons array.typecode */ /* matches pythons array.typecode */
{(char *)"typecode", (getter)BPy_IDArray_GetType, (setter)NULL, (char *)"The type of the data in the array, is an int.", NULL}, {(char *)"typecode", (getter)BPy_IDArray_GetType, (setter)NULL, (char *)"The type of the data in the array, is an int.", NULL},
{NULL, NULL, NULL, NULL, NULL}, {NULL, NULL, NULL, NULL, NULL},
}; };
@@ -996,7 +996,7 @@ static PyObject *BPy_IDArray_to_list(BPy_IDArray *self)
static PyMethodDef BPy_IDArray_methods[] = { static PyMethodDef BPy_IDArray_methods[] = {
{"to_list", (PyCFunction)BPy_IDArray_to_list, METH_NOARGS, {"to_list", (PyCFunction)BPy_IDArray_to_list, METH_NOARGS,
"return the array as a list"}, "return the array as a list"},
{NULL, NULL, 0, NULL} {NULL, NULL, 0, NULL}
}; };
@@ -1070,17 +1070,17 @@ static int BPy_IDArray_SetItem(BPy_IDArray *self, int index, PyObject *value)
} }
static PySequenceMethods BPy_IDArray_Seq = { static PySequenceMethods BPy_IDArray_Seq = {
(lenfunc) BPy_IDArray_Len, /* inquiry sq_length */ (lenfunc) BPy_IDArray_Len, /* inquiry sq_length */
NULL, /* binaryfunc sq_concat */ NULL, /* binaryfunc sq_concat */
NULL, /* intargfunc sq_repeat */ NULL, /* intargfunc sq_repeat */
(ssizeargfunc)BPy_IDArray_GetItem, /* intargfunc sq_item */ (ssizeargfunc)BPy_IDArray_GetItem, /* intargfunc sq_item */
NULL, /* intintargfunc sq_slice */ NULL, /* intintargfunc sq_slice */
(ssizeobjargproc)BPy_IDArray_SetItem,/* intobjargproc sq_ass_item */ (ssizeobjargproc)BPy_IDArray_SetItem, /* intobjargproc sq_ass_item */
NULL, /* intintobjargproc sq_ass_slice */ NULL, /* intintobjargproc sq_ass_slice */
NULL, /* objobjproc sq_contains */ NULL, /* objobjproc sq_contains */
/* Added in release 2.0 */ /* Added in release 2.0 */
NULL, /* binaryfunc sq_inplace_concat */ NULL, /* binaryfunc sq_inplace_concat */
NULL, /* intargfunc sq_inplace_repeat */ NULL, /* intargfunc sq_inplace_repeat */
}; };
@@ -1241,7 +1241,7 @@ PyTypeObject BPy_IDArray_Type = {
/* Methods to implement standard operations */ /* Methods to implement standard operations */
NULL, /* destructor tp_dealloc; */ NULL, /* destructor tp_dealloc; */
NULL, /* printfunc tp_print; */ NULL, /* printfunc tp_print; */
NULL, /* getattrfunc tp_getattr; */ NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */ NULL, /* setattrfunc tp_setattr; */
@@ -1251,12 +1251,12 @@ PyTypeObject BPy_IDArray_Type = {
/* Method suites for standard classes */ /* Method suites for standard classes */
NULL, /* PyNumberMethods *tp_as_number; */ NULL, /* PyNumberMethods *tp_as_number; */
&BPy_IDArray_Seq, /* PySequenceMethods *tp_as_sequence; */ &BPy_IDArray_Seq, /* PySequenceMethods *tp_as_sequence; */
&BPy_IDArray_AsMapping, /* PyMappingMethods *tp_as_mapping; */ &BPy_IDArray_AsMapping, /* PyMappingMethods *tp_as_mapping; */
/* More standard operations (here for binary compatibility) */ /* More standard operations (here for binary compatibility) */
NULL, /* hashfunc tp_hash; */ NULL, /* hashfunc tp_hash; */
NULL, /* ternaryfunc tp_call; */ NULL, /* ternaryfunc tp_call; */
NULL, /* reprfunc tp_str; */ NULL, /* reprfunc tp_str; */
NULL, /* getattrofunc tp_getattro; */ NULL, /* getattrofunc tp_getattro; */
@@ -1265,31 +1265,31 @@ PyTypeObject BPy_IDArray_Type = {
/* Functions to access object as input/output buffer */ /* Functions to access object as input/output buffer */
NULL, /* PyBufferProcs *tp_as_buffer; */ NULL, /* PyBufferProcs *tp_as_buffer; */
/*** Flags to define presence of optional/expanded features ***/ /*** Flags to define presence of optional/expanded features ***/
Py_TPFLAGS_DEFAULT, /* long tp_flags; */ Py_TPFLAGS_DEFAULT, /* long tp_flags; */
NULL, /* char *tp_doc; Documentation string */ NULL, /* char *tp_doc; Documentation string */
/*** Assigned meaning in release 2.0 ***/ /*** Assigned meaning in release 2.0 ***/
/* call function for all accessible objects */ /* call function for all accessible objects */
NULL, /* traverseproc tp_traverse; */ NULL, /* traverseproc tp_traverse; */
/* delete references to contained objects */ /* delete references to contained objects */
NULL, /* inquiry tp_clear; */ NULL, /* inquiry tp_clear; */
/*** Assigned meaning in release 2.1 ***/ /*** Assigned meaning in release 2.1 ***/
/*** rich comparisons ***/ /*** rich comparisons ***/
NULL, /* richcmpfunc tp_richcompare; */ NULL, /* richcmpfunc tp_richcompare; */
/*** weak reference enabler ***/ /*** weak reference enabler ***/
0, /* long tp_weaklistoffset; */ 0, /* long tp_weaklistoffset; */
/*** Added in release 2.2 ***/ /*** Added in release 2.2 ***/
/* Iterators */ /* Iterators */
NULL, /* getiterfunc tp_iter; */ NULL, /* getiterfunc tp_iter; */
NULL, /* iternextfunc tp_iternext; */ NULL, /* iternextfunc tp_iternext; */
/*** Attribute descriptor and subclassing stuff ***/ /*** Attribute descriptor and subclassing stuff ***/
BPy_IDArray_methods, /* struct PyMethodDef *tp_methods; */ BPy_IDArray_methods, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */ NULL, /* struct PyMemberDef *tp_members; */
BPy_IDArray_getseters, /* struct PyGetSetDef *tp_getset; */ BPy_IDArray_getseters, /* struct PyGetSetDef *tp_getset; */
NULL, /* struct _typeobject *tp_base; */ NULL, /* struct _typeobject *tp_base; */
@@ -1355,7 +1355,7 @@ PyTypeObject BPy_IDGroup_Iter_Type = {
/* Methods to implement standard operations */ /* Methods to implement standard operations */
NULL, /* destructor tp_dealloc; */ NULL, /* destructor tp_dealloc; */
NULL, /* printfunc tp_print; */ NULL, /* printfunc tp_print; */
NULL, /* getattrfunc tp_getattr; */ NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */ NULL, /* setattrfunc tp_setattr; */
@@ -1365,7 +1365,7 @@ PyTypeObject BPy_IDGroup_Iter_Type = {
/* Method suites for standard classes */ /* Method suites for standard classes */
NULL, /* PyNumberMethods *tp_as_number; */ NULL, /* PyNumberMethods *tp_as_number; */
NULL, /* PySequenceMethods *tp_as_sequence; */ NULL, /* PySequenceMethods *tp_as_sequence; */
NULL, /* PyMappingMethods *tp_as_mapping; */ NULL, /* PyMappingMethods *tp_as_mapping; */
/* More standard operations (here for binary compatibility) */ /* More standard operations (here for binary compatibility) */
@@ -1379,25 +1379,25 @@ PyTypeObject BPy_IDGroup_Iter_Type = {
/* Functions to access object as input/output buffer */ /* Functions to access object as input/output buffer */
NULL, /* PyBufferProcs *tp_as_buffer; */ NULL, /* PyBufferProcs *tp_as_buffer; */
/*** Flags to define presence of optional/expanded features ***/ /*** Flags to define presence of optional/expanded features ***/
Py_TPFLAGS_DEFAULT, /* long tp_flags; */ Py_TPFLAGS_DEFAULT, /* long tp_flags; */
NULL, /* char *tp_doc; Documentation string */ NULL, /* char *tp_doc; Documentation string */
/*** Assigned meaning in release 2.0 ***/ /*** Assigned meaning in release 2.0 ***/
/* call function for all accessible objects */ /* call function for all accessible objects */
NULL, /* traverseproc tp_traverse; */ NULL, /* traverseproc tp_traverse; */
/* delete references to contained objects */ /* delete references to contained objects */
NULL, /* inquiry tp_clear; */ NULL, /* inquiry tp_clear; */
/*** Assigned meaning in release 2.1 ***/ /*** Assigned meaning in release 2.1 ***/
/*** rich comparisons ***/ /*** rich comparisons ***/
NULL, /* richcmpfunc tp_richcompare; */ NULL, /* richcmpfunc tp_richcompare; */
/*** weak reference enabler ***/ /*** weak reference enabler ***/
0, /* long tp_weaklistoffset; */ 0, /* long tp_weaklistoffset; */
/*** Added in release 2.2 ***/ /*** Added in release 2.2 ***/
/* Iterators */ /* Iterators */
PyObject_SelfIter, /* getiterfunc tp_iter; */ PyObject_SelfIter, /* getiterfunc tp_iter; */
(iternextfunc) BPy_Group_Iter_Next, /* iternextfunc tp_iternext; */ (iternextfunc) BPy_Group_Iter_Next, /* iternextfunc tp_iternext; */

View File

@@ -156,8 +156,8 @@ void PyC_FileAndNum(const char **filename, int *lineno)
{ {
PyFrameObject *frame; PyFrameObject *frame;
if (filename) *filename = NULL; if (filename) *filename = NULL;
if (lineno) *lineno = -1; if (lineno) *lineno = -1;
if (!(frame = PyThreadState_GET()->frame)) { if (!(frame = PyThreadState_GET()->frame)) {
return; return;
@@ -538,7 +538,7 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
ret = PyObject_CallFunction(calcsize, (char *)"s", format); ret = PyObject_CallFunction(calcsize, (char *)"s", format);
if (ret) { if (ret) {
sizes[i]= PyLong_AsSsize_t(ret); sizes[i] = PyLong_AsSsize_t(ret);
Py_DECREF(ret); Py_DECREF(ret);
ret = PyObject_CallFunction(unpack, (char *)"sy#", format, (char *)ptr, sizes[i]); ret = PyObject_CallFunction(unpack, (char *)"sy#", format, (char *)ptr, sizes[i]);
} }
@@ -551,7 +551,7 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
PyList_SET_ITEM(values, i, Py_None); /* hold user */ PyList_SET_ITEM(values, i, Py_None); /* hold user */
Py_INCREF(Py_None); Py_INCREF(Py_None);
sizes[i]= 0; sizes[i] = 0;
} }
else { else {
if (PyTuple_GET_SIZE(ret) == 1) { if (PyTuple_GET_SIZE(ret) == 1) {

View File

@@ -85,7 +85,7 @@ int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *
} }
if (size > array_max || size < array_min) { if (size > array_max || size < array_min) {
if (array_max == array_min) { if (array_max == array_min) {
PyErr_Format(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
"%.200s: sequence size is %d, expected %d", "%.200s: sequence size is %d, expected %d",
error_prefix, size, array_max); error_prefix, size, array_max);
@@ -115,15 +115,15 @@ int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *
size = PySequence_Fast_GET_SIZE(value_fast); size = PySequence_Fast_GET_SIZE(value_fast);
if (size > array_max || size < array_min) { if (size > array_max || size < array_min) {
if (array_max == array_min) { if (array_max == array_min) {
PyErr_Format(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
"%.200s: sequence size is %d, expected %d", "%.200s: sequence size is %d, expected %d",
error_prefix, size, array_max); error_prefix, size, array_max);
} }
else { else {
PyErr_Format(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
"%.200s: sequence size is %d, expected [%d - %d]", "%.200s: sequence size is %d, expected [%d - %d]",
error_prefix, size, array_min, array_max); error_prefix, size, array_min, array_max);
} }
Py_DECREF(value_fast); Py_DECREF(value_fast);
return -1; return -1;
@@ -239,21 +239,22 @@ int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error
/* Utility functions */ /* Utility functions */
// LomontRRDCompare4, Ever Faster Float Comparisons by Randy Dillon // LomontRRDCompare4, Ever Faster Float Comparisons by Randy Dillon
#define SIGNMASK(i) (-(int)(((unsigned int)(i))>>31)) #define SIGNMASK(i) (-(int)(((unsigned int)(i)) >> 31))
int EXPP_FloatsAreEqual(float af, float bf, int maxDiff) int EXPP_FloatsAreEqual(float af, float bf, int maxDiff)
{ // solid, fast routine across all platforms {
// with constant time behavior /* solid, fast routine across all platforms
* with constant time behavior */
int ai = *(int *)(&af); int ai = *(int *)(&af);
int bi = *(int *)(&bf); int bi = *(int *)(&bf);
int test = SIGNMASK(ai^bi); int test = SIGNMASK(ai ^ bi);
int diff, v1, v2; int diff, v1, v2;
assert((0 == test) || (0xFFFFFFFF == test)); assert((0 == test) || (0xFFFFFFFF == test));
diff = (ai ^ (test & 0x7fffffff)) - bi; diff = (ai ^ (test & 0x7fffffff)) - bi;
v1 = maxDiff + diff; v1 = maxDiff + diff;
v2 = maxDiff - diff; v2 = maxDiff - diff;
return (v1|v2) >= 0; return (v1 | v2) >= 0;
} }
/*---------------------- EXPP_VectorsAreEqual ------------------------- /*---------------------- EXPP_VectorsAreEqual -------------------------
@@ -376,7 +377,7 @@ PyObject *BaseMathObject_owner_get(BaseMathObject *self, void *UNUSED(closure))
char BaseMathObject_is_wrapped_doc[] = "True when this object wraps external data (read-only).\n\n:type: boolean"; char BaseMathObject_is_wrapped_doc[] = "True when this object wraps external data (read-only).\n\n:type: boolean";
PyObject *BaseMathObject_is_wrapped_get(BaseMathObject *self, void *UNUSED(closure)) PyObject *BaseMathObject_is_wrapped_get(BaseMathObject *self, void *UNUSED(closure))
{ {
return PyBool_FromLong((self->wrapped == Py_WRAP) ? 1:0); return PyBool_FromLong((self->wrapped == Py_WRAP) ? 1 : 0);
} }
int BaseMathObject_traverse(BaseMathObject *self, visitproc visit, void *arg) int BaseMathObject_traverse(BaseMathObject *self, visitproc visit, void *arg)
@@ -445,14 +446,14 @@ PyMODINIT_FUNC PyInit_mathutils(void)
submodule = PyModule_Create(&M_Mathutils_module_def); submodule = PyModule_Create(&M_Mathutils_module_def);
/* each type has its own new() function */ /* each type has its own new() function */
PyModule_AddObject(submodule, "Vector", (PyObject *)&vector_Type); PyModule_AddObject(submodule, "Vector", (PyObject *)&vector_Type);
PyModule_AddObject(submodule, "Matrix", (PyObject *)&matrix_Type); PyModule_AddObject(submodule, "Matrix", (PyObject *)&matrix_Type);
PyModule_AddObject(submodule, "Euler", (PyObject *)&euler_Type); PyModule_AddObject(submodule, "Euler", (PyObject *)&euler_Type);
PyModule_AddObject(submodule, "Quaternion", (PyObject *)&quaternion_Type); PyModule_AddObject(submodule, "Quaternion", (PyObject *)&quaternion_Type);
PyModule_AddObject(submodule, "Color", (PyObject *)&color_Type); PyModule_AddObject(submodule, "Color", (PyObject *)&color_Type);
/* submodule */ /* submodule */
PyModule_AddObject(submodule, "geometry", (item = PyInit_mathutils_geometry())); PyModule_AddObject(submodule, "geometry", (item = PyInit_mathutils_geometry()));
/* XXX, python doesnt do imports with this usefully yet /* XXX, python doesnt do imports with this usefully yet
* 'from mathutils.geometry import PolyFill' * 'from mathutils.geometry import PolyFill'
* ...fails without this. */ * ...fails without this. */
@@ -460,7 +461,7 @@ PyMODINIT_FUNC PyInit_mathutils(void)
Py_INCREF(item); Py_INCREF(item);
/* Noise submodule */ /* Noise submodule */
PyModule_AddObject(submodule, "noise", (item = PyInit_mathutils_noise())); PyModule_AddObject(submodule, "noise", (item = PyInit_mathutils_noise()));
PyDict_SetItemString(sys_modules, "mathutils.noise", item); PyDict_SetItemString(sys_modules, "mathutils.noise", item);
Py_INCREF(item); Py_INCREF(item);

View File

@@ -50,17 +50,17 @@ static PyObject *Color_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
} }
switch (PyTuple_GET_SIZE(args)) { switch (PyTuple_GET_SIZE(args)) {
case 0: case 0:
break; break;
case 1: case 1:
if ((mathutils_array_parse(col, COLOR_SIZE, COLOR_SIZE, PyTuple_GET_ITEM(args, 0), "mathutils.Color()")) == -1) if ((mathutils_array_parse(col, COLOR_SIZE, COLOR_SIZE, PyTuple_GET_ITEM(args, 0), "mathutils.Color()")) == -1)
return NULL;
break;
default:
PyErr_SetString(PyExc_TypeError,
"mathutils.Color(): "
"more then a single arg given");
return NULL; return NULL;
break;
default:
PyErr_SetString(PyExc_TypeError,
"mathutils.Color(): "
"more then a single arg given");
return NULL;
} }
return Color_CreatePyObject(col, Py_NEW, type); return Color_CreatePyObject(col, Py_NEW, type);
} }
@@ -358,16 +358,16 @@ static int Color_ass_subscript(ColorObject *self, PyObject *item, PyObject *valu
//-----------------PROTCOL DECLARATIONS-------------------------- //-----------------PROTCOL DECLARATIONS--------------------------
static PySequenceMethods Color_SeqMethods = { static PySequenceMethods Color_SeqMethods = {
(lenfunc) Color_len, /* sq_length */ (lenfunc) Color_len, /* sq_length */
(binaryfunc) NULL, /* sq_concat */ (binaryfunc) NULL, /* sq_concat */
(ssizeargfunc) NULL, /* sq_repeat */ (ssizeargfunc) NULL, /* sq_repeat */
(ssizeargfunc) Color_item, /* sq_item */ (ssizeargfunc) Color_item, /* sq_item */
NULL, /* sq_slice, deprecated */ NULL, /* sq_slice, deprecated */
(ssizeobjargproc) Color_ass_item, /* sq_ass_item */ (ssizeobjargproc) Color_ass_item, /* sq_ass_item */
NULL, /* sq_ass_slice, deprecated */ NULL, /* sq_ass_slice, deprecated */
(objobjproc) NULL, /* sq_contains */ (objobjproc) NULL, /* sq_contains */
(binaryfunc) NULL, /* sq_inplace_concat */ (binaryfunc) NULL, /* sq_inplace_concat */
(ssizeargfunc) NULL, /* sq_inplace_repeat */ (ssizeargfunc) NULL, /* sq_inplace_repeat */
}; };
static PyMappingMethods Color_AsMapping = { static PyMappingMethods Color_AsMapping = {
@@ -490,12 +490,12 @@ static PyObject *Color_mul(PyObject *v1, PyObject *v2)
ColorObject *color1 = NULL, *color2 = NULL; ColorObject *color1 = NULL, *color2 = NULL;
float scalar; float scalar;
if ColorObject_Check(v1) { if (ColorObject_Check(v1)) {
color1 = (ColorObject *)v1; color1 = (ColorObject *)v1;
if (BaseMath_ReadCallback(color1) == -1) if (BaseMath_ReadCallback(color1) == -1)
return NULL; return NULL;
} }
if ColorObject_Check(v2) { if (ColorObject_Check(v2)) {
color2 = (ColorObject *)v2; color2 = (ColorObject *)v2;
if (BaseMath_ReadCallback(color2) == -1) if (BaseMath_ReadCallback(color2) == -1)
return NULL; return NULL;
@@ -532,7 +532,7 @@ static PyObject *Color_div(PyObject *v1, PyObject *v2)
ColorObject *color1 = NULL; ColorObject *color1 = NULL;
float scalar; float scalar;
if ColorObject_Check(v1) { if (ColorObject_Check(v1)) {
color1 = (ColorObject *)v1; color1 = (ColorObject *)v1;
if (BaseMath_ReadCallback(color1) == -1) if (BaseMath_ReadCallback(color1) == -1)
return NULL; return NULL;
@@ -633,40 +633,40 @@ static PyObject *Color_neg(ColorObject *self)
static PyNumberMethods Color_NumMethods = { static PyNumberMethods Color_NumMethods = {
(binaryfunc) Color_add, /*nb_add*/ (binaryfunc) Color_add, /*nb_add*/
(binaryfunc) Color_sub, /*nb_subtract*/ (binaryfunc) Color_sub, /*nb_subtract*/
(binaryfunc) Color_mul, /*nb_multiply*/ (binaryfunc) Color_mul, /*nb_multiply*/
NULL, /*nb_remainder*/ NULL, /*nb_remainder*/
NULL, /*nb_divmod*/ NULL, /*nb_divmod*/
NULL, /*nb_power*/ NULL, /*nb_power*/
(unaryfunc) Color_neg, /*nb_negative*/ (unaryfunc) Color_neg, /*nb_negative*/
(unaryfunc) NULL, /*tp_positive*/ (unaryfunc) NULL, /*tp_positive*/
(unaryfunc) NULL, /*tp_absolute*/ (unaryfunc) NULL, /*tp_absolute*/
(inquiry) NULL, /*tp_bool*/ (inquiry) NULL, /*tp_bool*/
(unaryfunc) NULL, /*nb_invert*/ (unaryfunc) NULL, /*nb_invert*/
NULL, /*nb_lshift*/ NULL, /*nb_lshift*/
(binaryfunc)NULL, /*nb_rshift*/ (binaryfunc)NULL, /*nb_rshift*/
NULL, /*nb_and*/ NULL, /*nb_and*/
NULL, /*nb_xor*/ NULL, /*nb_xor*/
NULL, /*nb_or*/ NULL, /*nb_or*/
NULL, /*nb_int*/ NULL, /*nb_int*/
NULL, /*nb_reserved*/ NULL, /*nb_reserved*/
NULL, /*nb_float*/ NULL, /*nb_float*/
Color_iadd, /* nb_inplace_add */ Color_iadd, /* nb_inplace_add */
Color_isub, /* nb_inplace_subtract */ Color_isub, /* nb_inplace_subtract */
Color_imul, /* nb_inplace_multiply */ Color_imul, /* nb_inplace_multiply */
NULL, /* nb_inplace_remainder */ NULL, /* nb_inplace_remainder */
NULL, /* nb_inplace_power */ NULL, /* nb_inplace_power */
NULL, /* nb_inplace_lshift */ NULL, /* nb_inplace_lshift */
NULL, /* nb_inplace_rshift */ NULL, /* nb_inplace_rshift */
NULL, /* nb_inplace_and */ NULL, /* nb_inplace_and */
NULL, /* nb_inplace_xor */ NULL, /* nb_inplace_xor */
NULL, /* nb_inplace_or */ NULL, /* nb_inplace_or */
NULL, /* nb_floor_divide */ NULL, /* nb_floor_divide */
Color_div, /* nb_true_divide */ Color_div, /* nb_true_divide */
NULL, /* nb_inplace_floor_divide */ NULL, /* nb_inplace_floor_divide */
Color_idiv, /* nb_inplace_true_divide */ Color_idiv, /* nb_inplace_true_divide */
NULL, /* nb_index */ NULL, /* nb_index */
}; };
/* color channel, vector.r/g/b */ /* color channel, vector.r/g/b */
@@ -679,7 +679,7 @@ static PyObject *Color_channel_get(ColorObject *self, void *type)
return Color_item(self, GET_INT_FROM_POINTER(type)); return Color_item(self, GET_INT_FROM_POINTER(type));
} }
static int Color_channel_set(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); return Color_ass_item(self, GET_INT_FROM_POINTER(type), value);
} }
@@ -702,7 +702,7 @@ static PyObject *Color_channel_hsv_get(ColorObject *self, void *type)
return PyFloat_FromDouble(hsv[i]); return PyFloat_FromDouble(hsv[i]);
} }
static int Color_channel_hsv_set(ColorObject *self, PyObject *value, void * type) static int Color_channel_hsv_set(ColorObject *self, PyObject *value, void *type)
{ {
float hsv[3]; float hsv[3];
int i = GET_INT_FROM_POINTER(type); int i = GET_INT_FROM_POINTER(type);
@@ -800,51 +800,51 @@ PyDoc_STRVAR(color_doc,
); );
PyTypeObject color_Type = { PyTypeObject color_Type = {
PyVarObject_HEAD_INIT(NULL, 0) PyVarObject_HEAD_INIT(NULL, 0)
"mathutils.Color", //tp_name "mathutils.Color", //tp_name
sizeof(ColorObject), //tp_basicsize sizeof(ColorObject), //tp_basicsize
0, //tp_itemsize 0, //tp_itemsize
(destructor)BaseMathObject_dealloc, //tp_dealloc (destructor)BaseMathObject_dealloc, //tp_dealloc
NULL, //tp_print NULL, //tp_print
NULL, //tp_getattr NULL, //tp_getattr
NULL, //tp_setattr NULL, //tp_setattr
NULL, //tp_compare NULL, //tp_compare
(reprfunc) Color_repr, //tp_repr (reprfunc) Color_repr, //tp_repr
&Color_NumMethods, //tp_as_number &Color_NumMethods, //tp_as_number
&Color_SeqMethods, //tp_as_sequence &Color_SeqMethods, //tp_as_sequence
&Color_AsMapping, //tp_as_mapping &Color_AsMapping, //tp_as_mapping
NULL, //tp_hash NULL, //tp_hash
NULL, //tp_call NULL, //tp_call
(reprfunc) Color_str, //tp_str (reprfunc) Color_str, //tp_str
NULL, //tp_getattro NULL, //tp_getattro
NULL, //tp_setattro NULL, //tp_setattro
NULL, //tp_as_buffer NULL, //tp_as_buffer
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, //tp_flags Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, //tp_flags
color_doc, //tp_doc color_doc, //tp_doc
(traverseproc)BaseMathObject_traverse, //tp_traverse (traverseproc)BaseMathObject_traverse, //tp_traverse
(inquiry)BaseMathObject_clear, //tp_clear (inquiry)BaseMathObject_clear, //tp_clear
(richcmpfunc)Color_richcmpr, //tp_richcompare (richcmpfunc)Color_richcmpr, //tp_richcompare
0, //tp_weaklistoffset 0, //tp_weaklistoffset
NULL, //tp_iter NULL, //tp_iter
NULL, //tp_iternext NULL, //tp_iternext
Color_methods, //tp_methods Color_methods, //tp_methods
NULL, //tp_members NULL, //tp_members
Color_getseters, //tp_getset Color_getseters, //tp_getset
NULL, //tp_base NULL, //tp_base
NULL, //tp_dict NULL, //tp_dict
NULL, //tp_descr_get NULL, //tp_descr_get
NULL, //tp_descr_set NULL, //tp_descr_set
0, //tp_dictoffset 0, //tp_dictoffset
NULL, //tp_init NULL, //tp_init
NULL, //tp_alloc NULL, //tp_alloc
Color_new, //tp_new Color_new, //tp_new
NULL, //tp_free NULL, //tp_free
NULL, //tp_is_gc NULL, //tp_is_gc
NULL, //tp_bases NULL, //tp_bases
NULL, //tp_mro NULL, //tp_mro
NULL, //tp_cache NULL, //tp_cache
NULL, //tp_subclasses NULL, //tp_subclasses
NULL, //tp_weaklist NULL, //tp_weaklist
NULL //tp_del NULL //tp_del
}; };
//------------------------Color_CreatePyObject (internal)------------- //------------------------Color_CreatePyObject (internal)-------------
//creates a new color object //creates a new color object
@@ -856,8 +856,8 @@ PyObject *Color_CreatePyObject(float *col, int type, PyTypeObject *base_type)
{ {
ColorObject *self; ColorObject *self;
self = base_type ? (ColorObject *)base_type->tp_alloc(base_type, 0) : self = base_type ? (ColorObject *)base_type->tp_alloc(base_type, 0) :
(ColorObject *)PyObject_GC_New(ColorObject, &color_Type); (ColorObject *)PyObject_GC_New(ColorObject, &color_Type);
if (self) { if (self) {
/* init callbacks as NULL */ /* init callbacks as NULL */

View File

@@ -61,16 +61,16 @@ static PyObject *Euler_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL; return NULL;
switch (PyTuple_GET_SIZE(args)) { switch (PyTuple_GET_SIZE(args)) {
case 0: case 0:
break; break;
case 2: case 2:
if ((order = euler_order_from_string(order_str, "mathutils.Euler()")) == -1) if ((order = euler_order_from_string(order_str, "mathutils.Euler()")) == -1)
return NULL; return NULL;
/* intentionally pass through */ /* intentionally pass through */
case 1: case 1:
if (mathutils_array_parse(eul, EULER_SIZE, EULER_SIZE, seq, "mathutils.Euler()") == -1) if (mathutils_array_parse(eul, EULER_SIZE, EULER_SIZE, seq, "mathutils.Euler()") == -1)
return NULL; return NULL;
break; break;
} }
return Euler_CreatePyObject(eul, order, Py_NEW, type); return Euler_CreatePyObject(eul, order, Py_NEW, type);
} }
@@ -86,12 +86,12 @@ short euler_order_from_string(const char *str, const char *error_prefix)
{ {
if ((str[0] && str[1] && str[2] && str[3] == '\0')) { if ((str[0] && str[1] && str[2] && str[3] == '\0')) {
switch (*((PY_INT32_T *)str)) { switch (*((PY_INT32_T *)str)) {
case 'X'|'Y'<<8|'Z'<<16: return EULER_ORDER_XYZ; case 'X' | 'Y' << 8 | 'Z' << 16: return EULER_ORDER_XYZ;
case 'X'|'Z'<<8|'Y'<<16: return EULER_ORDER_XZY; case 'X' | 'Z' << 8 | 'Y' << 16: return EULER_ORDER_XZY;
case 'Y'|'X'<<8|'Z'<<16: return EULER_ORDER_YXZ; case 'Y' | 'X' << 8 | 'Z' << 16: return EULER_ORDER_YXZ;
case 'Y'|'Z'<<8|'X'<<16: return EULER_ORDER_YZX; case 'Y' | 'Z' << 8 | 'X' << 16: return EULER_ORDER_YZX;
case 'Z'|'X'<<8|'Y'<<16: return EULER_ORDER_ZXY; case 'Z' | 'X' << 8 | 'Y' << 16: return EULER_ORDER_ZXY;
case 'Z'|'Y'<<8|'X'<<16: return EULER_ORDER_ZYX; case 'Z' | 'Y' << 8 | 'X' << 16: return EULER_ORDER_ZYX;
} }
} }
@@ -164,7 +164,7 @@ static PyObject *Euler_to_matrix(EulerObject *self)
eulO_to_mat3((float (*)[3])mat, self->eul, self->order); eulO_to_mat3((float (*)[3])mat, self->eul, self->order);
return Matrix_CreatePyObject(mat, 3, 3 , Py_NEW, NULL); return Matrix_CreatePyObject(mat, 3, 3, Py_NEW, NULL);
} }
PyDoc_STRVAR(Euler_zero_doc, PyDoc_STRVAR(Euler_zero_doc,
@@ -550,16 +550,16 @@ static int Euler_ass_subscript(EulerObject *self, PyObject *item, PyObject *valu
//-----------------PROTCOL DECLARATIONS-------------------------- //-----------------PROTCOL DECLARATIONS--------------------------
static PySequenceMethods Euler_SeqMethods = { static PySequenceMethods Euler_SeqMethods = {
(lenfunc) Euler_len, /* sq_length */ (lenfunc) Euler_len, /* sq_length */
(binaryfunc) NULL, /* sq_concat */ (binaryfunc) NULL, /* sq_concat */
(ssizeargfunc) NULL, /* sq_repeat */ (ssizeargfunc) NULL, /* sq_repeat */
(ssizeargfunc) Euler_item, /* sq_item */ (ssizeargfunc) Euler_item, /* sq_item */
(ssizessizeargfunc) NULL, /* sq_slice, deprecated */ (ssizessizeargfunc) NULL, /* sq_slice, deprecated */
(ssizeobjargproc) Euler_ass_item, /* sq_ass_item */ (ssizeobjargproc) Euler_ass_item, /* sq_ass_item */
(ssizessizeobjargproc) NULL, /* sq_ass_slice, deprecated */ (ssizessizeobjargproc) NULL, /* sq_ass_slice, deprecated */
(objobjproc) NULL, /* sq_contains */ (objobjproc) NULL, /* sq_contains */
(binaryfunc) NULL, /* sq_inplace_concat */ (binaryfunc) NULL, /* sq_inplace_concat */
(ssizeargfunc) NULL, /* sq_inplace_repeat */ (ssizeargfunc) NULL, /* sq_inplace_repeat */
}; };
static PyMappingMethods Euler_AsMapping = { static PyMappingMethods Euler_AsMapping = {
@@ -643,51 +643,51 @@ PyDoc_STRVAR(euler_doc,
); );
PyTypeObject euler_Type = { PyTypeObject euler_Type = {
PyVarObject_HEAD_INIT(NULL, 0) PyVarObject_HEAD_INIT(NULL, 0)
"mathutils.Euler", //tp_name "mathutils.Euler", //tp_name
sizeof(EulerObject), //tp_basicsize sizeof(EulerObject), //tp_basicsize
0, //tp_itemsize 0, //tp_itemsize
(destructor)BaseMathObject_dealloc, //tp_dealloc (destructor)BaseMathObject_dealloc, //tp_dealloc
NULL, //tp_print NULL, //tp_print
NULL, //tp_getattr NULL, //tp_getattr
NULL, //tp_setattr NULL, //tp_setattr
NULL, //tp_compare NULL, //tp_compare
(reprfunc) Euler_repr, //tp_repr (reprfunc) Euler_repr, //tp_repr
NULL, //tp_as_number NULL, //tp_as_number
&Euler_SeqMethods, //tp_as_sequence &Euler_SeqMethods, //tp_as_sequence
&Euler_AsMapping, //tp_as_mapping &Euler_AsMapping, //tp_as_mapping
NULL, //tp_hash NULL, //tp_hash
NULL, //tp_call NULL, //tp_call
(reprfunc) Euler_str, //tp_str (reprfunc) Euler_str, //tp_str
NULL, //tp_getattro NULL, //tp_getattro
NULL, //tp_setattro NULL, //tp_setattro
NULL, //tp_as_buffer NULL, //tp_as_buffer
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, //tp_flags Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, //tp_flags
euler_doc, //tp_doc euler_doc, //tp_doc
(traverseproc)BaseMathObject_traverse, //tp_traverse (traverseproc)BaseMathObject_traverse, //tp_traverse
(inquiry)BaseMathObject_clear, //tp_clear (inquiry)BaseMathObject_clear, //tp_clear
(richcmpfunc)Euler_richcmpr, //tp_richcompare (richcmpfunc)Euler_richcmpr, //tp_richcompare
0, //tp_weaklistoffset 0, //tp_weaklistoffset
NULL, //tp_iter NULL, //tp_iter
NULL, //tp_iternext NULL, //tp_iternext
Euler_methods, //tp_methods Euler_methods, //tp_methods
NULL, //tp_members NULL, //tp_members
Euler_getseters, //tp_getset Euler_getseters, //tp_getset
NULL, //tp_base NULL, //tp_base
NULL, //tp_dict NULL, //tp_dict
NULL, //tp_descr_get NULL, //tp_descr_get
NULL, //tp_descr_set NULL, //tp_descr_set
0, //tp_dictoffset 0, //tp_dictoffset
NULL, //tp_init NULL, //tp_init
NULL, //tp_alloc NULL, //tp_alloc
Euler_new, //tp_new Euler_new, //tp_new
NULL, //tp_free NULL, //tp_free
NULL, //tp_is_gc NULL, //tp_is_gc
NULL, //tp_bases NULL, //tp_bases
NULL, //tp_mro NULL, //tp_mro
NULL, //tp_cache NULL, //tp_cache
NULL, //tp_subclasses NULL, //tp_subclasses
NULL, //tp_weaklist NULL, //tp_weaklist
NULL //tp_del NULL //tp_del
}; };
//------------------------Euler_CreatePyObject (internal)------------- //------------------------Euler_CreatePyObject (internal)-------------
//creates a new euler object //creates a new euler object
@@ -699,8 +699,8 @@ PyObject *Euler_CreatePyObject(float *eul, short order, int type, PyTypeObject *
{ {
EulerObject *self; EulerObject *self;
self = base_type ? (EulerObject *)base_type->tp_alloc(base_type, 0) : self = base_type ? (EulerObject *)base_type->tp_alloc(base_type, 0) :
(EulerObject *)PyObject_GC_New(EulerObject, &euler_Type); (EulerObject *)PyObject_GC_New(EulerObject, &euler_Type);
if (self) { if (self) {
/* init callbacks as NULL */ /* init callbacks as NULL */

View File

@@ -431,8 +431,8 @@ static PyObject *C_Matrix_Identity(PyObject *cls, PyObject *args)
if (matSize < 2 || matSize > 4) { if (matSize < 2 || matSize > 4) {
PyErr_SetString(PyExc_RuntimeError, PyErr_SetString(PyExc_RuntimeError,
"Matrix.Identity(): " "Matrix.Identity(): "
"size must be between 2 and 4"); "size must be between 2 and 4");
return NULL; return NULL;
} }
@@ -461,9 +461,9 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args)
int matSize; int matSize;
double angle; /* use double because of precision problems at high values */ double angle; /* use double because of precision problems at high values */
float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f}; 0.0f, 0.0f, 0.0f, 1.0f};
if (!PyArg_ParseTuple(args, "di|O:Matrix.Rotation", &angle, &matSize, &vec)) { if (!PyArg_ParseTuple(args, "di|O:Matrix.Rotation", &angle, &matSize, &vec)) {
return NULL; return NULL;
@@ -549,7 +549,7 @@ PyDoc_STRVAR(C_Matrix_Translation_doc,
); );
static PyObject *C_Matrix_Translation(PyObject *cls, PyObject *value) static PyObject *C_Matrix_Translation(PyObject *cls, PyObject *value)
{ {
float mat[4][4]= MAT4_UNITY; float mat[4][4] = MAT4_UNITY;
if (mathutils_array_parse(mat[3], 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; return NULL;
@@ -601,7 +601,7 @@ static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args)
return NULL; return NULL;
} }
} }
if (vec == NULL) { //scaling along axis if (vec == NULL) { //scaling along axis
if (matSize == 2) { if (matSize == 2) {
mat[0] = factor; mat[0] = factor;
mat[3] = factor; mat[3] = factor;
@@ -612,8 +612,9 @@ static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args)
mat[8] = factor; mat[8] = factor;
} }
} }
else { //scaling in arbitrary direction else {
//normalize arbitrary axis /* scaling in arbitrary direction
* normalize arbitrary axis */
float norm = 0.0f; float norm = 0.0f;
int x; int x;
for (x = 0; x < vec_size; x++) { for (x = 0; x < vec_size; x++) {
@@ -624,21 +625,21 @@ static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args)
tvec[x] /= norm; tvec[x] /= norm;
} }
if (matSize == 2) { if (matSize == 2) {
mat[0] = 1 + ((factor - 1) *(tvec[0] * tvec[0])); mat[0] = 1 + ((factor - 1) * (tvec[0] * tvec[0]));
mat[1] = ((factor - 1) *(tvec[0] * tvec[1])); mat[1] = ((factor - 1) * (tvec[0] * tvec[1]));
mat[2] = ((factor - 1) *(tvec[0] * tvec[1])); mat[2] = ((factor - 1) * (tvec[0] * tvec[1]));
mat[3] = 1 + ((factor - 1) *(tvec[1] * tvec[1])); mat[3] = 1 + ((factor - 1) * (tvec[1] * tvec[1]));
} }
else { else {
mat[0] = 1 + ((factor - 1) *(tvec[0] * tvec[0])); mat[0] = 1 + ((factor - 1) * (tvec[0] * tvec[0]));
mat[1] = ((factor - 1) *(tvec[0] * tvec[1])); mat[1] = ((factor - 1) * (tvec[0] * tvec[1]));
mat[2] = ((factor - 1) *(tvec[0] * tvec[2])); mat[2] = ((factor - 1) * (tvec[0] * tvec[2]));
mat[3] = ((factor - 1) *(tvec[0] * tvec[1])); mat[3] = ((factor - 1) * (tvec[0] * tvec[1]));
mat[4] = 1 + ((factor - 1) *(tvec[1] * tvec[1])); mat[4] = 1 + ((factor - 1) * (tvec[1] * tvec[1]));
mat[5] = ((factor - 1) *(tvec[1] * tvec[2])); mat[5] = ((factor - 1) * (tvec[1] * tvec[2]));
mat[6] = ((factor - 1) *(tvec[0] * tvec[2])); mat[6] = ((factor - 1) * (tvec[0] * tvec[2]));
mat[7] = ((factor - 1) *(tvec[1] * tvec[2])); mat[7] = ((factor - 1) * (tvec[1] * tvec[2]));
mat[8] = 1 + ((factor - 1) *(tvec[2] * tvec[2])); mat[8] = 1 + ((factor - 1) * (tvec[2] * tvec[2]));
} }
} }
if (matSize == 4) { if (matSize == 4) {
@@ -684,7 +685,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args)
return NULL; return NULL;
} }
if (PyUnicode_Check(axis)) { //ortho projection onto cardinal plane if (PyUnicode_Check(axis)) { //ortho projection onto cardinal plane
Py_ssize_t plane_len; Py_ssize_t plane_len;
const char *plane = _PyUnicode_AsStringAndSize(axis, &plane_len); const char *plane = _PyUnicode_AsStringAndSize(axis, &plane_len);
if (matSize == 2) { if (matSize == 2) {
@@ -971,10 +972,10 @@ static PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args)
} }
/*must be 3-4 cols, 3-4 rows, square matrix */ /*must be 3-4 cols, 3-4 rows, square matrix */
if (self->num_row ==3 && self->num_col ==3) { if (self->num_row == 3 && self->num_col == 3) {
mat = (float (*)[3])self->matrix; mat = (float (*)[3])self->matrix;
} }
else if (self->num_row ==4 && self->num_col ==4) { else if (self->num_row == 4 && self->num_col == 4) {
copy_m3_m4(tmat, (float (*)[4])self->matrix); copy_m3_m4(tmat, (float (*)[4])self->matrix);
mat = tmat; mat = tmat;
} }
@@ -993,12 +994,12 @@ static PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args)
} }
if (eul_compat) { if (eul_compat) {
if (order == 1) mat3_to_compatible_eul(eul, eul_compatf, mat); if (order == 1) mat3_to_compatible_eul(eul, eul_compatf, mat);
else mat3_to_compatible_eulO(eul, eul_compatf, order, mat); else mat3_to_compatible_eulO(eul, eul_compatf, order, mat);
} }
else { else {
if (order == 1) mat3_to_eul(eul, mat); if (order == 1) mat3_to_eul(eul, mat);
else mat3_to_eulO(eul, order, mat); else mat3_to_eulO(eul, order, mat);
} }
return Euler_CreatePyObject(eul, order, Py_NEW, NULL); return Euler_CreatePyObject(eul, order, Py_NEW, NULL);
@@ -1202,10 +1203,10 @@ static PyObject *Matrix_invert(MatrixObject *self)
mat[3] = MATRIX_ITEM(self, 0, 0); mat[3] = MATRIX_ITEM(self, 0, 0);
} }
else if (self->num_col == 3) { else if (self->num_col == 3) {
adjoint_m3_m3((float (*)[3]) mat,(float (*)[3])self->matrix); adjoint_m3_m3((float (*)[3])mat, (float (*)[3])self->matrix);
} }
else if (self->num_col == 4) { else if (self->num_col == 4) {
adjoint_m4_m4((float (*)[4]) mat, (float (*)[4])self->matrix); adjoint_m4_m4((float (*)[4])mat, (float (*)[4])self->matrix);
} }
/* divide by determinate */ /* divide by determinate */
for (x = 0; x < (self->num_col * self->num_row); x++) { for (x = 0; x < (self->num_col * self->num_row); x++) {
@@ -1536,17 +1537,17 @@ static PyObject *Matrix_repr(MatrixObject *self)
} }
} }
switch (self->num_row) { switch (self->num_row) {
case 2: return PyUnicode_FromFormat("Matrix((%R,\n" case 2: return PyUnicode_FromFormat("Matrix((%R,\n"
" %R))", rows[0], rows[1]); " %R))", rows[0], rows[1]);
case 3: return PyUnicode_FromFormat("Matrix((%R,\n" case 3: return PyUnicode_FromFormat("Matrix((%R,\n"
" %R,\n" " %R,\n"
" %R))", rows[0], rows[1], rows[2]); " %R))", rows[0], rows[1], rows[2]);
case 4: return PyUnicode_FromFormat("Matrix((%R,\n" case 4: return PyUnicode_FromFormat("Matrix((%R,\n"
" %R,\n" " %R,\n"
" %R,\n" " %R,\n"
" %R))", rows[0], rows[1], rows[2], rows[3]); " %R))", rows[0], rows[1], rows[2], rows[3]);
} }
Py_FatalError("Matrix(): invalid row size!"); Py_FatalError("Matrix(): invalid row size!");
@@ -1905,8 +1906,8 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2)
if (mat1->num_col != mat2->num_row) { if (mat1->num_col != mat2->num_row) {
PyErr_SetString(PyExc_ValueError, PyErr_SetString(PyExc_ValueError,
"matrix1 * matrix2: matrix1 number of columns " "matrix1 * matrix2: matrix1 number of columns "
"and the matrix2 number of rows must be the same"); "and the matrix2 number of rows must be the same");
return NULL; return NULL;
} }
@@ -1966,16 +1967,16 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2)
/*-----------------PROTOCOL DECLARATIONS--------------------------*/ /*-----------------PROTOCOL DECLARATIONS--------------------------*/
static PySequenceMethods Matrix_SeqMethods = { static PySequenceMethods Matrix_SeqMethods = {
(lenfunc) Matrix_len, /* sq_length */ (lenfunc) Matrix_len, /* sq_length */
(binaryfunc) NULL, /* sq_concat */ (binaryfunc) NULL, /* sq_concat */
(ssizeargfunc) NULL, /* sq_repeat */ (ssizeargfunc) NULL, /* sq_repeat */
(ssizeargfunc) Matrix_item_row, /* sq_item */ (ssizeargfunc) Matrix_item_row, /* sq_item */
(ssizessizeargfunc) NULL, /* sq_slice, deprecated */ (ssizessizeargfunc) NULL, /* sq_slice, deprecated */
(ssizeobjargproc) Matrix_ass_item_row, /* sq_ass_item */ (ssizeobjargproc) Matrix_ass_item_row, /* sq_ass_item */
(ssizessizeobjargproc) NULL, /* sq_ass_slice, deprecated */ (ssizessizeobjargproc) NULL, /* sq_ass_slice, deprecated */
(objobjproc) NULL, /* sq_contains */ (objobjproc) NULL, /* sq_contains */
(binaryfunc) NULL, /* sq_inplace_concat */ (binaryfunc) NULL, /* sq_inplace_concat */
(ssizeargfunc) NULL, /* sq_inplace_repeat */ (ssizeargfunc) NULL, /* sq_inplace_repeat */
}; };
@@ -2056,40 +2057,40 @@ static PyMappingMethods Matrix_AsMapping = {
static PyNumberMethods Matrix_NumMethods = { static PyNumberMethods Matrix_NumMethods = {
(binaryfunc) Matrix_add, /*nb_add*/ (binaryfunc) Matrix_add, /*nb_add*/
(binaryfunc) Matrix_sub, /*nb_subtract*/ (binaryfunc) Matrix_sub, /*nb_subtract*/
(binaryfunc) Matrix_mul, /*nb_multiply*/ (binaryfunc) Matrix_mul, /*nb_multiply*/
NULL, /*nb_remainder*/ NULL, /*nb_remainder*/
NULL, /*nb_divmod*/ NULL, /*nb_divmod*/
NULL, /*nb_power*/ NULL, /*nb_power*/
(unaryfunc) 0, /*nb_negative*/ (unaryfunc) 0, /*nb_negative*/
(unaryfunc) 0, /*tp_positive*/ (unaryfunc) 0, /*tp_positive*/
(unaryfunc) 0, /*tp_absolute*/ (unaryfunc) 0, /*tp_absolute*/
(inquiry) 0, /*tp_bool*/ (inquiry) 0, /*tp_bool*/
(unaryfunc) Matrix_inverted, /*nb_invert*/ (unaryfunc) Matrix_inverted, /*nb_invert*/
NULL, /*nb_lshift*/ NULL, /*nb_lshift*/
(binaryfunc)0, /*nb_rshift*/ (binaryfunc)0, /*nb_rshift*/
NULL, /*nb_and*/ NULL, /*nb_and*/
NULL, /*nb_xor*/ NULL, /*nb_xor*/
NULL, /*nb_or*/ NULL, /*nb_or*/
NULL, /*nb_int*/ NULL, /*nb_int*/
NULL, /*nb_reserved*/ NULL, /*nb_reserved*/
NULL, /*nb_float*/ NULL, /*nb_float*/
NULL, /* nb_inplace_add */ NULL, /* nb_inplace_add */
NULL, /* nb_inplace_subtract */ NULL, /* nb_inplace_subtract */
NULL, /* nb_inplace_multiply */ NULL, /* nb_inplace_multiply */
NULL, /* nb_inplace_remainder */ NULL, /* nb_inplace_remainder */
NULL, /* nb_inplace_power */ NULL, /* nb_inplace_power */
NULL, /* nb_inplace_lshift */ NULL, /* nb_inplace_lshift */
NULL, /* nb_inplace_rshift */ NULL, /* nb_inplace_rshift */
NULL, /* nb_inplace_and */ NULL, /* nb_inplace_and */
NULL, /* nb_inplace_xor */ NULL, /* nb_inplace_xor */
NULL, /* nb_inplace_or */ NULL, /* nb_inplace_or */
NULL, /* nb_floor_divide */ NULL, /* nb_floor_divide */
NULL, /* nb_true_divide */ NULL, /* nb_true_divide */
NULL, /* nb_inplace_floor_divide */ NULL, /* nb_inplace_floor_divide */
NULL, /* nb_inplace_true_divide */ NULL, /* nb_inplace_true_divide */
NULL, /* nb_index */ NULL, /* nb_index */
}; };
PyDoc_STRVAR(Matrix_translation_doc, PyDoc_STRVAR(Matrix_translation_doc,
@@ -2233,7 +2234,7 @@ static PyGetSetDef Matrix_getseters[] = {
{(char *)"is_negative", (getter)Matrix_is_negative_get, (setter)NULL, Matrix_is_negative_doc, NULL}, {(char *)"is_negative", (getter)Matrix_is_negative_get, (setter)NULL, Matrix_is_negative_doc, NULL},
{(char *)"is_orthogonal", (getter)Matrix_is_orthogonal_get, (setter)NULL, Matrix_is_orthogonal_doc, NULL}, {(char *)"is_orthogonal", (getter)Matrix_is_orthogonal_get, (setter)NULL, Matrix_is_orthogonal_doc, NULL},
{(char *)"is_wrapped", (getter)BaseMathObject_is_wrapped_get, (setter)NULL, BaseMathObject_is_wrapped_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}, {(char *)"owner", (getter)BaseMathObject_owner_get, (setter)NULL, BaseMathObject_owner_doc, NULL},
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */ {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
}; };
@@ -2285,51 +2286,51 @@ PyDoc_STRVAR(matrix_doc,
); );
PyTypeObject matrix_Type = { PyTypeObject matrix_Type = {
PyVarObject_HEAD_INIT(NULL, 0) PyVarObject_HEAD_INIT(NULL, 0)
"mathutils.Matrix", /*tp_name*/ "mathutils.Matrix", /*tp_name*/
sizeof(MatrixObject), /*tp_basicsize*/ sizeof(MatrixObject), /*tp_basicsize*/
0, /*tp_itemsize*/ 0, /*tp_itemsize*/
(destructor)BaseMathObject_dealloc, /*tp_dealloc*/ (destructor)BaseMathObject_dealloc, /*tp_dealloc*/
NULL, /*tp_print*/ NULL, /*tp_print*/
NULL, /*tp_getattr*/ NULL, /*tp_getattr*/
NULL, /*tp_setattr*/ NULL, /*tp_setattr*/
NULL, /*tp_compare*/ NULL, /*tp_compare*/
(reprfunc) Matrix_repr, /*tp_repr*/ (reprfunc) Matrix_repr, /*tp_repr*/
&Matrix_NumMethods, /*tp_as_number*/ &Matrix_NumMethods, /*tp_as_number*/
&Matrix_SeqMethods, /*tp_as_sequence*/ &Matrix_SeqMethods, /*tp_as_sequence*/
&Matrix_AsMapping, /*tp_as_mapping*/ &Matrix_AsMapping, /*tp_as_mapping*/
NULL, /*tp_hash*/ NULL, /*tp_hash*/
NULL, /*tp_call*/ NULL, /*tp_call*/
(reprfunc) Matrix_str, /*tp_str*/ (reprfunc) Matrix_str, /*tp_str*/
NULL, /*tp_getattro*/ NULL, /*tp_getattro*/
NULL, /*tp_setattro*/ NULL, /*tp_setattro*/
NULL, /*tp_as_buffer*/ NULL, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
matrix_doc, /*tp_doc*/ matrix_doc, /*tp_doc*/
(traverseproc)BaseMathObject_traverse, //tp_traverse (traverseproc)BaseMathObject_traverse, //tp_traverse
(inquiry)BaseMathObject_clear, //tp_clear (inquiry)BaseMathObject_clear, //tp_clear
(richcmpfunc)Matrix_richcmpr, /*tp_richcompare*/ (richcmpfunc)Matrix_richcmpr, /*tp_richcompare*/
0, /*tp_weaklistoffset*/ 0, /*tp_weaklistoffset*/
NULL, /*tp_iter*/ NULL, /*tp_iter*/
NULL, /*tp_iternext*/ NULL, /*tp_iternext*/
Matrix_methods, /*tp_methods*/ Matrix_methods, /*tp_methods*/
NULL, /*tp_members*/ NULL, /*tp_members*/
Matrix_getseters, /*tp_getset*/ Matrix_getseters, /*tp_getset*/
NULL, /*tp_base*/ NULL, /*tp_base*/
NULL, /*tp_dict*/ NULL, /*tp_dict*/
NULL, /*tp_descr_get*/ NULL, /*tp_descr_get*/
NULL, /*tp_descr_set*/ NULL, /*tp_descr_set*/
0, /*tp_dictoffset*/ 0, /*tp_dictoffset*/
NULL, /*tp_init*/ NULL, /*tp_init*/
NULL, /*tp_alloc*/ NULL, /*tp_alloc*/
Matrix_new, /*tp_new*/ Matrix_new, /*tp_new*/
NULL, /*tp_free*/ NULL, /*tp_free*/
NULL, /*tp_is_gc*/ NULL, /*tp_is_gc*/
NULL, /*tp_bases*/ NULL, /*tp_bases*/
NULL, /*tp_mro*/ NULL, /*tp_mro*/
NULL, /*tp_cache*/ NULL, /*tp_cache*/
NULL, /*tp_subclasses*/ NULL, /*tp_subclasses*/
NULL, /*tp_weaklist*/ NULL, /*tp_weaklist*/
NULL /*tp_del*/ NULL /*tp_del*/
}; };
/* pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER /* pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER
@@ -2374,7 +2375,7 @@ PyObject *Matrix_CreatePyObject(float *mat,
return NULL; return NULL;
} }
if (mat) { /*if a float array passed*/ if (mat) { /*if a float array passed*/
memcpy(self->matrix, mat, num_col * num_row * sizeof(float)); memcpy(self->matrix, mat, num_col * num_row * sizeof(float));
} }
else if (num_col == num_row) { else if (num_col == num_row) {
@@ -2448,8 +2449,8 @@ static void MatrixAccess_dealloc(MatrixAccessObject *self)
static int MatrixAccess_len(MatrixAccessObject *self) static int MatrixAccess_len(MatrixAccessObject *self)
{ {
return (self->type == MAT_ACCESS_ROW) ? return (self->type == MAT_ACCESS_ROW) ?
self->matrix_user->num_row : self->matrix_user->num_row :
self->matrix_user->num_col; self->matrix_user->num_col;
} }
static PyObject *MatrixAccess_slice(MatrixAccessObject *self, int begin, int end) static PyObject *MatrixAccess_slice(MatrixAccessObject *self, int begin, int end)
@@ -2585,30 +2586,30 @@ static PyMappingMethods MatrixAccess_AsMapping = {
PyTypeObject matrix_access_Type = { PyTypeObject matrix_access_Type = {
PyVarObject_HEAD_INIT(NULL, 0) PyVarObject_HEAD_INIT(NULL, 0)
"MatrixAccess", /*tp_name*/ "MatrixAccess", /*tp_name*/
sizeof(MatrixAccessObject), /*tp_basicsize*/ sizeof(MatrixAccessObject), /*tp_basicsize*/
0, /*tp_itemsize*/ 0, /*tp_itemsize*/
(destructor)MatrixAccess_dealloc, /*tp_dealloc*/ (destructor)MatrixAccess_dealloc, /*tp_dealloc*/
NULL, /*tp_print*/ NULL, /*tp_print*/
NULL, /*tp_getattr*/ NULL, /*tp_getattr*/
NULL, /*tp_setattr*/ NULL, /*tp_setattr*/
NULL, /*tp_compare*/ NULL, /*tp_compare*/
NULL, /*tp_repr*/ NULL, /*tp_repr*/
NULL, /*tp_as_number*/ NULL, /*tp_as_number*/
NULL /*&MatrixAccess_SeqMethods*/ /* TODO */, /*tp_as_sequence*/ NULL /*&MatrixAccess_SeqMethods*/ /* TODO */, /*tp_as_sequence*/
&MatrixAccess_AsMapping, /*tp_as_mapping*/ &MatrixAccess_AsMapping, /*tp_as_mapping*/
NULL, /*tp_hash*/ NULL, /*tp_hash*/
NULL, /*tp_call*/ NULL, /*tp_call*/
NULL, /*tp_str*/ NULL, /*tp_str*/
NULL, /*tp_getattro*/ NULL, /*tp_getattro*/
NULL, /*tp_setattro*/ NULL, /*tp_setattro*/
NULL, /*tp_as_buffer*/ NULL, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
NULL, /*tp_doc*/ NULL, /*tp_doc*/
(traverseproc)MatrixAccess_traverse, //tp_traverse (traverseproc)MatrixAccess_traverse, //tp_traverse
(inquiry)MatrixAccess_clear, //tp_clear (inquiry)MatrixAccess_clear, //tp_clear
NULL /* (richcmpfunc)MatrixAccess_richcmpr */ /* TODO*/, /*tp_richcompare*/ NULL /* (richcmpfunc)MatrixAccess_richcmpr */ /* TODO*/, /*tp_richcompare*/
0, /*tp_weaklistoffset*/ 0, /*tp_weaklistoffset*/
(getiterfunc)MatrixAccess_iter, /* getiterfunc tp_iter; */ (getiterfunc)MatrixAccess_iter, /* getiterfunc tp_iter; */
}; };

View File

@@ -113,12 +113,12 @@ static PyObject *Quaternion_to_euler(QuaternionObject *self, PyObject *args)
quat_to_mat3(mat, tquat); quat_to_mat3(mat, tquat);
if (order == EULER_ORDER_XYZ) mat3_to_compatible_eul(eul, eul_compat->eul, mat); if (order == EULER_ORDER_XYZ) mat3_to_compatible_eul(eul, eul_compat->eul, mat);
else mat3_to_compatible_eulO(eul, eul_compat->eul, order, mat); else mat3_to_compatible_eulO(eul, eul_compat->eul, order, mat);
} }
else { else {
if (order == EULER_ORDER_XYZ) quat_to_eul(eul, tquat); if (order == EULER_ORDER_XYZ) quat_to_eul(eul, tquat);
else quat_to_eulO(eul, order, tquat); else quat_to_eulO(eul, order, tquat);
} }
return Euler_CreatePyObject(eul, order, Py_NEW, NULL); return Euler_CreatePyObject(eul, order, Py_NEW, NULL);
@@ -741,8 +741,8 @@ static PyObject *Quaternion_add(PyObject *q1, PyObject *q2)
Py_TYPE(q1)->tp_name, Py_TYPE(q2)->tp_name); Py_TYPE(q1)->tp_name, Py_TYPE(q2)->tp_name);
return NULL; return NULL;
} }
quat1 = (QuaternionObject*)q1; quat1 = (QuaternionObject *)q1;
quat2 = (QuaternionObject*)q2; quat2 = (QuaternionObject *)q2;
if (BaseMath_ReadCallback(quat1) == -1 || BaseMath_ReadCallback(quat2) == -1) if (BaseMath_ReadCallback(quat1) == -1 || BaseMath_ReadCallback(quat2) == -1)
return NULL; return NULL;
@@ -766,8 +766,8 @@ static PyObject *Quaternion_sub(PyObject *q1, PyObject *q2)
return NULL; return NULL;
} }
quat1 = (QuaternionObject*)q1; quat1 = (QuaternionObject *)q1;
quat2 = (QuaternionObject*)q2; quat2 = (QuaternionObject *)q2;
if (BaseMath_ReadCallback(quat1) == -1 || BaseMath_ReadCallback(quat2) == -1) if (BaseMath_ReadCallback(quat1) == -1 || BaseMath_ReadCallback(quat2) == -1)
return NULL; return NULL;
@@ -795,12 +795,12 @@ static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2)
QuaternionObject *quat1 = NULL, *quat2 = NULL; QuaternionObject *quat1 = NULL, *quat2 = NULL;
if (QuaternionObject_Check(q1)) { if (QuaternionObject_Check(q1)) {
quat1 = (QuaternionObject*)q1; quat1 = (QuaternionObject *)q1;
if (BaseMath_ReadCallback(quat1) == -1) if (BaseMath_ReadCallback(quat1) == -1)
return NULL; return NULL;
} }
if (QuaternionObject_Check(q2)) { if (QuaternionObject_Check(q2)) {
quat2 = (QuaternionObject*)q2; quat2 = (QuaternionObject *)q2;
if (BaseMath_ReadCallback(quat2) == -1) if (BaseMath_ReadCallback(quat2) == -1)
return NULL; return NULL;
} }
@@ -823,8 +823,8 @@ static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2)
if (vec2->size != 3) { if (vec2->size != 3) {
PyErr_SetString(PyExc_ValueError, PyErr_SetString(PyExc_ValueError,
"Vector multiplication: " "Vector multiplication: "
"only 3D vector rotations (with quats) " "only 3D vector rotations (with quats) "
"currently supported"); "currently supported");
return NULL; return NULL;
} }
@@ -869,16 +869,16 @@ static PyObject *Quaternion_neg(QuaternionObject *self)
//-----------------PROTOCOL DECLARATIONS-------------------------- //-----------------PROTOCOL DECLARATIONS--------------------------
static PySequenceMethods Quaternion_SeqMethods = { static PySequenceMethods Quaternion_SeqMethods = {
(lenfunc) Quaternion_len, /* sq_length */ (lenfunc) Quaternion_len, /* sq_length */
(binaryfunc) NULL, /* sq_concat */ (binaryfunc) NULL, /* sq_concat */
(ssizeargfunc) NULL, /* sq_repeat */ (ssizeargfunc) NULL, /* sq_repeat */
(ssizeargfunc) Quaternion_item, /* sq_item */ (ssizeargfunc) Quaternion_item, /* sq_item */
(ssizessizeargfunc) NULL, /* sq_slice, deprecated */ (ssizessizeargfunc) NULL, /* sq_slice, deprecated */
(ssizeobjargproc) Quaternion_ass_item, /* sq_ass_item */ (ssizeobjargproc) Quaternion_ass_item, /* sq_ass_item */
(ssizessizeobjargproc) NULL, /* sq_ass_slice, deprecated */ (ssizessizeobjargproc) NULL, /* sq_ass_slice, deprecated */
(objobjproc) NULL, /* sq_contains */ (objobjproc) NULL, /* sq_contains */
(binaryfunc) NULL, /* sq_inplace_concat */ (binaryfunc) NULL, /* sq_inplace_concat */
(ssizeargfunc) NULL, /* sq_inplace_repeat */ (ssizeargfunc) NULL, /* sq_inplace_repeat */
}; };
static PyMappingMethods Quaternion_AsMapping = { static PyMappingMethods Quaternion_AsMapping = {
@@ -888,40 +888,40 @@ static PyMappingMethods Quaternion_AsMapping = {
}; };
static PyNumberMethods Quaternion_NumMethods = { static PyNumberMethods Quaternion_NumMethods = {
(binaryfunc) Quaternion_add, /*nb_add*/ (binaryfunc) Quaternion_add, /*nb_add*/
(binaryfunc) Quaternion_sub, /*nb_subtract*/ (binaryfunc) Quaternion_sub, /*nb_subtract*/
(binaryfunc) Quaternion_mul, /*nb_multiply*/ (binaryfunc) Quaternion_mul, /*nb_multiply*/
NULL, /*nb_remainder*/ NULL, /*nb_remainder*/
NULL, /*nb_divmod*/ NULL, /*nb_divmod*/
NULL, /*nb_power*/ NULL, /*nb_power*/
(unaryfunc) Quaternion_neg, /*nb_negative*/ (unaryfunc) Quaternion_neg, /*nb_negative*/
(unaryfunc) 0, /*tp_positive*/ (unaryfunc) 0, /*tp_positive*/
(unaryfunc) 0, /*tp_absolute*/ (unaryfunc) 0, /*tp_absolute*/
(inquiry) 0, /*tp_bool*/ (inquiry) 0, /*tp_bool*/
(unaryfunc) 0, /*nb_invert*/ (unaryfunc) 0, /*nb_invert*/
NULL, /*nb_lshift*/ NULL, /*nb_lshift*/
(binaryfunc)0, /*nb_rshift*/ (binaryfunc)0, /*nb_rshift*/
NULL, /*nb_and*/ NULL, /*nb_and*/
NULL, /*nb_xor*/ NULL, /*nb_xor*/
NULL, /*nb_or*/ NULL, /*nb_or*/
NULL, /*nb_int*/ NULL, /*nb_int*/
NULL, /*nb_reserved*/ NULL, /*nb_reserved*/
NULL, /*nb_float*/ NULL, /*nb_float*/
NULL, /* nb_inplace_add */ NULL, /* nb_inplace_add */
NULL, /* nb_inplace_subtract */ NULL, /* nb_inplace_subtract */
NULL, /* nb_inplace_multiply */ NULL, /* nb_inplace_multiply */
NULL, /* nb_inplace_remainder */ NULL, /* nb_inplace_remainder */
NULL, /* nb_inplace_power */ NULL, /* nb_inplace_power */
NULL, /* nb_inplace_lshift */ NULL, /* nb_inplace_lshift */
NULL, /* nb_inplace_rshift */ NULL, /* nb_inplace_rshift */
NULL, /* nb_inplace_and */ NULL, /* nb_inplace_and */
NULL, /* nb_inplace_xor */ NULL, /* nb_inplace_xor */
NULL, /* nb_inplace_or */ NULL, /* nb_inplace_or */
NULL, /* nb_floor_divide */ NULL, /* nb_floor_divide */
NULL, /* nb_true_divide */ NULL, /* nb_true_divide */
NULL, /* nb_inplace_floor_divide */ NULL, /* nb_inplace_floor_divide */
NULL, /* nb_inplace_true_divide */ NULL, /* nb_inplace_true_divide */
NULL, /* nb_index */ NULL, /* nb_index */
}; };
PyDoc_STRVAR(Quaternion_axis_doc, PyDoc_STRVAR(Quaternion_axis_doc,
@@ -1070,19 +1070,19 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw
return NULL; return NULL;
switch (PyTuple_GET_SIZE(args)) { switch (PyTuple_GET_SIZE(args)) {
case 0: case 0:
break; break;
case 1: case 1:
if (mathutils_array_parse(quat, QUAT_SIZE, QUAT_SIZE, seq, "mathutils.Quaternion()") == -1) if (mathutils_array_parse(quat, QUAT_SIZE, QUAT_SIZE, seq, "mathutils.Quaternion()") == -1)
return NULL; return NULL;
break; break;
case 2: case 2:
if (mathutils_array_parse(quat, 3, 3, seq, "mathutils.Quaternion()") == -1) if (mathutils_array_parse(quat, 3, 3, seq, "mathutils.Quaternion()") == -1)
return NULL; return NULL;
angle = angle_wrap_rad(angle); /* clamp because of precision issues */ angle = angle_wrap_rad(angle); /* clamp because of precision issues */
axis_angle_to_quat(quat, quat, angle); axis_angle_to_quat(quat, quat, angle);
break; break;
/* PyArg_ParseTuple assures no more then 2 */ /* PyArg_ParseTuple assures no more then 2 */
} }
return Quaternion_CreatePyObject(quat, Py_NEW, type); return Quaternion_CreatePyObject(quat, Py_NEW, type);
} }
@@ -1172,7 +1172,7 @@ static PyGetSetDef Quaternion_getseters[] = {
{(char *)"z", (getter)Quaternion_axis_get, (setter)Quaternion_axis_set, Quaternion_axis_doc, (void *)3}, {(char *)"z", (getter)Quaternion_axis_get, (setter)Quaternion_axis_set, Quaternion_axis_doc, (void *)3},
{(char *)"magnitude", (getter)Quaternion_magnitude_get, (setter)NULL, Quaternion_magnitude_doc, NULL}, {(char *)"magnitude", (getter)Quaternion_magnitude_get, (setter)NULL, Quaternion_magnitude_doc, NULL},
{(char *)"angle", (getter)Quaternion_angle_get, (setter)Quaternion_angle_set, Quaternion_angle_doc, NULL}, {(char *)"angle", (getter)Quaternion_angle_get, (setter)Quaternion_angle_set, Quaternion_angle_doc, NULL},
{(char *)"axis",(getter)Quaternion_axis_vector_get, (setter)Quaternion_axis_vector_set, Quaternion_axis_vector_doc, NULL}, {(char *)"axis", (getter)Quaternion_axis_vector_get, (setter)Quaternion_axis_vector_set, Quaternion_axis_vector_doc, NULL},
{(char *)"is_wrapped", (getter)BaseMathObject_is_wrapped_get, (setter)NULL, BaseMathObject_is_wrapped_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}, {(char *)"owner", (getter)BaseMathObject_owner_get, (setter)NULL, BaseMathObject_owner_doc, NULL},
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */ {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
@@ -1184,51 +1184,51 @@ PyDoc_STRVAR(quaternion_doc,
); );
PyTypeObject quaternion_Type = { PyTypeObject quaternion_Type = {
PyVarObject_HEAD_INIT(NULL, 0) PyVarObject_HEAD_INIT(NULL, 0)
"mathutils.Quaternion", //tp_name "mathutils.Quaternion", //tp_name
sizeof(QuaternionObject), //tp_basicsize sizeof(QuaternionObject), //tp_basicsize
0, //tp_itemsize 0, //tp_itemsize
(destructor)BaseMathObject_dealloc, //tp_dealloc (destructor)BaseMathObject_dealloc, //tp_dealloc
NULL, //tp_print NULL, //tp_print
NULL, //tp_getattr NULL, //tp_getattr
NULL, //tp_setattr NULL, //tp_setattr
NULL, //tp_compare NULL, //tp_compare
(reprfunc) Quaternion_repr, //tp_repr (reprfunc) Quaternion_repr, //tp_repr
&Quaternion_NumMethods, //tp_as_number &Quaternion_NumMethods, //tp_as_number
&Quaternion_SeqMethods, //tp_as_sequence &Quaternion_SeqMethods, //tp_as_sequence
&Quaternion_AsMapping, //tp_as_mapping &Quaternion_AsMapping, //tp_as_mapping
NULL, //tp_hash NULL, //tp_hash
NULL, //tp_call NULL, //tp_call
(reprfunc) Quaternion_str, //tp_str (reprfunc) Quaternion_str, //tp_str
NULL, //tp_getattro NULL, //tp_getattro
NULL, //tp_setattro NULL, //tp_setattro
NULL, //tp_as_buffer NULL, //tp_as_buffer
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, //tp_flags Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, //tp_flags
quaternion_doc, //tp_doc quaternion_doc, //tp_doc
(traverseproc)BaseMathObject_traverse, //tp_traverse (traverseproc)BaseMathObject_traverse, //tp_traverse
(inquiry)BaseMathObject_clear, //tp_clear (inquiry)BaseMathObject_clear, //tp_clear
(richcmpfunc)Quaternion_richcmpr, //tp_richcompare (richcmpfunc)Quaternion_richcmpr, //tp_richcompare
0, //tp_weaklistoffset 0, //tp_weaklistoffset
NULL, //tp_iter NULL, //tp_iter
NULL, //tp_iternext NULL, //tp_iternext
Quaternion_methods, //tp_methods Quaternion_methods, //tp_methods
NULL, //tp_members NULL, //tp_members
Quaternion_getseters, //tp_getset Quaternion_getseters, //tp_getset
NULL, //tp_base NULL, //tp_base
NULL, //tp_dict NULL, //tp_dict
NULL, //tp_descr_get NULL, //tp_descr_get
NULL, //tp_descr_set NULL, //tp_descr_set
0, //tp_dictoffset 0, //tp_dictoffset
NULL, //tp_init NULL, //tp_init
NULL, //tp_alloc NULL, //tp_alloc
Quaternion_new, //tp_new Quaternion_new, //tp_new
NULL, //tp_free NULL, //tp_free
NULL, //tp_is_gc NULL, //tp_is_gc
NULL, //tp_bases NULL, //tp_bases
NULL, //tp_mro NULL, //tp_mro
NULL, //tp_cache NULL, //tp_cache
NULL, //tp_subclasses NULL, //tp_subclasses
NULL, //tp_weaklist NULL, //tp_weaklist
NULL, //tp_del NULL, //tp_del
}; };
//------------------------Quaternion_CreatePyObject (internal)------------- //------------------------Quaternion_CreatePyObject (internal)-------------
//creates a new quaternion object //creates a new quaternion object

File diff suppressed because it is too large Load Diff

View File

@@ -627,10 +627,10 @@ static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObje
} }
if (use_a) { PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(isect_a, 3, Py_NEW, NULL)); } if (use_a) { PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(isect_a, 3, Py_NEW, NULL)); }
else { PyTuple_SET_ITEM(ret, 0, Py_None); Py_INCREF(Py_None); } else { PyTuple_SET_ITEM(ret, 0, Py_None); Py_INCREF(Py_None); }
if (use_b) { PyTuple_SET_ITEM(ret, 1, Vector_CreatePyObject(isect_b, 3, Py_NEW, NULL)); } if (use_b) { PyTuple_SET_ITEM(ret, 1, Vector_CreatePyObject(isect_b, 3, Py_NEW, NULL)); }
else { PyTuple_SET_ITEM(ret, 1, Py_None); Py_INCREF(Py_None); } else { PyTuple_SET_ITEM(ret, 1, Py_None); Py_INCREF(Py_None); }
return ret; return ret;
} }
@@ -700,10 +700,10 @@ static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyO
} }
if (use_a) { PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(isect_a, 2, Py_NEW, NULL)); } if (use_a) { PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(isect_a, 2, Py_NEW, NULL)); }
else { PyTuple_SET_ITEM(ret, 0, Py_None); Py_INCREF(Py_None); } else { PyTuple_SET_ITEM(ret, 0, Py_None); Py_INCREF(Py_None); }
if (use_b) { PyTuple_SET_ITEM(ret, 1, Vector_CreatePyObject(isect_b, 2, Py_NEW, NULL)); } if (use_b) { PyTuple_SET_ITEM(ret, 1, Vector_CreatePyObject(isect_b, 2, Py_NEW, NULL)); }
else { PyTuple_SET_ITEM(ret, 1, Py_None); Py_INCREF(Py_None); } else { PyTuple_SET_ITEM(ret, 1, Py_None); Py_INCREF(Py_None); }
return ret; return ret;
} }
@@ -745,13 +745,13 @@ static PyObject *M_Geometry_intersect_point_line(PyObject *UNUSED(self), PyObjec
} }
/* accept 2d verts */ /* accept 2d verts */
if (pt->size == 3) { copy_v3_v3(pt_in, pt->vec);} if (pt->size == 3) { copy_v3_v3(pt_in, pt->vec); }
else { pt_in[2] = 0.0f; copy_v2_v2(pt_in, pt->vec); } else { pt_in[2] = 0.0f; copy_v2_v2(pt_in, pt->vec); }
if (line_1->size == 3) { copy_v3_v3(l1, line_1->vec);} if (line_1->size == 3) { copy_v3_v3(l1, line_1->vec); }
else { l1[2] = 0.0f; copy_v2_v2(l1, line_1->vec); } else { l1[2] = 0.0f; copy_v2_v2(l1, line_1->vec); }
if (line_2->size == 3) { copy_v3_v3(l2, line_2->vec);} if (line_2->size == 3) { copy_v3_v3(l2, line_2->vec); }
else { l2[2] = 0.0f; copy_v2_v2(l2, line_2->vec); } else { l2[2] = 0.0f; copy_v2_v2(l2, line_2->vec); }
/* do the calculation */ /* do the calculation */
@@ -937,8 +937,8 @@ static PyObject *M_Geometry_barycentric_transform(PyObject *UNUSED(self), PyObje
} }
barycentric_transform(vec, vec_pt->vec, barycentric_transform(vec, vec_pt->vec,
vec_t1_tar->vec, vec_t2_tar->vec, vec_t3_tar->vec, vec_t1_tar->vec, vec_t2_tar->vec, vec_t3_tar->vec,
vec_t1_src->vec, vec_t2_src->vec, vec_t3_src->vec); vec_t1_src->vec, vec_t2_src->vec, vec_t3_src->vec);
return Vector_CreatePyObject(vec, 3, Py_NEW, NULL); return Vector_CreatePyObject(vec, 3, Py_NEW, NULL);
} }
@@ -1010,7 +1010,7 @@ static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject
coord_array = MEM_callocN(dims * (resolu) * sizeof(float), "interpolate_bezier"); coord_array = MEM_callocN(dims * (resolu) * sizeof(float), "interpolate_bezier");
for (i = 0; i < dims; i++) { for (i = 0; i < dims; i++) {
forward_diff_bezier(k1[i], h1[i], h2[i], k2[i], coord_array + i, resolu - 1, sizeof(float)*dims); forward_diff_bezier(k1[i], h1[i], h2[i], k2[i], coord_array + i, resolu - 1, sizeof(float) * dims);
} }
list = PyList_New(resolu); list = PyList_New(resolu);
@@ -1095,7 +1095,7 @@ static PyObject *M_Geometry_tessellate_polygon(PyObject *UNUSED(self), PyObject
if (((VectorObject *)polyVec)->size > 2) if (((VectorObject *)polyVec)->size > 2)
fp[2] = ((VectorObject *)polyVec)->vec[2]; fp[2] = ((VectorObject *)polyVec)->vec[2];
else else
fp[2] = 0.0f; /* if its a 2d vector then set the z to be zero */ fp[2] = 0.0f; /* if its a 2d vector then set the z to be zero */
} }
else { else {
ls_error = 1; ls_error = 1;

View File

@@ -112,13 +112,13 @@
/* Period parameters */ /* Period parameters */
#define N 624 #define N 624
#define M 397 #define M 397
#define MATRIX_A 0x9908b0dfUL /* constant vector a */ #define MATRIX_A 0x9908b0dfUL /* constant vector a */
#define UMASK 0x80000000UL /* most significant w-r bits */ #define UMASK 0x80000000UL /* most significant w-r bits */
#define LMASK 0x7fffffffUL /* least significant r bits */ #define LMASK 0x7fffffffUL /* least significant r bits */
#define MIXBITS(u,v) (((u) & UMASK) | ((v) & LMASK)) #define MIXBITS(u, v) (((u) & UMASK) | ((v) & LMASK))
#define TWIST(u,v) ((MIXBITS(u,v) >> 1) ^ ((v)&1UL ? MATRIX_A : 0UL)) #define TWIST(u, v) ((MIXBITS(u, v) >> 1) ^ ((v) & 1UL ? MATRIX_A : 0UL))
static unsigned long state[N]; /* the array for the state vector */ static unsigned long state[N]; /* the array for the state vector */
static int left = 1; static int left = 1;
static int initf = 0; static int initf = 0;
static unsigned long *next; static unsigned long *next;
@@ -130,13 +130,13 @@ static void init_genrand(unsigned long s)
state[0] = s & 0xffffffffUL; state[0] = s & 0xffffffffUL;
for (j = 1; j < N; j++) { for (j = 1; j < N; j++) {
state[j] = state[j] =
(1812433253UL * (1812433253UL *
(state[j - 1] ^ (state[j - 1] >> 30)) + j); (state[j - 1] ^ (state[j - 1] >> 30)) + j);
/* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */ /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
/* In the previous versions, MSBs of the seed affect */ /* In the previous versions, MSBs of the seed affect */
/* only MSBs of the array state[]. */ /* only MSBs of the array state[]. */
/* 2002/01/09 modified by Makoto Matsumoto */ /* 2002/01/09 modified by Makoto Matsumoto */
state[j] &= 0xffffffffUL; /* for >32 bit machines */ state[j] &= 0xffffffffUL; /* for >32 bit machines */
} }
left = 1; left = 1;
initf = 1; initf = 1;
@@ -215,7 +215,7 @@ static void noise_vector(float x, float y, float z, int nb, float v[3])
/* Returns a turbulence value for a given position (x, y, z) */ /* Returns a turbulence value for a given position (x, y, z) */
static float turb(float x, float y, float z, int oct, int hard, int nb, static float turb(float x, float y, float z, int oct, int hard, int nb,
float ampscale, float freqscale) float ampscale, float freqscale)
{ {
float amp, out, t; float amp, out, t;
int i; int i;
@@ -334,7 +334,7 @@ PyDoc_STRVAR(M_Noise_random_vector_doc,
); );
static PyObject *M_Noise_random_vector(PyObject *UNUSED(self), PyObject *args) static PyObject *M_Noise_random_vector(PyObject *UNUSED(self), PyObject *args)
{ {
float vec[4]= {0.0f, 0.0f, 0.0f, 0.0f}; float vec[4] = {0.0f, 0.0f, 0.0f, 0.0f};
int size = 3; int size = 3;
if (!PyArg_ParseTuple(args, "|i:random_vector", &size)) if (!PyArg_ParseTuple(args, "|i:random_vector", &size))
@@ -729,7 +729,7 @@ static PyObject *M_Noise_voronoi(PyObject *UNUSED(self), PyObject *args)
float vec[3]; float vec[3];
float da[4], pa[12]; float da[4], pa[12];
int dtype = 0; int dtype = 0;
float me = 2.5f; /* default minkovsky exponent */ float me = 2.5f; /* default minkovsky exponent */
int i; int i;