forked from bartvdbraak/blender
formatting edits & remove debug print.
This commit is contained in:
parent
6955c47fac
commit
276e5f7095
@ -254,7 +254,7 @@ static PyObject *BPy_IDGroup_Map_GetItem(BPy_IDProperty *self, PyObject *item)
|
||||
|
||||
idprop= IDP_GetPropertyFromGroup(self->prop, name);
|
||||
|
||||
if(idprop==NULL) {
|
||||
if (idprop==NULL) {
|
||||
PyErr_SetString(PyExc_KeyError, "key not in subgroup dict");
|
||||
return NULL;
|
||||
}
|
||||
@ -273,20 +273,20 @@ static int idp_sequence_type(PyObject *seq)
|
||||
for (i=0; i < len; i++) {
|
||||
item = PySequence_GetItem(seq, i);
|
||||
if (PyFloat_Check(item)) {
|
||||
if(type == IDP_IDPARRAY) { /* mixed dict/int */
|
||||
if (type == IDP_IDPARRAY) { /* mixed dict/int */
|
||||
Py_DECREF(item);
|
||||
return -1;
|
||||
}
|
||||
type= IDP_DOUBLE;
|
||||
}
|
||||
else if (PyLong_Check(item)) {
|
||||
if(type == IDP_IDPARRAY) { /* mixed dict/int */
|
||||
if (type == IDP_IDPARRAY) { /* mixed dict/int */
|
||||
Py_DECREF(item);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (PyMapping_Check(item)) {
|
||||
if(i != 0 && (type != IDP_IDPARRAY)) { /* mixed dict/int */
|
||||
if (i != 0 && (type != IDP_IDPARRAY)) { /* mixed dict/int */
|
||||
Py_DECREF(item);
|
||||
return -1;
|
||||
}
|
||||
@ -309,7 +309,7 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(const char *name, IDProperty *g
|
||||
IDProperty *prop = NULL;
|
||||
IDPropertyTemplate val = {0};
|
||||
|
||||
if(strlen(name) >= sizeof(group->name))
|
||||
if (strlen(name) >= sizeof(group->name))
|
||||
return "the length of IDProperty names is limited to 31 characters";
|
||||
|
||||
if (PyFloat_Check(ob)) {
|
||||
@ -335,7 +335,7 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(const char *name, IDProperty *g
|
||||
PyObject *item;
|
||||
int i;
|
||||
|
||||
if((val.array.type= idp_sequence_type(ob)) == -1)
|
||||
if ((val.array.type= idp_sequence_type(ob)) == -1)
|
||||
return "only floats, ints and dicts are allowed in ID property arrays";
|
||||
|
||||
/*validate sequence and derive type.
|
||||
@ -369,7 +369,7 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(const char *name, IDProperty *g
|
||||
error= BPy_IDProperty_Map_ValidateAndCreate("", prop, item);
|
||||
Py_DECREF(item);
|
||||
|
||||
if(error)
|
||||
if (error)
|
||||
return error;
|
||||
}
|
||||
break;
|
||||
@ -415,7 +415,7 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(const char *name, IDProperty *g
|
||||
}
|
||||
else return "invalid property value";
|
||||
|
||||
if(group->type==IDP_IDPARRAY) {
|
||||
if (group->type==IDP_IDPARRAY) {
|
||||
IDP_AppendArray(group, prop);
|
||||
// IDP_FreeProperty(item); // IDP_AppendArray does a shallow copy (memcpy), only free memory
|
||||
MEM_freeN(prop);
|
||||
@ -598,7 +598,7 @@ static PyObject *BPy_IDGroup_Pop(BPy_IDProperty *self, PyObject *value)
|
||||
|
||||
idprop= IDP_GetPropertyFromGroup(self->prop, name);
|
||||
|
||||
if(idprop) {
|
||||
if (idprop) {
|
||||
pyform = BPy_IDGroup_MapDataToPy(idprop);
|
||||
|
||||
if (!pyform) {
|
||||
@ -1050,7 +1050,7 @@ static PyObject *BPy_IDArray_slice(BPy_IDArray *self, int begin, int end)
|
||||
case IDP_FLOAT:
|
||||
{
|
||||
float *array= (float*)IDP_Array(prop);
|
||||
for(count = begin; count < end; count++) {
|
||||
for (count = begin; count < end; count++) {
|
||||
PyTuple_SET_ITEM(tuple, count - begin, PyFloat_FromDouble(array[count]));
|
||||
}
|
||||
break;
|
||||
@ -1058,7 +1058,7 @@ static PyObject *BPy_IDArray_slice(BPy_IDArray *self, int begin, int end)
|
||||
case IDP_DOUBLE:
|
||||
{
|
||||
double *array= (double*)IDP_Array(prop);
|
||||
for(count = begin; count < end; count++) {
|
||||
for (count = begin; count < end; count++) {
|
||||
PyTuple_SET_ITEM(tuple, count - begin, PyFloat_FromDouble(array[count]));
|
||||
}
|
||||
break;
|
||||
@ -1066,7 +1066,7 @@ static PyObject *BPy_IDArray_slice(BPy_IDArray *self, int begin, int end)
|
||||
case IDP_INT:
|
||||
{
|
||||
int *array= (int*)IDP_Array(prop);
|
||||
for(count = begin; count < end; count++) {
|
||||
for (count = begin; count < end; count++) {
|
||||
PyTuple_SET_ITEM(tuple, count - begin, PyLong_FromLong(array[count]));
|
||||
}
|
||||
break;
|
||||
@ -1094,7 +1094,7 @@ static int BPy_IDArray_ass_slice(BPy_IDArray *self, int begin, int end, PyObject
|
||||
alloc_len= size * elem_size;
|
||||
|
||||
vec= MEM_mallocN(alloc_len, "array assignment"); /* NOTE: we count on int/float being the same size here */
|
||||
if(PyC_AsArray(vec, seq, size, py_type, is_double, "slice assignment: ") == -1) {
|
||||
if (PyC_AsArray(vec, seq, size, py_type, is_double, "slice assignment: ") == -1) {
|
||||
MEM_freeN(vec);
|
||||
return -1;
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ static PyObject *Buffer_to_list_recursive(Buffer *self)
|
||||
{
|
||||
PyObject *list;
|
||||
|
||||
if(self->ndimensions > 1) {
|
||||
if (self->ndimensions > 1) {
|
||||
int i, len= self->dimensions[0];
|
||||
list= PyList_New(len);
|
||||
|
||||
@ -213,7 +213,7 @@ PyTypeObject BGL_bufferType = {
|
||||
static PyObject *Method_##funcname (PyObject *UNUSED(self), PyObject *args) {\
|
||||
arg_def##nargs arg_list; \
|
||||
ret_def_##ret; \
|
||||
if(!PyArg_ParseTuple(args, arg_str##nargs arg_list, arg_ref##nargs arg_list)) return NULL;\
|
||||
if (!PyArg_ParseTuple(args, arg_str##nargs arg_list, arg_ref##nargs arg_list)) return NULL;\
|
||||
ret_set_##ret gl##funcname (arg_var##nargs arg_list);\
|
||||
ret_ret_##ret; \
|
||||
}
|
||||
@ -222,7 +222,7 @@ static PyObject *Method_##funcname (PyObject *UNUSED(self), PyObject *args) {\
|
||||
static PyObject *Method_##funcname (PyObject *UNUSED(self), PyObject *args) {\
|
||||
arg_def##nargs arg_list; \
|
||||
ret_def_##ret; \
|
||||
if(!PyArg_ParseTuple(args, arg_str##nargs arg_list, arg_ref##nargs arg_list)) return NULL;\
|
||||
if (!PyArg_ParseTuple(args, arg_str##nargs arg_list, arg_ref##nargs arg_list)) return NULL;\
|
||||
ret_set_##ret glu##funcname (arg_var##nargs arg_list);\
|
||||
ret_ret_##ret; \
|
||||
}
|
||||
@ -289,7 +289,7 @@ static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject
|
||||
int type;
|
||||
Py_ssize_t i, ndimensions = 0;
|
||||
|
||||
if(kwds && PyDict_Size(kwds)) {
|
||||
if (kwds && PyDict_Size(kwds)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"bgl.Buffer(): takes no keyword args");
|
||||
return NULL;
|
||||
@ -307,7 +307,7 @@ static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject
|
||||
|
||||
if (PyLong_Check(length_ob)) {
|
||||
ndimensions= 1;
|
||||
if(((dimensions[0]= PyLong_AsLong(length_ob)) < 1)) {
|
||||
if (((dimensions[0]= PyLong_AsLong(length_ob)) < 1)) {
|
||||
PyErr_SetString(PyExc_AttributeError,
|
||||
"dimensions must be between 1 and "STRINGIFY(MAX_DIMENSIONS));
|
||||
return NULL;
|
||||
@ -332,7 +332,7 @@ static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject
|
||||
else dimensions[i]= PyLong_AsLong(ob);
|
||||
Py_DECREF(ob);
|
||||
|
||||
if(dimensions[i] < 1) {
|
||||
if (dimensions[i] < 1) {
|
||||
PyErr_SetString(PyExc_AttributeError,
|
||||
"dimensions must be between 1 and "STRINGIFY(MAX_DIMENSIONS));
|
||||
return NULL;
|
||||
@ -490,7 +490,7 @@ static int Buffer_ass_slice(Buffer *self, int begin, int end, PyObject *seq)
|
||||
|
||||
for (count= begin; count < end; count++) {
|
||||
item= PySequence_GetItem(seq, count - begin);
|
||||
if(item) {
|
||||
if (item) {
|
||||
err= Buffer_ass_item(self, count, item);
|
||||
Py_DECREF(item);
|
||||
}
|
||||
@ -1293,7 +1293,7 @@ PyObject *BPyInit_bgl(void)
|
||||
submodule= PyModule_Create(&BGL_module_def);
|
||||
dict= PyModule_GetDict(submodule);
|
||||
|
||||
if(PyType_Ready(&BGL_bufferType) < 0)
|
||||
if (PyType_Ready(&BGL_bufferType) < 0)
|
||||
return NULL; /* should never happen */
|
||||
|
||||
|
||||
|
@ -62,7 +62,7 @@ void bpy_import_init(PyObject *builtins)
|
||||
/* move reload here
|
||||
* XXX, use import hooks */
|
||||
mod= PyImport_ImportModuleLevel((char *)"imp", NULL, NULL, NULL, 0);
|
||||
if(mod) {
|
||||
if (mod) {
|
||||
PyDict_SetItemString(PyModule_GetDict(mod), "reload", item=PyCFunction_New(&bpy_reload_meth, NULL)); Py_DECREF(item);
|
||||
Py_DECREF(mod);
|
||||
}
|
||||
@ -74,7 +74,7 @@ void bpy_import_init(PyObject *builtins)
|
||||
|
||||
static void free_compiled_text(Text *text)
|
||||
{
|
||||
if(text->compiled) {
|
||||
if (text->compiled) {
|
||||
Py_DECREF((PyObject *)text->compiled);
|
||||
}
|
||||
text->compiled= NULL;
|
||||
@ -102,7 +102,7 @@ PyObject *bpy_text_import(Text *text)
|
||||
char modulename[24];
|
||||
int len;
|
||||
|
||||
if(!text->compiled) {
|
||||
if (!text->compiled) {
|
||||
char fn_dummy[256];
|
||||
bpy_text_filename_get(fn_dummy, sizeof(fn_dummy), text);
|
||||
|
||||
@ -110,7 +110,7 @@ PyObject *bpy_text_import(Text *text)
|
||||
text->compiled= Py_CompileString(buf, fn_dummy, Py_file_input);
|
||||
MEM_freeN(buf);
|
||||
|
||||
if(PyErr_Occurred()) {
|
||||
if (PyErr_Occurred()) {
|
||||
PyErr_Print();
|
||||
PyErr_Clear();
|
||||
PySys_SetObject("last_traceback", NULL);
|
||||
@ -135,7 +135,7 @@ PyObject *bpy_text_import_name(char *name, int *found)
|
||||
|
||||
*found= 0;
|
||||
|
||||
if(!maggie) {
|
||||
if (!maggie) {
|
||||
printf("ERROR: bpy_import_main_set() was not called before running python. this is a bug.\n");
|
||||
return NULL;
|
||||
}
|
||||
@ -147,7 +147,7 @@ PyObject *bpy_text_import_name(char *name, int *found)
|
||||
|
||||
text= BLI_findstring(&maggie->text, txtname, offsetof(ID, name) + 2);
|
||||
|
||||
if(!text)
|
||||
if (!text)
|
||||
return NULL;
|
||||
else
|
||||
*found= 1;
|
||||
@ -169,7 +169,7 @@ PyObject *bpy_text_reimport(PyObject *module, int *found)
|
||||
//XXX Main *maggie= bpy_import_main ? bpy_import_main:G.main;
|
||||
Main *maggie= bpy_import_main;
|
||||
|
||||
if(!maggie) {
|
||||
if (!maggie) {
|
||||
printf("ERROR: bpy_import_main_set() was not called before running python. this is a bug.\n");
|
||||
return NULL;
|
||||
}
|
||||
@ -177,24 +177,24 @@ PyObject *bpy_text_reimport(PyObject *module, int *found)
|
||||
*found= 0;
|
||||
|
||||
/* get name, filename from the module itself */
|
||||
if((name= PyModule_GetName(module)) == NULL)
|
||||
if ((name= PyModule_GetName(module)) == NULL)
|
||||
return NULL;
|
||||
|
||||
if((filepath= (char *)PyModule_GetFilename(module)) == NULL)
|
||||
if ((filepath= (char *)PyModule_GetFilename(module)) == NULL)
|
||||
return NULL;
|
||||
|
||||
/* look up the text object */
|
||||
text= BLI_findstring(&maggie->text, BLI_path_basename(filepath), offsetof(ID, name) + 2);
|
||||
|
||||
/* uh-oh.... didn't find it */
|
||||
if(!text)
|
||||
if (!text)
|
||||
return NULL;
|
||||
else
|
||||
*found= 1;
|
||||
|
||||
/* if previously compiled, free the object */
|
||||
/* (can't see how could be NULL, but check just in case) */
|
||||
if(text->compiled){
|
||||
if (text->compiled) {
|
||||
Py_DECREF((PyObject *)text->compiled);
|
||||
}
|
||||
|
||||
@ -204,7 +204,7 @@ PyObject *bpy_text_reimport(PyObject *module, int *found)
|
||||
MEM_freeN(buf);
|
||||
|
||||
/* if compile failed.... return this error */
|
||||
if(PyErr_Occurred()) {
|
||||
if (PyErr_Occurred()) {
|
||||
PyErr_Print();
|
||||
PyErr_Clear();
|
||||
PySys_SetObject("last_traceback", NULL);
|
||||
@ -229,14 +229,14 @@ static PyObject *blender_import(PyObject *UNUSED(self), PyObject *args, PyObject
|
||||
//PyObject_Print(args, stderr, 0);
|
||||
static const char *kwlist[]= {"name", "globals", "locals", "fromlist", "level", NULL};
|
||||
|
||||
if(!PyArg_ParseTupleAndKeywords(args, kw, "s|OOOi:bpy_import_meth", (char **)kwlist,
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|OOOi:bpy_import_meth", (char **)kwlist,
|
||||
&name, &globals, &locals, &fromlist, &level))
|
||||
return NULL;
|
||||
|
||||
/* import existing builtin modules or modules that have been imported already */
|
||||
newmodule= PyImport_ImportModuleLevel(name, globals, locals, fromlist, level);
|
||||
|
||||
if(newmodule)
|
||||
if (newmodule)
|
||||
return newmodule;
|
||||
|
||||
PyErr_Fetch(&exception, &err, &tb); /* get the python error incase we cant import as blender text either */
|
||||
@ -244,7 +244,7 @@ static PyObject *blender_import(PyObject *UNUSED(self), PyObject *args, PyObject
|
||||
/* importing from existing modules failed, see if we have this module as blender text */
|
||||
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();
|
||||
Py_XDECREF(exception);
|
||||
Py_XDECREF(err);
|
||||
@ -278,14 +278,14 @@ static PyObject *blender_reload(PyObject *UNUSED(self), PyObject *module)
|
||||
|
||||
/* try reimporting from file */
|
||||
newmodule= PyImport_ReloadModule(module);
|
||||
if(newmodule)
|
||||
if (newmodule)
|
||||
return newmodule;
|
||||
|
||||
/* no file, try importing from memory */
|
||||
PyErr_Fetch(&exception, &err, &tb); /*restore for probable later use */
|
||||
|
||||
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();
|
||||
Py_XDECREF(exception);
|
||||
Py_XDECREF(err);
|
||||
@ -359,10 +359,10 @@ void bpy_text_clear_modules(int clear_all)
|
||||
*/
|
||||
while (PyDict_Next(modules, &pos, &key, &value)) {
|
||||
fname= PyModule_GetFilename(value);
|
||||
if(fname) {
|
||||
if (fname) {
|
||||
if (clear_all || ((strstr(fname, SEPSTR))==0)) { /* no path ? */
|
||||
file_extension= strstr(fname, ".py");
|
||||
if(file_extension && (*(file_extension + 3) == '\0' || *(file_extension + 4) == '\0')) { /* .py or pyc extension? */
|
||||
if (file_extension && (*(file_extension + 3) == '\0' || *(file_extension + 4) == '\0')) { /* .py or pyc extension? */
|
||||
/* now we can be fairly sure its a python import from the blendfile */
|
||||
PyList_Append(list, key); /* free'd with the list */
|
||||
}
|
||||
@ -374,7 +374,7 @@ void bpy_text_clear_modules(int clear_all)
|
||||
}
|
||||
|
||||
/* remove all our modules */
|
||||
for(pos=0; pos < PyList_GET_SIZE(list); pos++) {
|
||||
for (pos=0; pos < PyList_GET_SIZE(list); pos++) {
|
||||
/* PyObject_Print(key, stderr, 0); */
|
||||
key= PyList_GET_ITEM(list, pos);
|
||||
PyDict_DelItem(modules, key);
|
||||
|
@ -136,7 +136,7 @@ static void init_genrand(unsigned long s)
|
||||
{
|
||||
int j;
|
||||
state[0] = s & 0xffffffffUL;
|
||||
for(j = 1; j < N; j++) {
|
||||
for (j = 1; j < N; j++) {
|
||||
state[j] =
|
||||
(1812433253UL *
|
||||
(state[j - 1] ^ (state[j - 1] >> 30)) + j);
|
||||
@ -157,16 +157,16 @@ static void next_state(void)
|
||||
|
||||
/* if init_genrand() has not been called, */
|
||||
/* a default initial seed is used */
|
||||
if(initf == 0)
|
||||
if (initf == 0)
|
||||
init_genrand(5489UL);
|
||||
|
||||
left = N;
|
||||
next = state;
|
||||
|
||||
for(j = N - M + 1; --j; p++)
|
||||
for (j = N - M + 1; --j; p++)
|
||||
*p = p[M] ^ TWIST(p[0], p[1]);
|
||||
|
||||
for(j = M; --j; p++)
|
||||
for (j = M; --j; p++)
|
||||
*p = p[M - N] ^ TWIST(p[0], p[1]);
|
||||
|
||||
*p = p[M - N] ^ TWIST(p[0], state[0]);
|
||||
@ -176,7 +176,7 @@ static void next_state(void)
|
||||
|
||||
static void setRndSeed(int seed)
|
||||
{
|
||||
if(seed == 0)
|
||||
if (seed == 0)
|
||||
init_genrand(time(NULL));
|
||||
else
|
||||
init_genrand(seed);
|
||||
@ -187,7 +187,7 @@ static float frand(void)
|
||||
{
|
||||
unsigned long y;
|
||||
|
||||
if(--left == 0)
|
||||
if (--left == 0)
|
||||
next_state();
|
||||
y = *next++;
|
||||
|
||||
@ -207,7 +207,7 @@ static void randuvec(float v[3])
|
||||
{
|
||||
float r;
|
||||
v[2] = 2.f * frand() - 1.f;
|
||||
if((r = 1.f - v[2] * v[2]) > 0.f) {
|
||||
if ((r = 1.f - v[2] * v[2]) > 0.f) {
|
||||
float a = (float)(6.283185307f * frand());
|
||||
r = (float)sqrt(r);
|
||||
v[0] = (float)(r * cosf(a));
|
||||
@ -237,7 +237,7 @@ static PyObject *Noise_random_unit_vector(PyObject *UNUSED(self))
|
||||
static PyObject *Noise_seed_set(PyObject *UNUSED(self), PyObject *args)
|
||||
{
|
||||
int s;
|
||||
if(!PyArg_ParseTuple(args, "i:seed_set", &s))
|
||||
if (!PyArg_ParseTuple(args, "i:seed_set", &s))
|
||||
return NULL;
|
||||
setRndSeed(s);
|
||||
Py_RETURN_NONE;
|
||||
@ -251,7 +251,7 @@ static PyObject *Noise_noise(PyObject *UNUSED(self), PyObject *args)
|
||||
{
|
||||
float x, y, z;
|
||||
int nb = 1;
|
||||
if(!PyArg_ParseTuple(args, "(fff)|i:noise", &x, &y, &z, &nb))
|
||||
if (!PyArg_ParseTuple(args, "(fff)|i:noise", &x, &y, &z, &nb))
|
||||
return NULL;
|
||||
|
||||
return PyFloat_FromDouble((2.0f * BLI_gNoise(1.0f, x, y, z, 0, nb) - 1.0f));
|
||||
@ -275,7 +275,7 @@ static PyObject *Noise_vector(PyObject *UNUSED(self), PyObject *args)
|
||||
{
|
||||
float x, y, z, v[3];
|
||||
int nb = 1;
|
||||
if(!PyArg_ParseTuple(args, "(fff)|i:vector", &x, &y, &z, &nb))
|
||||
if (!PyArg_ParseTuple(args, "(fff)|i:vector", &x, &y, &z, &nb))
|
||||
return NULL;
|
||||
noise_vector(x, y, z, nb, v);
|
||||
return Py_BuildValue("[fff]", v[0], v[1], v[2]);
|
||||
@ -292,15 +292,15 @@ static float turb(float x, float y, float z, int oct, int hard, int nb,
|
||||
int i;
|
||||
amp = 1.f;
|
||||
out = (float)(2.0f * BLI_gNoise(1.f, x, y, z, 0, nb) - 1.0f);
|
||||
if(hard)
|
||||
if (hard)
|
||||
out = (float)fabs(out);
|
||||
for(i = 1; i < oct; i++) {
|
||||
for (i = 1; i < oct; i++) {
|
||||
amp *= ampscale;
|
||||
x *= freqscale;
|
||||
y *= freqscale;
|
||||
z *= freqscale;
|
||||
t = (float)(amp * (2.0f * BLI_gNoise(1.f, x, y, z, 0, nb) - 1.0f));
|
||||
if(hard)
|
||||
if (hard)
|
||||
t = (float)fabs(t);
|
||||
out += t;
|
||||
}
|
||||
@ -312,7 +312,7 @@ static PyObject *Noise_turbulence(PyObject *UNUSED(self), PyObject *args)
|
||||
float x, y, z;
|
||||
int oct, hd, nb = 1;
|
||||
float as = 0.5, fs = 2.0;
|
||||
if(!PyArg_ParseTuple(args, "(fff)ii|iff:turbulence", &x, &y, &z, &oct, &hd, &nb, &as, &fs))
|
||||
if (!PyArg_ParseTuple(args, "(fff)ii|iff:turbulence", &x, &y, &z, &oct, &hd, &nb, &as, &fs))
|
||||
return NULL;
|
||||
|
||||
return PyFloat_FromDouble(turb(x, y, z, oct, hd, nb, as, fs));
|
||||
@ -329,18 +329,18 @@ static void vTurb(float x, float y, float z, int oct, int hard, int nb,
|
||||
int i;
|
||||
amp = 1.f;
|
||||
noise_vector(x, y, z, nb, v);
|
||||
if(hard) {
|
||||
if (hard) {
|
||||
v[0] = (float)fabs(v[0]);
|
||||
v[1] = (float)fabs(v[1]);
|
||||
v[2] = (float)fabs(v[2]);
|
||||
}
|
||||
for(i = 1; i < oct; i++) {
|
||||
for (i = 1; i < oct; i++) {
|
||||
amp *= ampscale;
|
||||
x *= freqscale;
|
||||
y *= freqscale;
|
||||
z *= freqscale;
|
||||
noise_vector(x, y, z, nb, t);
|
||||
if(hard) {
|
||||
if (hard) {
|
||||
t[0] = (float)fabs(t[0]);
|
||||
t[1] = (float)fabs(t[1]);
|
||||
t[2] = (float)fabs(t[2]);
|
||||
@ -356,7 +356,7 @@ static PyObject *Noise_turbulence_vector(PyObject *UNUSED(self), PyObject *args)
|
||||
float x, y, z, v[3];
|
||||
int oct, hd, nb = 1;
|
||||
float as = 0.5, fs = 2.0;
|
||||
if(!PyArg_ParseTuple(args, "(fff)ii|iff:turbulence_vector", &x, &y, &z, &oct, &hd, &nb, &as, &fs))
|
||||
if (!PyArg_ParseTuple(args, "(fff)ii|iff:turbulence_vector", &x, &y, &z, &oct, &hd, &nb, &as, &fs))
|
||||
return NULL;
|
||||
vTurb(x, y, z, oct, hd, nb, as, fs, v);
|
||||
return Py_BuildValue("[fff]", v[0], v[1], v[2]);
|
||||
@ -370,7 +370,7 @@ static PyObject *Noise_fractal(PyObject *UNUSED(self), PyObject *args)
|
||||
{
|
||||
float x, y, z, H, lac, oct;
|
||||
int nb = 1;
|
||||
if(!PyArg_ParseTuple(args, "(fff)fff|i:fractal", &x, &y, &z, &H, &lac, &oct, &nb))
|
||||
if (!PyArg_ParseTuple(args, "(fff)fff|i:fractal", &x, &y, &z, &H, &lac, &oct, &nb))
|
||||
return NULL;
|
||||
return PyFloat_FromDouble(mg_fBm(x, y, z, H, lac, oct, nb));
|
||||
}
|
||||
@ -381,7 +381,7 @@ static PyObject *Noise_multi_fractal(PyObject *UNUSED(self), PyObject *args)
|
||||
{
|
||||
float x, y, z, H, lac, oct;
|
||||
int nb = 1;
|
||||
if(!PyArg_ParseTuple(args, "(fff)fff|i:multi_fractal", &x, &y, &z, &H, &lac, &oct, &nb))
|
||||
if (!PyArg_ParseTuple(args, "(fff)fff|i:multi_fractal", &x, &y, &z, &H, &lac, &oct, &nb))
|
||||
return NULL;
|
||||
|
||||
return PyFloat_FromDouble(mg_MultiFractal(x, y, z, H, lac, oct, nb));
|
||||
@ -393,7 +393,7 @@ static PyObject *Noise_vl_vector(PyObject *UNUSED(self), PyObject *args)
|
||||
{
|
||||
float x, y, z, d;
|
||||
int nt1 = 1, nt2 = 1;
|
||||
if(!PyArg_ParseTuple(args, "(fff)f|ii:vl_vector", &x, &y, &z, &d, &nt1, &nt2))
|
||||
if (!PyArg_ParseTuple(args, "(fff)f|ii:vl_vector", &x, &y, &z, &d, &nt1, &nt2))
|
||||
return NULL;
|
||||
return PyFloat_FromDouble(mg_VLNoise(x, y, z, d, nt1, nt2));
|
||||
}
|
||||
@ -404,7 +404,7 @@ static PyObject *Noise_hetero_terrain(PyObject *UNUSED(self), PyObject *args)
|
||||
{
|
||||
float x, y, z, H, lac, oct, ofs;
|
||||
int nb = 1;
|
||||
if(!PyArg_ParseTuple(args, "(fff)ffff|i:hetero_terrain", &x, &y, &z, &H, &lac, &oct, &ofs, &nb))
|
||||
if (!PyArg_ParseTuple(args, "(fff)ffff|i:hetero_terrain", &x, &y, &z, &H, &lac, &oct, &ofs, &nb))
|
||||
return NULL;
|
||||
|
||||
return PyFloat_FromDouble(mg_HeteroTerrain(x, y, z, H, lac, oct, ofs, nb));
|
||||
@ -416,7 +416,7 @@ static PyObject *Noise_hybrid_multi_fractal(PyObject *UNUSED(self), PyObject *ar
|
||||
{
|
||||
float x, y, z, H, lac, oct, ofs, gn;
|
||||
int nb = 1;
|
||||
if(!PyArg_ParseTuple(args, "(fff)fffff|i:hybrid_multi_fractal", &x, &y, &z, &H, &lac, &oct, &ofs, &gn, &nb))
|
||||
if (!PyArg_ParseTuple(args, "(fff)fffff|i:hybrid_multi_fractal", &x, &y, &z, &H, &lac, &oct, &ofs, &gn, &nb))
|
||||
return NULL;
|
||||
|
||||
return PyFloat_FromDouble(mg_HybridMultiFractal(x, y, z, H, lac, oct, ofs, gn, nb));
|
||||
@ -428,7 +428,7 @@ static PyObject *Noise_ridged_multi_fractal(PyObject *UNUSED(self), PyObject *ar
|
||||
{
|
||||
float x, y, z, H, lac, oct, ofs, gn;
|
||||
int nb = 1;
|
||||
if(!PyArg_ParseTuple(args, "(fff)fffff|i:ridged_multi_fractal", &x, &y, &z, &H, &lac, &oct, &ofs, &gn, &nb))
|
||||
if (!PyArg_ParseTuple(args, "(fff)fffff|i:ridged_multi_fractal", &x, &y, &z, &H, &lac, &oct, &ofs, &gn, &nb))
|
||||
return NULL;
|
||||
return PyFloat_FromDouble(mg_RidgedMultiFractal(x, y, z, H, lac, oct, ofs, gn, nb));
|
||||
}
|
||||
@ -440,7 +440,7 @@ static PyObject *Noise_voronoi(PyObject *UNUSED(self), PyObject *args)
|
||||
float x, y, z, da[4], pa[12];
|
||||
int dtype = 0;
|
||||
float me = 2.5; /* default minkovsky exponent */
|
||||
if(!PyArg_ParseTuple(args, "(fff)|if:voronoi", &x, &y, &z, &dtype, &me))
|
||||
if (!PyArg_ParseTuple(args, "(fff)|if:voronoi", &x, &y, &z, &dtype, &me))
|
||||
return NULL;
|
||||
voronoi(x, y, z, da, pa, me, dtype);
|
||||
return Py_BuildValue("[[ffff][[fff][fff][fff][fff]]]",
|
||||
@ -455,7 +455,7 @@ static PyObject *Noise_voronoi(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *Noise_cell(PyObject *UNUSED(self), PyObject *args)
|
||||
{
|
||||
float x, y, z;
|
||||
if(!PyArg_ParseTuple(args, "(fff):cell", &x, &y, &z))
|
||||
if (!PyArg_ParseTuple(args, "(fff):cell", &x, &y, &z))
|
||||
return NULL;
|
||||
|
||||
return PyFloat_FromDouble(cellNoise(x, y, z));
|
||||
@ -466,7 +466,7 @@ static PyObject *Noise_cell(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *Noise_cell_vector(PyObject *UNUSED(self), PyObject *args)
|
||||
{
|
||||
float x, y, z, ca[3];
|
||||
if(!PyArg_ParseTuple(args, "(fff):cell_vector", &x, &y, &z))
|
||||
if (!PyArg_ParseTuple(args, "(fff):cell_vector", &x, &y, &z))
|
||||
return NULL;
|
||||
cellNoiseV(x, y, z, ca);
|
||||
return Py_BuildValue("[fff]", ca[0], ca[1], ca[2]);
|
||||
@ -698,7 +698,7 @@ PyObject *BPyInit_noise(void)
|
||||
setRndSeed(0);
|
||||
|
||||
/* Constant noisetype dictionary */
|
||||
if(submodule) {
|
||||
if (submodule) {
|
||||
static PyStructSequence_Field noise_types_fields[] = {
|
||||
{(char *)"BLENDER", NULL},
|
||||
{(char *)"STDPERLIN", NULL},
|
||||
@ -747,7 +747,7 @@ PyObject *BPyInit_noise(void)
|
||||
PyModule_AddObject(submodule, "types", noise_types);
|
||||
}
|
||||
|
||||
if(submodule) {
|
||||
if (submodule) {
|
||||
static PyStructSequence_Field distance_metrics_fields[] = {
|
||||
{(char *)"DISTANCE", NULL},
|
||||
{(char *)"DISTANCE_SQUARED", NULL},
|
||||
|
@ -43,13 +43,13 @@ int PyC_AsArray(void *array, PyObject *value, const int length, const PyTypeObje
|
||||
int value_len;
|
||||
int i;
|
||||
|
||||
if(!(value_fast=PySequence_Fast(value, error_prefix))) {
|
||||
if (!(value_fast=PySequence_Fast(value, error_prefix))) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
value_len= PySequence_Fast_GET_SIZE(value_fast);
|
||||
|
||||
if(value_len != length) {
|
||||
if (value_len != length) {
|
||||
Py_DECREF(value);
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s: invalid sequence length. expected %d, got %d",
|
||||
@ -58,30 +58,30 @@ int PyC_AsArray(void *array, PyObject *value, const int length, const PyTypeObje
|
||||
}
|
||||
|
||||
/* for each type */
|
||||
if(type == &PyFloat_Type) {
|
||||
if(is_double) {
|
||||
if (type == &PyFloat_Type) {
|
||||
if (is_double) {
|
||||
double *array_double= array;
|
||||
for(i=0; i<length; i++) {
|
||||
for (i=0; i<length; i++) {
|
||||
array_double[i]= PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value_fast, i));
|
||||
}
|
||||
}
|
||||
else {
|
||||
float *array_float= array;
|
||||
for(i=0; i<length; i++) {
|
||||
for (i=0; i<length; i++) {
|
||||
array_float[i]= PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value_fast, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(type == &PyLong_Type) {
|
||||
else if (type == &PyLong_Type) {
|
||||
/* could use is_double for 'long int' but no use now */
|
||||
int *array_int= array;
|
||||
for(i=0; i<length; i++) {
|
||||
for (i=0; i<length; i++) {
|
||||
array_int[i]= PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value_fast, i));
|
||||
}
|
||||
}
|
||||
else if(type == &PyBool_Type) {
|
||||
else if (type == &PyBool_Type) {
|
||||
int *array_bool= array;
|
||||
for(i=0; i<length; i++) {
|
||||
for (i=0; i<length; i++) {
|
||||
array_bool[i]= (PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value_fast, i)) != 0);
|
||||
}
|
||||
}
|
||||
@ -95,7 +95,7 @@ int PyC_AsArray(void *array, PyObject *value, const int length, const PyTypeObje
|
||||
|
||||
Py_DECREF(value_fast);
|
||||
|
||||
if(PyErr_Occurred()) {
|
||||
if (PyErr_Occurred()) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%s: one or more items could not be used as a %s",
|
||||
error_prefix, type->tp_name);
|
||||
@ -119,7 +119,7 @@ void PyC_ObSpit(const char *name, PyObject *var)
|
||||
fprintf(stderr, " ptr:%p", (void *)var);
|
||||
|
||||
fprintf(stderr, " type:");
|
||||
if(Py_TYPE(var))
|
||||
if (Py_TYPE(var))
|
||||
fprintf(stderr, "%s", Py_TYPE(var)->tp_name);
|
||||
else
|
||||
fprintf(stderr, "<NIL>");
|
||||
@ -134,7 +134,7 @@ void PyC_LineSpit(void)
|
||||
int lineno;
|
||||
|
||||
/* Note, allow calling from outside python (RNA) */
|
||||
if(!PYC_INTERPRETER_ACTIVE) {
|
||||
if (!PYC_INTERPRETER_ACTIVE) {
|
||||
fprintf(stderr, "python line lookup failed, interpreter inactive\n");
|
||||
return;
|
||||
}
|
||||
@ -162,18 +162,18 @@ void PyC_FileAndNum(const char **filename, int *lineno)
|
||||
}
|
||||
|
||||
/* when executing a module */
|
||||
if(filename && *filename == NULL) {
|
||||
if (filename && *filename == NULL) {
|
||||
/* try an alternative method to get the filename - module based
|
||||
* references below are all borrowed (double checked) */
|
||||
PyObject *mod_name= PyDict_GetItemString(PyEval_GetGlobals(), "__name__");
|
||||
if(mod_name) {
|
||||
if (mod_name) {
|
||||
PyObject *mod= PyDict_GetItem(PyImport_GetModuleDict(), mod_name);
|
||||
if(mod) {
|
||||
if (mod) {
|
||||
*filename= PyModule_GetFilename(mod);
|
||||
}
|
||||
|
||||
/* unlikely, fallback */
|
||||
if(*filename == NULL) {
|
||||
if (*filename == NULL) {
|
||||
*filename= _PyUnicode_AsString(mod_name);
|
||||
}
|
||||
}
|
||||
@ -225,7 +225,7 @@ PyObject *PyC_Err_Format_Prefix(PyObject *exception_type_prefix, const char *for
|
||||
error_value_prefix= PyUnicode_FromFormatV(format, args); /* can fail and be NULL */
|
||||
va_end(args);
|
||||
|
||||
if(PyErr_Occurred()) {
|
||||
if (PyErr_Occurred()) {
|
||||
PyObject *error_type, *error_value, *error_traceback;
|
||||
PyErr_Fetch(&error_type, &error_value, &error_traceback);
|
||||
PyErr_Format(exception_type_prefix,
|
||||
@ -259,7 +259,7 @@ PyObject *PyC_ExceptionBuffer(void)
|
||||
PyObject *format_tb_func= NULL;
|
||||
PyObject *ret= NULL;
|
||||
|
||||
if(! (traceback_mod= PyImport_ImportModule("traceback")) ) {
|
||||
if (! (traceback_mod= PyImport_ImportModule("traceback")) ) {
|
||||
goto error_cleanup;
|
||||
}
|
||||
else if (! (format_tb_func= PyObject_GetAttrString(traceback_mod, "format_exc"))) {
|
||||
@ -268,7 +268,7 @@ PyObject *PyC_ExceptionBuffer(void)
|
||||
|
||||
ret= PyObject_CallObject(format_tb_func, NULL);
|
||||
|
||||
if(ret == Py_None) {
|
||||
if (ret == Py_None) {
|
||||
Py_DECREF(ret);
|
||||
ret= NULL;
|
||||
}
|
||||
@ -303,7 +303,7 @@ PyObject *PyC_ExceptionBuffer(void)
|
||||
* string_io = io.StringIO()
|
||||
*/
|
||||
|
||||
if(! (string_io_mod= PyImport_ImportModule("io")) ) {
|
||||
if (! (string_io_mod= PyImport_ImportModule("io")) ) {
|
||||
goto error_cleanup;
|
||||
}
|
||||
else if (! (string_io = PyObject_CallMethod(string_io_mod, (char *)"StringIO", NULL))) {
|
||||
@ -360,7 +360,7 @@ const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce)
|
||||
|
||||
result= _PyUnicode_AsString(py_str);
|
||||
|
||||
if(result) {
|
||||
if (result) {
|
||||
/* 99% of the time this is enough but we better support non unicode
|
||||
* chars since blender doesnt limit this */
|
||||
return result;
|
||||
@ -368,7 +368,7 @@ const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce)
|
||||
else {
|
||||
PyErr_Clear();
|
||||
|
||||
if(PyBytes_Check(py_str)) {
|
||||
if (PyBytes_Check(py_str)) {
|
||||
return PyBytes_AS_STRING(py_str);
|
||||
}
|
||||
else {
|
||||
@ -380,7 +380,7 @@ const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce)
|
||||
PyObject *PyC_UnicodeFromByte(const char *str)
|
||||
{
|
||||
PyObject *result= PyUnicode_FromString(str);
|
||||
if(result) {
|
||||
if (result) {
|
||||
/* 99% of the time this is enough but we better support non unicode
|
||||
* chars since blender doesnt limit this */
|
||||
return result;
|
||||
@ -412,7 +412,7 @@ PyObject *PyC_DefaultNameSpace(const char *filename)
|
||||
PyDict_SetItemString(interp->modules, "__main__", mod_main);
|
||||
Py_DECREF(mod_main); /* sys.modules owns now */
|
||||
PyModule_AddStringConstant(mod_main, "__name__", "__main__");
|
||||
if(filename)
|
||||
if (filename)
|
||||
PyModule_AddStringConstant(mod_main, "__file__", filename); /* __file__ only for nice UI'ness */
|
||||
PyModule_AddObject(mod_main, "__builtins__", interp->builtins);
|
||||
Py_INCREF(interp->builtins); /* AddObject steals a reference */
|
||||
@ -437,7 +437,7 @@ void PyC_MainModule_Restore(PyObject *main_mod)
|
||||
/* must be called before Py_Initialize, expects output of BLI_get_folder(BLENDER_PYTHON, NULL) */
|
||||
void PyC_SetHomePath(const char *py_path_bundle)
|
||||
{
|
||||
if(py_path_bundle==NULL) {
|
||||
if (py_path_bundle==NULL) {
|
||||
/* Common enough to have bundled *nix python but complain on OSX/Win */
|
||||
#if defined(__APPLE__) || defined(_WIN32)
|
||||
fprintf(stderr, "Warning! bundled python not found and is expected on this platform. (if you built with CMake: 'install' target may have not been built)\n");
|
||||
@ -450,7 +450,7 @@ void PyC_SetHomePath(const char *py_path_bundle)
|
||||
#ifdef __APPLE__
|
||||
/* OSX allow file/directory names to contain : character (represented as / in the Finder)
|
||||
but current Python lib (release 3.1.1) doesn't handle these correctly */
|
||||
if(strchr(py_path_bundle, ':'))
|
||||
if (strchr(py_path_bundle, ':'))
|
||||
printf("Warning : Blender application is located in a path containing : or / chars\
|
||||
\nThis may make python import function fail\n");
|
||||
#endif
|
||||
@ -481,7 +481,7 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
|
||||
{
|
||||
FILE *fp= fopen(filepath, "r");
|
||||
|
||||
if(fp) {
|
||||
if (fp) {
|
||||
PyGILState_STATE gilstate= PyGILState_Ensure();
|
||||
|
||||
va_list vargs;
|
||||
@ -508,13 +508,13 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
|
||||
|
||||
ret= PyObject_CallFunction(calcsize, (char *)"s", format);
|
||||
|
||||
if(ret) {
|
||||
if (ret) {
|
||||
sizes[i]= PyLong_AsSsize_t(ret);
|
||||
Py_DECREF(ret);
|
||||
ret = PyObject_CallFunction(unpack, (char *)"sy#", format, (char *)ptr, sizes[i]);
|
||||
}
|
||||
|
||||
if(ret == NULL) {
|
||||
if (ret == NULL) {
|
||||
printf("PyC_InlineRun error, line:%d\n", __LINE__);
|
||||
PyErr_Print();
|
||||
PyErr_Clear();
|
||||
@ -525,7 +525,7 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
|
||||
sizes[i]= 0;
|
||||
}
|
||||
else {
|
||||
if(PyTuple_GET_SIZE(ret) == 1) {
|
||||
if (PyTuple_GET_SIZE(ret) == 1) {
|
||||
/* convenience, convert single tuples into single values */
|
||||
PyObject *tmp= PyTuple_GET_ITEM(ret, 0);
|
||||
Py_INCREF(tmp);
|
||||
@ -545,13 +545,13 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
|
||||
|
||||
fclose(fp);
|
||||
|
||||
if(py_result) {
|
||||
if (py_result) {
|
||||
|
||||
/* we could skip this but then only slice assignment would work
|
||||
* better not be so strict */
|
||||
values= PyDict_GetItemString(py_dict, "values");
|
||||
|
||||
if(values && PyList_Check(values)) {
|
||||
if (values && PyList_Check(values)) {
|
||||
|
||||
/* dont use the result */
|
||||
Py_DECREF(py_result);
|
||||
@ -567,10 +567,10 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
|
||||
PyObject *item_new;
|
||||
/* prepend the string formatting and remake the tuple */
|
||||
item= PyList_GET_ITEM(values, i);
|
||||
if(PyTuple_CheckExact(item)) {
|
||||
if (PyTuple_CheckExact(item)) {
|
||||
int ofs= PyTuple_GET_SIZE(item);
|
||||
item_new= PyTuple_New(ofs + 1);
|
||||
while(ofs--) {
|
||||
while (ofs--) {
|
||||
PyObject *member= PyTuple_GET_ITEM(item, ofs);
|
||||
PyTuple_SET_ITEM(item_new, ofs + 1, member);
|
||||
Py_INCREF(member);
|
||||
@ -584,7 +584,7 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
|
||||
|
||||
ret = PyObject_Call(pack, item_new, NULL);
|
||||
|
||||
if(ret) {
|
||||
if (ret) {
|
||||
/* copy the bytes back into memory */
|
||||
memcpy(ptr, PyBytes_AS_STRING(ret), sizes[i]);
|
||||
Py_DECREF(ret);
|
||||
|
@ -109,7 +109,7 @@ static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObjec
|
||||
|
||||
list= PyList_New(0);
|
||||
|
||||
for(BLI_bpathIterator_init(&bpi, G.main, G.main->name, 0); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) {
|
||||
for (BLI_bpathIterator_init(&bpi, G.main, G.main->name, 0); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) {
|
||||
/* build the list */
|
||||
if (absolute) {
|
||||
BLI_bpathIterator_getPathExpanded(bpi, filepath_expanded);
|
||||
@ -149,10 +149,10 @@ static PyObject *bpy_user_resource(PyObject *UNUSED(self), PyObject *args, PyObj
|
||||
return NULL;
|
||||
|
||||
/* stupid string compare */
|
||||
if (!strcmp(type, "DATAFILES")) folder_id= BLENDER_USER_DATAFILES;
|
||||
else if(!strcmp(type, "CONFIG")) folder_id= BLENDER_USER_CONFIG;
|
||||
else if(!strcmp(type, "SCRIPTS")) folder_id= BLENDER_USER_SCRIPTS;
|
||||
else if(!strcmp(type, "AUTOSAVE")) folder_id= BLENDER_USER_AUTOSAVE;
|
||||
if (!strcmp(type, "DATAFILES")) folder_id= BLENDER_USER_DATAFILES;
|
||||
else if (!strcmp(type, "CONFIG")) folder_id= BLENDER_USER_CONFIG;
|
||||
else if (!strcmp(type, "SCRIPTS")) folder_id= BLENDER_USER_SCRIPTS;
|
||||
else if (!strcmp(type, "AUTOSAVE")) folder_id= BLENDER_USER_AUTOSAVE;
|
||||
else {
|
||||
PyErr_SetString(PyExc_ValueError, "invalid resource argument");
|
||||
return NULL;
|
||||
@ -193,9 +193,9 @@ static PyObject *bpy_resource_path(PyObject *UNUSED(self), PyObject *args, PyObj
|
||||
return NULL;
|
||||
|
||||
/* stupid string compare */
|
||||
if (!strcmp(type, "USER")) folder_id= BLENDER_RESOURCE_PATH_USER;
|
||||
else if(!strcmp(type, "LOCAL")) folder_id= BLENDER_RESOURCE_PATH_LOCAL;
|
||||
else if(!strcmp(type, "SYSTEM")) folder_id= BLENDER_RESOURCE_PATH_SYSTEM;
|
||||
if (!strcmp(type, "USER")) folder_id= BLENDER_RESOURCE_PATH_USER;
|
||||
else if (!strcmp(type, "LOCAL")) folder_id= BLENDER_RESOURCE_PATH_LOCAL;
|
||||
else if (!strcmp(type, "SYSTEM")) folder_id= BLENDER_RESOURCE_PATH_SYSTEM;
|
||||
else {
|
||||
PyErr_SetString(PyExc_ValueError, "invalid resource argument");
|
||||
return NULL;
|
||||
@ -215,7 +215,7 @@ static PyMethodDef meth_bpy_resource_path= {"resource_path", (PyCFunction)bpy_re
|
||||
static PyObject *bpy_import_test(const char *modname)
|
||||
{
|
||||
PyObject *mod= PyImport_ImportModuleLevel((char *)modname, NULL, NULL, NULL, 0);
|
||||
if(mod) {
|
||||
if (mod) {
|
||||
Py_DECREF(mod);
|
||||
}
|
||||
else {
|
||||
@ -238,7 +238,7 @@ void BPy_init_modules(void)
|
||||
|
||||
/* Needs to be first since this dir is needed for future modules */
|
||||
char *modpath= BLI_get_folder(BLENDER_SYSTEM_SCRIPTS, "modules");
|
||||
if(modpath) {
|
||||
if (modpath) {
|
||||
// printf("bpy: found module path '%s'.\n", modpath);
|
||||
PyObject *sys_path= PySys_GetObject("path"); /* borrow */
|
||||
PyObject *py_modpath= PyUnicode_FromString(modpath);
|
||||
|
@ -168,13 +168,13 @@ static int bpy_app_debug_set(PyObject *UNUSED(self), PyObject *value, void *UNUS
|
||||
{
|
||||
int param= PyObject_IsTrue(value);
|
||||
|
||||
if(param < 0) {
|
||||
if (param < 0) {
|
||||
PyErr_SetString(PyExc_TypeError, "bpy.app.debug can only be True/False");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(param) G.f |= G_DEBUG;
|
||||
else G.f &= ~G_DEBUG;
|
||||
if (param) G.f |= G_DEBUG;
|
||||
else G.f &= ~G_DEBUG;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -230,7 +230,7 @@ static void py_struct_seq_getset_init(void)
|
||||
/* tricky dynamic members, not to py-spec! */
|
||||
PyGetSetDef *getset;
|
||||
|
||||
for(getset= bpy_app_getsets; getset->name; getset++) {
|
||||
for (getset= bpy_app_getsets; getset->name; getset++) {
|
||||
PyDict_SetItemString(BlenderAppType.tp_dict, getset->name, PyDescr_NewGetSet(&BlenderAppType, getset));
|
||||
}
|
||||
}
|
||||
|
@ -77,13 +77,13 @@ static PyObject *make_app_cb_info(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for(pos= 0; pos < BLI_CB_EVT_TOT; pos++) {
|
||||
if(app_cb_info_fields[pos].name == NULL) {
|
||||
for (pos= 0; pos < BLI_CB_EVT_TOT; pos++) {
|
||||
if (app_cb_info_fields[pos].name == NULL) {
|
||||
Py_FatalError("invalid callback slots 1");
|
||||
}
|
||||
PyStructSequence_SET_ITEM(app_cb_info, pos, (py_cb_array[pos]= PyList_New(0)));
|
||||
}
|
||||
if(app_cb_info_fields[pos].name != NULL) {
|
||||
if (app_cb_info_fields[pos].name != NULL) {
|
||||
Py_FatalError("invalid callback slots 2");
|
||||
}
|
||||
|
||||
@ -103,12 +103,12 @@ PyObject *BPY_app_handlers_struct(void)
|
||||
BlenderAppCbType.tp_new= NULL;
|
||||
|
||||
/* assign the C callbacks */
|
||||
if(ret) {
|
||||
if (ret) {
|
||||
static bCallbackFuncStore funcstore_array[BLI_CB_EVT_TOT]= {{NULL}};
|
||||
bCallbackFuncStore *funcstore;
|
||||
int pos= 0;
|
||||
|
||||
for(pos= 0; pos < BLI_CB_EVT_TOT; pos++) {
|
||||
for (pos= 0; pos < BLI_CB_EVT_TOT; pos++) {
|
||||
funcstore= &funcstore_array[pos];
|
||||
funcstore->func= bpy_app_generic_callback;
|
||||
funcstore->alloc= 0;
|
||||
@ -124,7 +124,7 @@ void BPY_app_handlers_reset(void)
|
||||
{
|
||||
int pos= 0;
|
||||
|
||||
for(pos= 0; pos < BLI_CB_EVT_TOT; pos++) {
|
||||
for (pos= 0; pos < BLI_CB_EVT_TOT; pos++) {
|
||||
PyList_SetSlice(py_cb_array[pos], 0, PY_SSIZE_T_MAX, NULL);
|
||||
}
|
||||
}
|
||||
@ -134,7 +134,7 @@ void bpy_app_generic_callback(struct Main *UNUSED(main), struct ID *id, void *ar
|
||||
{
|
||||
PyObject *cb_list= py_cb_array[GET_INT_FROM_POINTER(arg)];
|
||||
Py_ssize_t cb_list_len;
|
||||
if((cb_list_len= PyList_GET_SIZE(cb_list)) > 0) {
|
||||
if ((cb_list_len= PyList_GET_SIZE(cb_list)) > 0) {
|
||||
PyGILState_STATE gilstate= PyGILState_Ensure();
|
||||
|
||||
PyObject* args= PyTuple_New(1); // save python creating each call
|
||||
@ -143,7 +143,7 @@ void bpy_app_generic_callback(struct Main *UNUSED(main), struct ID *id, void *ar
|
||||
Py_ssize_t pos;
|
||||
|
||||
/* setup arguments */
|
||||
if(id) {
|
||||
if (id) {
|
||||
PointerRNA id_ptr;
|
||||
RNA_id_pointer_create(id, &id_ptr);
|
||||
PyTuple_SET_ITEM(args, 0, pyrna_struct_CreatePyObject(&id_ptr));
|
||||
|
@ -99,7 +99,7 @@ void BPY_driver_reset(void)
|
||||
PyGILState_STATE gilstate;
|
||||
int use_gil= 1; /* !PYC_INTERPRETER_ACTIVE; */
|
||||
|
||||
if(use_gil)
|
||||
if (use_gil)
|
||||
gilstate= PyGILState_Ensure();
|
||||
|
||||
if (bpy_pydriver_Dict) { /* free the global dict used by pydrivers */
|
||||
@ -108,7 +108,7 @@ void BPY_driver_reset(void)
|
||||
bpy_pydriver_Dict= NULL;
|
||||
}
|
||||
|
||||
if(use_gil)
|
||||
if (use_gil)
|
||||
PyGILState_Release(gilstate);
|
||||
|
||||
return;
|
||||
@ -157,14 +157,14 @@ float BPY_driver_exec(ChannelDriver *driver)
|
||||
if ((expr == NULL) || (expr[0]=='\0'))
|
||||
return 0.0f;
|
||||
|
||||
if(!(G.f & G_SCRIPT_AUTOEXEC)) {
|
||||
if (!(G.f & G_SCRIPT_AUTOEXEC)) {
|
||||
printf("skipping driver '%s', automatic scripts are disabled\n", driver->expression);
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
use_gil= 1; /* !PYC_INTERPRETER_ACTIVE; */
|
||||
|
||||
if(use_gil)
|
||||
if (use_gil)
|
||||
gilstate= PyGILState_Ensure();
|
||||
|
||||
/* needed since drivers are updated directly after undo where 'main' is
|
||||
@ -175,17 +175,17 @@ float BPY_driver_exec(ChannelDriver *driver)
|
||||
if (!bpy_pydriver_Dict) {
|
||||
if (bpy_pydriver_create_dict() != 0) {
|
||||
fprintf(stderr, "Pydriver error: couldn't create Python dictionary");
|
||||
if(use_gil)
|
||||
if (use_gil)
|
||||
PyGILState_Release(gilstate);
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
if(driver->expr_comp==NULL)
|
||||
if (driver->expr_comp==NULL)
|
||||
driver->flag |= DRIVER_FLAG_RECOMPILE;
|
||||
|
||||
/* compile the expression first if it hasn't been compiled or needs to be rebuilt */
|
||||
if(driver->flag & DRIVER_FLAG_RECOMPILE) {
|
||||
if (driver->flag & DRIVER_FLAG_RECOMPILE) {
|
||||
Py_XDECREF(driver->expr_comp);
|
||||
driver->expr_comp= PyTuple_New(2);
|
||||
|
||||
@ -199,7 +199,7 @@ float BPY_driver_exec(ChannelDriver *driver)
|
||||
expr_code= PyTuple_GET_ITEM(((PyObject *)driver->expr_comp), 0);
|
||||
}
|
||||
|
||||
if(driver->flag & DRIVER_FLAG_RENAMEVAR) {
|
||||
if (driver->flag & DRIVER_FLAG_RENAMEVAR) {
|
||||
/* may not be set */
|
||||
expr_vars= PyTuple_GET_ITEM(((PyObject *)driver->expr_comp), 1);
|
||||
Py_XDECREF(expr_vars);
|
||||
@ -260,7 +260,7 @@ float BPY_driver_exec(ChannelDriver *driver)
|
||||
if (retval == NULL) {
|
||||
pydriver_error(driver);
|
||||
}
|
||||
else if((result= PyFloat_AsDouble(retval)) == -1.0 && PyErr_Occurred()) {
|
||||
else if ((result= PyFloat_AsDouble(retval)) == -1.0 && PyErr_Occurred()) {
|
||||
pydriver_error(driver);
|
||||
Py_DECREF(retval);
|
||||
result= 0.0;
|
||||
@ -271,10 +271,10 @@ float BPY_driver_exec(ChannelDriver *driver)
|
||||
Py_DECREF(retval);
|
||||
}
|
||||
|
||||
if(use_gil)
|
||||
if (use_gil)
|
||||
PyGILState_Release(gilstate);
|
||||
|
||||
if(finite(result)) {
|
||||
if (finite(result)) {
|
||||
return (float)result;
|
||||
}
|
||||
else {
|
||||
|
@ -100,14 +100,14 @@ void bpy_context_set(bContext *C, PyGILState_STATE *gilstate)
|
||||
{
|
||||
py_call_level++;
|
||||
|
||||
if(gilstate)
|
||||
if (gilstate)
|
||||
*gilstate= PyGILState_Ensure();
|
||||
|
||||
if(py_call_level==1) {
|
||||
if (py_call_level==1) {
|
||||
bpy_context_update(C);
|
||||
|
||||
#ifdef TIME_PY_RUN
|
||||
if(bpy_timer_count==0) {
|
||||
if (bpy_timer_count==0) {
|
||||
/* record time from the beginning */
|
||||
bpy_timer= PIL_check_seconds_timer();
|
||||
bpy_timer_run= bpy_timer_run_tot= 0.0;
|
||||
@ -125,13 +125,13 @@ void bpy_context_clear(bContext *UNUSED(C), PyGILState_STATE *gilstate)
|
||||
{
|
||||
py_call_level--;
|
||||
|
||||
if(gilstate)
|
||||
if (gilstate)
|
||||
PyGILState_Release(*gilstate);
|
||||
|
||||
if(py_call_level < 0) {
|
||||
if (py_call_level < 0) {
|
||||
fprintf(stderr, "ERROR: Python context internal state bug. this should not happen!\n");
|
||||
}
|
||||
else if(py_call_level==0) {
|
||||
else if (py_call_level==0) {
|
||||
// XXX - Calling classes currently wont store the context :\, cant set NULL because of this. but this is very flakey still.
|
||||
//BPy_SetContext(NULL);
|
||||
//bpy_import_main_set(NULL);
|
||||
@ -146,7 +146,7 @@ void bpy_context_clear(bContext *UNUSED(C), PyGILState_STATE *gilstate)
|
||||
|
||||
void BPY_text_free_code(Text *text)
|
||||
{
|
||||
if(text->compiled) {
|
||||
if (text->compiled) {
|
||||
Py_DECREF((PyObject *)text->compiled);
|
||||
text->compiled= NULL;
|
||||
}
|
||||
@ -273,10 +273,10 @@ void BPY_python_end(void)
|
||||
printf("*bpy stats* - ");
|
||||
printf("tot exec: %d, ", bpy_timer_count);
|
||||
printf("tot run: %.4fsec, ", bpy_timer_run_tot);
|
||||
if(bpy_timer_count>0)
|
||||
if (bpy_timer_count>0)
|
||||
printf("average run: %.6fsec, ", (bpy_timer_run_tot/bpy_timer_count));
|
||||
|
||||
if(bpy_timer>0.0)
|
||||
if (bpy_timer>0.0)
|
||||
printf("tot usage %.4f%%", (bpy_timer_run_tot/bpy_timer)*100.0);
|
||||
|
||||
printf("\n");
|
||||
@ -292,7 +292,7 @@ static void python_script_error_jump_text(struct Text *text)
|
||||
int lineno;
|
||||
int offset;
|
||||
python_script_error_jump(text->id.name+2, &lineno, &offset);
|
||||
if(lineno != -1) {
|
||||
if (lineno != -1) {
|
||||
/* select the line with the error */
|
||||
txt_move_to(text, lineno - 1, INT_MAX, FALSE);
|
||||
txt_move_to(text, lineno - 1, offset, TRUE);
|
||||
@ -332,22 +332,22 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text, st
|
||||
char fn_dummy[FILE_MAXDIR];
|
||||
bpy_text_filename_get(fn_dummy, sizeof(fn_dummy), text);
|
||||
|
||||
if(text->compiled == NULL) { /* if it wasn't already compiled, do it now */
|
||||
if (text->compiled == NULL) { /* if it wasn't already compiled, do it now */
|
||||
char *buf= txt_to_buf(text);
|
||||
|
||||
text->compiled= Py_CompileString(buf, fn_dummy, Py_file_input);
|
||||
|
||||
MEM_freeN(buf);
|
||||
|
||||
if(PyErr_Occurred()) {
|
||||
if(do_jump) {
|
||||
if (PyErr_Occurred()) {
|
||||
if (do_jump) {
|
||||
python_script_error_jump_text(text);
|
||||
}
|
||||
BPY_text_free_code(text);
|
||||
}
|
||||
}
|
||||
|
||||
if(text->compiled) {
|
||||
if (text->compiled) {
|
||||
py_dict= PyC_DefaultNameSpace(fn_dummy);
|
||||
py_result= PyEval_EvalCode(text->compiled, py_dict, py_dict);
|
||||
}
|
||||
@ -356,7 +356,7 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text, st
|
||||
else {
|
||||
FILE *fp= fopen(fn, "r");
|
||||
|
||||
if(fp) {
|
||||
if (fp) {
|
||||
py_dict= PyC_DefaultNameSpace(fn);
|
||||
|
||||
#ifdef _WIN32
|
||||
@ -390,8 +390,8 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text, st
|
||||
}
|
||||
|
||||
if (!py_result) {
|
||||
if(text) {
|
||||
if(do_jump) {
|
||||
if (text) {
|
||||
if (do_jump) {
|
||||
python_script_error_jump_text(text);
|
||||
}
|
||||
}
|
||||
@ -401,7 +401,7 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text, st
|
||||
Py_DECREF(py_result);
|
||||
}
|
||||
|
||||
if(py_dict) {
|
||||
if (py_dict) {
|
||||
#ifdef PYMODULE_CLEAR_WORKAROUND
|
||||
PyModuleObject *mmod= (PyModuleObject *)PyDict_GetItemString(PyThreadState_GET()->interp->modules, "__main__");
|
||||
PyObject *dict_back= mmod->md_dict;
|
||||
@ -450,7 +450,7 @@ int BPY_button_exec(bContext *C, const char *expr, double *value, const short ve
|
||||
|
||||
if (!value || !expr) return -1;
|
||||
|
||||
if(expr[0]=='\0') {
|
||||
if (expr[0]=='\0') {
|
||||
*value= 0.0;
|
||||
return error_ret;
|
||||
}
|
||||
@ -479,13 +479,13 @@ int BPY_button_exec(bContext *C, const char *expr, double *value, const short ve
|
||||
else {
|
||||
double val;
|
||||
|
||||
if(PyTuple_Check(retval)) {
|
||||
if (PyTuple_Check(retval)) {
|
||||
/* Users my have typed in 10km, 2m
|
||||
* add up all values */
|
||||
int i;
|
||||
val= 0.0;
|
||||
|
||||
for(i=0; i<PyTuple_GET_SIZE(retval); i++) {
|
||||
for (i=0; i<PyTuple_GET_SIZE(retval); i++) {
|
||||
val+= PyFloat_AsDouble(PyTuple_GET_ITEM(retval, i));
|
||||
}
|
||||
}
|
||||
@ -494,7 +494,7 @@ int BPY_button_exec(bContext *C, const char *expr, double *value, const short ve
|
||||
}
|
||||
Py_DECREF(retval);
|
||||
|
||||
if(val==-1 && PyErr_Occurred()) {
|
||||
if (val==-1 && PyErr_Occurred()) {
|
||||
error_ret= -1;
|
||||
}
|
||||
else if (!finite(val)) {
|
||||
@ -505,8 +505,8 @@ int BPY_button_exec(bContext *C, const char *expr, double *value, const short ve
|
||||
}
|
||||
}
|
||||
|
||||
if(error_ret) {
|
||||
if(verbose) {
|
||||
if (error_ret) {
|
||||
if (verbose) {
|
||||
BPy_errors_to_report(CTX_wm_reports(C));
|
||||
}
|
||||
else {
|
||||
@ -531,7 +531,7 @@ int BPY_string_exec(bContext *C, const char *expr)
|
||||
|
||||
if (!expr) return -1;
|
||||
|
||||
if(expr[0]=='\0') {
|
||||
if (expr[0]=='\0') {
|
||||
return error_ret;
|
||||
}
|
||||
|
||||
@ -572,20 +572,20 @@ void BPY_modules_load_user(bContext *C)
|
||||
Text *text;
|
||||
|
||||
/* can happen on file load */
|
||||
if(bmain==NULL)
|
||||
if (bmain==NULL)
|
||||
return;
|
||||
|
||||
/* update pointers since this can run from a nested script
|
||||
* on file load */
|
||||
if(py_call_level) {
|
||||
if (py_call_level) {
|
||||
bpy_context_update(C);
|
||||
}
|
||||
|
||||
bpy_context_set(C, &gilstate);
|
||||
|
||||
for(text=CTX_data_main(C)->text.first; text; text= text->id.next) {
|
||||
if(text->flags & TXT_ISSCRIPT && BLI_testextensie(text->id.name+2, ".py")) {
|
||||
if(!(G.f & G_SCRIPT_AUTOEXEC)) {
|
||||
for (text=CTX_data_main(C)->text.first; text; text= text->id.next) {
|
||||
if (text->flags & TXT_ISSCRIPT && BLI_testextensie(text->id.name+2, ".py")) {
|
||||
if (!(G.f & G_SCRIPT_AUTOEXEC)) {
|
||||
printf("scripts disabled for \"%s\", skipping '%s'\n", bmain->name, text->id.name+2);
|
||||
}
|
||||
else {
|
||||
@ -611,13 +611,13 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
|
||||
PointerRNA *ptr= NULL;
|
||||
int done= 0;
|
||||
|
||||
if(item==NULL) {
|
||||
if (item==NULL) {
|
||||
/* pass */
|
||||
}
|
||||
else if(item==Py_None) {
|
||||
else if (item==Py_None) {
|
||||
/* pass */
|
||||
}
|
||||
else if(BPy_StructRNA_Check(item)) {
|
||||
else if (BPy_StructRNA_Check(item)) {
|
||||
ptr= &(((BPy_StructRNA *)item)->ptr);
|
||||
|
||||
//result->ptr= ((BPy_StructRNA *)item)->ptr;
|
||||
@ -633,10 +633,10 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
|
||||
else {
|
||||
int len= PySequence_Fast_GET_SIZE(seq_fast);
|
||||
int i;
|
||||
for(i= 0; i < len; i++) {
|
||||
for (i= 0; i < len; i++) {
|
||||
PyObject *list_item= PySequence_Fast_GET_ITEM(seq_fast, i);
|
||||
|
||||
if(BPy_StructRNA_Check(list_item)) {
|
||||
if (BPy_StructRNA_Check(list_item)) {
|
||||
/*
|
||||
CollectionPointerLink *link= MEM_callocN(sizeof(CollectionPointerLink), "bpy_context_get");
|
||||
link->ptr= ((BPy_StructRNA *)item)->ptr;
|
||||
@ -656,12 +656,12 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
|
||||
}
|
||||
}
|
||||
|
||||
if(done==0) {
|
||||
if (done==0) {
|
||||
if (item) printf("PyContext '%s' not a valid type\n", member);
|
||||
else printf("PyContext '%s' not found\n", member);
|
||||
}
|
||||
else {
|
||||
if(G.f & G_DEBUG) {
|
||||
if (G.f & G_DEBUG) {
|
||||
printf("PyContext '%s' found\n", member);
|
||||
}
|
||||
}
|
||||
@ -759,7 +759,7 @@ PyInit_bpy(void)
|
||||
dealloc_obj_Type.tp_dealloc= dealloc_obj_dealloc;
|
||||
dealloc_obj_Type.tp_flags= Py_TPFLAGS_DEFAULT;
|
||||
|
||||
if(PyType_Ready(&dealloc_obj_Type) < 0)
|
||||
if (PyType_Ready(&dealloc_obj_Type) < 0)
|
||||
return NULL;
|
||||
|
||||
dob= (dealloc_obj *) dealloc_obj_Type.tp_alloc(&dealloc_obj_Type, 0);
|
||||
|
@ -68,7 +68,7 @@ static void atexit_func_call(const char *func_name, PyObject *atexit_func_arg)
|
||||
Py_DECREF(atexit_func);
|
||||
Py_DECREF(args);
|
||||
|
||||
if(ret) {
|
||||
if (ret) {
|
||||
Py_DECREF(ret);
|
||||
}
|
||||
else { /* should never happen */
|
||||
|
@ -184,7 +184,7 @@ static PyObject *bpy_lib_load(PyObject *UNUSED(self), PyObject *args, PyObject *
|
||||
const char* filename= NULL;
|
||||
int is_rel= 0, is_link= 0;
|
||||
|
||||
if(!PyArg_ParseTupleAndKeywords(args, kwds, "s|ii:load", (char **)kwlist, &filename, &is_link, &is_rel))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|ii:load", (char **)kwlist, &filename, &is_link, &is_rel))
|
||||
return NULL;
|
||||
|
||||
ret= PyObject_New(BPy_Library, &bpy_lib_Type);
|
||||
@ -210,10 +210,10 @@ static PyObject *_bpy_names(BPy_Library *self, int blocktype)
|
||||
|
||||
names= BLO_blendhandle_get_datablock_names(self->blo_handle, blocktype, &totnames);
|
||||
|
||||
if(names) {
|
||||
if (names) {
|
||||
int counter= 0;
|
||||
list= PyList_New(totnames);
|
||||
for(l= names; l; l= l->next) {
|
||||
for (l= names; l; l= l->next) {
|
||||
PyList_SET_ITEM(list, counter, PyUnicode_FromString((char *)l->link));
|
||||
counter++;
|
||||
}
|
||||
@ -237,8 +237,8 @@ static PyObject *bpy_lib_enter(BPy_Library *self, PyObject *UNUSED(args))
|
||||
|
||||
self->blo_handle= BLO_blendhandle_from_file(self->abspath, &reports);
|
||||
|
||||
if(self->blo_handle == NULL) {
|
||||
if(BPy_reports_to_error(&reports, PyExc_IOError, TRUE) != -1) {
|
||||
if (self->blo_handle == NULL) {
|
||||
if (BPy_reports_to_error(&reports, PyExc_IOError, TRUE) != -1) {
|
||||
PyErr_Format(PyExc_IOError,
|
||||
"load: %s failed to open blend file",
|
||||
self->abspath);
|
||||
@ -247,8 +247,8 @@ static PyObject *bpy_lib_enter(BPy_Library *self, PyObject *UNUSED(args))
|
||||
}
|
||||
else {
|
||||
int i= 0, code;
|
||||
while((code= BKE_idcode_iter_step(&i))) {
|
||||
if(BKE_idcode_is_linkable(code)) {
|
||||
while ((code= BKE_idcode_iter_step(&i))) {
|
||||
if (BKE_idcode_is_linkable(code)) {
|
||||
const char *name_plural= BKE_idcode_to_name_plural(code);
|
||||
PyObject *str= PyUnicode_FromString(name_plural);
|
||||
PyDict_SetItem(self->dict, str, PyList_New(0));
|
||||
@ -322,27 +322,27 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
|
||||
|
||||
{
|
||||
int i= 0, code;
|
||||
while((code= BKE_idcode_iter_step(&i))) {
|
||||
if(BKE_idcode_is_linkable(code)) {
|
||||
while ((code= BKE_idcode_iter_step(&i))) {
|
||||
if (BKE_idcode_is_linkable(code)) {
|
||||
const char *name_plural= BKE_idcode_to_name_plural(code);
|
||||
PyObject *ls= PyDict_GetItemString(self->dict, name_plural);
|
||||
// printf("lib: %s\n", name_plural);
|
||||
if(ls && PyList_Check(ls)) {
|
||||
if (ls && PyList_Check(ls)) {
|
||||
/* loop */
|
||||
Py_ssize_t size= PyList_GET_SIZE(ls);
|
||||
Py_ssize_t i;
|
||||
PyObject *item;
|
||||
const char *item_str;
|
||||
|
||||
for(i= 0; i < size; i++) {
|
||||
for (i= 0; i < size; i++) {
|
||||
item= PyList_GET_ITEM(ls, i);
|
||||
item_str= _PyUnicode_AsString(item);
|
||||
|
||||
// printf(" %s\n", item_str);
|
||||
|
||||
if(item_str) {
|
||||
if (item_str) {
|
||||
ID *id= BLO_library_append_named_part(mainl, &(self->blo_handle), item_str, code);
|
||||
if(id) {
|
||||
if (id) {
|
||||
#ifdef USE_RNA_DATABLOCKS
|
||||
PointerRNA id_ptr;
|
||||
RNA_id_pointer_create(id, &id_ptr);
|
||||
@ -382,7 +382,7 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
|
||||
}
|
||||
}
|
||||
|
||||
if(err == -1) {
|
||||
if (err == -1) {
|
||||
/* exception raised above, XXX, this leaks some memory */
|
||||
BLO_blendhandle_close(self->blo_handle);
|
||||
self->blo_handle= NULL;
|
||||
@ -399,10 +399,10 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
|
||||
recalc_all_library_objects(G.main);
|
||||
|
||||
/* append, rather than linking */
|
||||
if((self->flag & FILE_LINK)==0) {
|
||||
if ((self->flag & FILE_LINK)==0) {
|
||||
Library *lib= BLI_findstring(&G.main->library, self->abspath, offsetof(Library, name));
|
||||
if(lib) all_local(lib, 1);
|
||||
else BLI_assert(!"cant find name of just added library!");
|
||||
if (lib) all_local(lib, 1);
|
||||
else BLI_assert(!"cant find name of just added library!");
|
||||
}
|
||||
}
|
||||
|
||||
@ -426,7 +426,7 @@ int bpy_lib_init(PyObject *mod_par)
|
||||
/* some compilers dont like accessing this directly, delay assignment */
|
||||
bpy_lib_Type.tp_getattro= PyObject_GenericGetAttr;
|
||||
|
||||
if(PyType_Ready(&bpy_lib_Type) < 0)
|
||||
if (PyType_Ready(&bpy_lib_Type) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
|
@ -76,7 +76,7 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
|
||||
// XXX Todo, work out a better solution for passing on context, could make a tuple from self and pack the name and Context into it...
|
||||
bContext *C= (bContext *)BPy_GetContext();
|
||||
|
||||
if(C==NULL) {
|
||||
if (C==NULL) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Context is None, cant poll any operators");
|
||||
return NULL;
|
||||
}
|
||||
@ -93,8 +93,8 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(context_str) {
|
||||
if(RNA_enum_value_from_id(operator_context_items, context_str, &context)==0) {
|
||||
if (context_str) {
|
||||
if (RNA_enum_value_from_id(operator_context_items, context_str, &context)==0) {
|
||||
char *enum_str= BPy_enum_as_string(operator_context_items);
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"Calling operator \"bpy.ops.%s.poll\" error, "
|
||||
@ -105,7 +105,7 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
|
||||
}
|
||||
}
|
||||
|
||||
if(context_dict==NULL || context_dict==Py_None) {
|
||||
if (context_dict==NULL || context_dict==Py_None) {
|
||||
context_dict= NULL;
|
||||
}
|
||||
else if (!PyDict_Check(context_dict)) {
|
||||
@ -150,7 +150,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
|
||||
// XXX Todo, work out a better solution for passing on context, could make a tuple from self and pack the name and Context into it...
|
||||
bContext *C= (bContext *)BPy_GetContext();
|
||||
|
||||
if(C==NULL) {
|
||||
if (C==NULL) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Context is None, cant poll any operators");
|
||||
return NULL;
|
||||
}
|
||||
@ -167,7 +167,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!pyrna_write_check()) {
|
||||
if (!pyrna_write_check()) {
|
||||
PyErr_Format(PyExc_RuntimeError,
|
||||
"Calling operator \"bpy.ops.%s\" error, "
|
||||
"can't modify blend data in this state (drawing/rendering)",
|
||||
@ -175,8 +175,8 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(context_str) {
|
||||
if(RNA_enum_value_from_id(operator_context_items, context_str, &context)==0) {
|
||||
if (context_str) {
|
||||
if (RNA_enum_value_from_id(operator_context_items, context_str, &context)==0) {
|
||||
char *enum_str= BPy_enum_as_string(operator_context_items);
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"Calling operator \"bpy.ops.%s\" error, "
|
||||
@ -187,7 +187,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
|
||||
}
|
||||
}
|
||||
|
||||
if(context_dict==NULL || context_dict==Py_None) {
|
||||
if (context_dict==NULL || context_dict==Py_None) {
|
||||
context_dict= NULL;
|
||||
}
|
||||
else if (!PyDict_Check(context_dict)) {
|
||||
@ -203,7 +203,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
|
||||
CTX_py_dict_set(C, (void *)context_dict);
|
||||
Py_XINCREF(context_dict); /* so we done loose it */
|
||||
|
||||
if(WM_operator_poll_context((bContext*)C, ot, context) == FALSE) {
|
||||
if (WM_operator_poll_context((bContext*)C, ot, context) == FALSE) {
|
||||
const char *msg= CTX_wm_operator_poll_msg_get(C);
|
||||
PyErr_Format(PyExc_RuntimeError,
|
||||
"Operator bpy.ops.%.200s.poll() %.200s",
|
||||
@ -215,7 +215,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
|
||||
WM_operator_properties_create_ptr(&ptr, ot);
|
||||
WM_operator_properties_sanitize(&ptr, 0);
|
||||
|
||||
if(kw && PyDict_Size(kw))
|
||||
if (kw && PyDict_Size(kw))
|
||||
error_val= pyrna_pydict_to_props(&ptr, kw, 0, "Converting py args to operator properties: ");
|
||||
|
||||
|
||||
@ -245,10 +245,10 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
|
||||
error_val= BPy_reports_to_error(reports, PyExc_RuntimeError, FALSE);
|
||||
|
||||
/* operator output is nice to have in the terminal/console too */
|
||||
if(reports->list.first) {
|
||||
if (reports->list.first) {
|
||||
char *report_str= BKE_reports_string(reports, 0); /* all reports */
|
||||
|
||||
if(report_str) {
|
||||
if (report_str) {
|
||||
PySys_WriteStdout("%s\n", report_str);
|
||||
MEM_freeN(report_str);
|
||||
}
|
||||
@ -315,7 +315,7 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args)
|
||||
|
||||
bContext *C= (bContext *)BPy_GetContext();
|
||||
|
||||
if(C==NULL) {
|
||||
if (C==NULL) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Context is None, cant get the string representation of this object.");
|
||||
return NULL;
|
||||
}
|
||||
@ -336,7 +336,7 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args)
|
||||
/* Save another lookup */
|
||||
RNA_pointer_create(NULL, ot->srna, NULL, &ptr);
|
||||
|
||||
if(kw && PyDict_Size(kw))
|
||||
if (kw && PyDict_Size(kw))
|
||||
error_val= pyrna_pydict_to_props(&ptr, kw, 0, "Converting py args to operator properties: ");
|
||||
|
||||
if (error_val==0)
|
||||
@ -348,7 +348,7 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(buf) {
|
||||
if (buf) {
|
||||
pybuf= PyUnicode_FromString(buf);
|
||||
MEM_freeN(buf);
|
||||
}
|
||||
@ -364,7 +364,7 @@ static PyObject *pyop_dir(PyObject *UNUSED(self))
|
||||
GHashIterator *iter= WM_operatortype_iter();
|
||||
PyObject *list= PyList_New(0), *name;
|
||||
|
||||
for( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) {
|
||||
for ( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) {
|
||||
wmOperatorType *ot= BLI_ghashIterator_getValue(iter);
|
||||
|
||||
name= PyUnicode_FromString(ot->idname);
|
||||
@ -383,12 +383,12 @@ static PyObject *pyop_getrna(PyObject *UNUSED(self), PyObject *value)
|
||||
char *opname= _PyUnicode_AsString(value);
|
||||
BPy_StructRNA *pyrna= NULL;
|
||||
|
||||
if(opname==NULL) {
|
||||
if (opname==NULL) {
|
||||
PyErr_SetString(PyExc_TypeError, "_bpy.ops.get_rna() expects a string argument");
|
||||
return NULL;
|
||||
}
|
||||
ot= WM_operatortype_find(opname, TRUE);
|
||||
if(ot==NULL) {
|
||||
if (ot==NULL) {
|
||||
PyErr_Format(PyExc_KeyError, "_bpy.ops.get_rna(\"%s\") not found", opname);
|
||||
return NULL;
|
||||
}
|
||||
@ -416,12 +416,12 @@ static PyObject *pyop_getinstance(PyObject *UNUSED(self), PyObject *value)
|
||||
char *opname= _PyUnicode_AsString(value);
|
||||
BPy_StructRNA *pyrna= NULL;
|
||||
|
||||
if(opname==NULL) {
|
||||
if (opname==NULL) {
|
||||
PyErr_SetString(PyExc_TypeError, "_bpy.ops.get_instance() expects a string argument");
|
||||
return NULL;
|
||||
}
|
||||
ot= WM_operatortype_find(opname, TRUE);
|
||||
if(ot==NULL) {
|
||||
if (ot==NULL) {
|
||||
PyErr_Format(PyExc_KeyError, "_bpy.ops.get_instance(\"%s\") not found", opname);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ static void operator_properties_init(wmOperatorType *ot)
|
||||
* later */
|
||||
RNA_def_struct_identifier(ot->srna, ot->idname);
|
||||
|
||||
if(pyrna_deferred_register_class(ot->srna, py_class) != 0) {
|
||||
if (pyrna_deferred_register_class(ot->srna, py_class) != 0) {
|
||||
PyErr_Print(); /* failed to register operator props */
|
||||
PyErr_Clear();
|
||||
}
|
||||
@ -72,8 +72,9 @@ void operator_wrapper(wmOperatorType *ot, void *userdata)
|
||||
|
||||
RNA_pointer_create(NULL, ot->srna, NULL, &ptr);
|
||||
prop= RNA_struct_find_property(&ptr, "type");
|
||||
if(prop)
|
||||
if (prop) {
|
||||
ot->prop= prop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,11 +123,11 @@ static PyObject *pyrna_struct_as_instance(PointerRNA *ptr)
|
||||
PyObject *self= NULL;
|
||||
/* first get self */
|
||||
/* operators can store their own instance for later use */
|
||||
if(ptr->data) {
|
||||
if (ptr->data) {
|
||||
void **instance= RNA_struct_instance(ptr);
|
||||
|
||||
if(instance) {
|
||||
if(*instance) {
|
||||
if (instance) {
|
||||
if (*instance) {
|
||||
self= *instance;
|
||||
Py_INCREF(self);
|
||||
}
|
||||
@ -135,7 +135,7 @@ static PyObject *pyrna_struct_as_instance(PointerRNA *ptr)
|
||||
}
|
||||
|
||||
/* in most cases this will run */
|
||||
if(self == NULL) {
|
||||
if (self == NULL) {
|
||||
self= pyrna_struct_CreatePyObject(ptr);
|
||||
}
|
||||
|
||||
@ -167,7 +167,7 @@ static PyObject *bpy_prop_deferred_return(PyObject *func, PyObject *kw)
|
||||
PyTuple_SET_ITEM(ret, 0, func);
|
||||
Py_INCREF(func);
|
||||
|
||||
if(kw==NULL)
|
||||
if (kw==NULL)
|
||||
kw= PyDict_New();
|
||||
else
|
||||
Py_INCREF(kw);
|
||||
@ -190,7 +190,7 @@ static void bpy_prop_update_cb(struct bContext *C, struct PointerRNA *ptr, struc
|
||||
|
||||
BLI_assert(py_data != NULL);
|
||||
|
||||
if(!is_write_ok) {
|
||||
if (!is_write_ok) {
|
||||
pyrna_write_set(TRUE);
|
||||
}
|
||||
|
||||
@ -209,11 +209,11 @@ static void bpy_prop_update_cb(struct bContext *C, struct PointerRNA *ptr, struc
|
||||
|
||||
Py_DECREF(args);
|
||||
|
||||
if(ret == NULL) {
|
||||
if (ret == NULL) {
|
||||
printf_func_error(py_func);
|
||||
}
|
||||
else {
|
||||
if(ret != Py_None) {
|
||||
if (ret != Py_None) {
|
||||
PyErr_SetString(PyExc_ValueError, "the return value must be None");
|
||||
printf_func_error(py_func);
|
||||
}
|
||||
@ -223,15 +223,15 @@ static void bpy_prop_update_cb(struct bContext *C, struct PointerRNA *ptr, struc
|
||||
|
||||
bpy_context_clear(C, &gilstate);
|
||||
|
||||
if(!is_write_ok) {
|
||||
if (!is_write_ok) {
|
||||
pyrna_write_set(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
static int bpy_prop_callback_check(PyObject *py_func, int argcount)
|
||||
{
|
||||
if(py_func) {
|
||||
if(!PyFunction_Check(py_func)) {
|
||||
if (py_func) {
|
||||
if (!PyFunction_Check(py_func)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"update keyword: expected a function type, not a %.200s",
|
||||
Py_TYPE(py_func)->tp_name);
|
||||
@ -255,7 +255,7 @@ static int bpy_prop_callback_check(PyObject *py_func, int argcount)
|
||||
static int bpy_prop_callback_assign(struct PropertyRNA *prop, PyObject *update_cb)
|
||||
{
|
||||
/* assume this is already checked for type and arg length */
|
||||
if(update_cb) {
|
||||
if (update_cb) {
|
||||
PyObject **py_data= MEM_callocN(sizeof(PyObject *) * BPY_DATA_CB_SLOT_SIZE, "bpy_prop_callback_assign");
|
||||
RNA_def_property_update_runtime(prop, (void *)bpy_prop_update_cb);
|
||||
py_data[BPY_DATA_CB_SLOT_UPDATE]= update_cb;
|
||||
@ -270,7 +270,7 @@ static int bpy_prop_callback_assign(struct PropertyRNA *prop, PyObject *update_c
|
||||
/* utility function we need for parsing int's in an if statement */
|
||||
static int py_long_as_int(PyObject *py_long, int *r_int)
|
||||
{
|
||||
if(PyLong_CheckExact(py_long)) {
|
||||
if (PyLong_CheckExact(py_long)) {
|
||||
*r_int= (int)PyLong_AS_LONG(py_long);
|
||||
return 0;
|
||||
}
|
||||
@ -295,8 +295,8 @@ static int py_long_as_int(PyObject *py_long, int *r_int)
|
||||
return NULL; \
|
||||
} \
|
||||
srna= srna_from_self(self, #_func"(...):"); \
|
||||
if(srna==NULL) { \
|
||||
if(PyErr_Occurred()) \
|
||||
if (srna==NULL) { \
|
||||
if (PyErr_Occurred()) \
|
||||
return NULL; \
|
||||
return bpy_prop_deferred_return((void *)pymeth_##_func, kw); \
|
||||
} \
|
||||
@ -304,24 +304,24 @@ static int py_long_as_int(PyObject *py_long, int *r_int)
|
||||
/* terse macros for error checks shared between all funcs cant use function
|
||||
* calls because of static strins passed to pyrna_set_to_enum_bitfield */
|
||||
#define BPY_PROPDEF_CHECK(_func, _property_flag_items) \
|
||||
if(id_len >= MAX_IDPROP_NAME) { \
|
||||
if (id_len >= MAX_IDPROP_NAME) { \
|
||||
PyErr_Format(PyExc_TypeError, \
|
||||
#_func"(): '%.200s' too long, max length is %d", \
|
||||
id, MAX_IDPROP_NAME-1); \
|
||||
return NULL; \
|
||||
} \
|
||||
if(RNA_def_property_free_identifier(srna, id) == -1) { \
|
||||
if (RNA_def_property_free_identifier(srna, id) == -1) { \
|
||||
PyErr_Format(PyExc_TypeError, \
|
||||
#_func"(): '%s' is defined as a non-dynamic type", \
|
||||
id); \
|
||||
return NULL; \
|
||||
} \
|
||||
if(pyopts && pyrna_set_to_enum_bitfield(_property_flag_items, pyopts, &opts, #_func"(options={...}):")) \
|
||||
if (pyopts && pyrna_set_to_enum_bitfield(_property_flag_items, pyopts, &opts, #_func"(options={...}):")) \
|
||||
return NULL; \
|
||||
|
||||
#define BPY_PROPDEF_SUBTYPE_CHECK(_func, _property_flag_items, _subtype) \
|
||||
BPY_PROPDEF_CHECK(_func, _property_flag_items) \
|
||||
if(pysubtype && RNA_enum_value_from_id(_subtype, pysubtype, &subtype)==0) { \
|
||||
if (pysubtype && RNA_enum_value_from_id(_subtype, pysubtype, &subtype)==0) { \
|
||||
PyErr_Format(PyExc_TypeError, \
|
||||
#_func"(subtype='%s'): invalid subtype", \
|
||||
pysubtype); \
|
||||
@ -380,7 +380,7 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
|
||||
BPY_PROPDEF_HEAD(BoolProperty)
|
||||
|
||||
if(srna) {
|
||||
if (srna) {
|
||||
static const char *kwlist[]= {"attr", "name", "description", "default", "options", "subtype", "update", NULL};
|
||||
const char *id=NULL, *name="", *description="";
|
||||
int id_len;
|
||||
@ -412,9 +412,9 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
RNA_def_property_boolean_default(prop, def);
|
||||
RNA_def_property_ui_text(prop, name, description);
|
||||
|
||||
if(pyopts) {
|
||||
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
if (pyopts) {
|
||||
if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
}
|
||||
bpy_prop_callback_assign(prop, update_cb);
|
||||
RNA_def_property_duplicate_pointers(srna, prop);
|
||||
@ -446,7 +446,7 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
|
||||
|
||||
BPY_PROPDEF_HEAD(BoolVectorProperty)
|
||||
|
||||
if(srna) {
|
||||
if (srna) {
|
||||
static const char *kwlist[]= {"attr", "name", "description", "default", "options", "subtype", "size", "update", NULL};
|
||||
const char *id=NULL, *name="", *description="";
|
||||
int id_len;
|
||||
@ -472,12 +472,12 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
|
||||
|
||||
BPY_PROPDEF_SUBTYPE_CHECK(BoolVectorProperty, property_flag_items, property_subtype_array_items)
|
||||
|
||||
if(size < 1 || size > PYRNA_STACK_ARRAY) {
|
||||
if (size < 1 || size > PYRNA_STACK_ARRAY) {
|
||||
PyErr_Format(PyExc_TypeError, "BoolVectorProperty(size=%d): size must be between 0 and " STRINGIFY(PYRNA_STACK_ARRAY), size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(pydef && PyC_AsArray(def, pydef, size, &PyBool_Type, FALSE, "BoolVectorProperty(default=sequence)") < 0)
|
||||
if (pydef && PyC_AsArray(def, pydef, size, &PyBool_Type, FALSE, "BoolVectorProperty(default=sequence)") < 0)
|
||||
return NULL;
|
||||
|
||||
if (bpy_prop_callback_check(update_cb, 2) == -1) {
|
||||
@ -487,12 +487,12 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
|
||||
// prop= RNA_def_boolean_array(srna, id, size, pydef ? def:NULL, name, description);
|
||||
prop= RNA_def_property(srna, id, PROP_BOOLEAN, subtype);
|
||||
RNA_def_property_array(prop, size);
|
||||
if(pydef) RNA_def_property_boolean_array_default(prop, def);
|
||||
if (pydef) RNA_def_property_boolean_array_default(prop, def);
|
||||
RNA_def_property_ui_text(prop, name, description);
|
||||
|
||||
if(pyopts) {
|
||||
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
if (pyopts) {
|
||||
if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
}
|
||||
bpy_prop_callback_assign(prop, update_cb);
|
||||
RNA_def_property_duplicate_pointers(srna, prop);
|
||||
@ -520,7 +520,7 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
|
||||
BPY_PROPDEF_HEAD(IntProperty)
|
||||
|
||||
if(srna) {
|
||||
if (srna) {
|
||||
static const char *kwlist[]= {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "options", "subtype", "update", NULL};
|
||||
const char *id=NULL, *name="", *description="";
|
||||
int id_len;
|
||||
@ -555,9 +555,9 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
RNA_def_property_ui_text(prop, name, description);
|
||||
RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, 3);
|
||||
|
||||
if(pyopts) {
|
||||
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
if (pyopts) {
|
||||
if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
}
|
||||
bpy_prop_callback_assign(prop, update_cb);
|
||||
RNA_def_property_duplicate_pointers(srna, prop);
|
||||
@ -588,7 +588,7 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
|
||||
|
||||
BPY_PROPDEF_HEAD(IntVectorProperty)
|
||||
|
||||
if(srna) {
|
||||
if (srna) {
|
||||
static const char *kwlist[]= {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "options", "subtype", "size", "update", NULL};
|
||||
const char *id=NULL, *name="", *description="";
|
||||
int id_len;
|
||||
@ -616,12 +616,12 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
|
||||
|
||||
BPY_PROPDEF_SUBTYPE_CHECK(IntVectorProperty, property_flag_items, property_subtype_array_items)
|
||||
|
||||
if(size < 1 || size > PYRNA_STACK_ARRAY) {
|
||||
if (size < 1 || size > PYRNA_STACK_ARRAY) {
|
||||
PyErr_Format(PyExc_TypeError, "IntVectorProperty(size=%d): size must be between 0 and " STRINGIFY(PYRNA_STACK_ARRAY), size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(pydef && PyC_AsArray(def, pydef, size, &PyLong_Type, FALSE, "IntVectorProperty(default=sequence)") < 0)
|
||||
if (pydef && PyC_AsArray(def, pydef, size, &PyLong_Type, FALSE, "IntVectorProperty(default=sequence)") < 0)
|
||||
return NULL;
|
||||
|
||||
if (bpy_prop_callback_check(update_cb, 2) == -1) {
|
||||
@ -630,14 +630,14 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
|
||||
|
||||
prop= RNA_def_property(srna, id, PROP_INT, subtype);
|
||||
RNA_def_property_array(prop, size);
|
||||
if(pydef) RNA_def_property_int_array_default(prop, def);
|
||||
if (pydef) RNA_def_property_int_array_default(prop, def);
|
||||
RNA_def_property_range(prop, min, max);
|
||||
RNA_def_property_ui_text(prop, name, description);
|
||||
RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, 3);
|
||||
|
||||
if(pyopts) {
|
||||
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
if (pyopts) {
|
||||
if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
}
|
||||
bpy_prop_callback_assign(prop, update_cb);
|
||||
RNA_def_property_duplicate_pointers(srna, prop);
|
||||
@ -666,7 +666,7 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
|
||||
BPY_PROPDEF_HEAD(FloatProperty)
|
||||
|
||||
if(srna) {
|
||||
if (srna) {
|
||||
static const char *kwlist[]= {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "precision", "options", "subtype", "unit", "update", NULL};
|
||||
const char *id=NULL, *name="", *description="";
|
||||
int id_len;
|
||||
@ -695,7 +695,7 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
|
||||
BPY_PROPDEF_SUBTYPE_CHECK(FloatProperty, property_flag_items, property_subtype_number_items)
|
||||
|
||||
if(pyunit && RNA_enum_value_from_id(property_unit_items, pyunit, &unit)==0) {
|
||||
if (pyunit && RNA_enum_value_from_id(property_unit_items, pyunit, &unit)==0) {
|
||||
PyErr_Format(PyExc_TypeError, "FloatProperty(unit='%s'): invalid unit", pyunit);
|
||||
return NULL;
|
||||
}
|
||||
@ -710,9 +710,9 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
RNA_def_property_ui_text(prop, name, description);
|
||||
RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, precision);
|
||||
|
||||
if(pyopts) {
|
||||
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
if (pyopts) {
|
||||
if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
}
|
||||
bpy_prop_callback_assign(prop, update_cb);
|
||||
RNA_def_property_duplicate_pointers(srna, prop);
|
||||
@ -744,7 +744,7 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
|
||||
|
||||
BPY_PROPDEF_HEAD(FloatVectorProperty)
|
||||
|
||||
if(srna) {
|
||||
if (srna) {
|
||||
static const char *kwlist[]= {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "precision", "options", "subtype", "unit", "size", "update", NULL};
|
||||
const char *id=NULL, *name="", *description="";
|
||||
int id_len;
|
||||
@ -774,17 +774,17 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
|
||||
|
||||
BPY_PROPDEF_SUBTYPE_CHECK(FloatVectorProperty, property_flag_items, property_subtype_array_items)
|
||||
|
||||
if(pyunit && RNA_enum_value_from_id(property_unit_items, pyunit, &unit)==0) {
|
||||
if (pyunit && RNA_enum_value_from_id(property_unit_items, pyunit, &unit)==0) {
|
||||
PyErr_Format(PyExc_TypeError, "FloatVectorProperty(unit='%s'): invalid unit", pyunit);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(size < 1 || size > PYRNA_STACK_ARRAY) {
|
||||
if (size < 1 || size > PYRNA_STACK_ARRAY) {
|
||||
PyErr_Format(PyExc_TypeError, "FloatVectorProperty(size=%d): size must be between 0 and " STRINGIFY(PYRNA_STACK_ARRAY), size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(pydef && PyC_AsArray(def, pydef, size, &PyFloat_Type, FALSE, "FloatVectorProperty(default=sequence)") < 0)
|
||||
if (pydef && PyC_AsArray(def, pydef, size, &PyFloat_Type, FALSE, "FloatVectorProperty(default=sequence)") < 0)
|
||||
return NULL;
|
||||
|
||||
if (bpy_prop_callback_check(update_cb, 2) == -1) {
|
||||
@ -793,14 +793,14 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
|
||||
|
||||
prop= RNA_def_property(srna, id, PROP_FLOAT, subtype | unit);
|
||||
RNA_def_property_array(prop, size);
|
||||
if(pydef) RNA_def_property_float_array_default(prop, def);
|
||||
if (pydef) RNA_def_property_float_array_default(prop, def);
|
||||
RNA_def_property_range(prop, min, max);
|
||||
RNA_def_property_ui_text(prop, name, description);
|
||||
RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, precision);
|
||||
|
||||
if(pyopts) {
|
||||
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
if (pyopts) {
|
||||
if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
}
|
||||
bpy_prop_callback_assign(prop, update_cb);
|
||||
RNA_def_property_duplicate_pointers(srna, prop);
|
||||
@ -827,7 +827,7 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw
|
||||
|
||||
BPY_PROPDEF_HEAD(StringProperty)
|
||||
|
||||
if(srna) {
|
||||
if (srna) {
|
||||
static const char *kwlist[]= {"attr", "name", "description", "default", "maxlen", "options", "subtype", "update", NULL};
|
||||
const char *id=NULL, *name="", *description="", *def="";
|
||||
int id_len;
|
||||
@ -856,13 +856,13 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw
|
||||
}
|
||||
|
||||
prop= RNA_def_property(srna, id, PROP_STRING, subtype);
|
||||
if(maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen + 1); /* +1 since it includes null terminator */
|
||||
if(def) RNA_def_property_string_default(prop, def);
|
||||
if (maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen + 1); /* +1 since it includes null terminator */
|
||||
if (def) RNA_def_property_string_default(prop, def);
|
||||
RNA_def_property_ui_text(prop, name, description);
|
||||
|
||||
if(pyopts) {
|
||||
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
if (pyopts) {
|
||||
if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
}
|
||||
bpy_prop_callback_assign(prop, update_cb);
|
||||
RNA_def_property_duplicate_pointers(srna, prop);
|
||||
@ -878,7 +878,7 @@ static size_t strswapbufcpy(char *buf, const char **orig)
|
||||
char *dst= buf;
|
||||
size_t i= 0;
|
||||
*orig= buf;
|
||||
while((*dst= *src)) { dst++; src++; i++; }
|
||||
while ((*dst= *src)) { dst++; src++; i++; }
|
||||
return i + 1; /* include '\0' */
|
||||
}
|
||||
#endif
|
||||
@ -893,12 +893,12 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
|
||||
short def_used= 0;
|
||||
const char *def_cmp= NULL;
|
||||
|
||||
if(is_enum_flag) {
|
||||
if(seq_len > RNA_ENUM_BITFLAG_SIZE) {
|
||||
if (is_enum_flag) {
|
||||
if (seq_len > RNA_ENUM_BITFLAG_SIZE) {
|
||||
PyErr_SetString(PyExc_TypeError, "EnumProperty(...): maximum " STRINGIFY(RNA_ENUM_BITFLAG_SIZE) " members for a ENUM_FLAG type property");
|
||||
return NULL;
|
||||
}
|
||||
if(def && !PySet_Check(def)) {
|
||||
if (def && !PySet_Check(def)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"EnumProperty(...): default option must be a 'set' "
|
||||
"type when ENUM_FLAG is enabled, not a '%.200s'",
|
||||
@ -907,9 +907,9 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(def) {
|
||||
if (def) {
|
||||
def_cmp= _PyUnicode_AsString(def);
|
||||
if(def_cmp==NULL) {
|
||||
if (def_cmp==NULL) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"EnumProperty(...): default option must be a 'str' "
|
||||
"type when ENUM_FLAG is disabled, not a '%.200s'",
|
||||
@ -924,7 +924,7 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
|
||||
|
||||
items= MEM_callocN(sizeof(EnumPropertyItem) * (seq_len + 1), "enum_items_from_py1");
|
||||
|
||||
for(i=0; i<seq_len; i++) {
|
||||
for (i=0; i<seq_len; i++) {
|
||||
EnumPropertyItem tmp= {0, "", 0, "", ""};
|
||||
Py_ssize_t item_size;
|
||||
Py_ssize_t id_str_size;
|
||||
@ -933,7 +933,7 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
|
||||
|
||||
item= PySequence_Fast_GET_ITEM(seq_fast, i);
|
||||
|
||||
if( (PyTuple_CheckExact(item)) &&
|
||||
if ( (PyTuple_CheckExact(item)) &&
|
||||
(item_size= PyTuple_GET_SIZE(item)) &&
|
||||
(item_size == 3 || item_size == 4) &&
|
||||
(tmp.identifier= _PyUnicode_AsStringAndSize(PyTuple_GET_ITEM(item, 0), &id_str_size)) &&
|
||||
@ -941,22 +941,22 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
|
||||
(tmp.description= _PyUnicode_AsStringAndSize(PyTuple_GET_ITEM(item, 2), &desc_str_size)) &&
|
||||
(item_size < 4 || py_long_as_int(PyTuple_GET_ITEM(item, 3), &tmp.value) != -1) /* TODO, number isnt ensured to be unique from the script author */
|
||||
) {
|
||||
if(is_enum_flag) {
|
||||
if(item_size < 4) {
|
||||
if (is_enum_flag) {
|
||||
if (item_size < 4) {
|
||||
tmp.value= 1<<i;
|
||||
}
|
||||
|
||||
if(def && PySet_Contains(def, PyTuple_GET_ITEM(item, 0))) {
|
||||
if (def && PySet_Contains(def, PyTuple_GET_ITEM(item, 0))) {
|
||||
*defvalue |= tmp.value;
|
||||
def_used++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(item_size < 4) {
|
||||
if (item_size < 4) {
|
||||
tmp.value= i;
|
||||
}
|
||||
|
||||
if(def && def_used == 0 && strcmp(def_cmp, tmp.identifier)==0) {
|
||||
if (def && def_used == 0 && strcmp(def_cmp, tmp.identifier)==0) {
|
||||
*defvalue= tmp.value;
|
||||
def_used++; /* only ever 1 */
|
||||
}
|
||||
@ -978,9 +978,9 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
|
||||
|
||||
}
|
||||
|
||||
if(is_enum_flag) {
|
||||
if (is_enum_flag) {
|
||||
/* strict check that all set members were used */
|
||||
if(def && def_used != PySet_GET_SIZE(def)) {
|
||||
if (def && def_used != PySet_GET_SIZE(def)) {
|
||||
MEM_freeN(items);
|
||||
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
@ -990,7 +990,7 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(def && def_used == 0) {
|
||||
if (def && def_used == 0) {
|
||||
MEM_freeN(items);
|
||||
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
@ -1012,7 +1012,7 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
|
||||
EnumPropertyItem *items_ptr= items_dup;
|
||||
char *buf= ((char *)items_dup) + (sizeof(EnumPropertyItem) * (seq_len + 1));
|
||||
memcpy(items_dup, items, sizeof(EnumPropertyItem) * (seq_len + 1));
|
||||
for(i=0; i<seq_len; i++, items_ptr++) {
|
||||
for (i=0; i<seq_len; i++, items_ptr++) {
|
||||
buf += strswapbufcpy(buf, &items_ptr->identifier);
|
||||
buf += strswapbufcpy(buf, &items_ptr->name);
|
||||
buf += strswapbufcpy(buf, &items_ptr->description);
|
||||
@ -1052,14 +1052,14 @@ static EnumPropertyItem *bpy_props_enum_itemf(struct bContext *C, PointerRNA *pt
|
||||
|
||||
Py_DECREF(args);
|
||||
|
||||
if(items==NULL) {
|
||||
if (items==NULL) {
|
||||
err= -1;
|
||||
}
|
||||
else {
|
||||
PyObject *items_fast;
|
||||
int defvalue_dummy=0;
|
||||
|
||||
if(!(items_fast= PySequence_Fast(items, "EnumProperty(...): return value from the callback was not a sequence"))) {
|
||||
if (!(items_fast= PySequence_Fast(items, "EnumProperty(...): return value from the callback was not a sequence"))) {
|
||||
err= -1;
|
||||
}
|
||||
else {
|
||||
@ -1067,7 +1067,7 @@ static EnumPropertyItem *bpy_props_enum_itemf(struct bContext *C, PointerRNA *pt
|
||||
|
||||
Py_DECREF(items_fast);
|
||||
|
||||
if(!eitems) {
|
||||
if (!eitems) {
|
||||
err= -1;
|
||||
}
|
||||
}
|
||||
@ -1075,7 +1075,7 @@ static EnumPropertyItem *bpy_props_enum_itemf(struct bContext *C, PointerRNA *pt
|
||||
Py_DECREF(items);
|
||||
}
|
||||
|
||||
if(err != -1) { /* worked */
|
||||
if (err != -1) { /* worked */
|
||||
*free= 1;
|
||||
}
|
||||
else {
|
||||
@ -1118,7 +1118,7 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
|
||||
BPY_PROPDEF_HEAD(EnumProperty)
|
||||
|
||||
if(srna) {
|
||||
if (srna) {
|
||||
static const char *kwlist[]= {"attr", "items", "name", "description", "default", "options", "update", NULL};
|
||||
const char *id=NULL, *name="", *description="";
|
||||
PyObject *def= NULL;
|
||||
@ -1149,16 +1149,16 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
}
|
||||
|
||||
/* items can be a list or a callable */
|
||||
if(PyFunction_Check(items)) { /* dont use PyCallable_Check because we need the function code for errors */
|
||||
if (PyFunction_Check(items)) { /* dont use PyCallable_Check because we need the function code for errors */
|
||||
PyCodeObject *f_code= (PyCodeObject *)PyFunction_GET_CODE(items);
|
||||
if(f_code->co_argcount != 2) {
|
||||
if (f_code->co_argcount != 2) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"EnumProperty(...): expected 'items' function to take 2 arguments, not %d",
|
||||
f_code->co_argcount);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(def) {
|
||||
if (def) {
|
||||
/* note, using type error here is odd but python does this for invalid arguments */
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"EnumProperty(...): 'default' can't be set when 'items' is a function");
|
||||
@ -1169,7 +1169,7 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
eitems= DummyRNA_NULL_items;
|
||||
}
|
||||
else {
|
||||
if(!(items_fast= PySequence_Fast(items, "EnumProperty(...): expected a sequence of tuples for the enum items or a function"))) {
|
||||
if (!(items_fast= PySequence_Fast(items, "EnumProperty(...): expected a sequence of tuples for the enum items or a function"))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -1177,28 +1177,28 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
|
||||
Py_DECREF(items_fast);
|
||||
|
||||
if(!eitems) {
|
||||
if (!eitems) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if(opts & PROP_ENUM_FLAG) prop= RNA_def_enum_flag(srna, id, eitems, defvalue, name, description);
|
||||
else prop= RNA_def_enum(srna, id, eitems, defvalue, name, description);
|
||||
if (opts & PROP_ENUM_FLAG) prop= RNA_def_enum_flag(srna, id, eitems, defvalue, name, description);
|
||||
else prop= RNA_def_enum(srna, id, eitems, defvalue, name, description);
|
||||
|
||||
if(is_itemf) {
|
||||
if (is_itemf) {
|
||||
RNA_def_enum_funcs(prop, bpy_props_enum_itemf);
|
||||
RNA_def_enum_py_data(prop, (void *)items);
|
||||
/* Py_INCREF(items); */ /* watch out!, if user is tricky they can probably crash blender if they manage to free the callback, take care! */
|
||||
}
|
||||
|
||||
if(pyopts) {
|
||||
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
if (pyopts) {
|
||||
if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
}
|
||||
bpy_prop_callback_assign(prop, update_cb);
|
||||
RNA_def_property_duplicate_pointers(srna, prop);
|
||||
|
||||
if(is_itemf == FALSE) {
|
||||
if (is_itemf == FALSE) {
|
||||
MEM_freeN(eitems);
|
||||
}
|
||||
}
|
||||
@ -1210,8 +1210,8 @@ static StructRNA *pointer_type_from_py(PyObject *value, const char *error_prefix
|
||||
StructRNA *srna;
|
||||
|
||||
srna= srna_from_self(value, "");
|
||||
if(!srna) {
|
||||
if(PyErr_Occurred()) {
|
||||
if (!srna) {
|
||||
if (PyErr_Occurred()) {
|
||||
PyObject *msg= PyC_ExceptionBuffer();
|
||||
char *msg_char= _PyUnicode_AsString(msg);
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
@ -1227,7 +1227,7 @@ static StructRNA *pointer_type_from_py(PyObject *value, const char *error_prefix
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!RNA_struct_is_a(srna, &RNA_PropertyGroup)) {
|
||||
if (!RNA_struct_is_a(srna, &RNA_PropertyGroup)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s expected an RNA type derived from PropertyGroup",
|
||||
error_prefix);
|
||||
@ -1256,7 +1256,7 @@ static PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *k
|
||||
|
||||
BPY_PROPDEF_HEAD(PointerProperty)
|
||||
|
||||
if(srna) {
|
||||
if (srna) {
|
||||
static const char *kwlist[]= {"attr", "type", "name", "description", "options", "update", NULL};
|
||||
const char *id=NULL, *name="", *description="";
|
||||
int id_len;
|
||||
@ -1280,7 +1280,7 @@ static PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *k
|
||||
BPY_PROPDEF_CHECK(PointerProperty, property_flag_items)
|
||||
|
||||
ptype= pointer_type_from_py(type, "PointerProperty(...):");
|
||||
if(!ptype)
|
||||
if (!ptype)
|
||||
return NULL;
|
||||
|
||||
if (bpy_prop_callback_check(update_cb, 2) == -1) {
|
||||
@ -1288,9 +1288,9 @@ static PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *k
|
||||
}
|
||||
|
||||
prop= RNA_def_pointer_runtime(srna, id, ptype, name, description);
|
||||
if(pyopts) {
|
||||
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
if (pyopts) {
|
||||
if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
}
|
||||
bpy_prop_callback_assign(prop, update_cb);
|
||||
RNA_def_property_duplicate_pointers(srna, prop);
|
||||
@ -1316,7 +1316,7 @@ static PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject
|
||||
|
||||
BPY_PROPDEF_HEAD(CollectionProperty)
|
||||
|
||||
if(srna) {
|
||||
if (srna) {
|
||||
static const char *kwlist[]= {"attr", "type", "name", "description", "options", NULL};
|
||||
const char *id=NULL, *name="", *description="";
|
||||
int id_len;
|
||||
@ -1338,13 +1338,13 @@ static PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject
|
||||
BPY_PROPDEF_CHECK(CollectionProperty, property_flag_items)
|
||||
|
||||
ptype= pointer_type_from_py(type, "CollectionProperty(...):");
|
||||
if(!ptype)
|
||||
if (!ptype)
|
||||
return NULL;
|
||||
|
||||
prop= RNA_def_collection_runtime(srna, id, ptype, name, description);
|
||||
if(pyopts) {
|
||||
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
if (pyopts) {
|
||||
if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
}
|
||||
RNA_def_property_duplicate_pointers(srna, prop);
|
||||
}
|
||||
@ -1363,7 +1363,7 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw
|
||||
{
|
||||
StructRNA *srna;
|
||||
|
||||
if(PyTuple_GET_SIZE(args) == 1) {
|
||||
if (PyTuple_GET_SIZE(args) == 1) {
|
||||
PyObject *ret;
|
||||
self= PyTuple_GET_ITEM(args, 0);
|
||||
args= PyTuple_New(0);
|
||||
@ -1377,10 +1377,10 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw
|
||||
}
|
||||
|
||||
srna= srna_from_self(self, "RemoveProperty(...):");
|
||||
if(srna==NULL && PyErr_Occurred()) {
|
||||
if (srna==NULL && PyErr_Occurred()) {
|
||||
return NULL; /* self's type was compatible but error getting the srna */
|
||||
}
|
||||
else if(srna==NULL) {
|
||||
else if (srna==NULL) {
|
||||
PyErr_SetString(PyExc_TypeError, "RemoveProperty(): struct rna not available for this type");
|
||||
return NULL;
|
||||
}
|
||||
@ -1396,7 +1396,7 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(RNA_def_property_free_identifier(srna, id) != 1) {
|
||||
if (RNA_def_property_free_identifier(srna, id) != 1) {
|
||||
PyErr_Format(PyExc_TypeError, "RemoveProperty(): '%s' not a defined dynamic property", id);
|
||||
return NULL;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -70,18 +70,18 @@ static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char *error_prefi
|
||||
}
|
||||
|
||||
/* full paths can only be given from ID base */
|
||||
if(is_idbase) {
|
||||
if (is_idbase) {
|
||||
int r_index= -1;
|
||||
if(RNA_path_resolve_full(ptr, path, &r_ptr, &prop, &r_index)==0) {
|
||||
if (RNA_path_resolve_full(ptr, path, &r_ptr, &prop, &r_index)==0) {
|
||||
prop= NULL;
|
||||
}
|
||||
else if(r_index != -1) {
|
||||
else if (r_index != -1) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"%.200s path includes index, must be a separate argument",
|
||||
error_prefix, path);
|
||||
return -1;
|
||||
}
|
||||
else if(ptr->id.data != r_ptr.id.data) {
|
||||
else if (ptr->id.data != r_ptr.id.data) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"%.200s path spans ID blocks",
|
||||
error_prefix, path);
|
||||
@ -107,8 +107,8 @@ static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char *error_prefi
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(RNA_property_array_check(prop) == 0) {
|
||||
if((*index) == -1) {
|
||||
if (RNA_property_array_check(prop) == 0) {
|
||||
if ((*index) == -1) {
|
||||
*index= 0;
|
||||
}
|
||||
else {
|
||||
@ -120,7 +120,7 @@ static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char *error_prefi
|
||||
}
|
||||
else {
|
||||
int array_len= RNA_property_array_length(&r_ptr, prop);
|
||||
if((*index) < -1 || (*index) >= array_len) {
|
||||
if ((*index) < -1 || (*index) >= array_len) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s index out of range \"%s\", given %d, array length is %d",
|
||||
error_prefix, path, *index, array_len);
|
||||
@ -128,7 +128,7 @@ static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char *error_prefi
|
||||
}
|
||||
}
|
||||
|
||||
if(is_idbase) {
|
||||
if (is_idbase) {
|
||||
*path_full= BLI_strdup(path);
|
||||
}
|
||||
else {
|
||||
@ -156,10 +156,10 @@ static int pyrna_struct_keyframe_parse(PointerRNA *ptr, PyObject *args, PyObject
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kw, parse_str, (char **)kwlist, &path, index, cfra, group_name))
|
||||
return -1;
|
||||
|
||||
if(pyrna_struct_anim_args_parse(ptr, error_prefix, path, path_full, index) < 0)
|
||||
if (pyrna_struct_anim_args_parse(ptr, error_prefix, path, path_full, index) < 0)
|
||||
return -1;
|
||||
|
||||
if(*cfra==FLT_MAX)
|
||||
if (*cfra==FLT_MAX)
|
||||
*cfra= CTX_data_scene(BPy_GetContext())->r.cfra;
|
||||
|
||||
return 0; /* success */
|
||||
@ -191,7 +191,7 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb
|
||||
|
||||
PYRNA_STRUCT_CHECK_OBJ(self);
|
||||
|
||||
if(pyrna_struct_keyframe_parse(&self->ptr, args, kw,
|
||||
if (pyrna_struct_keyframe_parse(&self->ptr, args, kw,
|
||||
"s|ifs:bpy_struct.keyframe_insert()", "bpy_struct.keyframe_insert()",
|
||||
&path_full, &index, &cfra, &group_name) == -1)
|
||||
{
|
||||
@ -206,7 +206,7 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb
|
||||
result= insert_keyframe(&reports, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, 0);
|
||||
MEM_freeN((void *)path_full);
|
||||
|
||||
if(BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1)
|
||||
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1)
|
||||
return NULL;
|
||||
|
||||
return PyBool_FromLong(result);
|
||||
@ -239,7 +239,7 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
|
||||
|
||||
PYRNA_STRUCT_CHECK_OBJ(self);
|
||||
|
||||
if(pyrna_struct_keyframe_parse(&self->ptr, args, kw,
|
||||
if (pyrna_struct_keyframe_parse(&self->ptr, args, kw,
|
||||
"s|ifs:bpy_struct.keyframe_delete()",
|
||||
"bpy_struct.keyframe_insert()",
|
||||
&path_full, &index, &cfra, &group_name) == -1)
|
||||
@ -255,7 +255,7 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
|
||||
result= delete_keyframe(&reports, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, 0);
|
||||
MEM_freeN((void *)path_full);
|
||||
|
||||
if(BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1)
|
||||
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1)
|
||||
return NULL;
|
||||
|
||||
return PyBool_FromLong(result);
|
||||
@ -285,7 +285,7 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
|
||||
if (!PyArg_ParseTuple(args, "s|i:driver_add", &path, &index))
|
||||
return NULL;
|
||||
|
||||
if(pyrna_struct_anim_args_parse(&self->ptr, "bpy_struct.driver_add():", path, &path_full, &index) < 0) {
|
||||
if (pyrna_struct_anim_args_parse(&self->ptr, "bpy_struct.driver_add():", path, &path_full, &index) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
@ -297,10 +297,10 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
|
||||
|
||||
result= ANIM_add_driver(&reports, (ID *)self->ptr.id.data, path_full, index, 0, DRIVER_TYPE_PYTHON);
|
||||
|
||||
if(BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1)
|
||||
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1)
|
||||
return NULL;
|
||||
|
||||
if(result) {
|
||||
if (result) {
|
||||
ID *id= self->ptr.id.data;
|
||||
AnimData *adt= BKE_animdata_from_id(id);
|
||||
FCurve *fcu;
|
||||
@ -308,10 +308,10 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
|
||||
PointerRNA tptr;
|
||||
PyObject *item;
|
||||
|
||||
if(index == -1) { /* all, use a list */
|
||||
if (index == -1) { /* all, use a list */
|
||||
int i= 0;
|
||||
ret= PyList_New(0);
|
||||
while((fcu= list_find_fcurve(&adt->drivers, path_full, i++))) {
|
||||
while ((fcu= list_find_fcurve(&adt->drivers, path_full, i++))) {
|
||||
RNA_pointer_create(id, &RNA_FCurve, fcu, &tptr);
|
||||
item= pyrna_struct_CreatePyObject(&tptr);
|
||||
PyList_Append(ret, item);
|
||||
@ -361,7 +361,7 @@ PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args)
|
||||
if (!PyArg_ParseTuple(args, "s|i:driver_remove", &path, &index))
|
||||
return NULL;
|
||||
|
||||
if(pyrna_struct_anim_args_parse(&self->ptr, "bpy_struct.driver_remove():", path, &path_full, &index) < 0) {
|
||||
if (pyrna_struct_anim_args_parse(&self->ptr, "bpy_struct.driver_remove():", path, &path_full, &index) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
@ -374,7 +374,7 @@ PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args)
|
||||
|
||||
MEM_freeN((void *)path_full);
|
||||
|
||||
if(BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1)
|
||||
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1)
|
||||
return NULL;
|
||||
|
||||
WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION|ND_FCURVES_ORDER, NULL);
|
||||
|
@ -67,7 +67,7 @@ static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[]
|
||||
if (dim + 1 < totdim) {
|
||||
/* check that a sequence contains dimsize[dim] items */
|
||||
const Py_ssize_t seq_size= PySequence_Size(seq);
|
||||
if(seq_size == -1) {
|
||||
if (seq_size == -1) {
|
||||
PyErr_Format(PyExc_ValueError, "%s sequence expected at dimension %d, not '%s'",
|
||||
error_prefix, (int)dim + 1, Py_TYPE(seq)->tp_name);
|
||||
return -1;
|
||||
@ -77,7 +77,7 @@ static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[]
|
||||
int ok= 1;
|
||||
item= PySequence_GetItem(seq, i);
|
||||
|
||||
if(item == NULL) {
|
||||
if (item == NULL) {
|
||||
PyErr_Format(PyExc_TypeError, "%s sequence type '%s' failed to retrieve index %d",
|
||||
error_prefix, Py_TYPE(seq)->tp_name, i);
|
||||
ok= 0;
|
||||
@ -112,7 +112,7 @@ static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[]
|
||||
else {
|
||||
/* check that items are of correct type */
|
||||
const int seq_size= PySequence_Size(seq);
|
||||
if(seq_size == -1) {
|
||||
if (seq_size == -1) {
|
||||
PyErr_Format(PyExc_ValueError, "%s sequence expected at dimension %d, not '%s'",
|
||||
error_prefix, (int)dim + 1, Py_TYPE(seq)->tp_name);
|
||||
return -1;
|
||||
@ -120,7 +120,7 @@ static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[]
|
||||
for (i= 0; i < seq_size; i++) {
|
||||
PyObject *item= PySequence_GetItem(seq, i);
|
||||
|
||||
if(item == NULL) {
|
||||
if (item == NULL) {
|
||||
PyErr_Format(PyExc_TypeError, "%s sequence type '%s' failed to retrieve index %d",
|
||||
error_prefix, Py_TYPE(seq)->tp_name, i);
|
||||
return -1;
|
||||
@ -146,15 +146,15 @@ static int count_items(PyObject *seq, int dim)
|
||||
{
|
||||
int totitem= 0;
|
||||
|
||||
if(dim > 1) {
|
||||
if (dim > 1) {
|
||||
const Py_ssize_t seq_size= PySequence_Size(seq);
|
||||
Py_ssize_t i;
|
||||
for (i= 0; i < seq_size; i++) {
|
||||
PyObject *item= PySequence_GetItem(seq, i);
|
||||
if(item) {
|
||||
if (item) {
|
||||
const int tot= count_items(item, dim - 1);
|
||||
Py_DECREF(item);
|
||||
if(tot != -1) {
|
||||
if (tot != -1) {
|
||||
totitem += tot;
|
||||
}
|
||||
else {
|
||||
@ -184,7 +184,7 @@ static int validate_array_length(PyObject *rvalue, PointerRNA *ptr, PropertyRNA
|
||||
totdim= RNA_property_array_dimension(ptr, prop, dimsize);
|
||||
tot= count_items(rvalue, totdim - lvalue_dim);
|
||||
|
||||
if(tot == -1) {
|
||||
if (tot == -1) {
|
||||
PyErr_Format(PyExc_ValueError, "%s %.200s.%.200s, error validating the sequence length",
|
||||
error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop));
|
||||
return -1;
|
||||
@ -294,13 +294,13 @@ static char *copy_values(PyObject *seq, PointerRNA *ptr, PropertyRNA *prop, int
|
||||
|
||||
/* Note that 'data can be NULL' */
|
||||
|
||||
if(seq_size == -1) {
|
||||
if (seq_size == -1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i= 0; i < seq_size; i++) {
|
||||
PyObject *item= PySequence_GetItem(seq, i);
|
||||
if(item) {
|
||||
if (item) {
|
||||
if (dim + 1 < totdim) {
|
||||
data= copy_values(item, ptr, prop, dim + 1, data, item_size, index, convert_item, rna_set_index);
|
||||
}
|
||||
@ -334,7 +334,7 @@ static int py_to_array(PyObject *seq, PointerRNA *ptr, PropertyRNA *prop, char *
|
||||
|
||||
if (totitem) {
|
||||
/* note: this code is confusing */
|
||||
if(param_data && RNA_property_flag(prop) & PROP_DYNAMIC) {
|
||||
if (param_data && RNA_property_flag(prop) & PROP_DYNAMIC) {
|
||||
/* not freeing allocated mem, RNA_parameter_list_free() will do this */
|
||||
ParameterDynAlloc *param_alloc= (ParameterDynAlloc *)param_data;
|
||||
param_alloc->array_tot= (int)totitem;
|
||||
@ -351,7 +351,7 @@ static int py_to_array(PyObject *seq, PointerRNA *ptr, PropertyRNA *prop, char *
|
||||
|
||||
/* will only fail in very rare cases since we already validated the
|
||||
* python data, the check here is mainly for completeness. */
|
||||
if(copy_values(seq, ptr, prop, 0, data, item_size, NULL, convert_item, NULL) != NULL) {
|
||||
if (copy_values(seq, ptr, prop, 0, data, item_size, NULL, convert_item, NULL) != NULL) {
|
||||
if (param_data==NULL) {
|
||||
/* NULL can only pass through in case RNA property arraylength is 0 (impossible?) */
|
||||
rna_set_array(ptr, prop, data);
|
||||
@ -396,8 +396,8 @@ static int py_to_array_index(PyObject *py, PointerRNA *ptr, PropertyRNA *prop, i
|
||||
|
||||
index += arrayoffset;
|
||||
|
||||
if(lvalue_dim == totdim) { /* single item, assign directly */
|
||||
if(!check_item_type(py)) {
|
||||
if (lvalue_dim == totdim) { /* single item, assign directly */
|
||||
if (!check_item_type(py)) {
|
||||
PyErr_Format(PyExc_TypeError, "%s %.200s.%.200s, expected a %s type, not %s",
|
||||
error_prefix, RNA_struct_identifier(ptr->type),
|
||||
RNA_property_identifier(prop), item_type_str,
|
||||
@ -628,7 +628,7 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
|
||||
int type;
|
||||
int i;
|
||||
|
||||
if(len==0) /* possible with dynamic arrays */
|
||||
if (len==0) /* possible with dynamic arrays */
|
||||
return 0;
|
||||
|
||||
if (RNA_property_array_dimension(ptr, prop, NULL) > 1) {
|
||||
@ -642,7 +642,7 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
|
||||
case PROP_FLOAT:
|
||||
{
|
||||
float value_f= PyFloat_AsDouble(value);
|
||||
if(value_f==-1 && PyErr_Occurred()) {
|
||||
if (value_f==-1 && PyErr_Occurred()) {
|
||||
PyErr_Clear();
|
||||
return 0;
|
||||
}
|
||||
@ -650,7 +650,7 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
|
||||
float tmp[32];
|
||||
float *tmp_arr;
|
||||
|
||||
if(len * sizeof(float) > sizeof(tmp)) {
|
||||
if (len * sizeof(float) > sizeof(tmp)) {
|
||||
tmp_arr= PyMem_MALLOC(len * sizeof(float));
|
||||
}
|
||||
else {
|
||||
@ -659,11 +659,13 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
|
||||
|
||||
RNA_property_float_get_array(ptr, prop, tmp_arr);
|
||||
|
||||
for(i=0; i<len; i++)
|
||||
if(tmp_arr[i] == value_f)
|
||||
for (i=0; i<len; i++) {
|
||||
if (tmp_arr[i] == value_f) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(tmp_arr != tmp)
|
||||
if (tmp_arr != tmp)
|
||||
PyMem_FREE(tmp_arr);
|
||||
|
||||
return i<len ? 1 : 0;
|
||||
@ -674,7 +676,7 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
|
||||
case PROP_INT:
|
||||
{
|
||||
int value_i= PyLong_AsSsize_t(value);
|
||||
if(value_i==-1 && PyErr_Occurred()) {
|
||||
if (value_i==-1 && PyErr_Occurred()) {
|
||||
PyErr_Clear();
|
||||
return 0;
|
||||
}
|
||||
@ -682,23 +684,25 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
|
||||
int tmp[32];
|
||||
int *tmp_arr;
|
||||
|
||||
if(len * sizeof(int) > sizeof(tmp)) {
|
||||
if (len * sizeof(int) > sizeof(tmp)) {
|
||||
tmp_arr= PyMem_MALLOC(len * sizeof(int));
|
||||
}
|
||||
else {
|
||||
tmp_arr= tmp;
|
||||
}
|
||||
|
||||
if(type==PROP_BOOLEAN)
|
||||
if (type==PROP_BOOLEAN)
|
||||
RNA_property_boolean_get_array(ptr, prop, tmp_arr);
|
||||
else
|
||||
RNA_property_int_get_array(ptr, prop, tmp_arr);
|
||||
|
||||
for(i=0; i<len; i++)
|
||||
if(tmp_arr[i] == value_i)
|
||||
for (i=0; i<len; i++) {
|
||||
if (tmp_arr[i] == value_i) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(tmp_arr != tmp)
|
||||
if (tmp_arr != tmp)
|
||||
PyMem_FREE(tmp_arr);
|
||||
|
||||
return i<len ? 1 : 0;
|
||||
|
@ -114,19 +114,19 @@ void python_script_error_jump(const char *filepath, int *lineno, int *offset)
|
||||
|
||||
PyErr_Fetch(&exception, &value, (PyObject **)&tb);
|
||||
|
||||
if(exception && PyErr_GivenExceptionMatches(exception, PyExc_SyntaxError)) {
|
||||
if (exception && PyErr_GivenExceptionMatches(exception, PyExc_SyntaxError)) {
|
||||
/* no traceback available when SyntaxError.
|
||||
* python has no api's to this. reference parse_syntax_error() from pythonrun.c */
|
||||
PyErr_NormalizeException(&exception, &value, (PyObject **)&tb);
|
||||
PyErr_Restore(exception, value, (PyObject *)tb); /* takes away reference! */
|
||||
|
||||
if(value) { /* should always be true */
|
||||
if (value) { /* should always be true */
|
||||
PyObject *message;
|
||||
const char *filename, *text;
|
||||
|
||||
if(parse_syntax_error(value, &message, &filename, lineno, offset, &text)) {
|
||||
if (parse_syntax_error(value, &message, &filename, lineno, offset, &text)) {
|
||||
/* python adds a '/', prefix, so check for both */
|
||||
if( (strcmp(filename, filepath) == 0) ||
|
||||
if ((strcmp(filename, filepath) == 0) ||
|
||||
((filename[0] == '\\' || filename[0] == '/') && strcmp(filename + 1, filepath) == 0)
|
||||
) {
|
||||
/* good */
|
||||
@ -145,13 +145,13 @@ void python_script_error_jump(const char *filepath, int *lineno, int *offset)
|
||||
PyErr_Restore(exception, value, (PyObject *)tb); /* takes away reference! */
|
||||
PyErr_Print();
|
||||
|
||||
for(tb= (PyTracebackObject *)PySys_GetObject("last_traceback"); tb && (PyObject *)tb != Py_None; tb= tb->tb_next) {
|
||||
for (tb= (PyTracebackObject *)PySys_GetObject("last_traceback"); tb && (PyObject *)tb != Py_None; tb= tb->tb_next) {
|
||||
PyObject *coerce;
|
||||
const char *tb_filepath= traceback_filepath(tb, &coerce);
|
||||
const int match= strcmp(tb_filepath, filepath) != 0;
|
||||
Py_DECREF(coerce);
|
||||
|
||||
if(match) {
|
||||
if (match) {
|
||||
*lineno= tb->tb_lineno;
|
||||
break;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ char *BPy_enum_as_string(EnumPropertyItem *item)
|
||||
char *cstring;
|
||||
|
||||
for (e= item; item->identifier; item++) {
|
||||
if(item->identifier[0])
|
||||
if (item->identifier[0])
|
||||
BLI_dynstr_appendf(dynstr, (e==item)?"'%s'":", '%s'", item->identifier);
|
||||
}
|
||||
|
||||
@ -63,11 +63,11 @@ short BPy_reports_to_error(ReportList *reports, PyObject *exception, const short
|
||||
|
||||
report_str= BKE_reports_string(reports, RPT_ERROR);
|
||||
|
||||
if(clear) {
|
||||
if (clear) {
|
||||
BKE_reports_clear(reports);
|
||||
}
|
||||
|
||||
if(report_str) {
|
||||
if (report_str) {
|
||||
PyErr_SetString(exception, report_str);
|
||||
MEM_freeN(report_str);
|
||||
}
|
||||
@ -89,7 +89,7 @@ short BPy_errors_to_report(ReportList *reports)
|
||||
return 1;
|
||||
|
||||
/* less hassle if we allow NULL */
|
||||
if(reports==NULL) {
|
||||
if (reports==NULL) {
|
||||
PyErr_Print();
|
||||
PyErr_Clear();
|
||||
return 1;
|
||||
@ -97,13 +97,13 @@ short BPy_errors_to_report(ReportList *reports)
|
||||
|
||||
pystring= PyC_ExceptionBuffer();
|
||||
|
||||
if(pystring==NULL) {
|
||||
if (pystring==NULL) {
|
||||
BKE_report(reports, RPT_ERROR, "unknown py-exception, couldn't convert");
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyC_FileAndNum(&filename, &lineno);
|
||||
if(filename==NULL)
|
||||
if (filename==NULL)
|
||||
filename= "<unknown location>";
|
||||
|
||||
cstring= _PyUnicode_AsString(pystring);
|
||||
|
@ -77,7 +77,7 @@ PyInit_gpu(void)
|
||||
PyObject* m;
|
||||
|
||||
m = PyModule_Create(&gpumodule);
|
||||
if(m == NULL)
|
||||
if (m == NULL)
|
||||
return NULL;
|
||||
|
||||
// device constants
|
||||
@ -164,7 +164,7 @@ static PyObject* GPU_export_shader(PyObject* UNUSED(self), PyObject *args, PyObj
|
||||
|
||||
static const char *kwlist[] = {"scene", "material", NULL};
|
||||
|
||||
if(!PyArg_ParseTupleAndKeywords(args, kwds, "OO:export_shader", (char**)(kwlist), &pyscene, &pymat))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO:export_shader", (char**)(kwlist), &pyscene, &pymat))
|
||||
return NULL;
|
||||
|
||||
if (!strcmp(Py_TYPE(pyscene)->tp_name, "Scene") &&
|
||||
|
@ -49,14 +49,14 @@ static int mathutils_array_parse_fast(float *array, int array_min, int array_max
|
||||
int i, size;
|
||||
|
||||
/* non list/tuple cases */
|
||||
if(!(value_fast=PySequence_Fast(value, error_prefix))) {
|
||||
if (!(value_fast=PySequence_Fast(value, error_prefix))) {
|
||||
/* PySequence_Fast sets the error */
|
||||
return -1;
|
||||
}
|
||||
|
||||
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) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"%.200s: sequence size is %d, expected %d",
|
||||
@ -74,7 +74,7 @@ static int mathutils_array_parse_fast(float *array, int array_min, int array_max
|
||||
i= size;
|
||||
do {
|
||||
i--;
|
||||
if(((array[i]= PyFloat_AsDouble((item= PySequence_Fast_GET_ITEM(value_fast, i)))) == -1.0f) && PyErr_Occurred()) {
|
||||
if (((array[i]= PyFloat_AsDouble((item= PySequence_Fast_GET_ITEM(value_fast, i)))) == -1.0f) && PyErr_Occurred()) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s: sequence index %d expected a number, "
|
||||
"found '%.200s' type, ",
|
||||
@ -82,7 +82,7 @@ static int mathutils_array_parse_fast(float *array, int array_min, int array_max
|
||||
Py_DECREF(value_fast);
|
||||
return -1;
|
||||
}
|
||||
} while(i);
|
||||
} while (i);
|
||||
|
||||
Py_XDECREF(value_fast);
|
||||
return size;
|
||||
@ -94,16 +94,16 @@ int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *
|
||||
#if 1 /* approx 6x speedup for mathutils types */
|
||||
int size;
|
||||
|
||||
if( (size= VectorObject_Check(value) ? ((VectorObject *)value)->size : 0) ||
|
||||
if ( (size= VectorObject_Check(value) ? ((VectorObject *)value)->size : 0) ||
|
||||
(size= EulerObject_Check(value) ? 3 : 0) ||
|
||||
(size= QuaternionObject_Check(value) ? 4 : 0) ||
|
||||
(size= ColorObject_Check(value) ? 3 : 0))
|
||||
{
|
||||
if(BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
|
||||
if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(size > array_max || size < array_min) {
|
||||
if (size > array_max || size < array_min) {
|
||||
if (array_max == array_min) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"%.200s: sequence size is %d, expected %d",
|
||||
@ -129,8 +129,8 @@ int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *
|
||||
|
||||
int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error_prefix)
|
||||
{
|
||||
if(EulerObject_Check(value)) {
|
||||
if(BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
|
||||
if (EulerObject_Check(value)) {
|
||||
if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
@ -139,7 +139,7 @@ int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error
|
||||
}
|
||||
}
|
||||
else if (QuaternionObject_Check(value)) {
|
||||
if(BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
|
||||
if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
@ -150,10 +150,10 @@ int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error
|
||||
}
|
||||
}
|
||||
else if (MatrixObject_Check(value)) {
|
||||
if(BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
|
||||
if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
|
||||
return -1;
|
||||
}
|
||||
else if(((MatrixObject *)value)->col_size < 3 || ((MatrixObject *)value)->row_size < 3) {
|
||||
else if (((MatrixObject *)value)->col_size < 3 || ((MatrixObject *)value)->row_size < 3) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"%.200s: matrix must have minimum 3x3 dimensions",
|
||||
error_prefix);
|
||||
@ -202,7 +202,7 @@ int EXPP_FloatsAreEqual(float af, float bf, int maxDiff)
|
||||
int EXPP_VectorsAreEqual(float *vecA, float *vecB, int size, int floatSteps)
|
||||
{
|
||||
int x;
|
||||
for (x=0; x< size; x++){
|
||||
for (x=0; x< size; x++) {
|
||||
if (EXPP_FloatsAreEqual(vecA[x], vecB[x], floatSteps) == 0)
|
||||
return 0;
|
||||
}
|
||||
@ -220,8 +220,8 @@ int Mathutils_RegisterCallback(Mathutils_Callback *cb)
|
||||
int i;
|
||||
|
||||
/* find the first free slot */
|
||||
for(i= 0; mathutils_callbacks[i]; i++) {
|
||||
if(mathutils_callbacks[i]==cb) /* already registered? */
|
||||
for (i= 0; mathutils_callbacks[i]; i++) {
|
||||
if (mathutils_callbacks[i]==cb) /* already registered? */
|
||||
return i;
|
||||
}
|
||||
|
||||
@ -233,10 +233,10 @@ int Mathutils_RegisterCallback(Mathutils_Callback *cb)
|
||||
int _BaseMathObject_ReadCallback(BaseMathObject *self)
|
||||
{
|
||||
Mathutils_Callback *cb= mathutils_callbacks[self->cb_type];
|
||||
if(cb->get(self, self->cb_subtype) != -1)
|
||||
if (cb->get(self, self->cb_subtype) != -1)
|
||||
return 0;
|
||||
|
||||
if(!PyErr_Occurred()) {
|
||||
if (!PyErr_Occurred()) {
|
||||
PyErr_Format(PyExc_RuntimeError,
|
||||
"%s read, user has become invalid",
|
||||
Py_TYPE(self)->tp_name);
|
||||
@ -247,10 +247,10 @@ int _BaseMathObject_ReadCallback(BaseMathObject *self)
|
||||
int _BaseMathObject_WriteCallback(BaseMathObject *self)
|
||||
{
|
||||
Mathutils_Callback *cb= mathutils_callbacks[self->cb_type];
|
||||
if(cb->set(self, self->cb_subtype) != -1)
|
||||
if (cb->set(self, self->cb_subtype) != -1)
|
||||
return 0;
|
||||
|
||||
if(!PyErr_Occurred()) {
|
||||
if (!PyErr_Occurred()) {
|
||||
PyErr_Format(PyExc_RuntimeError,
|
||||
"%s write, user has become invalid",
|
||||
Py_TYPE(self)->tp_name);
|
||||
@ -261,10 +261,10 @@ int _BaseMathObject_WriteCallback(BaseMathObject *self)
|
||||
int _BaseMathObject_ReadIndexCallback(BaseMathObject *self, int index)
|
||||
{
|
||||
Mathutils_Callback *cb= mathutils_callbacks[self->cb_type];
|
||||
if(cb->get_index(self, self->cb_subtype, index) != -1)
|
||||
if (cb->get_index(self, self->cb_subtype, index) != -1)
|
||||
return 0;
|
||||
|
||||
if(!PyErr_Occurred()) {
|
||||
if (!PyErr_Occurred()) {
|
||||
PyErr_Format(PyExc_RuntimeError,
|
||||
"%s read index, user has become invalid",
|
||||
Py_TYPE(self)->tp_name);
|
||||
@ -275,10 +275,10 @@ int _BaseMathObject_ReadIndexCallback(BaseMathObject *self, int index)
|
||||
int _BaseMathObject_WriteIndexCallback(BaseMathObject *self, int index)
|
||||
{
|
||||
Mathutils_Callback *cb= mathutils_callbacks[self->cb_type];
|
||||
if(cb->set_index(self, self->cb_subtype, index) != -1)
|
||||
if (cb->set_index(self, self->cb_subtype, index) != -1)
|
||||
return 0;
|
||||
|
||||
if(!PyErr_Occurred()) {
|
||||
if (!PyErr_Occurred()) {
|
||||
PyErr_Format(PyExc_RuntimeError,
|
||||
"%s write index, user has become invalid",
|
||||
Py_TYPE(self)->tp_name);
|
||||
@ -316,11 +316,11 @@ int BaseMathObject_clear(BaseMathObject *self)
|
||||
void BaseMathObject_dealloc(BaseMathObject *self)
|
||||
{
|
||||
/* only free non wrapped */
|
||||
if(self->wrapped != Py_WRAP) {
|
||||
if (self->wrapped != Py_WRAP) {
|
||||
PyMem_Free(self->data);
|
||||
}
|
||||
|
||||
if(self->cb_user) {
|
||||
if (self->cb_user) {
|
||||
PyObject_GC_UnTrack(self);
|
||||
BaseMathObject_clear(self);
|
||||
}
|
||||
@ -350,15 +350,15 @@ PyMODINIT_FUNC PyInit_mathutils(void)
|
||||
PyObject *submodule;
|
||||
PyObject *item;
|
||||
|
||||
if(PyType_Ready(&vector_Type) < 0)
|
||||
if (PyType_Ready(&vector_Type) < 0)
|
||||
return NULL;
|
||||
if(PyType_Ready(&matrix_Type) < 0)
|
||||
if (PyType_Ready(&matrix_Type) < 0)
|
||||
return NULL;
|
||||
if(PyType_Ready(&euler_Type) < 0)
|
||||
if (PyType_Ready(&euler_Type) < 0)
|
||||
return NULL;
|
||||
if(PyType_Ready(&quaternion_Type) < 0)
|
||||
if (PyType_Ready(&quaternion_Type) < 0)
|
||||
return NULL;
|
||||
if(PyType_Ready(&color_Type) < 0)
|
||||
if (PyType_Ready(&color_Type) < 0)
|
||||
return NULL;
|
||||
|
||||
submodule = PyModule_Create(&M_Mathutils_module_def);
|
||||
|
@ -42,7 +42,7 @@ static PyObject *Color_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
float col[3]= {0.0f, 0.0f, 0.0f};
|
||||
|
||||
if(kwds && PyDict_Size(kwds)) {
|
||||
if (kwds && PyDict_Size(kwds)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"mathutils.Color(): "
|
||||
"takes no keyword args");
|
||||
@ -53,7 +53,7 @@ static PyObject *Color_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||
case 0:
|
||||
break;
|
||||
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:
|
||||
@ -75,13 +75,13 @@ static PyObject *Color_ToTupleExt(ColorObject *self, int ndigits)
|
||||
|
||||
ret= PyTuple_New(COLOR_SIZE);
|
||||
|
||||
if(ndigits >= 0) {
|
||||
for(i= 0; i < COLOR_SIZE; i++) {
|
||||
if (ndigits >= 0) {
|
||||
for (i= 0; i < COLOR_SIZE; i++) {
|
||||
PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(double_round((double)self->col[i], ndigits)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(i= 0; i < COLOR_SIZE; i++) {
|
||||
for (i= 0; i < COLOR_SIZE; i++) {
|
||||
PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(self->col[i]));
|
||||
}
|
||||
}
|
||||
@ -102,7 +102,7 @@ PyDoc_STRVAR(Color_copy_doc,
|
||||
);
|
||||
static PyObject *Color_copy(ColorObject *self)
|
||||
{
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
return newColorObject(self->col, Py_NEW, Py_TYPE(self));
|
||||
@ -115,7 +115,7 @@ static PyObject *Color_repr(ColorObject * self)
|
||||
{
|
||||
PyObject *ret, *tuple;
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
tuple= Color_ToTupleExt(self, -1);
|
||||
@ -137,7 +137,7 @@ static PyObject* Color_richcmpr(PyObject *a, PyObject *b, int op)
|
||||
ColorObject *colA= (ColorObject*)a;
|
||||
ColorObject *colB= (ColorObject*)b;
|
||||
|
||||
if(BaseMath_ReadCallback(colA) == -1 || BaseMath_ReadCallback(colB) == -1)
|
||||
if (BaseMath_ReadCallback(colA) == -1 || BaseMath_ReadCallback(colB) == -1)
|
||||
return NULL;
|
||||
|
||||
ok= EXPP_VectorsAreEqual(colA->col, colB->col, COLOR_SIZE, 1) ? 0 : -1;
|
||||
@ -175,16 +175,16 @@ static int Color_len(ColorObject *UNUSED(self))
|
||||
//sequence accessor (get)
|
||||
static PyObject *Color_item(ColorObject * self, int i)
|
||||
{
|
||||
if(i<0) i= COLOR_SIZE-i;
|
||||
if (i<0) i= COLOR_SIZE-i;
|
||||
|
||||
if(i < 0 || i >= COLOR_SIZE) {
|
||||
if (i < 0 || i >= COLOR_SIZE) {
|
||||
PyErr_SetString(PyExc_IndexError,
|
||||
"color[attribute]: "
|
||||
"array index out of range");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(BaseMath_ReadIndexCallback(self, i) == -1)
|
||||
if (BaseMath_ReadIndexCallback(self, i) == -1)
|
||||
return NULL;
|
||||
|
||||
return PyFloat_FromDouble(self->col[i]);
|
||||
@ -196,16 +196,16 @@ static int Color_ass_item(ColorObject * self, int i, PyObject *value)
|
||||
{
|
||||
float f = PyFloat_AsDouble(value);
|
||||
|
||||
if(f == -1 && PyErr_Occurred()) { // parsed item not a number
|
||||
if (f == -1 && PyErr_Occurred()) { // parsed item not a number
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"color[attribute] = x: "
|
||||
"argument not a number");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(i<0) i= COLOR_SIZE-i;
|
||||
if (i<0) i= COLOR_SIZE-i;
|
||||
|
||||
if(i < 0 || i >= COLOR_SIZE){
|
||||
if (i < 0 || i >= COLOR_SIZE) {
|
||||
PyErr_SetString(PyExc_IndexError, "color[attribute] = x: "
|
||||
"array assignment index out of range");
|
||||
return -1;
|
||||
@ -213,7 +213,7 @@ static int Color_ass_item(ColorObject * self, int i, PyObject *value)
|
||||
|
||||
self->col[i] = f;
|
||||
|
||||
if(BaseMath_WriteIndexCallback(self, i) == -1)
|
||||
if (BaseMath_WriteIndexCallback(self, i) == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
@ -225,7 +225,7 @@ static PyObject *Color_slice(ColorObject * self, int begin, int end)
|
||||
PyObject *tuple;
|
||||
int count;
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
CLAMP(begin, 0, COLOR_SIZE);
|
||||
@ -234,7 +234,7 @@ static PyObject *Color_slice(ColorObject * self, int begin, int end)
|
||||
begin= MIN2(begin, end);
|
||||
|
||||
tuple= PyTuple_New(end - begin);
|
||||
for(count= begin; count < end; count++) {
|
||||
for (count= begin; count < end; count++) {
|
||||
PyTuple_SET_ITEM(tuple, count - begin, PyFloat_FromDouble(self->col[count]));
|
||||
}
|
||||
|
||||
@ -247,7 +247,7 @@ static int Color_ass_slice(ColorObject *self, int begin, int end, PyObject *seq)
|
||||
int i, size;
|
||||
float col[COLOR_SIZE];
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return -1;
|
||||
|
||||
CLAMP(begin, 0, COLOR_SIZE);
|
||||
@ -255,17 +255,17 @@ static int Color_ass_slice(ColorObject *self, int begin, int end, PyObject *seq)
|
||||
CLAMP(end, 0, COLOR_SIZE);
|
||||
begin = MIN2(begin, end);
|
||||
|
||||
if((size=mathutils_array_parse(col, 0, COLOR_SIZE, seq, "mathutils.Color[begin:end] = []")) == -1)
|
||||
if ((size=mathutils_array_parse(col, 0, COLOR_SIZE, seq, "mathutils.Color[begin:end] = []")) == -1)
|
||||
return -1;
|
||||
|
||||
if(size != (end - begin)){
|
||||
if (size != (end - begin)) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"color[begin:end] = []: "
|
||||
"size mismatch in slice assignment");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for(i= 0; i < COLOR_SIZE; i++)
|
||||
for (i= 0; i < COLOR_SIZE; i++)
|
||||
self->col[begin + i] = col[i];
|
||||
|
||||
(void)BaseMath_WriteCallback(self);
|
||||
@ -379,7 +379,7 @@ static PyObject *Color_add(PyObject *v1, PyObject *v2)
|
||||
color1 = (ColorObject*)v1;
|
||||
color2 = (ColorObject*)v2;
|
||||
|
||||
if(BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1)
|
||||
if (BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1)
|
||||
return NULL;
|
||||
|
||||
add_vn_vnvn(col, color1->col, color2->col, COLOR_SIZE);
|
||||
@ -401,7 +401,7 @@ static PyObject *Color_iadd(PyObject *v1, PyObject *v2)
|
||||
color1 = (ColorObject*)v1;
|
||||
color2 = (ColorObject*)v2;
|
||||
|
||||
if(BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1)
|
||||
if (BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1)
|
||||
return NULL;
|
||||
|
||||
add_vn_vn(color1->col, color2->col, COLOR_SIZE);
|
||||
@ -426,7 +426,7 @@ static PyObject *Color_sub(PyObject *v1, PyObject *v2)
|
||||
color1 = (ColorObject*)v1;
|
||||
color2 = (ColorObject*)v2;
|
||||
|
||||
if(BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1)
|
||||
if (BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1)
|
||||
return NULL;
|
||||
|
||||
sub_vn_vnvn(col, color1->col, color2->col, COLOR_SIZE);
|
||||
@ -448,7 +448,7 @@ static PyObject *Color_isub(PyObject *v1, PyObject *v2)
|
||||
color1 = (ColorObject*)v1;
|
||||
color2 = (ColorObject*)v2;
|
||||
|
||||
if(BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1)
|
||||
if (BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1)
|
||||
return NULL;
|
||||
|
||||
sub_vn_vn(color1->col, color2->col, COLOR_SIZE);
|
||||
@ -473,12 +473,12 @@ static PyObject *Color_mul(PyObject *v1, PyObject *v2)
|
||||
|
||||
if ColorObject_Check(v1) {
|
||||
color1= (ColorObject *)v1;
|
||||
if(BaseMath_ReadCallback(color1) == -1)
|
||||
if (BaseMath_ReadCallback(color1) == -1)
|
||||
return NULL;
|
||||
}
|
||||
if ColorObject_Check(v2) {
|
||||
color2= (ColorObject *)v2;
|
||||
if(BaseMath_ReadCallback(color2) == -1)
|
||||
if (BaseMath_ReadCallback(color2) == -1)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -515,7 +515,7 @@ static PyObject *Color_div(PyObject *v1, PyObject *v2)
|
||||
|
||||
if ColorObject_Check(v1) {
|
||||
color1= (ColorObject *)v1;
|
||||
if(BaseMath_ReadCallback(color1) == -1)
|
||||
if (BaseMath_ReadCallback(color1) == -1)
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
@ -526,7 +526,7 @@ static PyObject *Color_div(PyObject *v1, PyObject *v2)
|
||||
|
||||
/* make sure v1 is always the vector */
|
||||
if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* COLOR * FLOAT */
|
||||
if(scalar==0.0f) {
|
||||
if (scalar==0.0f) {
|
||||
PyErr_SetString(PyExc_ZeroDivisionError,
|
||||
"Color division: divide by zero error");
|
||||
return NULL;
|
||||
@ -547,7 +547,7 @@ static PyObject *Color_imul(PyObject *v1, PyObject *v2)
|
||||
ColorObject *color = (ColorObject *)v1;
|
||||
float scalar;
|
||||
|
||||
if(BaseMath_ReadCallback(color) == -1)
|
||||
if (BaseMath_ReadCallback(color) == -1)
|
||||
return NULL;
|
||||
|
||||
/* only support color *= float */
|
||||
@ -572,12 +572,12 @@ static PyObject *Color_idiv(PyObject *v1, PyObject *v2)
|
||||
ColorObject *color = (ColorObject *)v1;
|
||||
float scalar;
|
||||
|
||||
if(BaseMath_ReadCallback(color) == -1)
|
||||
if (BaseMath_ReadCallback(color) == -1)
|
||||
return NULL;
|
||||
|
||||
/* only support color /= float */
|
||||
if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* COLOR /= FLOAT */
|
||||
if(scalar==0.0f) {
|
||||
if (scalar==0.0f) {
|
||||
PyErr_SetString(PyExc_ZeroDivisionError,
|
||||
"Color division: divide by zero error");
|
||||
return NULL;
|
||||
@ -603,7 +603,7 @@ static PyObject *Color_neg(ColorObject *self)
|
||||
{
|
||||
float tcol[COLOR_SIZE];
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
negate_vn_vn(tcol, self->col, COLOR_SIZE);
|
||||
@ -665,7 +665,7 @@ static PyObject *Color_getChannelHSV(ColorObject * self, void *type)
|
||||
float hsv[3];
|
||||
int i= GET_INT_FROM_POINTER(type);
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
rgb_to_hsv(self->col[0], self->col[1], self->col[2], &(hsv[0]), &(hsv[1]), &(hsv[2]));
|
||||
@ -679,14 +679,14 @@ static int Color_setChannelHSV(ColorObject * self, PyObject *value, void * type)
|
||||
int i= GET_INT_FROM_POINTER(type);
|
||||
float f = PyFloat_AsDouble(value);
|
||||
|
||||
if(f == -1 && PyErr_Occurred()) {
|
||||
if (f == -1 && PyErr_Occurred()) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"color.h/s/v = value: "
|
||||
"argument not a number");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return -1;
|
||||
|
||||
rgb_to_hsv(self->col[0], self->col[1], self->col[2], &(hsv[0]), &(hsv[1]), &(hsv[2]));
|
||||
@ -694,7 +694,7 @@ static int Color_setChannelHSV(ColorObject * self, PyObject *value, void * type)
|
||||
hsv[i] = f;
|
||||
hsv_to_rgb(hsv[0], hsv[1], hsv[2], &(self->col[0]), &(self->col[1]), &(self->col[2]));
|
||||
|
||||
if(BaseMath_WriteCallback(self) == -1)
|
||||
if (BaseMath_WriteCallback(self) == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
@ -706,7 +706,7 @@ static PyObject *Color_getHSV(ColorObject * self, void *UNUSED(closure))
|
||||
float hsv[3];
|
||||
PyObject *ret;
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
rgb_to_hsv(self->col[0], self->col[1], self->col[2], &(hsv[0]), &(hsv[1]), &(hsv[2]));
|
||||
@ -722,7 +722,7 @@ static int Color_setHSV(ColorObject * self, PyObject *value, void *UNUSED(closur
|
||||
{
|
||||
float hsv[3];
|
||||
|
||||
if(mathutils_array_parse(hsv, 3, 3, value, "mathutils.Color.hsv = value") == -1)
|
||||
if (mathutils_array_parse(hsv, 3, 3, value, "mathutils.Color.hsv = value") == -1)
|
||||
return -1;
|
||||
|
||||
CLAMP(hsv[0], 0.0f, 1.0f);
|
||||
@ -731,7 +731,7 @@ static int Color_setHSV(ColorObject * self, PyObject *value, void *UNUSED(closur
|
||||
|
||||
hsv_to_rgb(hsv[0], hsv[1], hsv[2], &(self->col[0]), &(self->col[1]), &(self->col[2]));
|
||||
|
||||
if(BaseMath_WriteCallback(self) == -1)
|
||||
if (BaseMath_WriteCallback(self) == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
@ -834,11 +834,11 @@ PyObject *newColorObject(float *col, int type, PyTypeObject *base_type)
|
||||
self->cb_user= NULL;
|
||||
self->cb_type= self->cb_subtype= 0;
|
||||
|
||||
if(type == Py_WRAP){
|
||||
if(type == Py_WRAP) {
|
||||
self->col = col;
|
||||
self->wrapped = Py_WRAP;
|
||||
}
|
||||
else if (type == Py_NEW){
|
||||
else if (type == Py_NEW) {
|
||||
self->col = PyMem_Malloc(COLOR_SIZE * sizeof(float));
|
||||
if(col)
|
||||
copy_v3_v3(self->col, col);
|
||||
|
@ -50,21 +50,21 @@ static PyObject *Euler_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||
float eul[EULER_SIZE]= {0.0f, 0.0f, 0.0f};
|
||||
short order= EULER_ORDER_XYZ;
|
||||
|
||||
if(kwds && PyDict_Size(kwds)) {
|
||||
if (kwds && PyDict_Size(kwds)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"mathutils.Euler(): "
|
||||
"takes no keyword args");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!PyArg_ParseTuple(args, "|Os:mathutils.Euler", &seq, &order_str))
|
||||
if (!PyArg_ParseTuple(args, "|Os:mathutils.Euler", &seq, &order_str))
|
||||
return NULL;
|
||||
|
||||
switch(PyTuple_GET_SIZE(args)) {
|
||||
case 0:
|
||||
break;
|
||||
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;
|
||||
/* intentionally pass through */
|
||||
case 1:
|
||||
@ -84,7 +84,7 @@ static const char *euler_order_str(EulerObject *self)
|
||||
|
||||
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)) {
|
||||
case 'X'|'Y'<<8|'Z'<<16: return EULER_ORDER_XYZ;
|
||||
case 'X'|'Z'<<8|'Y'<<16: return EULER_ORDER_XZY;
|
||||
@ -109,13 +109,13 @@ static PyObject *Euler_ToTupleExt(EulerObject *self, int ndigits)
|
||||
|
||||
ret= PyTuple_New(EULER_SIZE);
|
||||
|
||||
if(ndigits >= 0) {
|
||||
for(i= 0; i < EULER_SIZE; i++) {
|
||||
if (ndigits >= 0) {
|
||||
for (i= 0; i < EULER_SIZE; i++) {
|
||||
PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(double_round((double)self->eul[i], ndigits)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(i= 0; i < EULER_SIZE; i++) {
|
||||
for (i= 0; i < EULER_SIZE; i++) {
|
||||
PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(self->eul[i]));
|
||||
}
|
||||
}
|
||||
@ -138,7 +138,7 @@ static PyObject *Euler_to_quaternion(EulerObject * self)
|
||||
{
|
||||
float quat[4];
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
eulO_to_quat(quat, self->eul, self->order);
|
||||
@ -159,7 +159,7 @@ static PyObject *Euler_to_matrix(EulerObject * self)
|
||||
{
|
||||
float mat[9];
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
eulO_to_mat3((float (*)[3])mat, self->eul, self->order);
|
||||
@ -176,7 +176,7 @@ static PyObject *Euler_zero(EulerObject * self)
|
||||
{
|
||||
zero_v3(self->eul);
|
||||
|
||||
if(BaseMath_WriteCallback(self) == -1)
|
||||
if (BaseMath_WriteCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
Py_RETURN_NONE;
|
||||
@ -198,21 +198,21 @@ static PyObject *Euler_rotate_axis(EulerObject * self, PyObject *args)
|
||||
float angle = 0.0f;
|
||||
int axis; /* actually a character */
|
||||
|
||||
if(!PyArg_ParseTuple(args, "Cf:rotate", &axis, &angle)){
|
||||
if (!PyArg_ParseTuple(args, "Cf:rotate", &axis, &angle)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"Euler.rotate_axis(): "
|
||||
"expected an axis 'X', 'Y', 'Z' and an angle (float)");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!(ELEM3(axis, 'X', 'Y', 'Z'))){
|
||||
if (!(ELEM3(axis, 'X', 'Y', 'Z'))) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"Euler.rotate_axis(): "
|
||||
"expected axis to be 'X', 'Y' or 'Z'");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
|
||||
@ -235,10 +235,10 @@ static PyObject *Euler_rotate(EulerObject * self, PyObject *value)
|
||||
{
|
||||
float self_rmat[3][3], other_rmat[3][3], rmat[3][3];
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
if(mathutils_any_to_rotmat(other_rmat, value, "euler.rotate(value)") == -1)
|
||||
if (mathutils_any_to_rotmat(other_rmat, value, "euler.rotate(value)") == -1)
|
||||
return NULL;
|
||||
|
||||
eulO_to_mat3(self_rmat, self->eul, self->order);
|
||||
@ -262,10 +262,10 @@ static PyObject *Euler_make_compatible(EulerObject * self, PyObject *value)
|
||||
{
|
||||
float teul[EULER_SIZE];
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
if(mathutils_array_parse(teul, EULER_SIZE, EULER_SIZE, value, "euler.make_compatible(other), invalid 'other' arg") == -1)
|
||||
if (mathutils_array_parse(teul, EULER_SIZE, EULER_SIZE, value, "euler.make_compatible(other), invalid 'other' arg") == -1)
|
||||
return NULL;
|
||||
|
||||
compatible_eul(self->eul, teul);
|
||||
@ -291,7 +291,7 @@ PyDoc_STRVAR(Euler_copy_doc,
|
||||
);
|
||||
static PyObject *Euler_copy(EulerObject *self)
|
||||
{
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
return newEulerObject(self->eul, self->order, Py_NEW, Py_TYPE(self));
|
||||
@ -304,7 +304,7 @@ static PyObject *Euler_repr(EulerObject * self)
|
||||
{
|
||||
PyObject *ret, *tuple;
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
tuple= Euler_ToTupleExt(self, -1);
|
||||
@ -324,7 +324,7 @@ static PyObject* Euler_richcmpr(PyObject *a, PyObject *b, int op)
|
||||
EulerObject *eulA= (EulerObject*)a;
|
||||
EulerObject *eulB= (EulerObject*)b;
|
||||
|
||||
if(BaseMath_ReadCallback(eulA) == -1 || BaseMath_ReadCallback(eulB) == -1)
|
||||
if (BaseMath_ReadCallback(eulA) == -1 || BaseMath_ReadCallback(eulB) == -1)
|
||||
return NULL;
|
||||
|
||||
ok= ((eulA->order == eulB->order) && EXPP_VectorsAreEqual(eulA->eul, eulB->eul, EULER_SIZE, 1)) ? 0 : -1;
|
||||
@ -362,16 +362,16 @@ static int Euler_len(EulerObject *UNUSED(self))
|
||||
//sequence accessor (get)
|
||||
static PyObject *Euler_item(EulerObject * self, int i)
|
||||
{
|
||||
if(i<0) i= EULER_SIZE-i;
|
||||
if (i<0) i= EULER_SIZE-i;
|
||||
|
||||
if(i < 0 || i >= EULER_SIZE) {
|
||||
if (i < 0 || i >= EULER_SIZE) {
|
||||
PyErr_SetString(PyExc_IndexError,
|
||||
"euler[attribute]: "
|
||||
"array index out of range");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(BaseMath_ReadIndexCallback(self, i) == -1)
|
||||
if (BaseMath_ReadIndexCallback(self, i) == -1)
|
||||
return NULL;
|
||||
|
||||
return PyFloat_FromDouble(self->eul[i]);
|
||||
@ -383,16 +383,16 @@ static int Euler_ass_item(EulerObject * self, int i, PyObject *value)
|
||||
{
|
||||
float f = PyFloat_AsDouble(value);
|
||||
|
||||
if(f == -1 && PyErr_Occurred()) { // parsed item not a number
|
||||
if (f == -1 && PyErr_Occurred()) { // parsed item not a number
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"euler[attribute] = x: "
|
||||
"argument not a number");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(i<0) i= EULER_SIZE-i;
|
||||
if (i<0) i= EULER_SIZE-i;
|
||||
|
||||
if(i < 0 || i >= EULER_SIZE){
|
||||
if (i < 0 || i >= EULER_SIZE) {
|
||||
PyErr_SetString(PyExc_IndexError,
|
||||
"euler[attribute] = x: "
|
||||
"array assignment index out of range");
|
||||
@ -401,7 +401,7 @@ static int Euler_ass_item(EulerObject * self, int i, PyObject *value)
|
||||
|
||||
self->eul[i] = f;
|
||||
|
||||
if(BaseMath_WriteIndexCallback(self, i) == -1)
|
||||
if (BaseMath_WriteIndexCallback(self, i) == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
@ -413,7 +413,7 @@ static PyObject *Euler_slice(EulerObject * self, int begin, int end)
|
||||
PyObject *tuple;
|
||||
int count;
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
CLAMP(begin, 0, EULER_SIZE);
|
||||
@ -422,7 +422,7 @@ static PyObject *Euler_slice(EulerObject * self, int begin, int end)
|
||||
begin= MIN2(begin, end);
|
||||
|
||||
tuple= PyTuple_New(end - begin);
|
||||
for(count = begin; count < end; count++) {
|
||||
for (count = begin; count < end; count++) {
|
||||
PyTuple_SET_ITEM(tuple, count - begin, PyFloat_FromDouble(self->eul[count]));
|
||||
}
|
||||
|
||||
@ -435,7 +435,7 @@ static int Euler_ass_slice(EulerObject *self, int begin, int end, PyObject *seq)
|
||||
int i, size;
|
||||
float eul[EULER_SIZE];
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return -1;
|
||||
|
||||
CLAMP(begin, 0, EULER_SIZE);
|
||||
@ -443,17 +443,17 @@ static int Euler_ass_slice(EulerObject *self, int begin, int end, PyObject *seq)
|
||||
CLAMP(end, 0, EULER_SIZE);
|
||||
begin = MIN2(begin, end);
|
||||
|
||||
if((size=mathutils_array_parse(eul, 0, EULER_SIZE, seq, "mathutils.Euler[begin:end] = []")) == -1)
|
||||
if ((size=mathutils_array_parse(eul, 0, EULER_SIZE, seq, "mathutils.Euler[begin:end] = []")) == -1)
|
||||
return -1;
|
||||
|
||||
if(size != (end - begin)){
|
||||
if (size != (end - begin)) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"euler[begin:end] = []: "
|
||||
"size mismatch in slice assignment");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for(i= 0; i < EULER_SIZE; i++)
|
||||
for (i= 0; i < EULER_SIZE; i++)
|
||||
self->eul[begin + i] = eul[i];
|
||||
|
||||
(void)BaseMath_WriteCallback(self);
|
||||
@ -566,7 +566,7 @@ static int Euler_setAxis(EulerObject *self, PyObject *value, void *type)
|
||||
/* rotation order */
|
||||
static PyObject *Euler_getOrder(EulerObject *self, void *UNUSED(closure))
|
||||
{
|
||||
if(BaseMath_ReadCallback(self) == -1) /* can read order too */
|
||||
if (BaseMath_ReadCallback(self) == -1) /* can read order too */
|
||||
return NULL;
|
||||
|
||||
return PyUnicode_FromString(euler_order_str(self));
|
||||
@ -577,7 +577,7 @@ static int Euler_setOrder(EulerObject *self, PyObject *value, void *UNUSED(closu
|
||||
const char *order_str= _PyUnicode_AsString(value);
|
||||
short order= euler_order_from_string(order_str, "euler.order");
|
||||
|
||||
if(order == -1)
|
||||
if (order == -1)
|
||||
return -1;
|
||||
|
||||
self->order= order;
|
||||
@ -678,18 +678,18 @@ PyObject *newEulerObject(float *eul, short order, int type, PyTypeObject *base_t
|
||||
self= base_type ? (EulerObject *)base_type->tp_alloc(base_type, 0) :
|
||||
(EulerObject *)PyObject_GC_New(EulerObject, &euler_Type);
|
||||
|
||||
if(self) {
|
||||
if (self) {
|
||||
/* init callbacks as NULL */
|
||||
self->cb_user= NULL;
|
||||
self->cb_type= self->cb_subtype= 0;
|
||||
|
||||
if(type == Py_WRAP) {
|
||||
if (type == Py_WRAP) {
|
||||
self->eul = eul;
|
||||
self->wrapped = Py_WRAP;
|
||||
}
|
||||
else if (type == Py_NEW) {
|
||||
self->eul = PyMem_Malloc(EULER_SIZE * sizeof(float));
|
||||
if(eul) {
|
||||
if (eul) {
|
||||
copy_v3_v3(self->eul, eul);
|
||||
}
|
||||
else {
|
||||
@ -711,7 +711,7 @@ PyObject *newEulerObject(float *eul, short order, int type, PyTypeObject *base_t
|
||||
PyObject *newEulerObject_cb(PyObject *cb_user, short order, int cb_type, int cb_subtype)
|
||||
{
|
||||
EulerObject *self= (EulerObject *)newEulerObject(NULL, order, Py_NEW, NULL);
|
||||
if(self) {
|
||||
if (self) {
|
||||
Py_INCREF(cb_user);
|
||||
self->cb_user= cb_user;
|
||||
self->cb_type= (unsigned char)cb_type;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -53,13 +53,13 @@ static PyObject *Quaternion_to_tuple_ext(QuaternionObject *self, int ndigits)
|
||||
|
||||
ret= PyTuple_New(QUAT_SIZE);
|
||||
|
||||
if(ndigits >= 0) {
|
||||
for(i= 0; i < QUAT_SIZE; i++) {
|
||||
if (ndigits >= 0) {
|
||||
for (i= 0; i < QUAT_SIZE; i++) {
|
||||
PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(double_round((double)self->quat[i], ndigits)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(i= 0; i < QUAT_SIZE; i++) {
|
||||
for (i= 0; i < QUAT_SIZE; i++) {
|
||||
PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(self->quat[i]));
|
||||
}
|
||||
}
|
||||
@ -90,34 +90,34 @@ static PyObject *Quaternion_to_euler(QuaternionObject *self, PyObject *args)
|
||||
short order= EULER_ORDER_XYZ;
|
||||
EulerObject *eul_compat = NULL;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "|sO!:to_euler", &order_str, &euler_Type, &eul_compat))
|
||||
if (!PyArg_ParseTuple(args, "|sO!:to_euler", &order_str, &euler_Type, &eul_compat))
|
||||
return NULL;
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
if(order_str) {
|
||||
if (order_str) {
|
||||
order= euler_order_from_string(order_str, "Matrix.to_euler()");
|
||||
|
||||
if(order == -1)
|
||||
if (order == -1)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
normalize_qt_qt(tquat, self->quat);
|
||||
|
||||
if(eul_compat) {
|
||||
if (eul_compat) {
|
||||
float mat[3][3];
|
||||
|
||||
if(BaseMath_ReadCallback(eul_compat) == -1)
|
||||
if (BaseMath_ReadCallback(eul_compat) == -1)
|
||||
return NULL;
|
||||
|
||||
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 {
|
||||
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);
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ static PyObject *Quaternion_to_matrix(QuaternionObject *self)
|
||||
{
|
||||
float mat[9]; /* all values are set */
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
quat_to_mat3((float (*)[3])mat, self->quat);
|
||||
@ -158,10 +158,10 @@ static PyObject *Quaternion_cross(QuaternionObject *self, PyObject *value)
|
||||
{
|
||||
float quat[QUAT_SIZE], tquat[QUAT_SIZE];
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.cross(other), invalid 'other' arg") == -1)
|
||||
if (mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.cross(other), invalid 'other' arg") == -1)
|
||||
return NULL;
|
||||
|
||||
mul_qt_qtqt(quat, self->quat, tquat);
|
||||
@ -183,10 +183,10 @@ static PyObject *Quaternion_dot(QuaternionObject *self, PyObject *value)
|
||||
{
|
||||
float tquat[QUAT_SIZE];
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.dot(other), invalid 'other' arg") == -1)
|
||||
if (mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.dot(other), invalid 'other' arg") == -1)
|
||||
return NULL;
|
||||
|
||||
return PyFloat_FromDouble(dot_qtqt(self->quat, tquat));
|
||||
@ -206,10 +206,10 @@ static PyObject *Quaternion_rotation_difference(QuaternionObject *self, PyObject
|
||||
{
|
||||
float tquat[QUAT_SIZE], quat[QUAT_SIZE];
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.difference(other), invalid 'other' arg") == -1)
|
||||
if (mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.difference(other), invalid 'other' arg") == -1)
|
||||
return NULL;
|
||||
|
||||
rotation_between_quats_to_quat(quat, self->quat, tquat);
|
||||
@ -234,20 +234,20 @@ static PyObject *Quaternion_slerp(QuaternionObject *self, PyObject *args)
|
||||
PyObject *value;
|
||||
float tquat[QUAT_SIZE], quat[QUAT_SIZE], fac;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "Of:slerp", &value, &fac)) {
|
||||
if (!PyArg_ParseTuple(args, "Of:slerp", &value, &fac)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"quat.slerp(): "
|
||||
"expected Quaternion types and float");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.slerp(other), invalid 'other' arg") == -1)
|
||||
if (mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.slerp(other), invalid 'other' arg") == -1)
|
||||
return NULL;
|
||||
|
||||
if(fac > 1.0f || fac < 0.0f) {
|
||||
if (fac > 1.0f || fac < 0.0f) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"quat.slerp(): "
|
||||
"interpolation factor must be between 0.0 and 1.0");
|
||||
@ -272,10 +272,10 @@ static PyObject *Quaternion_rotate(QuaternionObject *self, PyObject *value)
|
||||
float self_rmat[3][3], other_rmat[3][3], rmat[3][3];
|
||||
float tquat[4], length;
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
if(mathutils_any_to_rotmat(other_rmat, value, "Quaternion.rotate(value)") == -1)
|
||||
if (mathutils_any_to_rotmat(other_rmat, value, "Quaternion.rotate(value)") == -1)
|
||||
return NULL;
|
||||
|
||||
length= normalize_qt_qt(tquat, self->quat);
|
||||
@ -298,7 +298,7 @@ PyDoc_STRVAR(Quaternion_normalize_doc,
|
||||
);
|
||||
static PyObject *Quaternion_normalize(QuaternionObject *self)
|
||||
{
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
normalize_qt(self->quat);
|
||||
@ -327,7 +327,7 @@ PyDoc_STRVAR(Quaternion_invert_doc,
|
||||
);
|
||||
static PyObject *Quaternion_invert(QuaternionObject *self)
|
||||
{
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
invert_qt(self->quat);
|
||||
@ -359,7 +359,7 @@ PyDoc_STRVAR(Quaternion_identity_doc,
|
||||
);
|
||||
static PyObject *Quaternion_identity(QuaternionObject *self)
|
||||
{
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
unit_qt(self->quat);
|
||||
@ -378,7 +378,7 @@ PyDoc_STRVAR(Quaternion_negate_doc,
|
||||
);
|
||||
static PyObject *Quaternion_negate(QuaternionObject *self)
|
||||
{
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
mul_qt_fl(self->quat, -1.0f);
|
||||
@ -394,7 +394,7 @@ PyDoc_STRVAR(Quaternion_conjugate_doc,
|
||||
);
|
||||
static PyObject *Quaternion_conjugate(QuaternionObject *self)
|
||||
{
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
conjugate_qt(self->quat);
|
||||
@ -429,7 +429,7 @@ PyDoc_STRVAR(Quaternion_copy_doc,
|
||||
);
|
||||
static PyObject *Quaternion_copy(QuaternionObject *self)
|
||||
{
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
return newQuaternionObject(self->quat, Py_NEW, Py_TYPE(self));
|
||||
@ -441,7 +441,7 @@ static PyObject *Quaternion_repr(QuaternionObject *self)
|
||||
{
|
||||
PyObject *ret, *tuple;
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
tuple= Quaternion_to_tuple_ext(self, -1);
|
||||
@ -461,7 +461,7 @@ static PyObject* Quaternion_richcmpr(PyObject *a, PyObject *b, int op)
|
||||
QuaternionObject *quatA= (QuaternionObject *)a;
|
||||
QuaternionObject *quatB= (QuaternionObject *)b;
|
||||
|
||||
if(BaseMath_ReadCallback(quatA) == -1 || BaseMath_ReadCallback(quatB) == -1)
|
||||
if (BaseMath_ReadCallback(quatA) == -1 || BaseMath_ReadCallback(quatB) == -1)
|
||||
return NULL;
|
||||
|
||||
ok= (EXPP_VectorsAreEqual(quatA->quat, quatB->quat, QUAT_SIZE, 1)) ? 0 : -1;
|
||||
@ -499,16 +499,16 @@ static int Quaternion_len(QuaternionObject *UNUSED(self))
|
||||
//sequence accessor (get)
|
||||
static PyObject *Quaternion_item(QuaternionObject *self, int i)
|
||||
{
|
||||
if(i<0) i= QUAT_SIZE-i;
|
||||
if (i<0) i= QUAT_SIZE-i;
|
||||
|
||||
if(i < 0 || i >= QUAT_SIZE) {
|
||||
if (i < 0 || i >= QUAT_SIZE) {
|
||||
PyErr_SetString(PyExc_IndexError,
|
||||
"quaternion[attribute]: "
|
||||
"array index out of range");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(BaseMath_ReadIndexCallback(self, i) == -1)
|
||||
if (BaseMath_ReadIndexCallback(self, i) == -1)
|
||||
return NULL;
|
||||
|
||||
return PyFloat_FromDouble(self->quat[i]);
|
||||
@ -519,16 +519,16 @@ static PyObject *Quaternion_item(QuaternionObject *self, int i)
|
||||
static int Quaternion_ass_item(QuaternionObject *self, int i, PyObject *ob)
|
||||
{
|
||||
float scalar= (float)PyFloat_AsDouble(ob);
|
||||
if(scalar==-1.0f && PyErr_Occurred()) { /* parsed item not a number */
|
||||
if (scalar==-1.0f && PyErr_Occurred()) { /* parsed item not a number */
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"quaternion[index] = x: "
|
||||
"index argument not a number");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(i<0) i= QUAT_SIZE-i;
|
||||
if (i<0) i= QUAT_SIZE-i;
|
||||
|
||||
if(i < 0 || i >= QUAT_SIZE){
|
||||
if (i < 0 || i >= QUAT_SIZE) {
|
||||
PyErr_SetString(PyExc_IndexError,
|
||||
"quaternion[attribute] = x: "
|
||||
"array assignment index out of range");
|
||||
@ -536,7 +536,7 @@ static int Quaternion_ass_item(QuaternionObject *self, int i, PyObject *ob)
|
||||
}
|
||||
self->quat[i] = scalar;
|
||||
|
||||
if(BaseMath_WriteIndexCallback(self, i) == -1)
|
||||
if (BaseMath_WriteIndexCallback(self, i) == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
@ -548,7 +548,7 @@ static PyObject *Quaternion_slice(QuaternionObject *self, int begin, int end)
|
||||
PyObject *tuple;
|
||||
int count;
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
CLAMP(begin, 0, QUAT_SIZE);
|
||||
@ -557,7 +557,7 @@ static PyObject *Quaternion_slice(QuaternionObject *self, int begin, int end)
|
||||
begin= MIN2(begin, end);
|
||||
|
||||
tuple= PyTuple_New(end - begin);
|
||||
for(count= begin; count < end; count++) {
|
||||
for (count= begin; count < end; count++) {
|
||||
PyTuple_SET_ITEM(tuple, count - begin, PyFloat_FromDouble(self->quat[count]));
|
||||
}
|
||||
|
||||
@ -570,7 +570,7 @@ static int Quaternion_ass_slice(QuaternionObject *self, int begin, int end, PyOb
|
||||
int i, size;
|
||||
float quat[QUAT_SIZE];
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return -1;
|
||||
|
||||
CLAMP(begin, 0, QUAT_SIZE);
|
||||
@ -578,10 +578,10 @@ static int Quaternion_ass_slice(QuaternionObject *self, int begin, int end, PyOb
|
||||
CLAMP(end, 0, QUAT_SIZE);
|
||||
begin = MIN2(begin, end);
|
||||
|
||||
if((size=mathutils_array_parse(quat, 0, QUAT_SIZE, seq, "mathutils.Quaternion[begin:end] = []")) == -1)
|
||||
if ((size=mathutils_array_parse(quat, 0, QUAT_SIZE, seq, "mathutils.Quaternion[begin:end] = []")) == -1)
|
||||
return -1;
|
||||
|
||||
if(size != (end - begin)){
|
||||
if (size != (end - begin)) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"quaternion[begin:end] = []: "
|
||||
"size mismatch in slice assignment");
|
||||
@ -589,7 +589,7 @@ static int Quaternion_ass_slice(QuaternionObject *self, int begin, int end, PyOb
|
||||
}
|
||||
|
||||
/* parsed well - now set in vector */
|
||||
for(i= 0; i < size; i++)
|
||||
for (i= 0; i < size; i++)
|
||||
self->quat[begin + i] = quat[i];
|
||||
|
||||
(void)BaseMath_WriteCallback(self);
|
||||
@ -674,7 +674,7 @@ static PyObject *Quaternion_add(PyObject *q1, PyObject *q2)
|
||||
float quat[QUAT_SIZE];
|
||||
QuaternionObject *quat1 = NULL, *quat2 = NULL;
|
||||
|
||||
if(!QuaternionObject_Check(q1) || !QuaternionObject_Check(q2)) {
|
||||
if (!QuaternionObject_Check(q1) || !QuaternionObject_Check(q2)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"Quaternion addition: "
|
||||
"arguments not valid for this operation");
|
||||
@ -683,7 +683,7 @@ static PyObject *Quaternion_add(PyObject *q1, PyObject *q2)
|
||||
quat1 = (QuaternionObject*)q1;
|
||||
quat2 = (QuaternionObject*)q2;
|
||||
|
||||
if(BaseMath_ReadCallback(quat1) == -1 || BaseMath_ReadCallback(quat2) == -1)
|
||||
if (BaseMath_ReadCallback(quat1) == -1 || BaseMath_ReadCallback(quat2) == -1)
|
||||
return NULL;
|
||||
|
||||
add_qt_qtqt(quat, quat1->quat, quat2->quat, 1.0f);
|
||||
@ -697,7 +697,7 @@ static PyObject *Quaternion_sub(PyObject *q1, PyObject *q2)
|
||||
float quat[QUAT_SIZE];
|
||||
QuaternionObject *quat1 = NULL, *quat2 = NULL;
|
||||
|
||||
if(!QuaternionObject_Check(q1) || !QuaternionObject_Check(q2)) {
|
||||
if (!QuaternionObject_Check(q1) || !QuaternionObject_Check(q2)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"Quaternion addition: "
|
||||
"arguments not valid for this operation");
|
||||
@ -707,10 +707,10 @@ static PyObject *Quaternion_sub(PyObject *q1, PyObject *q2)
|
||||
quat1 = (QuaternionObject*)q1;
|
||||
quat2 = (QuaternionObject*)q2;
|
||||
|
||||
if(BaseMath_ReadCallback(quat1) == -1 || BaseMath_ReadCallback(quat2) == -1)
|
||||
if (BaseMath_ReadCallback(quat1) == -1 || BaseMath_ReadCallback(quat2) == -1)
|
||||
return NULL;
|
||||
|
||||
for(x = 0; x < QUAT_SIZE; x++) {
|
||||
for (x = 0; x < QUAT_SIZE; x++) {
|
||||
quat[x] = quat1->quat[x] - quat2->quat[x];
|
||||
}
|
||||
|
||||
@ -732,24 +732,24 @@ static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2)
|
||||
float quat[QUAT_SIZE], scalar;
|
||||
QuaternionObject *quat1 = NULL, *quat2 = NULL;
|
||||
|
||||
if(QuaternionObject_Check(q1)) {
|
||||
if (QuaternionObject_Check(q1)) {
|
||||
quat1 = (QuaternionObject*)q1;
|
||||
if(BaseMath_ReadCallback(quat1) == -1)
|
||||
if (BaseMath_ReadCallback(quat1) == -1)
|
||||
return NULL;
|
||||
}
|
||||
if(QuaternionObject_Check(q2)) {
|
||||
if (QuaternionObject_Check(q2)) {
|
||||
quat2 = (QuaternionObject*)q2;
|
||||
if(BaseMath_ReadCallback(quat2) == -1)
|
||||
if (BaseMath_ReadCallback(quat2) == -1)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(quat1 && quat2) { /* QUAT*QUAT (cross product) */
|
||||
if (quat1 && quat2) { /* QUAT*QUAT (cross product) */
|
||||
mul_qt_qtqt(quat, quat1->quat, quat2->quat);
|
||||
return newQuaternionObject(quat, Py_NEW, Py_TYPE(q1));
|
||||
}
|
||||
/* the only case this can happen (for a supported type is "FLOAT*QUAT") */
|
||||
else if(quat2) { /* FLOAT*QUAT */
|
||||
if(((scalar= PyFloat_AsDouble(q1)) == -1.0f && PyErr_Occurred())==0) {
|
||||
else if (quat2) { /* FLOAT*QUAT */
|
||||
if (((scalar= PyFloat_AsDouble(q1)) == -1.0f && PyErr_Occurred())==0) {
|
||||
return quat_mul_float(quat2, scalar);
|
||||
}
|
||||
}
|
||||
@ -759,14 +759,14 @@ static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2)
|
||||
VectorObject *vec2 = (VectorObject *)q2;
|
||||
float tvec[3];
|
||||
|
||||
if(vec2->size != 3) {
|
||||
if (vec2->size != 3) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"Vector multiplication: "
|
||||
"only 3D vector rotations (with quats) "
|
||||
"currently supported");
|
||||
return NULL;
|
||||
}
|
||||
if(BaseMath_ReadCallback(vec2) == -1) {
|
||||
if (BaseMath_ReadCallback(vec2) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -776,7 +776,7 @@ static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2)
|
||||
return newVectorObject(tvec, 3, Py_NEW, Py_TYPE(vec2));
|
||||
}
|
||||
/* QUAT * FLOAT */
|
||||
else if((((scalar= PyFloat_AsDouble(q2)) == -1.0f && PyErr_Occurred())==0)) {
|
||||
else if ((((scalar= PyFloat_AsDouble(q2)) == -1.0f && PyErr_Occurred())==0)) {
|
||||
return quat_mul_float(quat1, scalar);
|
||||
}
|
||||
}
|
||||
@ -797,7 +797,7 @@ static PyObject *Quaternion_neg(QuaternionObject *self)
|
||||
{
|
||||
float tquat[QUAT_SIZE];
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
negate_v4_v4(tquat, self->quat);
|
||||
@ -874,7 +874,7 @@ static int Quaternion_setAxis(QuaternionObject *self, PyObject *value, void *typ
|
||||
|
||||
static PyObject *Quaternion_getMagnitude(QuaternionObject *self, void *UNUSED(closure))
|
||||
{
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
return PyFloat_FromDouble(sqrt(dot_qtqt(self->quat, self->quat)));
|
||||
@ -884,7 +884,7 @@ static PyObject *Quaternion_getAngle(QuaternionObject *self, void *UNUSED(closur
|
||||
{
|
||||
float tquat[4];
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
normalize_qt_qt(tquat, self->quat);
|
||||
@ -899,7 +899,7 @@ static int Quaternion_setAngle(QuaternionObject *self, PyObject *value, void *UN
|
||||
float axis[3], angle_dummy;
|
||||
double angle;
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return -1;
|
||||
|
||||
len= normalize_qt_qt(tquat, self->quat);
|
||||
@ -907,7 +907,7 @@ static int Quaternion_setAngle(QuaternionObject *self, PyObject *value, void *UN
|
||||
|
||||
angle= PyFloat_AsDouble(value);
|
||||
|
||||
if(angle==-1.0 && PyErr_Occurred()) { /* parsed item not a number */
|
||||
if (angle==-1.0 && PyErr_Occurred()) { /* parsed item not a number */
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"Quaternion.angle = value: float expected");
|
||||
return -1;
|
||||
@ -916,7 +916,7 @@ static int Quaternion_setAngle(QuaternionObject *self, PyObject *value, void *UN
|
||||
angle= angle_wrap_rad(angle);
|
||||
|
||||
/* If the axis of rotation is 0,0,0 set it to 1,0,0 - for zero-degree rotations */
|
||||
if( EXPP_FloatsAreEqual(axis[0], 0.0f, 10) &&
|
||||
if ( EXPP_FloatsAreEqual(axis[0], 0.0f, 10) &&
|
||||
EXPP_FloatsAreEqual(axis[1], 0.0f, 10) &&
|
||||
EXPP_FloatsAreEqual(axis[2], 0.0f, 10)
|
||||
) {
|
||||
@ -926,7 +926,7 @@ static int Quaternion_setAngle(QuaternionObject *self, PyObject *value, void *UN
|
||||
axis_angle_to_quat(self->quat, axis, angle);
|
||||
mul_qt_fl(self->quat, len);
|
||||
|
||||
if(BaseMath_WriteCallback(self) == -1)
|
||||
if (BaseMath_WriteCallback(self) == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
@ -939,14 +939,14 @@ static PyObject *Quaternion_getAxisVec(QuaternionObject *self, void *UNUSED(clos
|
||||
float axis[3];
|
||||
float angle;
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
normalize_qt_qt(tquat, self->quat);
|
||||
quat_to_axis_angle(axis, &angle, tquat);
|
||||
|
||||
/* If the axis of rotation is 0,0,0 set it to 1,0,0 - for zero-degree rotations */
|
||||
if( EXPP_FloatsAreEqual(axis[0], 0.0f, 10) &&
|
||||
if ( EXPP_FloatsAreEqual(axis[0], 0.0f, 10) &&
|
||||
EXPP_FloatsAreEqual(axis[1], 0.0f, 10) &&
|
||||
EXPP_FloatsAreEqual(axis[2], 0.0f, 10)
|
||||
) {
|
||||
@ -964,7 +964,7 @@ static int Quaternion_setAxisVec(QuaternionObject *self, PyObject *value, void *
|
||||
float axis[3];
|
||||
float angle;
|
||||
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return -1;
|
||||
|
||||
len= normalize_qt_qt(tquat, self->quat);
|
||||
@ -976,7 +976,7 @@ static int Quaternion_setAxisVec(QuaternionObject *self, PyObject *value, void *
|
||||
axis_angle_to_quat(self->quat, axis, angle);
|
||||
mul_qt_fl(self->quat, len);
|
||||
|
||||
if(BaseMath_WriteCallback(self) == -1)
|
||||
if (BaseMath_WriteCallback(self) == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
@ -989,14 +989,14 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw
|
||||
double angle = 0.0f;
|
||||
float quat[QUAT_SIZE]= {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
|
||||
if(kwds && PyDict_Size(kwds)) {
|
||||
if (kwds && PyDict_Size(kwds)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"mathutils.Quaternion(): "
|
||||
"takes no keyword args");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!PyArg_ParseTuple(args, "|Od:mathutils.Quaternion", &seq, &angle))
|
||||
if (!PyArg_ParseTuple(args, "|Od:mathutils.Quaternion", &seq, &angle))
|
||||
return NULL;
|
||||
|
||||
switch(PyTuple_GET_SIZE(args)) {
|
||||
@ -1021,7 +1021,7 @@ static PyObject *quat__apply_to_copy(PyNoArgsFunction quat_func, QuaternionObjec
|
||||
{
|
||||
PyObject *ret= Quaternion_copy(self);
|
||||
PyObject *ret_dummy= quat_func(ret);
|
||||
if(ret_dummy) {
|
||||
if (ret_dummy) {
|
||||
Py_DECREF(ret_dummy);
|
||||
return (PyObject *)ret;
|
||||
}
|
||||
@ -1144,18 +1144,18 @@ PyObject *newQuaternionObject(float *quat, int type, PyTypeObject *base_type)
|
||||
self= base_type ? (QuaternionObject *)base_type->tp_alloc(base_type, 0) :
|
||||
(QuaternionObject *)PyObject_GC_New(QuaternionObject, &quaternion_Type);
|
||||
|
||||
if(self) {
|
||||
if (self) {
|
||||
/* init callbacks as NULL */
|
||||
self->cb_user= NULL;
|
||||
self->cb_type= self->cb_subtype= 0;
|
||||
|
||||
if(type == Py_WRAP){
|
||||
if (type == Py_WRAP) {
|
||||
self->quat = quat;
|
||||
self->wrapped = Py_WRAP;
|
||||
}
|
||||
else if (type == Py_NEW){
|
||||
else if (type == Py_NEW) {
|
||||
self->quat = PyMem_Malloc(QUAT_SIZE * sizeof(float));
|
||||
if(!quat) { //new empty
|
||||
if (!quat) { //new empty
|
||||
unit_qt(self->quat);
|
||||
}
|
||||
else {
|
||||
@ -1173,7 +1173,7 @@ PyObject *newQuaternionObject(float *quat, int type, PyTypeObject *base_type)
|
||||
PyObject *newQuaternionObject_cb(PyObject *cb_user, int cb_type, int cb_subtype)
|
||||
{
|
||||
QuaternionObject *self= (QuaternionObject *)newQuaternionObject(NULL, Py_NEW, NULL);
|
||||
if(self) {
|
||||
if (self) {
|
||||
Py_INCREF(cb_user);
|
||||
self->cb_user= cb_user;
|
||||
self->cb_type= (unsigned char)cb_type;
|
||||
|
@ -123,11 +123,11 @@ static PyObject *Vector_normalize(VectorObject *self)
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
for(i = 0; i < self->size; i++) {
|
||||
for (i = 0; i < self->size; i++) {
|
||||
norm += self->vec[i] * self->vec[i];
|
||||
}
|
||||
norm = (float) sqrt(norm);
|
||||
for(i = 0; i < self->size; i++) {
|
||||
for (i = 0; i < self->size; i++) {
|
||||
self->vec[i] /= norm;
|
||||
}
|
||||
|
||||
@ -251,11 +251,11 @@ static PyObject *Vector_resize_4d(VectorObject *self)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(self->size == 2){
|
||||
if(self->size == 2) {
|
||||
self->vec[2] = 0.0f;
|
||||
self->vec[3] = 1.0f;
|
||||
}
|
||||
else if(self->size == 3){
|
||||
else if(self->size == 3) {
|
||||
self->vec[3] = 1.0f;
|
||||
}
|
||||
self->size = 4;
|
||||
@ -332,12 +332,12 @@ static PyObject *Vector_to_tuple_ext(VectorObject *self, int ndigits)
|
||||
ret= PyTuple_New(self->size);
|
||||
|
||||
if(ndigits >= 0) {
|
||||
for(i = 0; i < self->size; i++) {
|
||||
for (i = 0; i < self->size; i++) {
|
||||
PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(double_round((double)self->vec[i], ndigits)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(i = 0; i < self->size; i++) {
|
||||
for (i = 0; i < self->size; i++) {
|
||||
PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(self->vec[i]));
|
||||
}
|
||||
}
|
||||
@ -581,7 +581,7 @@ static PyObject *Vector_dot(VectorObject *self, PyObject *value)
|
||||
if(mathutils_array_parse(tvec, self->size, self->size, value, "Vector.dot(other), invalid 'other' arg") == -1)
|
||||
return NULL;
|
||||
|
||||
for(x = 0; x < self->size; x++) {
|
||||
for (x = 0; x < self->size; x++) {
|
||||
dot += (double)(self->vec[x] * tvec[x]);
|
||||
}
|
||||
|
||||
@ -621,11 +621,11 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args)
|
||||
if(mathutils_array_parse(tvec, size, size, value, "Vector.angle(other), invalid 'other' arg") == -1)
|
||||
return NULL;
|
||||
|
||||
for(x = 0; x < size; x++) {
|
||||
for (x = 0; x < size; x++) {
|
||||
test_v1 += (double)(self->vec[x] * self->vec[x]);
|
||||
test_v2 += (double)(tvec[x] * tvec[x]);
|
||||
}
|
||||
if (!test_v1 || !test_v2){
|
||||
if (!test_v1 || !test_v2) {
|
||||
/* avoid exception */
|
||||
if(fallback) {
|
||||
Py_INCREF(fallback);
|
||||
@ -640,7 +640,7 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
//dot product
|
||||
for(x = 0; x < self->size; x++) {
|
||||
for (x = 0; x < self->size; x++) {
|
||||
dot += (double)(self->vec[x] * tvec[x]);
|
||||
}
|
||||
dot /= (sqrt(test_v1) * sqrt(test_v2));
|
||||
@ -714,13 +714,13 @@ static PyObject *Vector_project(VectorObject *self, PyObject *value)
|
||||
return NULL;
|
||||
|
||||
//get dot products
|
||||
for(x = 0; x < size; x++) {
|
||||
for (x = 0; x < size; x++) {
|
||||
dot += (double)(self->vec[x] * tvec[x]);
|
||||
dot2 += (double)(tvec[x] * tvec[x]);
|
||||
}
|
||||
//projection
|
||||
dot /= dot2;
|
||||
for(x = 0; x < size; x++) {
|
||||
for (x = 0; x < size; x++) {
|
||||
vec[x] = (float)dot * tvec[x];
|
||||
}
|
||||
return newVectorObject(vec, size, Py_NEW, Py_TYPE(self));
|
||||
@ -757,7 +757,7 @@ static PyObject *Vector_lerp(VectorObject *self, PyObject *args)
|
||||
|
||||
ifac= 1.0f - fac;
|
||||
|
||||
for(x = 0; x < size; x++) {
|
||||
for (x = 0; x < size; x++) {
|
||||
vec[x] = (ifac * self->vec[x]) + (fac * tvec[x]);
|
||||
}
|
||||
return newVectorObject(vec, size, Py_NEW, Py_TYPE(self));
|
||||
@ -872,7 +872,7 @@ static int vector_ass_item_internal(VectorObject *self, int i, PyObject *value,
|
||||
|
||||
if(i<0) i= self->size-i;
|
||||
|
||||
if(i < 0 || i >= self->size){
|
||||
if(i < 0 || i >= self->size) {
|
||||
if(is_attr) {
|
||||
PyErr_Format(PyExc_AttributeError,
|
||||
"Vector.%c = x: unavailable on %dd vector",
|
||||
@ -912,7 +912,7 @@ static PyObject *Vector_slice(VectorObject *self, int begin, int end)
|
||||
begin= MIN2(begin, end);
|
||||
|
||||
tuple= PyTuple_New(end - begin);
|
||||
for(count = begin; count < end; count++) {
|
||||
for (count = begin; count < end; count++) {
|
||||
PyTuple_SET_ITEM(tuple, count - begin, PyFloat_FromDouble(self->vec[count]));
|
||||
}
|
||||
|
||||
@ -936,7 +936,7 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *se
|
||||
return -1;
|
||||
|
||||
/*parsed well - now set in vector*/
|
||||
for(y = 0; y < size; y++){
|
||||
for (y = 0; y < size; y++) {
|
||||
self->vec[begin + y] = vec[y];
|
||||
}
|
||||
|
||||
@ -1088,7 +1088,7 @@ int column_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject* vec,
|
||||
double dot = 0.0f;
|
||||
int x, y, z = 0;
|
||||
|
||||
if(mat->row_size != vec->size){
|
||||
if(mat->row_size != vec->size) {
|
||||
if(mat->row_size == 4 && vec->size == 3) {
|
||||
vec_cpy[3] = 1.0f;
|
||||
}
|
||||
@ -1105,8 +1105,8 @@ int column_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject* vec,
|
||||
|
||||
rvec[3] = 1.0f;
|
||||
|
||||
for(x = 0; x < mat->col_size; x++) {
|
||||
for(y = 0; y < mat->row_size; y++) {
|
||||
for (x = 0; x < mat->col_size; x++) {
|
||||
for (y = 0; y < mat->row_size; y++) {
|
||||
dot += (double)(mat->matrix[y][x] * vec_cpy[y]);
|
||||
}
|
||||
rvec[z++] = (float)dot;
|
||||
@ -1153,7 +1153,7 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2)
|
||||
}
|
||||
|
||||
/*dot product*/
|
||||
for(i = 0; i < vec1->size; i++) {
|
||||
for (i = 0; i < vec1->size; i++) {
|
||||
dot += (double)(vec1->vec[i] * vec2->vec[i]);
|
||||
}
|
||||
return PyFloat_FromDouble(dot);
|
||||
@ -1325,7 +1325,7 @@ static PyObject *Vector_div(PyObject *v1, PyObject *v2)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for(i = 0; i < vec1->size; i++) {
|
||||
for (i = 0; i < vec1->size; i++) {
|
||||
vec[i] = vec1->vec[i] / scalar;
|
||||
}
|
||||
return newVectorObject(vec, vec1->size, Py_NEW, Py_TYPE(v1));
|
||||
@ -1354,7 +1354,7 @@ static PyObject *Vector_idiv(PyObject *v1, PyObject *v2)
|
||||
"divide by zero error");
|
||||
return NULL;
|
||||
}
|
||||
for(i = 0; i < vec1->size; i++) {
|
||||
for (i = 0; i < vec1->size; i++) {
|
||||
vec1->vec[i] /= scalar;
|
||||
}
|
||||
|
||||
@ -1383,7 +1383,7 @@ static double vec_magnitude_nosqrt(float *data, int size)
|
||||
double dot = 0.0f;
|
||||
int i;
|
||||
|
||||
for(i=0; i<size; i++){
|
||||
for (i=0; i<size; i++) {
|
||||
dot += (double)data[i];
|
||||
}
|
||||
/*return (double)sqrt(dot);*/
|
||||
@ -1403,8 +1403,8 @@ static PyObject* Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa
|
||||
double epsilon = .000001f;
|
||||
double lenA, lenB;
|
||||
|
||||
if (!VectorObject_Check(objectA) || !VectorObject_Check(objectB)){
|
||||
if (comparison_type == Py_NE){
|
||||
if (!VectorObject_Check(objectA) || !VectorObject_Check(objectB)) {
|
||||
if (comparison_type == Py_NE) {
|
||||
Py_RETURN_TRUE;
|
||||
}
|
||||
else {
|
||||
@ -1417,8 +1417,8 @@ static PyObject* Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa
|
||||
if(BaseMath_ReadCallback(vecA) == -1 || BaseMath_ReadCallback(vecB) == -1)
|
||||
return NULL;
|
||||
|
||||
if (vecA->size != vecB->size){
|
||||
if (comparison_type == Py_NE){
|
||||
if (vecA->size != vecB->size) {
|
||||
if (comparison_type == Py_NE) {
|
||||
Py_RETURN_TRUE;
|
||||
}
|
||||
else {
|
||||
@ -1426,18 +1426,18 @@ static PyObject* Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa
|
||||
}
|
||||
}
|
||||
|
||||
switch (comparison_type){
|
||||
switch (comparison_type) {
|
||||
case Py_LT:
|
||||
lenA = vec_magnitude_nosqrt(vecA->vec, vecA->size);
|
||||
lenB = vec_magnitude_nosqrt(vecB->vec, vecB->size);
|
||||
if(lenA < lenB){
|
||||
if(lenA < lenB) {
|
||||
result = 1;
|
||||
}
|
||||
break;
|
||||
case Py_LE:
|
||||
lenA = vec_magnitude_nosqrt(vecA->vec, vecA->size);
|
||||
lenB = vec_magnitude_nosqrt(vecB->vec, vecB->size);
|
||||
if(lenA < lenB){
|
||||
if(lenA < lenB) {
|
||||
result = 1;
|
||||
}
|
||||
else {
|
||||
@ -1453,14 +1453,14 @@ static PyObject* Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa
|
||||
case Py_GT:
|
||||
lenA = vec_magnitude_nosqrt(vecA->vec, vecA->size);
|
||||
lenB = vec_magnitude_nosqrt(vecB->vec, vecB->size);
|
||||
if(lenA > lenB){
|
||||
if(lenA > lenB) {
|
||||
result = 1;
|
||||
}
|
||||
break;
|
||||
case Py_GE:
|
||||
lenA = vec_magnitude_nosqrt(vecA->vec, vecA->size);
|
||||
lenB = vec_magnitude_nosqrt(vecB->vec, vecB->size);
|
||||
if(lenA > lenB){
|
||||
if(lenA > lenB) {
|
||||
result = 1;
|
||||
}
|
||||
else {
|
||||
@ -1471,7 +1471,7 @@ static PyObject* Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa
|
||||
printf("The result of the comparison could not be evaluated");
|
||||
break;
|
||||
}
|
||||
if (result == 1){
|
||||
if (result == 1) {
|
||||
Py_RETURN_TRUE;
|
||||
}
|
||||
else {
|
||||
@ -1631,7 +1631,7 @@ static PyObject *Vector_getLength(VectorObject *self, void *UNUSED(closure))
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
for(i = 0; i < self->size; i++){
|
||||
for (i = 0; i < self->size; i++) {
|
||||
dot += (double)(self->vec[i] * self->vec[i]);
|
||||
}
|
||||
return PyFloat_FromDouble(sqrt(dot));
|
||||
@ -1661,7 +1661,7 @@ static int Vector_setLength(VectorObject *self, PyObject *value)
|
||||
return 0;
|
||||
}
|
||||
|
||||
for(i = 0; i < self->size; i++){
|
||||
for (i = 0; i < self->size; i++) {
|
||||
dot += (double)(self->vec[i] * self->vec[i]);
|
||||
}
|
||||
|
||||
@ -1675,7 +1675,7 @@ static int Vector_setLength(VectorObject *self, PyObject *value)
|
||||
|
||||
dot= dot/param;
|
||||
|
||||
for(i = 0; i < self->size; i++){
|
||||
for (i = 0; i < self->size; i++) {
|
||||
self->vec[i]= self->vec[i] / (float)dot;
|
||||
}
|
||||
|
||||
@ -1693,7 +1693,7 @@ static PyObject *Vector_getLengthSquared(VectorObject *self, void *UNUSED(closur
|
||||
if(BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
for(i = 0; i < self->size; i++){
|
||||
for (i = 0; i < self->size; i++) {
|
||||
dot += (double)(self->vec[i] * self->vec[i]);
|
||||
}
|
||||
return PyFloat_FromDouble(dot);
|
||||
@ -1778,7 +1778,7 @@ static int Vector_setSwizzle(VectorObject *self, PyObject *value, void *closure)
|
||||
|
||||
if (((scalarVal=PyFloat_AsDouble(value)) == -1 && PyErr_Occurred())==0) {
|
||||
int i;
|
||||
for(i=0; i < MAX_DIMENSIONS; i++)
|
||||
for (i=0; i < MAX_DIMENSIONS; i++)
|
||||
vec_assign[i]= scalarVal;
|
||||
|
||||
size_from= axis_from;
|
||||
@ -2219,8 +2219,8 @@ static int row_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject *v
|
||||
double dot = 0.0f;
|
||||
int x, y, z= 0, vec_size= vec->size;
|
||||
|
||||
if(mat->col_size != vec_size){
|
||||
if(mat->col_size == 4 && vec_size != 3){
|
||||
if(mat->col_size != vec_size) {
|
||||
if(mat->col_size == 4 && vec_size != 3) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"vector * matrix: matrix column size "
|
||||
"and the vector size must be the same");
|
||||
@ -2235,11 +2235,11 @@ static int row_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject *v
|
||||
return -1;
|
||||
|
||||
memcpy(vec_cpy, vec->vec, vec_size * sizeof(float));
|
||||
printf("asasas\n");
|
||||
|
||||
rvec[3] = 1.0f;
|
||||
//muliplication
|
||||
for(x = 0; x < mat->row_size; x++) {
|
||||
for(y = 0; y < mat->col_size; y++) {
|
||||
for (x = 0; x < mat->row_size; x++) {
|
||||
for (y = 0; y < mat->col_size; y++) {
|
||||
dot += mat->matrix[x][y] * vec_cpy[y];
|
||||
}
|
||||
rvec[z++] = (float)dot;
|
||||
|
@ -86,16 +86,16 @@ static PyObject *M_Geometry_intersect_ray_tri(PyObject *UNUSED(self), PyObject*
|
||||
float det, inv_det, u, v, t;
|
||||
int clip= 1;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "O!O!O!O!O!|i:intersect_ray_tri", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3, &vector_Type, &ray, &vector_Type, &ray_off , &clip)) {
|
||||
if (!PyArg_ParseTuple(args, "O!O!O!O!O!|i:intersect_ray_tri", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3, &vector_Type, &ray, &vector_Type, &ray_off , &clip)) {
|
||||
return NULL;
|
||||
}
|
||||
if(vec1->size != 3 || vec2->size != 3 || vec3->size != 3 || ray->size != 3 || ray_off->size != 3) {
|
||||
if (vec1->size != 3 || vec2->size != 3 || vec3->size != 3 || ray->size != 3 || ray_off->size != 3) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"only 3D vectors for all parameters");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1 || BaseMath_ReadCallback(vec3) == -1 || BaseMath_ReadCallback(ray) == -1 || BaseMath_ReadCallback(ray_off) == -1)
|
||||
if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1 || BaseMath_ReadCallback(vec3) == -1 || BaseMath_ReadCallback(ray) == -1 || BaseMath_ReadCallback(ray_off) == -1)
|
||||
return NULL;
|
||||
|
||||
VECCOPY(v1, vec1->vec);
|
||||
@ -174,19 +174,19 @@ static PyObject *M_Geometry_intersect_line_line(PyObject *UNUSED(self), PyObject
|
||||
VectorObject *vec1, *vec2, *vec3, *vec4;
|
||||
float v1[3], v2[3], v3[3], v4[3], i1[3], i2[3];
|
||||
|
||||
if(!PyArg_ParseTuple(args, "O!O!O!O!:intersect_line_line", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3, &vector_Type, &vec4)) {
|
||||
if (!PyArg_ParseTuple(args, "O!O!O!O!:intersect_line_line", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3, &vector_Type, &vec4)) {
|
||||
return NULL;
|
||||
}
|
||||
if(vec1->size != vec2->size || vec1->size != vec3->size || vec3->size != vec2->size) {
|
||||
if (vec1->size != vec2->size || vec1->size != vec3->size || vec3->size != vec2->size) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"vectors must be of the same size");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1 || BaseMath_ReadCallback(vec3) == -1 || BaseMath_ReadCallback(vec4) == -1)
|
||||
if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1 || BaseMath_ReadCallback(vec3) == -1 || BaseMath_ReadCallback(vec4) == -1)
|
||||
return NULL;
|
||||
|
||||
if(vec1->size == 3 || vec1->size == 2) {
|
||||
if (vec1->size == 3 || vec1->size == 2) {
|
||||
int result;
|
||||
|
||||
if (vec1->size == 3) {
|
||||
@ -257,42 +257,42 @@ static PyObject *M_Geometry_normal(PyObject *UNUSED(self), PyObject* args)
|
||||
VectorObject *vec1, *vec2, *vec3, *vec4;
|
||||
float n[3];
|
||||
|
||||
if(PyTuple_GET_SIZE(args) == 3) {
|
||||
if(!PyArg_ParseTuple(args, "O!O!O!:normal", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3)) {
|
||||
if (PyTuple_GET_SIZE(args) == 3) {
|
||||
if (!PyArg_ParseTuple(args, "O!O!O!:normal", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3)) {
|
||||
return NULL;
|
||||
}
|
||||
if(vec1->size != vec2->size || vec1->size != vec3->size) {
|
||||
if (vec1->size != vec2->size || vec1->size != vec3->size) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"vectors must be of the same size");
|
||||
return NULL;
|
||||
}
|
||||
if(vec1->size < 3) {
|
||||
if (vec1->size < 3) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"2D vectors unsupported");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1 || BaseMath_ReadCallback(vec3) == -1)
|
||||
if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1 || BaseMath_ReadCallback(vec3) == -1)
|
||||
return NULL;
|
||||
|
||||
normal_tri_v3(n, vec1->vec, vec2->vec, vec3->vec);
|
||||
}
|
||||
else {
|
||||
if(!PyArg_ParseTuple(args, "O!O!O!O!:normal", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3, &vector_Type, &vec4)) {
|
||||
if (!PyArg_ParseTuple(args, "O!O!O!O!:normal", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3, &vector_Type, &vec4)) {
|
||||
return NULL;
|
||||
}
|
||||
if(vec1->size != vec2->size || vec1->size != vec3->size || vec1->size != vec4->size) {
|
||||
if (vec1->size != vec2->size || vec1->size != vec3->size || vec1->size != vec4->size) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"vectors must be of the same size");
|
||||
return NULL;
|
||||
}
|
||||
if(vec1->size < 3) {
|
||||
if (vec1->size < 3) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"2D vectors unsupported");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1 || BaseMath_ReadCallback(vec3) == -1 || BaseMath_ReadCallback(vec4) == -1)
|
||||
if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1 || BaseMath_ReadCallback(vec3) == -1 || BaseMath_ReadCallback(vec4) == -1)
|
||||
return NULL;
|
||||
|
||||
normal_quad_v3(n, vec1->vec, vec2->vec, vec3->vec, vec4->vec);
|
||||
@ -320,17 +320,17 @@ static PyObject *M_Geometry_area_tri(PyObject *UNUSED(self), PyObject* args)
|
||||
{
|
||||
VectorObject *vec1, *vec2, *vec3;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "O!O!O!:area_tri", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3)) {
|
||||
if (!PyArg_ParseTuple(args, "O!O!O!:area_tri", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(vec1->size != vec2->size || vec1->size != vec3->size) {
|
||||
if (vec1->size != vec2->size || vec1->size != vec3->size) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"vectors must be of the same size");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1 || BaseMath_ReadCallback(vec3) == -1)
|
||||
if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1 || BaseMath_ReadCallback(vec3) == -1)
|
||||
return NULL;
|
||||
|
||||
if (vec1->size == 3) {
|
||||
@ -367,7 +367,7 @@ static PyObject *M_Geometry_intersect_line_line_2d(PyObject *UNUSED(self), PyObj
|
||||
{
|
||||
VectorObject *line_a1, *line_a2, *line_b1, *line_b2;
|
||||
float vi[2];
|
||||
if(!PyArg_ParseTuple(args, "O!O!O!O!:intersect_line_line_2d",
|
||||
if (!PyArg_ParseTuple(args, "O!O!O!O!:intersect_line_line_2d",
|
||||
&vector_Type, &line_a1,
|
||||
&vector_Type, &line_a2,
|
||||
&vector_Type, &line_b1,
|
||||
@ -376,10 +376,10 @@ static PyObject *M_Geometry_intersect_line_line_2d(PyObject *UNUSED(self), PyObj
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(BaseMath_ReadCallback(line_a1) == -1 || BaseMath_ReadCallback(line_a2) == -1 || BaseMath_ReadCallback(line_b1) == -1 || BaseMath_ReadCallback(line_b2) == -1)
|
||||
if (BaseMath_ReadCallback(line_a1) == -1 || BaseMath_ReadCallback(line_a2) == -1 || BaseMath_ReadCallback(line_b1) == -1 || BaseMath_ReadCallback(line_b2) == -1)
|
||||
return NULL;
|
||||
|
||||
if(isect_seg_seg_v2_point(line_a1->vec, line_a2->vec, line_b1->vec, line_b2->vec, vi) == 1) {
|
||||
if (isect_seg_seg_v2_point(line_a1->vec, line_a2->vec, line_b1->vec, line_b2->vec, vi) == 1) {
|
||||
return newVectorObject(vi, 2, Py_NEW, NULL);
|
||||
}
|
||||
else {
|
||||
@ -411,7 +411,7 @@ static PyObject *M_Geometry_intersect_line_plane(PyObject *UNUSED(self), PyObjec
|
||||
VectorObject *line_a, *line_b, *plane_co, *plane_no;
|
||||
int no_flip= 0;
|
||||
float isect[3];
|
||||
if(!PyArg_ParseTuple(args, "O!O!O!O!|i:intersect_line_plane",
|
||||
if (!PyArg_ParseTuple(args, "O!O!O!O!|i:intersect_line_plane",
|
||||
&vector_Type, &line_a,
|
||||
&vector_Type, &line_b,
|
||||
&vector_Type, &plane_co,
|
||||
@ -421,7 +421,7 @@ static PyObject *M_Geometry_intersect_line_plane(PyObject *UNUSED(self), PyObjec
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( BaseMath_ReadCallback(line_a) == -1 ||
|
||||
if ( BaseMath_ReadCallback(line_a) == -1 ||
|
||||
BaseMath_ReadCallback(line_b) == -1 ||
|
||||
BaseMath_ReadCallback(plane_co) == -1 ||
|
||||
BaseMath_ReadCallback(plane_no) == -1
|
||||
@ -429,14 +429,14 @@ static PyObject *M_Geometry_intersect_line_plane(PyObject *UNUSED(self), PyObjec
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(ELEM4(2, line_a->size, line_b->size, plane_co->size, plane_no->size)) {
|
||||
if (ELEM4(2, line_a->size, line_b->size, plane_co->size, plane_no->size)) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"geometry.intersect_line_plane(...): "
|
||||
" can't use 2D Vectors");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(isect_line_plane_v3(isect, line_a->vec, line_b->vec, plane_co->vec, plane_no->vec, no_flip) == 1) {
|
||||
if (isect_line_plane_v3(isect, line_a->vec, line_b->vec, plane_co->vec, plane_no->vec, no_flip) == 1) {
|
||||
return newVectorObject(isect, 3, Py_NEW, NULL);
|
||||
}
|
||||
else {
|
||||
@ -471,7 +471,7 @@ static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObje
|
||||
float isect_a[3];
|
||||
float isect_b[3];
|
||||
|
||||
if(!PyArg_ParseTuple(args, "O!O!O!f|i:intersect_line_sphere",
|
||||
if (!PyArg_ParseTuple(args, "O!O!O!f|i:intersect_line_sphere",
|
||||
&vector_Type, &line_a,
|
||||
&vector_Type, &line_b,
|
||||
&vector_Type, &sphere_co,
|
||||
@ -480,14 +480,14 @@ static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObje
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( BaseMath_ReadCallback(line_a) == -1 ||
|
||||
if ( BaseMath_ReadCallback(line_a) == -1 ||
|
||||
BaseMath_ReadCallback(line_b) == -1 ||
|
||||
BaseMath_ReadCallback(sphere_co) == -1
|
||||
) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(ELEM3(2, line_a->size, line_b->size, sphere_co->size)) {
|
||||
if (ELEM3(2, line_a->size, line_b->size, sphere_co->size)) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"geometry.intersect_line_sphere(...): "
|
||||
" can't use 2D Vectors");
|
||||
@ -502,22 +502,22 @@ static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObje
|
||||
|
||||
switch(isect_line_sphere_v3(line_a->vec, line_b->vec, sphere_co->vec, sphere_radius, isect_a, isect_b)) {
|
||||
case 1:
|
||||
if(!(!clip || (((lambda= line_point_factor_v3(isect_a, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_a= FALSE;
|
||||
if (!(!clip || (((lambda= line_point_factor_v3(isect_a, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_a= FALSE;
|
||||
use_b= FALSE;
|
||||
break;
|
||||
case 2:
|
||||
if(!(!clip || (((lambda= line_point_factor_v3(isect_a, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_a= FALSE;
|
||||
if(!(!clip || (((lambda= line_point_factor_v3(isect_b, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_b= FALSE;
|
||||
if (!(!clip || (((lambda= line_point_factor_v3(isect_a, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_a= FALSE;
|
||||
if (!(!clip || (((lambda= line_point_factor_v3(isect_b, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_b= FALSE;
|
||||
break;
|
||||
default:
|
||||
use_a= FALSE;
|
||||
use_b= FALSE;
|
||||
}
|
||||
|
||||
if(use_a) { PyTuple_SET_ITEM(ret, 0, newVectorObject(isect_a, 3, Py_NEW, NULL)); }
|
||||
if (use_a) { PyTuple_SET_ITEM(ret, 0, newVectorObject(isect_a, 3, Py_NEW, NULL)); }
|
||||
else { PyTuple_SET_ITEM(ret, 0, Py_None); Py_INCREF(Py_None); }
|
||||
|
||||
if(use_b) { PyTuple_SET_ITEM(ret, 1, newVectorObject(isect_b, 3, Py_NEW, NULL)); }
|
||||
if (use_b) { PyTuple_SET_ITEM(ret, 1, newVectorObject(isect_b, 3, Py_NEW, NULL)); }
|
||||
else { PyTuple_SET_ITEM(ret, 1, Py_None); Py_INCREF(Py_None); }
|
||||
|
||||
return ret;
|
||||
@ -551,7 +551,7 @@ static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyO
|
||||
float isect_a[3];
|
||||
float isect_b[3];
|
||||
|
||||
if(!PyArg_ParseTuple(args, "O!O!O!f|i:intersect_line_sphere_2d",
|
||||
if (!PyArg_ParseTuple(args, "O!O!O!f|i:intersect_line_sphere_2d",
|
||||
&vector_Type, &line_a,
|
||||
&vector_Type, &line_b,
|
||||
&vector_Type, &sphere_co,
|
||||
@ -560,7 +560,7 @@ static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyO
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( BaseMath_ReadCallback(line_a) == -1 ||
|
||||
if ( BaseMath_ReadCallback(line_a) == -1 ||
|
||||
BaseMath_ReadCallback(line_b) == -1 ||
|
||||
BaseMath_ReadCallback(sphere_co) == -1
|
||||
) {
|
||||
@ -575,22 +575,22 @@ static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyO
|
||||
|
||||
switch(isect_line_sphere_v2(line_a->vec, line_b->vec, sphere_co->vec, sphere_radius, isect_a, isect_b)) {
|
||||
case 1:
|
||||
if(!(!clip || (((lambda= line_point_factor_v2(isect_a, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_a= FALSE;
|
||||
if (!(!clip || (((lambda= line_point_factor_v2(isect_a, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_a= FALSE;
|
||||
use_b= FALSE;
|
||||
break;
|
||||
case 2:
|
||||
if(!(!clip || (((lambda= line_point_factor_v2(isect_a, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_a= FALSE;
|
||||
if(!(!clip || (((lambda= line_point_factor_v2(isect_b, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_b= FALSE;
|
||||
if (!(!clip || (((lambda= line_point_factor_v2(isect_a, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_a= FALSE;
|
||||
if (!(!clip || (((lambda= line_point_factor_v2(isect_b, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_b= FALSE;
|
||||
break;
|
||||
default:
|
||||
use_a= FALSE;
|
||||
use_b= FALSE;
|
||||
}
|
||||
|
||||
if(use_a) { PyTuple_SET_ITEM(ret, 0, newVectorObject(isect_a, 2, Py_NEW, NULL)); }
|
||||
if (use_a) { PyTuple_SET_ITEM(ret, 0, newVectorObject(isect_a, 2, Py_NEW, NULL)); }
|
||||
else { PyTuple_SET_ITEM(ret, 0, Py_None); Py_INCREF(Py_None); }
|
||||
|
||||
if(use_b) { PyTuple_SET_ITEM(ret, 1, newVectorObject(isect_b, 2, Py_NEW, NULL)); }
|
||||
if (use_b) { PyTuple_SET_ITEM(ret, 1, newVectorObject(isect_b, 2, Py_NEW, NULL)); }
|
||||
else { PyTuple_SET_ITEM(ret, 1, Py_None); Py_INCREF(Py_None); }
|
||||
|
||||
return ret;
|
||||
@ -617,7 +617,7 @@ static PyObject *M_Geometry_intersect_point_line(PyObject *UNUSED(self), PyObjec
|
||||
float lambda;
|
||||
PyObject *ret;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "O!O!O!:intersect_point_line",
|
||||
if (!PyArg_ParseTuple(args, "O!O!O!:intersect_point_line",
|
||||
&vector_Type, &pt,
|
||||
&vector_Type, &line_1,
|
||||
&vector_Type, &line_2)
|
||||
@ -625,7 +625,7 @@ static PyObject *M_Geometry_intersect_point_line(PyObject *UNUSED(self), PyObjec
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(BaseMath_ReadCallback(pt) == -1 || BaseMath_ReadCallback(line_1) == -1 || BaseMath_ReadCallback(line_2) == -1)
|
||||
if (BaseMath_ReadCallback(pt) == -1 || BaseMath_ReadCallback(line_1) == -1 || BaseMath_ReadCallback(line_2) == -1)
|
||||
return NULL;
|
||||
|
||||
/* accept 2d verts */
|
||||
@ -666,7 +666,7 @@ static PyObject *M_Geometry_intersect_point_tri_2d(PyObject *UNUSED(self), PyObj
|
||||
{
|
||||
VectorObject *pt_vec, *tri_p1, *tri_p2, *tri_p3;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "O!O!O!O!:intersect_point_tri_2d",
|
||||
if (!PyArg_ParseTuple(args, "O!O!O!O!:intersect_point_tri_2d",
|
||||
&vector_Type, &pt_vec,
|
||||
&vector_Type, &tri_p1,
|
||||
&vector_Type, &tri_p2,
|
||||
@ -675,7 +675,7 @@ static PyObject *M_Geometry_intersect_point_tri_2d(PyObject *UNUSED(self), PyObj
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(BaseMath_ReadCallback(pt_vec) == -1 || BaseMath_ReadCallback(tri_p1) == -1 || BaseMath_ReadCallback(tri_p2) == -1 || BaseMath_ReadCallback(tri_p3) == -1)
|
||||
if (BaseMath_ReadCallback(pt_vec) == -1 || BaseMath_ReadCallback(tri_p1) == -1 || BaseMath_ReadCallback(tri_p2) == -1 || BaseMath_ReadCallback(tri_p3) == -1)
|
||||
return NULL;
|
||||
|
||||
return PyLong_FromLong(isect_point_tri_v2(pt_vec->vec, tri_p1->vec, tri_p2->vec, tri_p3->vec));
|
||||
@ -702,7 +702,7 @@ static PyObject *M_Geometry_intersect_point_quad_2d(PyObject *UNUSED(self), PyOb
|
||||
{
|
||||
VectorObject *pt_vec, *quad_p1, *quad_p2, *quad_p3, *quad_p4;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "O!O!O!O!O!:intersect_point_quad_2d",
|
||||
if (!PyArg_ParseTuple(args, "O!O!O!O!O!:intersect_point_quad_2d",
|
||||
&vector_Type, &pt_vec,
|
||||
&vector_Type, &quad_p1,
|
||||
&vector_Type, &quad_p2,
|
||||
@ -712,7 +712,7 @@ static PyObject *M_Geometry_intersect_point_quad_2d(PyObject *UNUSED(self), PyOb
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(BaseMath_ReadCallback(pt_vec) == -1 || BaseMath_ReadCallback(quad_p1) == -1 || BaseMath_ReadCallback(quad_p2) == -1 || BaseMath_ReadCallback(quad_p3) == -1 || BaseMath_ReadCallback(quad_p4) == -1)
|
||||
if (BaseMath_ReadCallback(pt_vec) == -1 || BaseMath_ReadCallback(quad_p1) == -1 || BaseMath_ReadCallback(quad_p2) == -1 || BaseMath_ReadCallback(quad_p3) == -1 || BaseMath_ReadCallback(quad_p4) == -1)
|
||||
return NULL;
|
||||
|
||||
return PyLong_FromLong(isect_point_quad_v2(pt_vec->vec, quad_p1->vec, quad_p2->vec, quad_p3->vec, quad_p4->vec));
|
||||
@ -747,7 +747,7 @@ static PyObject *M_Geometry_barycentric_transform(PyObject *UNUSED(self), PyObje
|
||||
VectorObject *vec_t1_src, *vec_t2_src, *vec_t3_src;
|
||||
float vec[3];
|
||||
|
||||
if(!PyArg_ParseTuple(args, "O!O!O!O!O!O!O!:barycentric_transform",
|
||||
if (!PyArg_ParseTuple(args, "O!O!O!O!O!O!O!:barycentric_transform",
|
||||
&vector_Type, &vec_pt,
|
||||
&vector_Type, &vec_t1_src,
|
||||
&vector_Type, &vec_t2_src,
|
||||
@ -759,7 +759,7 @@ static PyObject *M_Geometry_barycentric_transform(PyObject *UNUSED(self), PyObje
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( vec_pt->size != 3 ||
|
||||
if ( vec_pt->size != 3 ||
|
||||
vec_t1_src->size != 3 ||
|
||||
vec_t2_src->size != 3 ||
|
||||
vec_t3_src->size != 3 ||
|
||||
@ -814,7 +814,7 @@ static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject*
|
||||
float h2[4]= {0.0, 0.0, 0.0, 0.0};
|
||||
|
||||
|
||||
if(!PyArg_ParseTuple(args, "O!O!O!O!i:interpolate_bezier",
|
||||
if (!PyArg_ParseTuple(args, "O!O!O!O!i:interpolate_bezier",
|
||||
&vector_Type, &vec_k1,
|
||||
&vector_Type, &vec_h1,
|
||||
&vector_Type, &vec_h2,
|
||||
@ -823,30 +823,30 @@ static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject*
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(resolu <= 1) {
|
||||
if (resolu <= 1) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"resolution must be 2 or over");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(BaseMath_ReadCallback(vec_k1) == -1 || BaseMath_ReadCallback(vec_h1) == -1 || BaseMath_ReadCallback(vec_k2) == -1 || BaseMath_ReadCallback(vec_h2) == -1)
|
||||
if (BaseMath_ReadCallback(vec_k1) == -1 || BaseMath_ReadCallback(vec_h1) == -1 || BaseMath_ReadCallback(vec_k2) == -1 || BaseMath_ReadCallback(vec_h2) == -1)
|
||||
return NULL;
|
||||
|
||||
dims= MAX4(vec_k1->size, vec_h1->size, vec_h2->size, vec_k2->size);
|
||||
|
||||
for(i=0; i < vec_k1->size; i++) k1[i]= vec_k1->vec[i];
|
||||
for(i=0; i < vec_h1->size; i++) h1[i]= vec_h1->vec[i];
|
||||
for(i=0; i < vec_k2->size; i++) k2[i]= vec_k2->vec[i];
|
||||
for(i=0; i < vec_h2->size; i++) h2[i]= vec_h2->vec[i];
|
||||
for (i=0; i < vec_k1->size; i++) k1[i]= vec_k1->vec[i];
|
||||
for (i=0; i < vec_h1->size; i++) h1[i]= vec_h1->vec[i];
|
||||
for (i=0; i < vec_k2->size; i++) k2[i]= vec_k2->vec[i];
|
||||
for (i=0; i < vec_h2->size; i++) h2[i]= vec_h2->vec[i];
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
list= PyList_New(resolu);
|
||||
fp= coord_array;
|
||||
for(i=0; i<resolu; i++, fp= fp+dims) {
|
||||
for (i=0; i<resolu; i++, fp= fp+dims) {
|
||||
PyList_SET_ITEM(list, i, newVectorObject(fp, dims, Py_NEW, NULL));
|
||||
}
|
||||
MEM_freeN(coord_array);
|
||||
@ -875,7 +875,7 @@ static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject *
|
||||
float *fp; /*pointer to the array of malloced dl->verts to set the points from the vectors */
|
||||
int index, *dl_face, totpoints=0;
|
||||
|
||||
if(!PySequence_Check(polyLineSeq)) {
|
||||
if (!PySequence_Check(polyLineSeq)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"expected a sequence of poly lines");
|
||||
return NULL;
|
||||
@ -883,7 +883,7 @@ static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject *
|
||||
|
||||
len_polylines= PySequence_Size(polyLineSeq);
|
||||
|
||||
for(i= 0; i < len_polylines; ++i) {
|
||||
for (i= 0; i < len_polylines; ++i) {
|
||||
polyLine= PySequence_GetItem(polyLineSeq, i);
|
||||
if (!PySequence_Check(polyLine)) {
|
||||
freedisplist(&dispbase);
|
||||
@ -914,16 +914,16 @@ static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject *
|
||||
dl->verts= fp= MEM_callocN(sizeof(float)*3*len_polypoints, "dl verts");
|
||||
dl->index= MEM_callocN(sizeof(int)*3*len_polypoints, "dl index");
|
||||
|
||||
for(index= 0; index<len_polypoints; ++index, fp+=3) {
|
||||
for (index= 0; index<len_polypoints; ++index, fp+=3) {
|
||||
polyVec= PySequence_GetItem(polyLine, index);
|
||||
if(VectorObject_Check(polyVec)) {
|
||||
if (VectorObject_Check(polyVec)) {
|
||||
|
||||
if(BaseMath_ReadCallback((VectorObject *)polyVec) == -1)
|
||||
if (BaseMath_ReadCallback((VectorObject *)polyVec) == -1)
|
||||
ls_error= 1;
|
||||
|
||||
fp[0]= ((VectorObject *)polyVec)->vec[0];
|
||||
fp[1]= ((VectorObject *)polyVec)->vec[1];
|
||||
if(((VectorObject *)polyVec)->size > 2)
|
||||
if (((VectorObject *)polyVec)->size > 2)
|
||||
fp[2]= ((VectorObject *)polyVec)->vec[2];
|
||||
else
|
||||
fp[2]= 0.0f; /* if its a 2d vector then set the z to be zero */
|
||||
@ -939,7 +939,7 @@ static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject *
|
||||
Py_DECREF(polyLine);
|
||||
}
|
||||
|
||||
if(ls_error) {
|
||||
if (ls_error) {
|
||||
freedisplist(&dispbase); /* possible some dl was allocated */
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"A point in one of the polylines "
|
||||
@ -955,7 +955,7 @@ static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject *
|
||||
dl= dispbase.first;
|
||||
|
||||
tri_list= PyList_New(dl->parts);
|
||||
if(!tri_list) {
|
||||
if (!tri_list) {
|
||||
freedisplist(&dispbase);
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
"failed to make a new list");
|
||||
@ -964,7 +964,7 @@ static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject *
|
||||
|
||||
index= 0;
|
||||
dl_face= dl->index;
|
||||
while(index < dl->parts) {
|
||||
while (index < dl->parts) {
|
||||
PyList_SET_ITEM(tri_list, index, Py_BuildValue("iii", dl_face[0], dl_face[1], dl_face[2]));
|
||||
dl_face+= 3;
|
||||
index++;
|
||||
@ -989,7 +989,7 @@ static int boxPack_FromPyObject(PyObject *value, boxPack **boxarray)
|
||||
|
||||
|
||||
/* Error checking must already be done */
|
||||
if(!PyList_Check(value)) {
|
||||
if (!PyList_Check(value)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"can only back a list of [x, y, w, h]");
|
||||
return -1;
|
||||
@ -1000,9 +1000,9 @@ static int boxPack_FromPyObject(PyObject *value, boxPack **boxarray)
|
||||
(*boxarray)= MEM_mallocN(len*sizeof(boxPack), "boxPack box");
|
||||
|
||||
|
||||
for(i= 0; i < len; i++) {
|
||||
for (i= 0; i < len; i++) {
|
||||
list_item= PyList_GET_ITEM(value, i);
|
||||
if(!PyList_Check(list_item) || PyList_GET_SIZE(list_item) < 4) {
|
||||
if (!PyList_Check(list_item) || PyList_GET_SIZE(list_item) < 4) {
|
||||
MEM_freeN(*boxarray);
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"can only pack a list of [x, y, w, h]");
|
||||
@ -1040,7 +1040,7 @@ static void boxPack_ToPyObject(PyObject *value, boxPack **boxarray)
|
||||
|
||||
len= PyList_GET_SIZE(value);
|
||||
|
||||
for(i= 0; i < len; i++) {
|
||||
for (i= 0; i < len; i++) {
|
||||
box= (*boxarray)+i;
|
||||
list_item= PyList_GET_ITEM(value, box->index);
|
||||
PyList_SET_ITEM(list_item, 0, PyFloat_FromDouble(box->x));
|
||||
@ -1066,7 +1066,7 @@ static PyObject *M_Geometry_box_pack_2d(PyObject *UNUSED(self), PyObject *boxlis
|
||||
|
||||
PyObject *ret;
|
||||
|
||||
if(!PyList_Check(boxlist)) {
|
||||
if (!PyList_Check(boxlist)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"expected a list of boxes [[x, y, w, h], ... ]");
|
||||
return NULL;
|
||||
@ -1075,7 +1075,7 @@ static PyObject *M_Geometry_box_pack_2d(PyObject *UNUSED(self), PyObject *boxlis
|
||||
len= PyList_GET_SIZE(boxlist);
|
||||
if (len) {
|
||||
boxPack *boxarray= NULL;
|
||||
if(boxPack_FromPyObject(boxlist, &boxarray) == -1) {
|
||||
if (boxPack_FromPyObject(boxlist, &boxarray) == -1) {
|
||||
return NULL; /* exception set */
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user