Merged changes in the trunk up to revision 42021.

Conflicts resolved:
source/blender/blenkernel/intern/scene.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/interface/resources.c
source/blender/render/intern/source/pipeline.c
This commit is contained in:
Tamito Kajiyama
2011-11-20 21:02:12 +00:00
497 changed files with 12939 additions and 5809 deletions

View File

@@ -74,7 +74,7 @@ void BPY_modules_load_user(struct bContext *C);
void BPY_app_handlers_reset(const short do_all);
void BPY_driver_reset(void);
float BPY_driver_exec(struct ChannelDriver *driver);
float BPY_driver_exec(struct ChannelDriver *driver, const float evaltime);
int BPY_button_exec(struct bContext *C, const char *expr, double *value, const short verbose);
int BPY_string_exec(struct bContext *C, const char *expr);

View File

@@ -33,17 +33,17 @@ set(INC_SYS
)
set(SRC
IDProp.c
bgl.c
blf_py_api.c
bpy_internal_import.c
idprop_py_api.c
noise_py_api.c
py_capi_utils.c
IDProp.h
bgl.h
blf_py_api.h
bpy_internal_import.h
idprop_py_api.h
noise_py_api.h
py_capi_utils.h
)

View File

@@ -21,14 +21,14 @@
* ***** END GPL LICENSE BLOCK *****
*/
/** \file blender/python/generic/IDProp.c
/** \file blender/python/generic/idprop_py_api.c
* \ingroup pygen
*/
#include <Python.h>
#include "IDProp.h"
#include "idprop_py_api.h"
#include "MEM_guardedalloc.h"
#include "BLI_string.h"
@@ -49,6 +49,83 @@ extern PyTypeObject BPy_IDGroup_Type;
/*********************** ID Property Main Wrapper Stuff ***************/
/* ----------------------------------------------------------------------------
* static conversion functions to avoid duplicate code, no type checking.
*/
static PyObject *idprop_py_from_idp_string(IDProperty *prop)
{
if (prop->subtype == IDP_STRING_SUB_BYTE) {
return PyBytes_FromStringAndSize(IDP_Array(prop), prop->len);
}
else {
#ifdef USE_STRING_COERCE
return PyC_UnicodeFromByteAndSize(IDP_Array(prop), prop->len - 1);
#else
return PyUnicode_FromStringAndSize(IDP_Array(prop), prop->len - 1);
#endif
}
}
static PyObject *idprop_py_from_idp_int(IDProperty *prop)
{
return PyLong_FromLong((long)prop->data.val);
}
static PyObject *idprop_py_from_idp_float(IDProperty *prop)
{
return PyFloat_FromDouble((double)(*(float*)(&prop->data.val)));
}
static PyObject *idprop_py_from_idp_double(IDProperty *prop)
{
return PyFloat_FromDouble((*(double*)(&prop->data.val)));
}
static PyObject *idprop_py_from_idp_group(ID *id, IDProperty *prop, IDProperty *parent)
{
BPy_IDProperty *group= PyObject_New(BPy_IDProperty, &BPy_IDGroup_Type);
group->id = id;
group->prop = prop;
group->parent = parent; /* can be NULL */
return (PyObject*) group;
}
static PyObject *idprop_py_from_idp_array(ID *id, IDProperty *prop)
{
BPy_IDProperty *array = PyObject_New(BPy_IDProperty, &BPy_IDArray_Type);
array->id = id;
array->prop = prop;
return (PyObject*) array;
}
static PyObject *idprop_py_from_idp_idparray(ID *id, IDProperty *prop)
{
PyObject *seq = PyList_New(prop->len), *wrap;
IDProperty *array= IDP_IDPArray(prop);
int i;
if (!seq) {
PyErr_Format(PyExc_RuntimeError,
"%s: IDP_IDPARRAY: PyList_New(%d) failed",
__func__, prop->len);
return NULL;
}
for (i=0; i<prop->len; i++) {
wrap= BPy_IDGroup_WrapData(id, array++, prop);
if (!wrap) /* BPy_IDGroup_MapDataToPy sets the error */
return NULL;
PyList_SET_ITEM(seq, i, wrap);
}
return seq;
}
/* -------------------------------------------------------------------------- */
/* use for both array and group */
static long BPy_IDGroup_hash(BPy_IDProperty *self)
{
@@ -60,61 +137,26 @@ static PyObject *BPy_IDGroup_repr(BPy_IDProperty *self)
return PyUnicode_FromFormat( "<bpy id property from \"%s\">", self->id->name);
}
PyObject *BPy_IDGroup_WrapData( ID *id, IDProperty *prop )
PyObject *BPy_IDGroup_WrapData(ID *id, IDProperty *prop, IDProperty *parent)
{
switch ( prop->type ) {
case IDP_STRING:
#ifdef USE_STRING_COERCE
return PyC_UnicodeFromByteAndSize(IDP_Array(prop), prop->len - 1);
#else
return PyUnicode_FromStringAndSize(IDP_Array(prop), prop->len - 1);
#endif
case IDP_INT:
return PyLong_FromLong( (long)prop->data.val );
case IDP_FLOAT:
return PyFloat_FromDouble( (double)(*(float*)(&prop->data.val)) );
case IDP_DOUBLE:
return PyFloat_FromDouble( (*(double*)(&prop->data.val)) );
case IDP_GROUP:
/*blegh*/
{
BPy_IDProperty *group = PyObject_New(BPy_IDProperty, &BPy_IDGroup_Type);
group->id = id;
group->prop = prop;
return (PyObject*) group;
}
case IDP_ARRAY:
{
BPy_IDProperty *array = PyObject_New(BPy_IDProperty, &BPy_IDArray_Type);
array->id = id;
array->prop = prop;
return (PyObject*) array;
}
case IDP_IDPARRAY: /* this could be better a internal type */
{
PyObject *seq = PyList_New(prop->len), *wrap;
IDProperty *array= IDP_IDPArray(prop);
int i;
if (!seq) {
PyErr_Format(PyExc_RuntimeError, "BPy_IDGroup_MapDataToPy, IDP_IDPARRAY: PyList_New(%d) failed", prop->len);
return NULL;
}
for (i=0; i<prop->len; i++) {
wrap= BPy_IDGroup_WrapData(id, array++);
if (!wrap) /* BPy_IDGroup_MapDataToPy sets the error */
return NULL;
PyList_SET_ITEM(seq, i, wrap);
}
return seq;
}
/* case IDP_IDPARRAY: TODO */
switch (prop->type) {
case IDP_STRING:
return idprop_py_from_idp_string(prop);
case IDP_INT:
return idprop_py_from_idp_int(prop);
case IDP_FLOAT:
return idprop_py_from_idp_float(prop);
case IDP_DOUBLE:
return idprop_py_from_idp_double(prop);
case IDP_GROUP:
return idprop_py_from_idp_group(id, prop, parent);
case IDP_ARRAY:
return idprop_py_from_idp_idparray(id, prop);
case IDP_IDPARRAY: /* this could be better a internal type */
idprop_py_from_idp_array(id, prop);
default:
Py_RETURN_NONE;
}
Py_RETURN_NONE;
}
#if 0 /* UNUSED, currenly assignment overwrites into new properties, rather than setting in-place */
@@ -128,6 +170,7 @@ static int BPy_IDGroup_SetData(BPy_IDProperty *self, IDProperty *prop, PyObject
PyErr_SetString(PyExc_TypeError, "expected a string!");
return -1;
}
/* NOTE: if this code is enabled, bytes support needs to be added */
#ifdef USE_STRING_COERCE
{
int alloc_len;
@@ -260,8 +303,7 @@ static PyObject *BPy_IDGroup_Map_GetItem(BPy_IDProperty *self, PyObject *item)
return NULL;
}
return BPy_IDGroup_WrapData(self->id, idprop);
return BPy_IDGroup_WrapData(self->id, idprop, self->prop);
}
/*returns NULL on success, error string on failure*/
@@ -323,23 +365,33 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty
if (PyFloat_Check(ob)) {
val.d = PyFloat_AsDouble(ob);
prop = IDP_New(IDP_DOUBLE, val, name);
prop = IDP_New(IDP_DOUBLE, &val, name);
}
else if (PyLong_Check(ob)) {
val.i = (int) PyLong_AsSsize_t(ob);
prop = IDP_New(IDP_INT, val, name);
prop = IDP_New(IDP_INT, &val, name);
}
else if (PyUnicode_Check(ob)) {
#ifdef USE_STRING_COERCE
PyObject *value_coerce= NULL;
val.str = (char *)PyC_UnicodeAsByte(ob, &value_coerce);
prop = IDP_New(IDP_STRING, val, name);
val.string.str = (char *)PyC_UnicodeAsByte(ob, &value_coerce);
val.string.subtype = IDP_STRING_SUB_UTF8;
prop = IDP_New(IDP_STRING, &val, name);
Py_XDECREF(value_coerce);
#else
val.str = _PyUnicode_AsString(ob);
prop = IDP_New(IDP_STRING, val, name);
#endif
}
else if (PyBytes_Check(ob)) {
val.string.str= PyBytes_AS_STRING(ob);
val.string.len= PyBytes_GET_SIZE(ob);
val.string.subtype= IDP_STRING_SUB_BYTE;
prop = IDP_New(IDP_STRING, &val, name);
//prop = IDP_NewString(PyBytes_AS_STRING(ob), name, PyBytes_GET_SIZE(ob));
//prop->subtype= IDP_STRING_SUB_BYTE;
}
else if (PySequence_Check(ob)) {
PyObject *item;
int i;
@@ -355,7 +407,7 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty
switch(val.array.type) {
case IDP_DOUBLE:
prop = IDP_New(IDP_ARRAY, val, name);
prop = IDP_New(IDP_ARRAY, &val, name);
for (i=0; i<val.array.len; i++) {
item = PySequence_GetItem(ob, i);
((double*)IDP_Array(prop))[i] = (float)PyFloat_AsDouble(item);
@@ -363,7 +415,7 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty
}
break;
case IDP_INT:
prop = IDP_New(IDP_ARRAY, val, name);
prop = IDP_New(IDP_ARRAY, &val, name);
for (i=0; i<val.array.len; i++) {
item = PySequence_GetItem(ob, i);
((int*)IDP_Array(prop))[i] = (int)PyLong_AsSsize_t(item);
@@ -393,7 +445,7 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty
/*we allocate the group first; if we hit any invalid data,
we can delete it easily enough.*/
prop = IDP_New(IDP_GROUP, val, name);
prop = IDP_New(IDP_GROUP, &val, name);
len = PyMapping_Length(ob);
for (i=0; i<len; i++) {
key = PySequence_GetItem(keys, i);
@@ -489,108 +541,109 @@ static PyObject *BPy_IDGroup_iter(BPy_IDProperty *self)
return (PyObject*) iter;
}
/* for simple, non nested types this is the same as BPy_IDGroup_WrapData */
static PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop)
{
switch (prop->type) {
case IDP_STRING:
#ifdef USE_STRING_COERCE
return PyC_UnicodeFromByteAndSize(IDP_Array(prop), prop->len - 1);
#else
return PyUnicode_FromStringAndSize(IDP_Array(prop), prop->len - 1);
#endif
break;
case IDP_STRING:
return idprop_py_from_idp_string(prop);
case IDP_INT:
return idprop_py_from_idp_int(prop);
case IDP_FLOAT:
return idprop_py_from_idp_float(prop);
case IDP_DOUBLE:
return idprop_py_from_idp_double(prop);
case IDP_ARRAY:
{
PyObject *seq = PyList_New(prop->len);
int i;
if (!seq) {
PyErr_Format(PyExc_RuntimeError,
"%s: IDP_ARRAY: PyList_New(%d) failed",
__func__, prop->len);
return NULL;
}
switch(prop->subtype) {
case IDP_FLOAT:
return PyFloat_FromDouble(*((float*)&prop->data.val));
break;
case IDP_DOUBLE:
return PyFloat_FromDouble(*((double*)&prop->data.val));
break;
case IDP_INT:
return PyLong_FromSsize_t( prop->data.val );
break;
case IDP_ARRAY:
{
PyObject *seq = PyList_New(prop->len);
int i;
if (!seq) {
PyErr_Format(PyExc_RuntimeError, "BPy_IDGroup_MapDataToPy, IDP_ARRAY: PyList_New(%d) failed", prop->len);
return NULL;
}
switch(prop->subtype) {
case IDP_FLOAT:
{
float *array= (float*)IDP_Array(prop);
for (i=0; i<prop->len; i++) {
PyList_SET_ITEM(seq, i, PyFloat_FromDouble(array[i]));
}
break;
}
case IDP_DOUBLE:
{
double *array= (double*)IDP_Array(prop);
for (i=0; i<prop->len; i++) {
PyList_SET_ITEM(seq, i, PyFloat_FromDouble(array[i]));
}
break;
}
case IDP_INT:
{
int *array= (int*)IDP_Array(prop);
for (i=0; i<prop->len; i++) {
PyList_SET_ITEM(seq, i, PyLong_FromLong(array[i]));
}
break;
}
default:
PyErr_SetString(PyExc_RuntimeError, "invalid/corrupt array type!");
Py_DECREF(seq);
return NULL;
}
return seq;
}
case IDP_IDPARRAY:
{
PyObject *seq = PyList_New(prop->len), *wrap;
IDProperty *array= IDP_IDPArray(prop);
int i;
if (!seq) {
PyErr_Format(PyExc_RuntimeError, "BPy_IDGroup_MapDataToPy, IDP_IDPARRAY: PyList_New(%d) failed", prop->len);
return NULL;
}
float *array= (float*)IDP_Array(prop);
for (i=0; i<prop->len; i++) {
wrap= BPy_IDGroup_MapDataToPy(array++);
if (!wrap) /* BPy_IDGroup_MapDataToPy sets the error */
return NULL;
PyList_SET_ITEM(seq, i, wrap);
PyList_SET_ITEM(seq, i, PyFloat_FromDouble(array[i]));
}
return seq;
break;
}
case IDP_GROUP:
case IDP_DOUBLE:
{
PyObject *dict = PyDict_New(), *wrap;
IDProperty *loop;
for (loop=prop->data.group.first; loop; loop=loop->next) {
wrap = BPy_IDGroup_MapDataToPy(loop);
if (!wrap) /* BPy_IDGroup_MapDataToPy sets the error */
return NULL;
PyDict_SetItemString(dict, loop->name, wrap);
Py_DECREF(wrap);
double *array= (double*)IDP_Array(prop);
for (i=0; i<prop->len; i++) {
PyList_SET_ITEM(seq, i, PyFloat_FromDouble(array[i]));
}
return dict;
break;
}
case IDP_INT:
{
int *array= (int*)IDP_Array(prop);
for (i=0; i<prop->len; i++) {
PyList_SET_ITEM(seq, i, PyLong_FromLong(array[i]));
}
break;
}
default:
PyErr_Format(PyExc_RuntimeError,
"%s: invalid/corrupt array type '%d'!",
__func__, prop->subtype);
Py_DECREF(seq);
return NULL;
}
return seq;
}
case IDP_IDPARRAY:
{
PyObject *seq = PyList_New(prop->len), *wrap;
IDProperty *array= IDP_IDPArray(prop);
int i;
if (!seq) {
PyErr_Format(PyExc_RuntimeError,
"%s: IDP_IDPARRAY: PyList_New(%d) failed",
__func__, prop->len);
return NULL;
}
for (i=0; i<prop->len; i++) {
wrap= BPy_IDGroup_MapDataToPy(array++);
if (!wrap) /* BPy_IDGroup_MapDataToPy sets the error */
return NULL;
PyList_SET_ITEM(seq, i, wrap);
}
return seq;
}
case IDP_GROUP:
{
PyObject *dict = PyDict_New(), *wrap;
IDProperty *loop;
for (loop=prop->data.group.first; loop; loop=loop->next) {
wrap = BPy_IDGroup_MapDataToPy(loop);
if (!wrap) /* BPy_IDGroup_MapDataToPy sets the error */
return NULL;
PyDict_SetItemString(dict, loop->name, wrap);
Py_DECREF(wrap);
}
return dict;
}
}
PyErr_Format(PyExc_RuntimeError, "eek!! '%s' property exists with a bad type code '%d' !!!", prop->name, prop->type);
PyErr_Format(PyExc_RuntimeError,
"%s ERROR: '%s' property exists with a bad type code '%d'!",
__func__, prop->name, prop->type);
return NULL;
}
@@ -601,7 +654,9 @@ static PyObject *BPy_IDGroup_Pop(BPy_IDProperty *self, PyObject *value)
const char *name = _PyUnicode_AsString(value);
if (!name) {
PyErr_SetString(PyExc_TypeError, "pop expected at least 1 argument, got 0");
PyErr_Format(PyExc_TypeError,
"pop expected at least a string argument, not %.200s",
Py_TYPE(value)->tp_name);
return NULL;
}
@@ -654,44 +709,44 @@ static void BPy_IDGroup_CorrectListLen(IDProperty *prop, PyObject *seq, int len,
PyObject *BPy_Wrap_GetKeys(IDProperty *prop)
{
PyObject *seq = PyList_New(prop->len);
PyObject *list = PyList_New(prop->len);
IDProperty *loop;
int i;
for (i=0, loop=prop->data.group.first; loop && (i < prop->len); loop=loop->next, i++)
PyList_SET_ITEM(seq, i, PyUnicode_FromString(loop->name));
PyList_SET_ITEM(list, i, PyUnicode_FromString(loop->name));
/* if the id prop is corrupt, count the remaining */
for (; loop; loop=loop->next, i++) {}
if (i != prop->len) { /* if the loop didnt finish, we know the length is wrong */
BPy_IDGroup_CorrectListLen(prop, seq, i, __func__);
Py_DECREF(seq); /*free the list*/
BPy_IDGroup_CorrectListLen(prop, list, i, __func__);
Py_DECREF(list); /*free the list*/
/*call self again*/
return BPy_Wrap_GetKeys(prop);
}
return seq;
return list;
}
PyObject *BPy_Wrap_GetValues(ID *id, IDProperty *prop)
{
PyObject *seq = PyList_New(prop->len);
PyObject *list = PyList_New(prop->len);
IDProperty *loop;
int i;
for (i=0, loop=prop->data.group.first; loop; loop=loop->next, i++) {
PyList_SET_ITEM(seq, i, BPy_IDGroup_WrapData(id, loop));
PyList_SET_ITEM(list, i, BPy_IDGroup_WrapData(id, loop, prop));
}
if (i != prop->len) {
BPy_IDGroup_CorrectListLen(prop, seq, i, __func__);
Py_DECREF(seq); /*free the list*/
BPy_IDGroup_CorrectListLen(prop, list, i, __func__);
Py_DECREF(list); /*free the list*/
/*call self again*/
return BPy_Wrap_GetValues(id, prop);
}
return seq;
return list;
}
PyObject *BPy_Wrap_GetItems(ID *id, IDProperty *prop)
@@ -703,7 +758,7 @@ PyObject *BPy_Wrap_GetItems(ID *id, IDProperty *prop)
for (i=0, loop=prop->data.group.first; loop; loop=loop->next, i++) {
PyObject *item= PyTuple_New(2);
PyTuple_SET_ITEM(item, 0, PyUnicode_FromString(loop->name));
PyTuple_SET_ITEM(item, 1, BPy_IDGroup_WrapData(id, loop));
PyTuple_SET_ITEM(item, 1, BPy_IDGroup_WrapData(id, loop, prop));
PyList_SET_ITEM(seq, i, item);
}
@@ -738,7 +793,9 @@ static int BPy_IDGroup_Contains(BPy_IDProperty *self, PyObject *value)
const char *name = _PyUnicode_AsString(value);
if (!name) {
PyErr_SetString(PyExc_TypeError, "expected a string");
PyErr_Format(PyExc_TypeError,
"expected a string, not a %.200s",
Py_TYPE(value)->tp_name);
return -1;
}
@@ -751,7 +808,9 @@ static PyObject *BPy_IDGroup_Update(BPy_IDProperty *self, PyObject *value)
Py_ssize_t i=0;
if (!PyDict_Check(value)) {
PyErr_SetString(PyExc_TypeError, "expected an object derived from dict");
PyErr_Format(PyExc_TypeError,
"expected a dict not a %.200s",
Py_TYPE(value)->tp_name);
return NULL;
}
@@ -781,7 +840,7 @@ static PyObject* BPy_IDGroup_Get(BPy_IDProperty *self, PyObject *args)
idprop= IDP_GetPropertyFromGroup(self->prop, key);
if (idprop) {
PyObject* pyobj = BPy_IDGroup_WrapData(self->id, idprop);
PyObject* pyobj = BPy_IDGroup_WrapData(self->id, idprop, self->prop);
if (pyobj)
return pyobj;
}
@@ -890,18 +949,6 @@ PyTypeObject BPy_IDGroup_Type = {
BPy_IDGroup_getseters, /* struct PyGetSetDef *tp_getset; */
};
/*********** Main external wrapping function *******/
PyObject *BPy_Wrap_IDProperty(ID *id, IDProperty *prop, IDProperty *parent)
{
BPy_IDProperty *wrap = PyObject_New(BPy_IDProperty, &BPy_IDGroup_Type);
wrap->prop = prop;
wrap->parent = parent;
wrap->id = id;
//wrap->destroy = 0;
return (PyObject*) wrap;
}
/********Array Wrapper********/
static PyTypeObject *idp_array_py_type(BPy_IDArray *self, short *is_double)
@@ -938,7 +985,10 @@ static PyObject *BPy_IDArray_GetType(BPy_IDArray *self)
return PyUnicode_FromString("i");
}
PyErr_SetString(PyExc_RuntimeError, "invalid/corrupt array type!");
PyErr_Format(PyExc_RuntimeError,
"%s: invalid/corrupt array type '%d'!",
__func__, self->prop->subtype);
return NULL;
}
@@ -980,7 +1030,10 @@ static PyObject *BPy_IDArray_GetItem(BPy_IDArray *self, int index)
return PyLong_FromLong((long)((int*)IDP_Array(self->prop))[index]);
}
PyErr_SetString(PyExc_RuntimeError, "invalid/corrupt array type!");
PyErr_Format(PyExc_RuntimeError,
"%s: invalid/corrupt array type '%d'!",
__func__, self->prop->subtype);
return NULL;
}
@@ -1143,7 +1196,9 @@ static PyObject *BPy_IDArray_subscript(BPy_IDArray* self, PyObject* item)
}
}
else {
PyErr_Format(PyExc_TypeError, "vector indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
PyErr_Format(PyExc_TypeError,
"vector indices must be integers, not %.200s",
__func__, Py_TYPE(item)->tp_name);
return NULL;
}
}
@@ -1172,7 +1227,9 @@ static int BPy_IDArray_ass_subscript(BPy_IDArray* self, PyObject* item, PyObject
}
}
else {
PyErr_Format(PyExc_TypeError, "vector indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
PyErr_Format(PyExc_TypeError,
"vector indices must be integers, not %.200s",
Py_TYPE(item)->tp_name);
return -1;
}
}
@@ -1289,7 +1346,7 @@ static PyObject *BPy_Group_Iter_Next(BPy_IDGroup_Iter *self)
if (self->mode == IDPROP_ITER_ITEMS) {
ret = PyTuple_New(2);
PyTuple_SET_ITEM(ret, 0, PyUnicode_FromString(cur->name));
PyTuple_SET_ITEM(ret, 1, BPy_IDGroup_WrapData(self->group->id, cur));
PyTuple_SET_ITEM(ret, 1, BPy_IDGroup_WrapData(self->group->id, cur, self->group->prop));
return ret;
}
else {

View File

@@ -20,13 +20,13 @@
* ***** END GPL LICENSE BLOCK *****
*/
/** \file blender/python/generic/IDProp.h
/** \file blender/python/generic/idprop_py_api.h
* \ingroup pygen
*/
#ifndef IDPROP_H
#define IDPROP_H
#ifndef PY_IDPROP_API_H
#define PY_IDPROP_API_H
struct ID;
struct IDProperty;
@@ -53,14 +53,13 @@ typedef struct BPy_IDGroup_Iter {
int mode;
} BPy_IDGroup_Iter;
PyObject *BPy_Wrap_IDProperty(struct ID *id, struct IDProperty *prop, struct IDProperty *parent);
PyObject *BPy_Wrap_GetKeys(struct IDProperty *prop);
PyObject *BPy_Wrap_GetValues(struct ID *id, struct IDProperty *prop);
PyObject *BPy_Wrap_GetItems(struct ID *id, struct IDProperty *prop);
int BPy_Wrap_SetMapItem(struct IDProperty *prop, PyObject *key, PyObject *val);
PyObject *BPy_IDGroup_WrapData(struct ID *id, struct IDProperty *prop );
PyObject *BPy_IDGroup_WrapData(struct ID *id, struct IDProperty *prop, struct IDProperty *parent);
const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *key, struct IDProperty *group, PyObject *ob);
void IDProp_Init_Types(void);
@@ -68,4 +67,4 @@ void IDProp_Init_Types(void);
#define IDPROP_ITER_KEYS 0
#define IDPROP_ITER_ITEMS 1
#endif /* IDPROP_H */
#endif /* PY_IDPROP_API_H */

View File

@@ -291,7 +291,7 @@ static float turb(float x, float y, float z, int oct, int hard, int nb,
amp = 1.f;
out = (float)(2.0f * BLI_gNoise(1.f, x, y, z, 0, nb) - 1.0f);
if (hard)
out = (float)fabs(out);
out = fabsf(out);
for (i = 1; i < oct; i++) {
amp *= ampscale;
x *= freqscale;
@@ -299,7 +299,7 @@ static float turb(float x, float y, float z, int oct, int hard, int nb,
z *= freqscale;
t = (float)(amp * (2.0f * BLI_gNoise(1.f, x, y, z, 0, nb) - 1.0f));
if (hard)
t = (float)fabs(t);
t = fabsf(t);
out += t;
}
return out;
@@ -321,16 +321,16 @@ static PyObject *Noise_turbulence(PyObject *UNUSED(self), PyObject *args)
/* Turbulence Vector */
static void vTurb(float x, float y, float z, int oct, int hard, int nb,
float ampscale, float freqscale, float v[3])
float ampscale, float freqscale, float v[3])
{
float amp, t[3];
int i;
amp = 1.f;
noise_vector(x, y, z, nb, v);
if (hard) {
v[0] = (float)fabs(v[0]);
v[1] = (float)fabs(v[1]);
v[2] = (float)fabs(v[2]);
v[0] = fabsf(v[0]);
v[1] = fabsf(v[1]);
v[2] = fabsf(v[2]);
}
for (i = 1; i < oct; i++) {
amp *= ampscale;
@@ -339,9 +339,9 @@ static void vTurb(float x, float y, float z, int oct, int hard, int nb,
z *= freqscale;
noise_vector(x, y, z, nb, t);
if (hard) {
t[0] = (float)fabs(t[0]);
t[1] = (float)fabs(t[1]);
t[2] = (float)fabs(t[2]);
t[0] = fabsf(t[0]);
t[1] = fabsf(t[1]);
t[2] = fabsf(t[2]);
}
v[0] += amp * t[0];
v[1] += amp * t[1];

View File

@@ -53,7 +53,7 @@
#include "MEM_guardedalloc.h"
/* external util modules */
#include "../generic/IDProp.h"
#include "../generic/idprop_py_api.h"
#include "../generic/bgl.h"
#include "../generic/blf_py_api.h"
#include "../mathutils/mathutils.h"

View File

@@ -91,6 +91,29 @@ int bpy_pydriver_create_dict(void)
return 0;
}
/* note, this function should do nothing most runs, only when changing frame */
static PyObject *bpy_pydriver_InternStr__frame= NULL;
static void bpy_pydriver_update_dict(const float evaltime)
{
/* not thread safe but neither is python */
static float evaltime_prev= FLT_MAX;
if (evaltime_prev != evaltime) {
/* currently only update the frame */
if (bpy_pydriver_InternStr__frame == NULL) {
bpy_pydriver_InternStr__frame= PyUnicode_FromString("frame");
}
PyDict_SetItem(bpy_pydriver_Dict,
bpy_pydriver_InternStr__frame,
PyFloat_FromDouble(evaltime));
evaltime_prev= evaltime;
}
}
/* Update function, it gets rid of pydrivers global dictionary, forcing
* BPY_driver_exec to recreate it. This function is used to force
* reloading the Blender text module "pydrivers.py", if available, so
@@ -110,6 +133,11 @@ void BPY_driver_reset(void)
bpy_pydriver_Dict= NULL;
}
if (bpy_pydriver_InternStr__frame) {
Py_DECREF(bpy_pydriver_InternStr__frame);
bpy_pydriver_InternStr__frame= NULL;
}
if (use_gil)
PyGILState_Release(gilstate);
@@ -139,7 +167,7 @@ static void pydriver_error(ChannelDriver *driver)
* now release the GIL on python operator execution instead, using
* PyEval_SaveThread() / PyEval_RestoreThread() so we dont lock up blender.
*/
float BPY_driver_exec(ChannelDriver *driver)
float BPY_driver_exec(ChannelDriver *driver, const float evaltime)
{
PyObject *driver_vars=NULL;
PyObject *retval= NULL;
@@ -183,6 +211,10 @@ float BPY_driver_exec(ChannelDriver *driver)
}
}
/* update global namespace */
bpy_pydriver_update_dict(evaltime);
if (driver->expr_comp==NULL)
driver->flag |= DRIVER_FLAG_RECOMPILE;
@@ -246,6 +278,7 @@ float BPY_driver_exec(ChannelDriver *driver)
}
}
#if 0 // slow, with this can avoid all Py_CompileString above.
/* execute expression to get a value */
retval= PyRun_String(expr, Py_eval_input, bpy_pydriver_Dict, driver_vars);

View File

@@ -33,7 +33,7 @@ int bpy_pydriver_create_dict(void);
extern PyObject *bpy_pydriver_Dict;
/* externals */
float BPY_driver_exec(struct ChannelDriver *driver);
float BPY_driver_exec(struct ChannelDriver *driver, const float evaltime);
void BPY_driver_reset(void);
#endif // BPY_DRIVER_H

View File

@@ -74,6 +74,7 @@ static EnumPropertyItem property_subtype_string_items[]= {
{PROP_FILEPATH, "FILE_PATH", 0, "File Path", ""},
{PROP_DIRPATH, "DIR_PATH", 0, "Directory Path", ""},
{PROP_FILENAME, "FILENAME", 0, "Filename", ""},
{PROP_BYTESTRING, "BYTE_STRING", 0, "Byte String", ""},
{PROP_TRANSLATE, "TRANSLATE", 0, "Translate", ""},
{PROP_NONE, "NONE", 0, "None", ""},
@@ -425,6 +426,7 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
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 (opts & PROP_SKIP_SAVE) RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
bpy_prop_callback_assign(prop, update_cb);
RNA_def_property_duplicate_pointers(srna, prop);
@@ -503,6 +505,7 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
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 (opts & PROP_SKIP_SAVE) RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
bpy_prop_callback_assign(prop, update_cb);
RNA_def_property_duplicate_pointers(srna, prop);
@@ -568,6 +571,7 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
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 (opts & PROP_SKIP_SAVE) RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
bpy_prop_callback_assign(prop, update_cb);
RNA_def_property_duplicate_pointers(srna, prop);
@@ -648,6 +652,7 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
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 (opts & PROP_SKIP_SAVE) RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
bpy_prop_callback_assign(prop, update_cb);
RNA_def_property_duplicate_pointers(srna, prop);
@@ -723,6 +728,7 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
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 (opts & PROP_SKIP_SAVE) RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
bpy_prop_callback_assign(prop, update_cb);
RNA_def_property_duplicate_pointers(srna, prop);
@@ -811,6 +817,7 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
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 (opts & PROP_SKIP_SAVE) RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
bpy_prop_callback_assign(prop, update_cb);
RNA_def_property_duplicate_pointers(srna, prop);
@@ -873,6 +880,7 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw
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 (opts & PROP_SKIP_SAVE) RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
bpy_prop_callback_assign(prop, update_cb);
RNA_def_property_duplicate_pointers(srna, prop);
@@ -1204,6 +1212,7 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
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 (opts & PROP_SKIP_SAVE) RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
bpy_prop_callback_assign(prop, update_cb);
RNA_def_property_duplicate_pointers(srna, prop);
@@ -1301,6 +1310,7 @@ static PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *k
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 (opts & PROP_SKIP_SAVE) RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
bpy_prop_callback_assign(prop, update_cb);
RNA_def_property_duplicate_pointers(srna, prop);
@@ -1355,6 +1365,7 @@ static PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject
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 (opts & PROP_SKIP_SAVE) RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
RNA_def_property_duplicate_pointers(srna, prop);
}

View File

@@ -64,6 +64,7 @@
#include "MEM_guardedalloc.h"
#include "BKE_main.h"
#include "BKE_idcode.h"
#include "BKE_context.h"
#include "BKE_global.h" /* evil G.* */
@@ -73,7 +74,7 @@
#include "BKE_animsys.h"
#include "BKE_fcurve.h"
#include "../generic/IDProp.h" /* for IDprop lookups */
#include "../generic/idprop_py_api.h" /* for IDprop lookups */
#include "../generic/py_capi_utils.h"
#ifdef WITH_INTERNATIONAL
@@ -598,7 +599,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
int subtype, totdim;
int len;
int is_thick;
int flag= RNA_property_flag(prop);
const int flag= RNA_property_flag(prop);
/* disallow dynamic sized arrays to be wrapped since the size could change
* to a size mathutils does not support */
@@ -614,7 +615,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
if (!is_thick)
ret= pyrna_prop_CreatePyObject(ptr, prop); /* owned by the mathutils PyObject */
switch(RNA_property_subtype(prop)) {
switch(subtype) {
case PROP_ALL_VECTOR_SUBTYPES:
if (len>=2 && len <= 4) {
if (is_thick) {
@@ -902,7 +903,7 @@ static PyObject *pyrna_prop_str(BPy_PropertyRNA *self)
}
/* if a pointer, try to print name of pointer target too */
if (RNA_property_type(self->prop) == PROP_POINTER) {
if (type == PROP_POINTER) {
ptr= RNA_property_pointer_get(&self->ptr, self->prop);
name= RNA_struct_name_get_alloc(&ptr, NULL, 0, NULL);
@@ -916,7 +917,7 @@ static PyObject *pyrna_prop_str(BPy_PropertyRNA *self)
return ret;
}
}
if (RNA_property_type(self->prop) == PROP_COLLECTION) {
if (type == PROP_COLLECTION) {
PointerRNA r_ptr;
if (RNA_property_collection_type_get(&self->ptr, self->prop, &r_ptr)) {
return PyUnicode_FromFormat("<bpy_%.200s, %.200s>",
@@ -1301,7 +1302,7 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
{
PyObject *ret;
int type= RNA_property_type(prop);
const int type= RNA_property_type(prop);
if (RNA_property_array_check(prop)) {
return pyrna_py_from_array(ptr, prop);
@@ -1320,7 +1321,7 @@ PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
break;
case PROP_STRING:
{
int subtype= RNA_property_subtype(prop);
const int subtype= RNA_property_subtype(prop);
const char *buf;
int buf_len;
char buf_fixed[32];
@@ -1328,14 +1329,22 @@ PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
buf= RNA_property_string_get_alloc(ptr, prop, buf_fixed, sizeof(buf_fixed), &buf_len);
#ifdef USE_STRING_COERCE
/* only file paths get special treatment, they may contain non utf-8 chars */
if (ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) {
if (subtype == PROP_BYTESTRING) {
ret= PyBytes_FromStringAndSize(buf, buf_len);
}
else if (ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) {
ret= PyC_UnicodeFromByteAndSize(buf, buf_len);
}
else {
ret= PyUnicode_FromStringAndSize(buf, buf_len);
}
#else // USE_STRING_COERCE
ret= PyUnicode_FromStringAndSize(buf, buf_len);
if (subtype == PROP_BYTESTRING) {
ret= PyBytes_FromStringAndSize(buf, buf_len);
}
else {
ret= PyUnicode_FromStringAndSize(buf, buf_len);
}
#endif // USE_STRING_COERCE
if (buf_fixed != buf) {
MEM_freeN((void *)buf);
@@ -1450,7 +1459,7 @@ static PyObject *pyrna_func_to_py(PointerRNA *ptr, FunctionRNA *func)
static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyObject *value, const char *error_prefix)
{
/* XXX hard limits should be checked here */
int type= RNA_property_type(prop);
const int type= RNA_property_type(prop);
if (RNA_property_array_check(prop)) {
@@ -1534,53 +1543,91 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
}
case PROP_STRING:
{
const int subtype= RNA_property_subtype(prop);
const char *param;
#ifdef USE_STRING_COERCE
PyObject *value_coerce= NULL;
int subtype= RNA_property_subtype(prop);
if (ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) {
/* TODO, get size */
param= PyC_UnicodeAsByte(value, &value_coerce);
}
else {
param= _PyUnicode_AsString(value);
#ifdef WITH_INTERNATIONAL
if (subtype == PROP_TRANSLATE) {
param= IFACE_(param);
}
#endif // WITH_INTERNATIONAL
}
#else // USE_STRING_COERCE
param= _PyUnicode_AsString(value);
#endif // USE_STRING_COERCE
if (subtype == PROP_BYTESTRING) {
if (param==NULL) {
if (PyUnicode_Check(value)) {
/* there was an error assigning a string type,
* rather than setting a new error, prefix the existing one
*/
PyC_Err_Format_Prefix(PyExc_TypeError,
"%.200s %.200s.%.200s error assigning string",
error_prefix, RNA_struct_identifier(ptr->type),
RNA_property_identifier(prop));
/* Byte String */
param= PyBytes_AsString(value);
if (param==NULL) {
if (PyBytes_Check(value)) {
/* there was an error assigning a string type,
* rather than setting a new error, prefix the existing one
*/
PyC_Err_Format_Prefix(PyExc_TypeError,
"%.200s %.200s.%.200s error assigning bytes",
error_prefix, RNA_struct_identifier(ptr->type),
RNA_property_identifier(prop));
}
else {
PyErr_Format(PyExc_TypeError,
"%.200s %.200s.%.200s expected a bytes type, not %.200s",
error_prefix, RNA_struct_identifier(ptr->type),
RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
}
return -1;
}
else {
PyErr_Format(PyExc_TypeError,
"%.200s %.200s.%.200s expected a string type, not %.200s",
error_prefix, RNA_struct_identifier(ptr->type),
RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
/* same as unicode */
if (data) *((char**)data)= (char *)param; /*XXX, this is suspect but needed for function calls, need to see if theres a better way */
else RNA_property_string_set(ptr, prop, param);
}
return -1;
}
else {
if (data) *((char**)data)= (char *)param; /*XXX, this is suspect but needed for function calls, need to see if theres a better way */
else RNA_property_string_set(ptr, prop, param);
}
/* Unicode String */
#ifdef USE_STRING_COERCE
Py_XDECREF(value_coerce);
PyObject *value_coerce= NULL;
if (ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) {
/* TODO, get size */
param= PyC_UnicodeAsByte(value, &value_coerce);
}
else {
param= _PyUnicode_AsString(value);
#ifdef WITH_INTERNATIONAL
if (subtype == PROP_TRANSLATE) {
param= IFACE_(param);
}
#endif // WITH_INTERNATIONAL
}
#else // USE_STRING_COERCE
param= _PyUnicode_AsString(value);
#endif // USE_STRING_COERCE
if (param==NULL) {
if (PyUnicode_Check(value)) {
/* there was an error assigning a string type,
* rather than setting a new error, prefix the existing one
*/
PyC_Err_Format_Prefix(PyExc_TypeError,
"%.200s %.200s.%.200s error assigning string",
error_prefix, RNA_struct_identifier(ptr->type),
RNA_property_identifier(prop));
}
else {
PyErr_Format(PyExc_TypeError,
"%.200s %.200s.%.200s expected a string type, not %.200s",
error_prefix, RNA_struct_identifier(ptr->type),
RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
}
return -1;
}
else {
/* same as bytes */
if (data) *((char**)data)= (char *)param; /*XXX, this is suspect but needed for function calls, need to see if theres a better way */
else RNA_property_string_set(ptr, prop, param);
}
#ifdef USE_STRING_COERCE
Py_XDECREF(value_coerce);
#endif // USE_STRING_COERCE
}
break;
}
case PROP_ENUM:
@@ -2050,6 +2097,84 @@ static PyObject *pyrna_prop_collection_subscript_str(BPy_PropertyRNA *self, cons
}
/* static PyObject *pyrna_prop_array_subscript_str(BPy_PropertyRNA *self, char *keyname) */
/* special case: bpy.data.objects["some_id_name", "//some_lib_name.blend"]
* also for: bpy.data.objects.get(("some_id_name", "//some_lib_name.blend"), fallback) */
static PyObject *pyrna_prop_collection_subscript_str_lib_pair(BPy_PropertyRNA *self, PyObject *key, const char *err_prefix, const short err_not_found)
{
char *keyname;
/* first validate the args, all we know is that they are a tuple */
if (PyTuple_GET_SIZE(key) != 2) {
PyErr_Format(PyExc_KeyError,
"%s: tuple key must be a pair, not size %d",
err_prefix, PyTuple_GET_SIZE(key));
return NULL;
}
else if (self->ptr.type != &RNA_BlendData) {
PyErr_Format(PyExc_KeyError,
"%s: is only valid for bpy.data collections, not %.200s",
err_prefix, RNA_struct_identifier(self->ptr.type));
return NULL;
}
else if ((keyname= _PyUnicode_AsString(PyTuple_GET_ITEM(key, 0))) == NULL) {
PyErr_Format(PyExc_KeyError,
"%s: id must be a string, not %.200s",
err_prefix, Py_TYPE(PyTuple_GET_ITEM(key, 0))->tp_name);
return NULL;
}
else {
PyObject *keylib= PyTuple_GET_ITEM(key, 1);
Library *lib;
PyObject *ret= NULL;
if (keylib == Py_None) {
lib= NULL;
}
else if (PyUnicode_Check(keylib)) {
Main *bmain= self->ptr.data;
const char *keylib_str= _PyUnicode_AsString(keylib);
lib= BLI_findstring(&bmain->library, keylib_str, offsetof(Library, name));
if (lib == NULL) {
if (err_not_found) {
PyErr_Format(PyExc_KeyError,
"%s: lib name '%.240s' "
"does not reference a valid library",
err_prefix, keylib_str);
}
return NULL;
}
}
else {
PyErr_Format(PyExc_KeyError,
"%s: lib must be a sting or None, not %.200s",
err_prefix, Py_TYPE(keylib)->tp_name);
return NULL;
}
/* lib is either a valid poniter or NULL,
* either way can do direct comparison with id.lib */
RNA_PROP_BEGIN(&self->ptr, itemptr, self->prop) {
ID *id= itemptr.data; /* always an ID */
if (id->lib == lib && (strncmp(keyname, id->name+2, sizeof(id->name)-2) == 0)) {
ret= pyrna_struct_CreatePyObject(&itemptr);
break;
}
}
RNA_PROP_END;
/* we may want to fail silently as with collection.get() */
if ((ret == NULL) && err_not_found) {
/* only runs for getitem access so use fixed string */
PyErr_SetString(PyExc_KeyError,
"bpy_prop_collection[key, lib]: not found");
}
return ret;
}
}
static PyObject *pyrna_prop_collection_subscript_slice(BPy_PropertyRNA *self, Py_ssize_t start, Py_ssize_t stop)
{
CollectionPropertyIterator rna_macro_iter;
@@ -2220,6 +2345,10 @@ static PyObject *pyrna_prop_collection_subscript(BPy_PropertyRNA *self, PyObject
}
}
}
else if (PyTuple_Check(key)) {
/* special case, for ID datablocks we */
return pyrna_prop_collection_subscript_str_lib_pair(self, key, "bpy_prop_collection[id, lib]", TRUE);
}
else {
PyErr_Format(PyExc_TypeError,
"bpy_prop_collection[key]: invalid key, "
@@ -2736,7 +2865,7 @@ static PyObject *pyrna_struct_subscript(BPy_StructRNA *self, PyObject *key)
return NULL;
}
return BPy_IDGroup_WrapData(self->ptr.id.data, idprop);
return BPy_IDGroup_WrapData(self->ptr.id.data, idprop, group);
}
static int pyrna_struct_ass_subscript(BPy_StructRNA *self, PyObject *key, PyObject *value)
@@ -2751,7 +2880,7 @@ static int pyrna_struct_ass_subscript(BPy_StructRNA *self, PyObject *key, PyObje
if (rna_disallow_writes && rna_id_write_error(&self->ptr, key)) {
return -1;
}
#endif // USE_STRING_COERCE
#endif // USE_PEDANTIC_WRITE
if (group==NULL) {
PyErr_SetString(PyExc_TypeError, "bpy_struct[key]= val: id properties not supported for this type");
@@ -3440,7 +3569,7 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject
if (rna_disallow_writes && rna_id_write_error(&self->ptr, pyname)) {
return -1;
}
#endif // USE_STRING_COERCE
#endif // USE_PEDANTIC_WRITE
if (name == NULL) {
PyErr_SetString(PyExc_AttributeError, "bpy_struct: __setattr__ must be a string");
@@ -3600,7 +3729,7 @@ static int pyrna_prop_collection_setattro(BPy_PropertyRNA *self, PyObject *pynam
if (rna_disallow_writes && rna_id_write_error(&self->ptr, pyname)) {
return -1;
}
#endif // USE_STRING_COERCE
#endif // USE_PEDANTIC_WRITE
if (name == NULL) {
PyErr_SetString(PyExc_AttributeError, "bpy_prop: __setattr__ must be a string");
@@ -3846,7 +3975,7 @@ static PyObject *pyrna_struct_get(BPy_StructRNA *self, PyObject *args)
idprop= IDP_GetPropertyFromGroup(group, key);
if (idprop) {
return BPy_IDGroup_WrapData(self->ptr.id.data, idprop);
return BPy_IDGroup_WrapData(self->ptr.id.data, idprop, group);
}
}
@@ -3869,6 +3998,7 @@ static PyObject *pyrna_struct_as_pointer(BPy_StructRNA *self)
return PyLong_FromVoidPtr(self->ptr.data);
}
/* TODO, get (string, lib) pair */
PyDoc_STRVAR(pyrna_prop_collection_get_doc,
".. method:: get(key, default=None)\n"
"\n"
@@ -3885,16 +4015,31 @@ static PyObject *pyrna_prop_collection_get(BPy_PropertyRNA *self, PyObject *args
{
PointerRNA newptr;
const char *key;
PyObject *key_ob;
PyObject* def= Py_None;
PYRNA_PROP_CHECK_OBJ(self);
if (!PyArg_ParseTuple(args, "s|O:get", &key, &def))
if (!PyArg_ParseTuple(args, "O|O:get", &key_ob, &def))
return NULL;
if (RNA_property_collection_lookup_string(&self->ptr, self->prop, key, &newptr))
return pyrna_struct_CreatePyObject(&newptr);
if (PyUnicode_Check(key_ob)) {
const char *key= _PyUnicode_AsString(key_ob);
if (RNA_property_collection_lookup_string(&self->ptr, self->prop, key, &newptr))
return pyrna_struct_CreatePyObject(&newptr);
}
else if (PyTuple_Check(key_ob)) {
PyObject *ret= pyrna_prop_collection_subscript_str_lib_pair(self, key_ob, "bpy_prop_collection.get((id, lib))", FALSE);
if (ret) {
return ret;
}
}
else {
PyErr_Format(PyExc_KeyError,
"bpy_prop_collection.get(key, ...): key must be a string or tuple, not %.200s",
Py_TYPE(key_ob)->tp_name);
}
return Py_INCREF(def), def;
}
@@ -4365,8 +4510,8 @@ static PyObject *pyrna_prop_new(PyTypeObject *type, PyObject *args, PyObject *UN
static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *data)
{
PyObject *ret;
int type= RNA_property_type(prop);
int flag= RNA_property_flag(prop);
const int type= RNA_property_type(prop);
const int flag= RNA_property_flag(prop);
if (RNA_property_array_check(prop)) {
int a, len;
@@ -4442,7 +4587,7 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat
{
char *data_ch;
PyObject *value_coerce= NULL;
int subtype= RNA_property_subtype(prop);
const int subtype= RNA_property_subtype(prop);
if (flag & PROP_THICK_WRAP)
data_ch= (char *)data;
@@ -4450,14 +4595,22 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat
data_ch= *(char **)data;
#ifdef USE_STRING_COERCE
if (ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) {
if (subtype == PROP_BYTESTRING) {
ret= PyBytes_FromString(data_ch);
}
else if (ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) {
ret= PyC_UnicodeFromByte(data_ch);
}
else {
ret= PyUnicode_FromString(data_ch);
}
#else
ret= PyUnicode_FromString(data_ch);
if (subtype == PROP_BYTESTRING) {
ret= PyBytes_FromString(buf);
}
else {
ret= PyUnicode_FromString(data_ch);
}
#endif
#ifdef USE_STRING_COERCE

View File

@@ -370,9 +370,10 @@ static PyObject *Color_add(PyObject *v1, PyObject *v2)
float col[COLOR_SIZE];
if (!ColorObject_Check(v1) || !ColorObject_Check(v2)) {
PyErr_SetString(PyExc_TypeError,
"Color addition: "
"arguments not valid for this operation");
PyErr_Format(PyExc_TypeError,
"Color addition: (%s + %s) "
"invalid type for this operation",
Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name);
return NULL;
}
color1 = (ColorObject*)v1;
@@ -392,9 +393,10 @@ static PyObject *Color_iadd(PyObject *v1, PyObject *v2)
ColorObject *color1 = NULL, *color2 = NULL;
if (!ColorObject_Check(v1) || !ColorObject_Check(v2)) {
PyErr_SetString(PyExc_TypeError,
"Color addition: "
"arguments not valid for this operation");
PyErr_Format(PyExc_TypeError,
"Color addition: (%s += %s) "
"invalid type for this operation",
Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name);
return NULL;
}
color1 = (ColorObject*)v1;
@@ -417,9 +419,10 @@ static PyObject *Color_sub(PyObject *v1, PyObject *v2)
float col[COLOR_SIZE];
if (!ColorObject_Check(v1) || !ColorObject_Check(v2)) {
PyErr_SetString(PyExc_TypeError,
"Color subtraction: "
"arguments not valid for this operation");
PyErr_Format(PyExc_TypeError,
"Color subtraction: (%s - %s) "
"invalid type for this operation",
Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name);
return NULL;
}
color1 = (ColorObject*)v1;
@@ -439,9 +442,10 @@ static PyObject *Color_isub(PyObject *v1, PyObject *v2)
ColorObject *color1= NULL, *color2= NULL;
if (!ColorObject_Check(v1) || !ColorObject_Check(v2)) {
PyErr_SetString(PyExc_TypeError,
"Color subtraction: "
"arguments not valid for this operation");
PyErr_Format(PyExc_TypeError,
"Color subtraction: (%s -= %s) "
"invalid type for this operation",
Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name);
return NULL;
}
color1 = (ColorObject*)v1;
@@ -554,9 +558,10 @@ static PyObject *Color_imul(PyObject *v1, PyObject *v2)
mul_vn_fl(color->col, COLOR_SIZE, scalar);
}
else {
PyErr_SetString(PyExc_TypeError,
"Color multiplication: "
"arguments not acceptable for this operation");
PyErr_Format(PyExc_TypeError,
"Color multiplication: (%s *= %s) "
"invalid type for this operation",
Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name);
return NULL;
}
@@ -585,9 +590,10 @@ static PyObject *Color_idiv(PyObject *v1, PyObject *v2)
mul_vn_fl(color->col, COLOR_SIZE, 1.0f / scalar);
}
else {
PyErr_SetString(PyExc_TypeError,
"Color multiplication: "
"arguments not acceptable for this operation");
PyErr_Format(PyExc_TypeError,
"Color division: (%s /= %s) "
"invalid type for this operation",
Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name);
return NULL;
}
@@ -828,18 +834,18 @@ PyObject *newColorObject(float *col, int type, PyTypeObject *base_type)
self= base_type ? (ColorObject *)base_type->tp_alloc(base_type, 0) :
(ColorObject *)PyObject_GC_New(ColorObject, &color_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->col = col;
self->wrapped = Py_WRAP;
}
else if (type == Py_NEW) {
self->col = PyMem_Malloc(COLOR_SIZE * sizeof(float));
if(col)
if (col)
copy_v3_v3(self->col, col);
else
zero_v3(self->col);
@@ -857,7 +863,7 @@ PyObject *newColorObject(float *col, int type, PyTypeObject *base_type)
PyObject *newColorObject_cb(PyObject *cb_user, int cb_type, int cb_subtype)
{
ColorObject *self= (ColorObject *)newColorObject(NULL, Py_NEW, NULL);
if(self) {
if (self) {
Py_INCREF(cb_user);
self->cb_user= cb_user;
self->cb_type= (unsigned char)cb_type;

View File

@@ -941,8 +941,10 @@ static PyObject *Matrix_invert(MatrixObject *self)
int x, y, z = 0;
float det = 0.0f;
float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f};
if (BaseMath_ReadCallback(self) == -1)
return NULL;
@@ -964,9 +966,11 @@ static PyObject *Matrix_invert(MatrixObject *self)
mat[1] = -self->matrix[0][1];
mat[2] = -self->matrix[1][0];
mat[3] = self->matrix[0][0];
} else if (self->row_size == 3) {
}
else if (self->row_size == 3) {
adjoint_m3_m3((float (*)[3]) mat,(float (*)[3])self->contigPtr);
} else if (self->row_size == 4) {
}
else if (self->row_size == 4) {
adjoint_m4_m4((float (*)[4]) mat, (float (*)[4])self->contigPtr);
}
/*divide by determinate*/
@@ -1183,7 +1187,8 @@ static PyObject *Matrix_transpose(MatrixObject *self)
t = self->matrix[1][0];
self->matrix[1][0] = self->matrix[0][1];
self->matrix[0][1] = t;
} else if (self->row_size == 3) {
}
else if (self->row_size == 3) {
transpose_m3((float (*)[3])self->contigPtr);
}
else {
@@ -1253,7 +1258,8 @@ static PyObject *Matrix_identity(MatrixObject *self)
self->matrix[0][1] = 0.0f;
self->matrix[1][0] = 0.0f;
self->matrix[1][1] = 1.0f;
} else if (self->row_size == 3) {
}
else if (self->row_size == 3) {
unit_m3((float (*)[3])self->contigPtr);
}
else {
@@ -1489,9 +1495,10 @@ static PyObject *Matrix_add(PyObject *m1, PyObject *m2)
mat2 = (MatrixObject*)m2;
if (!MatrixObject_Check(m1) || !MatrixObject_Check(m2)) {
PyErr_SetString(PyExc_TypeError,
"Matrix addition: "
"arguments not valid for this operation");
PyErr_Format(PyExc_TypeError,
"Matrix addition: (%s + %s) "
"invalid type for this operation",
Py_TYPE(m1)->tp_name, Py_TYPE(m2)->tp_name);
return NULL;
}
@@ -1520,9 +1527,11 @@ static PyObject *Matrix_sub(PyObject *m1, PyObject *m2)
mat2 = (MatrixObject*)m2;
if (!MatrixObject_Check(m1) || !MatrixObject_Check(m2)) {
PyErr_SetString(PyExc_TypeError,
"Matrix addition: "
"arguments not valid for this operation");
PyErr_Format(PyExc_TypeError,
"Matrix subtraction: (%s - %s) "
"invalid type for this operation",
Py_TYPE(m1)->tp_name, Py_TYPE(m2)->tp_name
);
return NULL;
}
@@ -1654,7 +1663,8 @@ static PyObject *Matrix_subscript(MatrixObject* self, PyObject* item)
if (i < 0)
i += self->row_size;
return Matrix_item(self, i);
} else if (PySlice_Check(item)) {
}
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
if (PySlice_GetIndicesEx((void *)item, self->row_size, &start, &stop, &step, &slicelength) < 0)

View File

@@ -639,7 +639,8 @@ static PyObject *Quaternion_subscript(QuaternionObject *self, PyObject *item)
if (i < 0)
i += QUAT_SIZE;
return Quaternion_item(self, i);
} else if (PySlice_Check(item)) {
}
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
if (PySlice_GetIndicesEx((void *)item, QUAT_SIZE, &start, &stop, &step, &slicelength) < 0)
@@ -707,9 +708,10 @@ static PyObject *Quaternion_add(PyObject *q1, PyObject *q2)
QuaternionObject *quat1 = NULL, *quat2 = NULL;
if (!QuaternionObject_Check(q1) || !QuaternionObject_Check(q2)) {
PyErr_SetString(PyExc_TypeError,
"Quaternion addition: "
"arguments not valid for this operation");
PyErr_Format(PyExc_TypeError,
"Quaternion addition: (%s + %s) "
"invalid type for this operation",
Py_TYPE(q1)->tp_name, Py_TYPE(q2)->tp_name);
return NULL;
}
quat1 = (QuaternionObject*)q1;
@@ -730,9 +732,10 @@ static PyObject *Quaternion_sub(PyObject *q1, PyObject *q2)
QuaternionObject *quat1 = NULL, *quat2 = NULL;
if (!QuaternionObject_Check(q1) || !QuaternionObject_Check(q2)) {
PyErr_SetString(PyExc_TypeError,
"Quaternion addition: "
"arguments not valid for this operation");
PyErr_Format(PyExc_TypeError,
"Quaternion subtraction: (%s - %s) "
"invalid type for this operation",
Py_TYPE(q1)->tp_name, Py_TYPE(q2)->tp_name);
return NULL;
}

View File

@@ -61,7 +61,7 @@ static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *UNUSED
case 0:
break;
case 1:
if((size=mathutils_array_parse(vec, 2, 4, PyTuple_GET_ITEM(args, 0), "mathutils.Vector()")) == -1)
if ((size=mathutils_array_parse(vec, 2, 4, PyTuple_GET_ITEM(args, 0), "mathutils.Vector()")) == -1)
return NULL;
break;
default:
@@ -77,7 +77,7 @@ static PyObject *vec__apply_to_copy(PyNoArgsFunction vec_func, VectorObject *sel
{
PyObject *ret= Vector_copy(self);
PyObject *ret_dummy= vec_func(ret);
if(ret_dummy) {
if (ret_dummy) {
Py_DECREF(ret_dummy);
return (PyObject *)ret;
}
@@ -97,7 +97,7 @@ static PyObject *Vector_zero(VectorObject *self)
{
fill_vn(self->vec, self->size, 0.0f);
if(BaseMath_WriteCallback(self) == -1)
if (BaseMath_WriteCallback(self) == -1)
return NULL;
Py_RETURN_NONE;
@@ -119,7 +119,7 @@ static PyObject *Vector_normalize(VectorObject *self)
int i;
float norm = 0.0f;
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
for (i = 0; i < self->size; i++) {
@@ -156,13 +156,13 @@ PyDoc_STRVAR(Vector_resize_2d_doc,
);
static PyObject *Vector_resize_2d(VectorObject *self)
{
if(self->wrapped==Py_WRAP) {
if (self->wrapped==Py_WRAP) {
PyErr_SetString(PyExc_TypeError,
"Vector.resize_2d(): "
"cannot resize wrapped data - only python vectors");
return NULL;
}
if(self->cb_user) {
if (self->cb_user) {
PyErr_SetString(PyExc_TypeError,
"Vector.resize_2d(): "
"cannot resize a vector that has an owner");
@@ -170,7 +170,7 @@ static PyObject *Vector_resize_2d(VectorObject *self)
}
self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 2));
if(self->vec == NULL) {
if (self->vec == NULL) {
PyErr_SetString(PyExc_MemoryError,
"Vector.resize_2d(): "
"problem allocating pointer space");
@@ -197,7 +197,7 @@ static PyObject *Vector_resize_3d(VectorObject *self)
"cannot resize wrapped data - only python vectors");
return NULL;
}
if(self->cb_user) {
if (self->cb_user) {
PyErr_SetString(PyExc_TypeError,
"Vector.resize_3d(): "
"cannot resize a vector that has an owner");
@@ -205,14 +205,14 @@ static PyObject *Vector_resize_3d(VectorObject *self)
}
self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 3));
if(self->vec == NULL) {
if (self->vec == NULL) {
PyErr_SetString(PyExc_MemoryError,
"Vector.resize_3d(): "
"problem allocating pointer space");
return NULL;
}
if(self->size == 2)
if (self->size == 2)
self->vec[2] = 0.0f;
self->size = 3;
@@ -229,13 +229,13 @@ PyDoc_STRVAR(Vector_resize_4d_doc,
);
static PyObject *Vector_resize_4d(VectorObject *self)
{
if(self->wrapped==Py_WRAP) {
if (self->wrapped==Py_WRAP) {
PyErr_SetString(PyExc_TypeError,
"Vector.resize_4d(): "
"cannot resize wrapped data - only python vectors");
return NULL;
}
if(self->cb_user) {
if (self->cb_user) {
PyErr_SetString(PyExc_TypeError,
"Vector.resize_4d(): "
"cannot resize a vector that has an owner");
@@ -243,18 +243,18 @@ static PyObject *Vector_resize_4d(VectorObject *self)
}
self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 4));
if(self->vec == NULL) {
if (self->vec == NULL) {
PyErr_SetString(PyExc_MemoryError,
"Vector.resize_4d(): "
"problem allocating pointer space");
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;
@@ -270,7 +270,7 @@ PyDoc_STRVAR(Vector_to_2d_doc,
);
static PyObject *Vector_to_2d(VectorObject *self)
{
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
return newVectorObject(self->vec, 2, Py_NEW, Py_TYPE(self));
@@ -287,7 +287,7 @@ static PyObject *Vector_to_3d(VectorObject *self)
{
float tvec[3]= {0.0f};
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
memcpy(tvec, self->vec, sizeof(float) * MIN2(self->size, 3));
@@ -305,7 +305,7 @@ static PyObject *Vector_to_4d(VectorObject *self)
{
float tvec[4]= {0.0f, 0.0f, 0.0f, 1.0f};
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
memcpy(tvec, self->vec, sizeof(float) * MIN2(self->size, 4));
@@ -330,7 +330,7 @@ static PyObject *Vector_to_tuple_ext(VectorObject *self, int ndigits)
ret= PyTuple_New(self->size);
if(ndigits >= 0) {
if (ndigits >= 0) {
for (i = 0; i < self->size; i++) {
PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(double_round((double)self->vec[i], ndigits)));
}
@@ -348,20 +348,20 @@ static PyObject *Vector_to_tuple(VectorObject *self, PyObject *args)
{
int ndigits= 0;
if(!PyArg_ParseTuple(args, "|i:to_tuple", &ndigits))
if (!PyArg_ParseTuple(args, "|i:to_tuple", &ndigits))
return NULL;
if(ndigits > 22 || ndigits < 0) {
if (ndigits > 22 || ndigits < 0) {
PyErr_SetString(PyExc_ValueError,
"Vector.to_tuple(ndigits): "
"ndigits must be between 0 and 21");
return NULL;
}
if(PyTuple_GET_SIZE(args)==0)
if (PyTuple_GET_SIZE(args)==0)
ndigits= -1;
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
return Vector_to_tuple_ext(self, ndigits);
@@ -385,7 +385,7 @@ static PyObject *Vector_to_track_quat(VectorObject *self, PyObject *args)
const char *strack, *sup;
short track = 2, up = 1;
if(!PyArg_ParseTuple(args, "|ss:to_track_quat", &strack, &sup))
if (!PyArg_ParseTuple(args, "|ss:to_track_quat", &strack, &sup))
return NULL;
if (self->size != 3) {
@@ -395,7 +395,7 @@ static PyObject *Vector_to_track_quat(VectorObject *self, PyObject *args)
return NULL;
}
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
if (strack) {
@@ -508,10 +508,10 @@ static PyObject *Vector_reflect(VectorObject *self, PyObject *value)
float reflect[3] = {0.0f};
float tvec[MAX_DIMENSIONS];
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
if((value_size= mathutils_array_parse(tvec, 2, 4, value, "Vector.reflect(other), invalid 'other' arg")) == -1)
if ((value_size= mathutils_array_parse(tvec, 2, 4, value, "Vector.reflect(other), invalid 'other' arg")) == -1)
return NULL;
mirror[0] = tvec[0];
@@ -547,10 +547,10 @@ static PyObject *Vector_cross(VectorObject *self, PyObject *value)
VectorObject *ret;
float tvec[MAX_DIMENSIONS];
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
if(mathutils_array_parse(tvec, self->size, self->size, value, "Vector.cross(other), invalid 'other' arg") == -1)
if (mathutils_array_parse(tvec, self->size, self->size, value, "Vector.cross(other), invalid 'other' arg") == -1)
return NULL;
ret= (VectorObject *)newVectorObject(NULL, 3, Py_NEW, Py_TYPE(self));
@@ -574,10 +574,10 @@ static PyObject *Vector_dot(VectorObject *self, PyObject *value)
double dot = 0.0;
int x;
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
if(mathutils_array_parse(tvec, self->size, self->size, value, "Vector.dot(other), invalid 'other' arg") == -1)
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++) {
@@ -611,13 +611,13 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args)
int x;
PyObject *fallback= NULL;
if(!PyArg_ParseTuple(args, "O|O:angle", &value, &fallback))
if (!PyArg_ParseTuple(args, "O|O:angle", &value, &fallback))
return NULL;
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
if(mathutils_array_parse(tvec, size, size, value, "Vector.angle(other), invalid 'other' arg") == -1)
if (mathutils_array_parse(tvec, size, size, value, "Vector.angle(other), invalid 'other' arg") == -1)
return NULL;
for (x = 0; x < size; x++) {
@@ -626,7 +626,7 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args)
}
if (!test_v1 || !test_v2) {
/* avoid exception */
if(fallback) {
if (fallback) {
Py_INCREF(fallback);
return fallback;
}
@@ -648,7 +648,7 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args)
}
PyDoc_STRVAR(Vector_rotation_difference_doc,
".. function:: difference(other)\n"
".. function:: rotation_difference(other)\n"
"\n"
" Returns a quaternion representing the rotational difference between this\n"
" vector and another.\n"
@@ -664,17 +664,17 @@ static PyObject *Vector_rotation_difference(VectorObject *self, PyObject *value)
{
float quat[4], vec_a[3], vec_b[3];
if(self->size < 3) {
if (self->size < 3) {
PyErr_SetString(PyExc_ValueError,
"vec.difference(value): "
"expects both vectors to be size 3 or 4");
return NULL;
}
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
if(mathutils_array_parse(vec_b, 3, MAX_DIMENSIONS, value, "Vector.difference(other), invalid 'other' arg") == -1)
if (mathutils_array_parse(vec_b, 3, MAX_DIMENSIONS, value, "Vector.difference(other), invalid 'other' arg") == -1)
return NULL;
normalize_v3_v3(vec_a, self->vec);
@@ -703,13 +703,13 @@ static PyObject *Vector_project(VectorObject *self, PyObject *value)
double dot = 0.0f, dot2 = 0.0f;
int x;
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
if(mathutils_array_parse(tvec, size, size, value, "Vector.project(other), invalid 'other' arg") == -1)
if (mathutils_array_parse(tvec, size, size, value, "Vector.project(other), invalid 'other' arg") == -1)
return NULL;
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
//get dot products
@@ -745,13 +745,13 @@ static PyObject *Vector_lerp(VectorObject *self, PyObject *args)
float tvec[MAX_DIMENSIONS], vec[MAX_DIMENSIONS];
int x;
if(!PyArg_ParseTuple(args, "Of:lerp", &value, &fac))
if (!PyArg_ParseTuple(args, "Of:lerp", &value, &fac))
return NULL;
if(mathutils_array_parse(tvec, size, size, value, "Vector.lerp(other), invalid 'other' arg") == -1)
if (mathutils_array_parse(tvec, size, size, value, "Vector.lerp(other), invalid 'other' arg") == -1)
return NULL;
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
ifac= 1.0f - fac;
@@ -774,13 +774,13 @@ static PyObject *Vector_rotate(VectorObject *self, PyObject *value)
{
float other_rmat[3][3];
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
if(mathutils_any_to_rotmat(other_rmat, value, "Vector.rotate(value)") == -1)
if (mathutils_any_to_rotmat(other_rmat, value, "Vector.rotate(value)") == -1)
return NULL;
if(self->size < 3) {
if (self->size < 3) {
PyErr_SetString(PyExc_ValueError,
"Vector must be 3D or 4D");
return NULL;
@@ -805,7 +805,7 @@ PyDoc_STRVAR(Vector_copy_doc,
);
static PyObject *Vector_copy(VectorObject *self)
{
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
return newVectorObject(self->vec, self->size, Py_NEW, Py_TYPE(self));
@@ -815,7 +815,7 @@ static PyObject *Vector_repr(VectorObject *self)
{
PyObject *ret, *tuple;
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
tuple= Vector_to_tuple_ext(self, -1);
@@ -833,10 +833,10 @@ static int Vector_len(VectorObject *self)
/* sequence accessor (get): vector[index] */
static PyObject *vector_item_internal(VectorObject *self, int i, const int is_attr)
{
if(i<0) i= self->size-i;
if (i<0) i= self->size-i;
if(i < 0 || i >= self->size) {
if(is_attr) {
if (i < 0 || i >= self->size) {
if (is_attr) {
PyErr_Format(PyExc_AttributeError,
"Vector.%c: unavailable on %dd vector",
*(((char *)"xyzw") + i), self->size);
@@ -848,7 +848,7 @@ static PyObject *vector_item_internal(VectorObject *self, int i, const int is_at
return NULL;
}
if(BaseMath_ReadIndexCallback(self, i) == -1)
if (BaseMath_ReadIndexCallback(self, i) == -1)
return NULL;
return PyFloat_FromDouble(self->vec[i]);
@@ -862,17 +862,17 @@ static PyObject *Vector_item(VectorObject *self, int i)
static int vector_ass_item_internal(VectorObject *self, int i, PyObject *value, const int is_attr)
{
float scalar;
if((scalar=PyFloat_AsDouble(value))==-1.0f && PyErr_Occurred()) { /* parsed item not a number */
if ((scalar=PyFloat_AsDouble(value))==-1.0f && PyErr_Occurred()) { /* parsed item not a number */
PyErr_SetString(PyExc_TypeError,
"vector[index] = x: "
"index argument not a number");
return -1;
}
if(i<0) i= self->size-i;
if (i<0) i= self->size-i;
if(i < 0 || i >= self->size) {
if(is_attr) {
if (i < 0 || i >= self->size) {
if (is_attr) {
PyErr_Format(PyExc_AttributeError,
"Vector.%c = x: unavailable on %dd vector",
*(((char *)"xyzw") + i), self->size);
@@ -886,7 +886,7 @@ static int vector_ass_item_internal(VectorObject *self, int i, PyObject *value,
}
self->vec[i] = scalar;
if(BaseMath_WriteIndexCallback(self, i) == -1)
if (BaseMath_WriteIndexCallback(self, i) == -1)
return -1;
return 0;
}
@@ -902,7 +902,7 @@ static PyObject *Vector_slice(VectorObject *self, int begin, int end)
PyObject *tuple;
int count;
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
CLAMP(begin, 0, self->size);
@@ -923,7 +923,7 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *se
int y, size = 0;
float vec[MAX_DIMENSIONS];
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return -1;
CLAMP(begin, 0, self->size);
@@ -931,7 +931,7 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *se
begin = MIN2(begin, end);
size = (end - begin);
if(mathutils_array_parse(vec, size, size, seq, "vector[begin:end] = [...]") == -1)
if (mathutils_array_parse(vec, size, size, seq, "vector[begin:end] = [...]") == -1)
return -1;
/*parsed well - now set in vector*/
@@ -939,7 +939,7 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *se
self->vec[begin + y] = vec[y];
}
if(BaseMath_WriteCallback(self) == -1)
if (BaseMath_WriteCallback(self) == -1)
return -1;
return 0;
@@ -953,19 +953,20 @@ static PyObject *Vector_add(PyObject *v1, PyObject *v2)
float vec[MAX_DIMENSIONS];
if (!VectorObject_Check(v1) || !VectorObject_Check(v2)) {
PyErr_SetString(PyExc_AttributeError,
"Vector addition: "
"arguments not valid for this operation");
PyErr_Format(PyExc_AttributeError,
"Vector addition: (%s + %s) "
"invalid type for this operation",
Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name);
return NULL;
}
vec1 = (VectorObject*)v1;
vec2 = (VectorObject*)v2;
if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1)
if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1)
return NULL;
/*VECTOR + VECTOR*/
if(vec1->size != vec2->size) {
if (vec1->size != vec2->size) {
PyErr_SetString(PyExc_AttributeError,
"Vector addition: "
"vectors must have the same dimensions for this operation");
@@ -983,22 +984,23 @@ static PyObject *Vector_iadd(PyObject *v1, PyObject *v2)
VectorObject *vec1 = NULL, *vec2 = NULL;
if (!VectorObject_Check(v1) || !VectorObject_Check(v2)) {
PyErr_SetString(PyExc_AttributeError,
"Vector addition: "
"arguments not valid for this operation");
PyErr_Format(PyExc_AttributeError,
"Vector addition: (%s += %s) "
"invalid type for this operation",
Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name);
return NULL;
}
vec1 = (VectorObject*)v1;
vec2 = (VectorObject*)v2;
if(vec1->size != vec2->size) {
if (vec1->size != vec2->size) {
PyErr_SetString(PyExc_AttributeError,
"Vector addition: "
"vectors must have the same dimensions for this operation");
return NULL;
}
if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1)
if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1)
return NULL;
add_vn_vn(vec1->vec, vec2->vec, vec1->size);
@@ -1015,18 +1017,19 @@ static PyObject *Vector_sub(PyObject *v1, PyObject *v2)
float vec[MAX_DIMENSIONS];
if (!VectorObject_Check(v1) || !VectorObject_Check(v2)) {
PyErr_SetString(PyExc_AttributeError,
"Vector subtraction: "
"arguments not valid for this operation");
PyErr_Format(PyExc_AttributeError,
"Vector subtraction: (%s - %s) "
"invalid type for this operation",
Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name);
return NULL;
}
vec1 = (VectorObject*)v1;
vec2 = (VectorObject*)v2;
if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1)
if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1)
return NULL;
if(vec1->size != vec2->size) {
if (vec1->size != vec2->size) {
PyErr_SetString(PyExc_AttributeError,
"Vector subtraction: "
"vectors must have the same dimensions for this operation");
@@ -1044,22 +1047,23 @@ static PyObject *Vector_isub(PyObject *v1, PyObject *v2)
VectorObject *vec1= NULL, *vec2= NULL;
if (!VectorObject_Check(v1) || !VectorObject_Check(v2)) {
PyErr_SetString(PyExc_AttributeError,
"Vector subtraction: "
"arguments not valid for this operation");
PyErr_Format(PyExc_AttributeError,
"Vector subtraction: (%s -= %s) "
"invalid type for this operation",
Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name);
return NULL;
}
vec1 = (VectorObject*)v1;
vec2 = (VectorObject*)v2;
if(vec1->size != vec2->size) {
if (vec1->size != vec2->size) {
PyErr_SetString(PyExc_AttributeError,
"Vector subtraction: "
"vectors must have the same dimensions for this operation");
return NULL;
}
if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1)
if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1)
return NULL;
sub_vn_vn(vec1->vec, vec2->vec, vec1->size);
@@ -1087,8 +1091,8 @@ 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 == 4 && vec->size == 3) {
if (mat->row_size != vec->size) {
if (mat->row_size == 4 && vec->size == 3) {
vec_cpy[3] = 1.0f;
}
else {
@@ -1129,12 +1133,12 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2)
if VectorObject_Check(v1) {
vec1= (VectorObject *)v1;
if(BaseMath_ReadCallback(vec1) == -1)
if (BaseMath_ReadCallback(vec1) == -1)
return NULL;
}
if VectorObject_Check(v2) {
vec2= (VectorObject *)v2;
if(BaseMath_ReadCallback(vec2) == -1)
if (BaseMath_ReadCallback(vec2) == -1)
return NULL;
}
@@ -1144,7 +1148,7 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2)
int i;
double dot = 0.0f;
if(vec1->size != vec2->size) {
if (vec1->size != vec2->size) {
PyErr_SetString(PyExc_ValueError,
"Vector multiplication: "
"vectors must have the same dimensions for this operation");
@@ -1162,9 +1166,9 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2)
/* VEC * MATRIX */
float tvec[MAX_DIMENSIONS];
if(BaseMath_ReadCallback((MatrixObject *)v2) == -1)
if (BaseMath_ReadCallback((MatrixObject *)v2) == -1)
return NULL;
if(row_vector_multiplication(tvec, vec1, (MatrixObject*)v2) == -1) {
if (row_vector_multiplication(tvec, vec1, (MatrixObject*)v2) == -1) {
return NULL;
}
@@ -1182,13 +1186,13 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2)
QuaternionObject *quat2 = (QuaternionObject*)v2;
float tvec[3];
if(vec1->size != 3) {
if (vec1->size != 3) {
PyErr_SetString(PyExc_ValueError,
"Vector multiplication: "
"only 3D vector rotations (with quats) currently supported");
return NULL;
}
if(BaseMath_ReadCallback(quat2) == -1) {
if (BaseMath_ReadCallback(quat2) == -1) {
return NULL;
}
@@ -1224,7 +1228,7 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2)
VectorObject *vec = (VectorObject *)v1;
float scalar;
if(BaseMath_ReadCallback(vec) == -1)
if (BaseMath_ReadCallback(vec) == -1)
return NULL;
/* only support vec*=float and vec*=mat
@@ -1239,10 +1243,10 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2)
return NULL;
#else
float rvec[MAX_DIMENSIONS];
if(BaseMath_ReadCallback((MatrixObject *)v2) == -1)
if (BaseMath_ReadCallback((MatrixObject *)v2) == -1)
return NULL;
if(column_vector_multiplication(rvec, vec, (MatrixObject*)v2) == -1)
if (column_vector_multiplication(rvec, vec, (MatrixObject*)v2) == -1)
return NULL;
memcpy(vec->vec, rvec, sizeof(float) * vec->size);
@@ -1262,14 +1266,14 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2)
#else
QuaternionObject *quat2 = (QuaternionObject*)v2;
if(vec->size != 3) {
if (vec->size != 3) {
PyErr_SetString(PyExc_ValueError,
"Vector multiplication: "
"only 3D vector rotations (with quats) currently supported");
return NULL;
}
if(BaseMath_ReadCallback(quat2) == -1) {
if (BaseMath_ReadCallback(quat2) == -1) {
return NULL;
}
@@ -1281,9 +1285,10 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2)
mul_vn_fl(vec->vec, vec->size, scalar);
}
else {
PyErr_SetString(PyExc_TypeError,
"Vector multiplication: "
"arguments not acceptable for this operation");
PyErr_Format(PyExc_TypeError,
"Vector multiplication: (%s *= %s) "
"invalid type for this operation",
Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name);
return NULL;
}
@@ -1299,7 +1304,7 @@ static PyObject *Vector_div(PyObject *v1, PyObject *v2)
float vec[4], scalar;
VectorObject *vec1 = NULL;
if(!VectorObject_Check(v1)) { /* not a vector */
if (!VectorObject_Check(v1)) { /* not a vector */
PyErr_SetString(PyExc_TypeError,
"Vector division: "
"Vector must be divided by a float");
@@ -1307,17 +1312,17 @@ static PyObject *Vector_div(PyObject *v1, PyObject *v2)
}
vec1 = (VectorObject*)v1; /* vector */
if(BaseMath_ReadCallback(vec1) == -1)
if (BaseMath_ReadCallback(vec1) == -1)
return NULL;
if((scalar=PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */
if ((scalar=PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */
PyErr_SetString(PyExc_TypeError,
"Vector division: "
"Vector must be divided by a float");
return NULL;
}
if(scalar==0.0f) {
if (scalar==0.0f) {
PyErr_SetString(PyExc_ZeroDivisionError,
"Vector division: "
"divide by zero error");
@@ -1337,17 +1342,17 @@ static PyObject *Vector_idiv(PyObject *v1, PyObject *v2)
float scalar;
VectorObject *vec1 = (VectorObject*)v1;
if(BaseMath_ReadCallback(vec1) == -1)
if (BaseMath_ReadCallback(vec1) == -1)
return NULL;
if((scalar=PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */
if ((scalar=PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */
PyErr_SetString(PyExc_TypeError,
"Vector division: "
"Vector must be divided by a float");
return NULL;
}
if(scalar==0.0f) {
if (scalar==0.0f) {
PyErr_SetString(PyExc_ZeroDivisionError,
"Vector division: "
"divide by zero error");
@@ -1369,7 +1374,7 @@ static PyObject *Vector_neg(VectorObject *self)
{
float tvec[MAX_DIMENSIONS];
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
negate_vn_vn(tvec, self->vec, self->size);
@@ -1413,7 +1418,7 @@ static PyObject* Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa
vecA = (VectorObject*)objectA;
vecB = (VectorObject*)objectB;
if(BaseMath_ReadCallback(vecA) == -1 || BaseMath_ReadCallback(vecB) == -1)
if (BaseMath_ReadCallback(vecA) == -1 || BaseMath_ReadCallback(vecB) == -1)
return NULL;
if (vecA->size != vecB->size) {
@@ -1429,14 +1434,14 @@ static PyObject* Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa
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 {
@@ -1452,14 +1457,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 {
@@ -1627,7 +1632,7 @@ static PyObject *Vector_getLength(VectorObject *self, void *UNUSED(closure))
double dot = 0.0f;
int i;
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
for (i = 0; i < self->size; i++) {
@@ -1641,10 +1646,10 @@ static int Vector_setLength(VectorObject *self, PyObject *value)
double dot = 0.0f, param;
int i;
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return -1;
if((param=PyFloat_AsDouble(value)) == -1.0 && PyErr_Occurred()) {
if ((param=PyFloat_AsDouble(value)) == -1.0 && PyErr_Occurred()) {
PyErr_SetString(PyExc_TypeError,
"length must be set to a number");
return -1;
@@ -1689,7 +1694,7 @@ static PyObject *Vector_getLengthSquared(VectorObject *self, void *UNUSED(closur
double dot = 0.0f;
int i;
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
for (i = 0; i < self->size; i++) {
@@ -1708,7 +1713,7 @@ static PyObject *Vector_getSwizzle(VectorObject *self, void *closure)
float vec[MAX_DIMENSIONS];
unsigned int swizzleClosure;
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
/* Unpack the axes from the closure into an array. */
@@ -1717,7 +1722,7 @@ static PyObject *Vector_getSwizzle(VectorObject *self, void *closure)
while (swizzleClosure & SWIZZLE_VALID_AXIS)
{
axis_from = swizzleClosure & SWIZZLE_AXIS;
if(axis_from >= self->size) {
if (axis_from >= self->size) {
PyErr_SetString(PyExc_AttributeError,
"Vector swizzle: "
"specified axis not present");
@@ -1755,7 +1760,7 @@ static int Vector_setSwizzle(VectorObject *self, PyObject *value, void *closure)
float tvec[MAX_DIMENSIONS];
float vec_assign[MAX_DIMENSIONS];
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return -1;
/* Check that the closure can be used with this vector: even 2D vectors have
@@ -1782,11 +1787,11 @@ static int Vector_setSwizzle(VectorObject *self, PyObject *value, void *closure)
size_from= axis_from;
}
else if(PyErr_Clear(), (size_from=mathutils_array_parse(vec_assign, 2, 4, value, "mathutils.Vector.**** = swizzle assignment")) == -1) {
else if (PyErr_Clear(), (size_from=mathutils_array_parse(vec_assign, 2, 4, value, "mathutils.Vector.**** = swizzle assignment")) == -1) {
return -1;
}
if(axis_from != size_from) {
if (axis_from != size_from) {
PyErr_SetString(PyExc_AttributeError,
"Vector swizzle: size does not match swizzle");
return -1;
@@ -1806,7 +1811,7 @@ static int Vector_setSwizzle(VectorObject *self, PyObject *value, void *closure)
memcpy(self->vec, tvec, axis_from * sizeof(float));
/* continue with BaseMathObject_WriteCallback at the end */
if(BaseMath_WriteCallback(self) == -1)
if (BaseMath_WriteCallback(self) == -1)
return -1;
else
return 0;
@@ -2218,8 +2223,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");
@@ -2230,7 +2235,7 @@ static int row_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject *v
}
}
if(BaseMath_ReadCallback(vec) == -1 || BaseMath_ReadCallback(mat) == -1)
if (BaseMath_ReadCallback(vec) == -1 || BaseMath_ReadCallback(mat) == -1)
return -1;
memcpy(vec_cpy, vec->vec, vec_size * sizeof(float));
@@ -2258,7 +2263,7 @@ PyDoc_STRVAR(Vector_negate_doc,
);
static PyObject *Vector_negate(VectorObject *self)
{
if(BaseMath_ReadCallback(self) == -1)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
negate_vn(self->vec, self->size);
@@ -2401,7 +2406,7 @@ PyObject *newVectorObject(float *vec, const int size, const int type, PyTypeObje
{
VectorObject *self;
if(size > 4 || size < 2) {
if (size > 4 || size < 2) {
PyErr_SetString(PyExc_RuntimeError,
"Vector(): invalid size");
return NULL;
@@ -2410,25 +2415,25 @@ PyObject *newVectorObject(float *vec, const int size, const int type, PyTypeObje
self= base_type ? (VectorObject *)base_type->tp_alloc(base_type, 0) :
(VectorObject *)PyObject_GC_New(VectorObject, &vector_Type);
if(self) {
if (self) {
self->size = size;
/* init callbacks as NULL */
self->cb_user= NULL;
self->cb_type= self->cb_subtype= 0;
if(type == Py_WRAP) {
if (type == Py_WRAP) {
self->vec = vec;
self->wrapped = Py_WRAP;
}
else if (type == Py_NEW) {
self->vec= PyMem_Malloc(size * sizeof(float));
if(vec) {
if (vec) {
memcpy(self->vec, vec, size * sizeof(float));
}
else { /* new empty */
fill_vn(self->vec, size, 0.0f);
if(size == 4) { /* do the homogenous thing */
if (size == 4) { /* do the homogenous thing */
self->vec[3] = 1.0f;
}
}
@@ -2445,7 +2450,7 @@ PyObject *newVectorObject_cb(PyObject *cb_user, int size, int cb_type, int cb_su
{
float dummy[4] = {0.0, 0.0, 0.0, 0.0}; /* dummy init vector, callbacks will be used on access */
VectorObject *self= (VectorObject *)newVectorObject(dummy, size, Py_NEW, NULL);
if(self) {
if (self) {
Py_INCREF(cb_user);
self->cb_user= cb_user;
self->cb_type= (unsigned char)cb_type;

View File

@@ -48,8 +48,6 @@
#include "BLI_utildefines.h"
#define SWAP_FLOAT(a, b, tmp) tmp=a; a=b; b=tmp
#define eps 0.000001
/*-------------------------DOC STRINGS ---------------------------*/
PyDoc_STRVAR(M_Geometry_doc,
@@ -85,7 +83,14 @@ 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) {
@@ -94,8 +99,14 @@ static PyObject *M_Geometry_intersect_ray_tri(PyObject *UNUSED(self), PyObject*
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;
}
copy_v3_v3(v1, vec1->vec);
copy_v3_v3(v2, vec2->vec);
@@ -173,17 +184,28 @@ 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) {
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) {
int result;
@@ -257,9 +279,14 @@ static PyObject *M_Geometry_normal(PyObject *UNUSED(self), PyObject* args)
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 (!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) {
PyErr_SetString(PyExc_ValueError,
"vectors must be of the same size");
@@ -271,13 +298,22 @@ static PyObject *M_Geometry_normal(PyObject *UNUSED(self), PyObject* args)
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) {
@@ -291,8 +327,13 @@ static PyObject *M_Geometry_normal(PyObject *UNUSED(self), PyObject* args)
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);
}
@@ -319,7 +360,11 @@ 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;
}
@@ -329,8 +374,12 @@ static PyObject *M_Geometry_area_tri(PyObject *UNUSED(self), PyObject* args)
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) {
return PyFloat_FromDouble(area_tri_v3(vec1->vec, vec2->vec, vec3->vec));
@@ -367,16 +416,21 @@ 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",
&vector_Type, &line_a1,
&vector_Type, &line_a2,
&vector_Type, &line_b1,
&vector_Type, &line_b2)
) {
&vector_Type, &line_a1,
&vector_Type, &line_a2,
&vector_Type, &line_b1,
&vector_Type, &line_b2))
{
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) {
return newVectorObject(vi, 2, Py_NEW, NULL);
@@ -411,20 +465,20 @@ static PyObject *M_Geometry_intersect_line_plane(PyObject *UNUSED(self), PyObjec
int no_flip= 0;
float isect[3];
if (!PyArg_ParseTuple(args, "O!O!O!O!|i:intersect_line_plane",
&vector_Type, &line_a,
&vector_Type, &line_b,
&vector_Type, &plane_co,
&vector_Type, &plane_no,
&no_flip)
) {
&vector_Type, &line_a,
&vector_Type, &line_b,
&vector_Type, &plane_co,
&vector_Type, &plane_no,
&no_flip))
{
return NULL;
}
if ( BaseMath_ReadCallback(line_a) == -1 ||
BaseMath_ReadCallback(line_b) == -1 ||
BaseMath_ReadCallback(plane_co) == -1 ||
BaseMath_ReadCallback(plane_no) == -1
) {
BaseMath_ReadCallback(plane_no) == -1)
{
return NULL;
}
@@ -443,6 +497,65 @@ static PyObject *M_Geometry_intersect_line_plane(PyObject *UNUSED(self), PyObjec
}
}
PyDoc_STRVAR(M_Geometry_intersect_plane_plane_doc,
".. function:: intersect_plane_plane(plane_a_co, plane_a_no, plane_b_co, plane_b_no)\n"
"\n"
" Return the intersection between two planes\n"
"\n"
" :arg plane_a_co: Point on the first plane\n"
" :type plane_a_co: :class:`mathutils.Vector`\n"
" :arg plane_a_no: Normal of the first plane\n"
" :type plane_a_no: :class:`mathutils.Vector`\n"
" :arg plane_b_co: Point on the second plane\n"
" :type plane_b_co: :class:`mathutils.Vector`\n"
" :arg plane_b_no: Normal of the second plane\n"
" :type plane_b_no: :class:`mathutils.Vector`\n"
" :return: The line of the intersection represented as a point and a vector\n"
" :rtype: tuple pair of :class:`mathutils.Vector`\n"
);
static PyObject *M_Geometry_intersect_plane_plane(PyObject *UNUSED(self), PyObject* args)
{
PyObject *ret;
VectorObject *plane_a_co, *plane_a_no, *plane_b_co, *plane_b_no;
float isect_co[3];
float isect_no[3];
if (!PyArg_ParseTuple(args, "O!O!O!O!|i:intersect_plane_plane",
&vector_Type, &plane_a_co,
&vector_Type, &plane_a_no,
&vector_Type, &plane_b_co,
&vector_Type, &plane_b_no))
{
return NULL;
}
if ( BaseMath_ReadCallback(plane_a_co) == -1 ||
BaseMath_ReadCallback(plane_a_no) == -1 ||
BaseMath_ReadCallback(plane_b_co) == -1 ||
BaseMath_ReadCallback(plane_b_no) == -1)
{
return NULL;
}
if (ELEM4(2, plane_a_co->size, plane_a_no->size, plane_b_co->size, plane_b_no->size)) {
PyErr_SetString(PyExc_ValueError,
"geometry.intersect_plane_plane(...): "
" can't use 2D Vectors");
return NULL;
}
isect_plane_plane_v3(isect_co, isect_no,
plane_a_co->vec, plane_a_no->vec,
plane_b_co->vec, plane_b_no->vec);
normalize_v3(isect_no);
ret= PyTuple_New(2);
PyTuple_SET_ITEM(ret, 0, newVectorObject(isect_co, 3, Py_NEW, NULL));
PyTuple_SET_ITEM(ret, 1, newVectorObject(isect_no, 3, Py_NEW, NULL));
return ret;
}
PyDoc_STRVAR(M_Geometry_intersect_line_sphere_doc,
".. function:: intersect_line_sphere(line_a, line_b, sphere_co, sphere_radius, clip=True)\n"
@@ -471,18 +584,18 @@ static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObje
float isect_b[3];
if (!PyArg_ParseTuple(args, "O!O!O!f|i:intersect_line_sphere",
&vector_Type, &line_a,
&vector_Type, &line_b,
&vector_Type, &sphere_co,
&sphere_radius, &clip)
) {
&vector_Type, &line_a,
&vector_Type, &line_b,
&vector_Type, &sphere_co,
&sphere_radius, &clip))
{
return NULL;
}
if ( BaseMath_ReadCallback(line_a) == -1 ||
if ( BaseMath_ReadCallback(line_a) == -1 ||
BaseMath_ReadCallback(line_b) == -1 ||
BaseMath_ReadCallback(sphere_co) == -1
) {
BaseMath_ReadCallback(sphere_co) == -1)
{
return NULL;
}
@@ -551,18 +664,18 @@ static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyO
float isect_b[3];
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,
&sphere_radius, &clip)
) {
&vector_Type, &line_a,
&vector_Type, &line_b,
&vector_Type, &sphere_co,
&sphere_radius, &clip))
{
return NULL;
}
if ( BaseMath_ReadCallback(line_a) == -1 ||
BaseMath_ReadCallback(line_b) == -1 ||
BaseMath_ReadCallback(sphere_co) == -1
) {
BaseMath_ReadCallback(sphere_co) == -1)
{
return NULL;
}
else {
@@ -617,16 +730,20 @@ static PyObject *M_Geometry_intersect_point_line(PyObject *UNUSED(self), PyObjec
PyObject *ret;
if (!PyArg_ParseTuple(args, "O!O!O!:intersect_point_line",
&vector_Type, &pt,
&vector_Type, &line_1,
&vector_Type, &line_2)
) {
&vector_Type, &pt,
&vector_Type, &line_1,
&vector_Type, &line_2))
{
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 */
if (pt->size==3) { copy_v3_v3(pt_in, pt->vec);}
else { pt_in[2]=0.0; copy_v2_v2(pt_in, pt->vec); }
@@ -666,17 +783,22 @@ 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",
&vector_Type, &pt_vec,
&vector_Type, &tri_p1,
&vector_Type, &tri_p2,
&vector_Type, &tri_p3)
) {
&vector_Type, &pt_vec,
&vector_Type, &tri_p1,
&vector_Type, &tri_p2,
&vector_Type, &tri_p3))
{
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,18 +824,24 @@ 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",
&vector_Type, &pt_vec,
&vector_Type, &quad_p1,
&vector_Type, &quad_p2,
&vector_Type, &quad_p3,
&vector_Type, &quad_p4)
) {
&vector_Type, &pt_vec,
&vector_Type, &quad_p1,
&vector_Type, &quad_p2,
&vector_Type, &quad_p3,
&vector_Type, &quad_p4))
{
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));
}
@@ -738,8 +866,8 @@ static PyObject *M_Geometry_distance_point_to_plane(PyObject *UNUSED(self), PyOb
if (!PyArg_ParseTuple(args, "O!O!O!:distance_point_to_plane",
&vector_Type, &pt,
&vector_Type, &plene_co,
&vector_Type, &plane_no)
) {
&vector_Type, &plane_no))
{
return NULL;
}
@@ -783,14 +911,14 @@ static PyObject *M_Geometry_barycentric_transform(PyObject *UNUSED(self), PyObje
float vec[3];
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,
&vector_Type, &vec_t3_src,
&vector_Type, &vec_t1_tar,
&vector_Type, &vec_t2_tar,
&vector_Type, &vec_t3_tar)
) {
&vector_Type, &vec_pt,
&vector_Type, &vec_t1_src,
&vector_Type, &vec_t2_src,
&vector_Type, &vec_t3_src,
&vector_Type, &vec_t1_tar,
&vector_Type, &vec_t2_tar,
&vector_Type, &vec_t3_tar))
{
return NULL;
}
@@ -850,11 +978,11 @@ static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject*
if (!PyArg_ParseTuple(args, "O!O!O!O!i:interpolate_bezier",
&vector_Type, &vec_k1,
&vector_Type, &vec_h1,
&vector_Type, &vec_h2,
&vector_Type, &vec_k2, &resolu)
) {
&vector_Type, &vec_k1,
&vector_Type, &vec_h1,
&vector_Type, &vec_h2,
&vector_Type, &vec_k2, &resolu))
{
return NULL;
}
@@ -864,8 +992,13 @@ static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject*
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);
@@ -1137,6 +1270,7 @@ static PyMethodDef M_Geometry_methods[]= {
{"intersect_line_line", (PyCFunction) M_Geometry_intersect_line_line, METH_VARARGS, M_Geometry_intersect_line_line_doc},
{"intersect_line_line_2d", (PyCFunction) M_Geometry_intersect_line_line_2d, METH_VARARGS, M_Geometry_intersect_line_line_2d_doc},
{"intersect_line_plane", (PyCFunction) M_Geometry_intersect_line_plane, METH_VARARGS, M_Geometry_intersect_line_plane_doc},
{"intersect_plane_plane", (PyCFunction) M_Geometry_intersect_plane_plane, METH_VARARGS, M_Geometry_intersect_plane_plane_doc},
{"intersect_line_sphere", (PyCFunction) M_Geometry_intersect_line_sphere, METH_VARARGS, M_Geometry_intersect_line_sphere_doc},
{"intersect_line_sphere_2d", (PyCFunction) M_Geometry_intersect_line_sphere_2d, METH_VARARGS, M_Geometry_intersect_line_sphere_2d_doc},
{"distance_point_to_plane", (PyCFunction) M_Geometry_distance_point_to_plane, METH_VARARGS, M_Geometry_distance_point_to_plane_doc},