style cleanup: comments
This commit is contained in:
@@ -337,7 +337,7 @@ static int rna_id_write_error(PointerRNA *ptr, PyObject *key)
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
#endif // USE_PEDANTIC_WRITE
|
||||
#endif /* USE_PEDANTIC_WRITE */
|
||||
|
||||
|
||||
#ifdef USE_PEDANTIC_WRITE
|
||||
@@ -350,7 +350,7 @@ void pyrna_write_set(int val)
|
||||
{
|
||||
rna_disallow_writes = !val;
|
||||
}
|
||||
#else // USE_PEDANTIC_WRITE
|
||||
#else /* USE_PEDANTIC_WRITE */
|
||||
int pyrna_write_check(void)
|
||||
{
|
||||
return TRUE;
|
||||
@@ -359,7 +359,7 @@ void pyrna_write_set(int UNUSED(val))
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
#endif // USE_PEDANTIC_WRITE
|
||||
#endif /* USE_PEDANTIC_WRITE */
|
||||
|
||||
static Py_ssize_t pyrna_prop_collection_length(BPy_PropertyRNA *self);
|
||||
static Py_ssize_t pyrna_prop_array_length(BPy_PropertyArrayRNA *self);
|
||||
@@ -426,7 +426,7 @@ static int mathutils_rna_vector_set(BaseMathObject *bmo, int subtype)
|
||||
if (rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) {
|
||||
return -1;
|
||||
}
|
||||
#endif // USE_PEDANTIC_WRITE
|
||||
#endif /* USE_PEDANTIC_WRITE */
|
||||
|
||||
if (!RNA_property_editable_flag(&self->ptr, self->prop)) {
|
||||
PyErr_Format(PyExc_AttributeError,
|
||||
@@ -490,7 +490,7 @@ static int mathutils_rna_vector_set_index(BaseMathObject *bmo, int UNUSED(subtyp
|
||||
if (rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) {
|
||||
return -1;
|
||||
}
|
||||
#endif // USE_PEDANTIC_WRITE
|
||||
#endif /* USE_PEDANTIC_WRITE */
|
||||
|
||||
if (!RNA_property_editable_flag(&self->ptr, self->prop)) {
|
||||
PyErr_Format(PyExc_AttributeError,
|
||||
@@ -547,7 +547,7 @@ static int mathutils_rna_matrix_set(BaseMathObject *bmo, int UNUSED(subtype))
|
||||
if (rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) {
|
||||
return -1;
|
||||
}
|
||||
#endif // USE_PEDANTIC_WRITE
|
||||
#endif /* USE_PEDANTIC_WRITE */
|
||||
|
||||
if (!RNA_property_editable_flag(&self->ptr, self->prop)) {
|
||||
PyErr_Format(PyExc_AttributeError,
|
||||
@@ -588,7 +588,7 @@ static short pyrna_rotation_euler_order_get(PointerRNA *ptr, PropertyRNA **prop_
|
||||
return order_fallback;
|
||||
}
|
||||
|
||||
#endif // USE_MATHUTILS
|
||||
#endif /* USE_MATHUTILS */
|
||||
|
||||
/* note that PROP_NONE is included as a vector subtype. this is because its handy to
|
||||
* have x/y access to fcurve keyframes and other fixed size float arrays of length 2-4. */
|
||||
@@ -672,7 +672,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
|
||||
PropertyRNA *prop_eul_order = NULL;
|
||||
short order = pyrna_rotation_euler_order_get(ptr, &prop_eul_order, EULER_ORDER_XYZ);
|
||||
|
||||
ret = Euler_CreatePyObject(NULL, order, Py_NEW, NULL); // TODO, get order from RNA
|
||||
ret = Euler_CreatePyObject(NULL, order, Py_NEW, NULL); /* TODO, get order from RNA */
|
||||
RNA_property_float_get_array(ptr, prop, ((EulerObject *)ret)->eul);
|
||||
}
|
||||
else {
|
||||
@@ -698,7 +698,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
|
||||
case PROP_COLOR_GAMMA:
|
||||
if (len == 3) { /* color */
|
||||
if (is_thick) {
|
||||
ret = Color_CreatePyObject(NULL, Py_NEW, NULL); // TODO, get order from RNA
|
||||
ret = Color_CreatePyObject(NULL, Py_NEW, NULL);
|
||||
RNA_property_float_get_array(ptr, prop, ((ColorObject *)ret)->col);
|
||||
}
|
||||
else {
|
||||
@@ -722,10 +722,10 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
|
||||
ret = pyrna_prop_CreatePyObject(ptr, prop); /* owned by the mathutils PyObject */
|
||||
}
|
||||
}
|
||||
#else // USE_MATHUTILS
|
||||
#else /* USE_MATHUTILS */
|
||||
(void)ptr;
|
||||
(void)prop;
|
||||
#endif // USE_MATHUTILS
|
||||
#endif /* USE_MATHUTILS */
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1302,7 +1302,7 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
|
||||
val, RNA_struct_identifier(ptr->type),
|
||||
ptr_name, RNA_property_identifier(prop));
|
||||
|
||||
#if 0 // gives python decoding errors while generating docs :(
|
||||
#if 0 /* gives python decoding errors while generating docs :( */
|
||||
char error_str[256];
|
||||
BLI_snprintf(error_str, sizeof(error_str),
|
||||
"RNA Warning: Current value \"%d\" "
|
||||
@@ -1371,14 +1371,14 @@ PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
|
||||
else {
|
||||
ret = PyUnicode_FromStringAndSize(buf, buf_len);
|
||||
}
|
||||
#else // USE_STRING_COERCE
|
||||
#else /* USE_STRING_COERCE */
|
||||
if (subtype == PROP_BYTESTRING) {
|
||||
ret = PyBytes_FromStringAndSize(buf, buf_len);
|
||||
}
|
||||
else {
|
||||
ret = PyUnicode_FromStringAndSize(buf, buf_len);
|
||||
}
|
||||
#endif // USE_STRING_COERCE
|
||||
#endif /* USE_STRING_COERCE */
|
||||
if (buf_fixed != buf) {
|
||||
MEM_freeN((void *)buf);
|
||||
}
|
||||
@@ -1635,12 +1635,12 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
|
||||
if (subtype == PROP_TRANSLATE) {
|
||||
param = IFACE_(param);
|
||||
}
|
||||
#endif // WITH_INTERNATIONAL
|
||||
#endif /* WITH_INTERNATIONAL */
|
||||
|
||||
}
|
||||
#else // USE_STRING_COERCE
|
||||
#else /* USE_STRING_COERCE */
|
||||
param = _PyUnicode_AsString(value);
|
||||
#endif // USE_STRING_COERCE
|
||||
#endif /* USE_STRING_COERCE */
|
||||
|
||||
if (param == NULL) {
|
||||
if (PyUnicode_Check(value)) {
|
||||
@@ -1668,7 +1668,7 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
|
||||
}
|
||||
#ifdef USE_STRING_COERCE
|
||||
Py_XDECREF(value_coerce);
|
||||
#endif // USE_STRING_COERCE
|
||||
#endif /* USE_STRING_COERCE */
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1995,7 +1995,7 @@ static int pyrna_py_to_prop_array_index(BPy_PropertyArrayRNA *self, int index, P
|
||||
return ret;
|
||||
}
|
||||
|
||||
//---------------sequence-------------------------------------------
|
||||
/* ---------------sequence------------------------------------------- */
|
||||
static Py_ssize_t pyrna_prop_array_length(BPy_PropertyArrayRNA *self)
|
||||
{
|
||||
PYRNA_PROP_CHECK_INT((BPy_PropertyRNA *)self);
|
||||
@@ -2982,7 +2982,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_PEDANTIC_WRITE
|
||||
#endif /* USE_PEDANTIC_WRITE */
|
||||
|
||||
if (group == NULL) {
|
||||
PyErr_SetString(PyExc_TypeError, "bpy_struct[key] = val: id properties not supported for this type");
|
||||
@@ -3441,7 +3441,7 @@ static PyObject *pyrna_struct_dir(BPy_StructRNA *self)
|
||||
return ret;
|
||||
}
|
||||
|
||||
//---------------getattr--------------------------------------------
|
||||
/* ---------------getattr-------------------------------------------- */
|
||||
static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
|
||||
{
|
||||
const char *name = _PyUnicode_AsString(pyname);
|
||||
@@ -3455,7 +3455,7 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
|
||||
PyErr_SetString(PyExc_AttributeError, "bpy_struct: __getattr__ must be a string");
|
||||
ret = NULL;
|
||||
}
|
||||
else if (name[0] == '_') { // rna can't start with a "_", so for __dict__ and similar we can skip using rna lookups
|
||||
else if (name[0] == '_') { /* rna can't start with a "_", so for __dict__ and similar we can skip using rna lookups */
|
||||
/* annoying exception, maybe we need to have different types for this... */
|
||||
if ((strcmp(name, "__getitem__") == 0 || strcmp(name, "__setitem__") == 0) && !RNA_struct_idprops_check(self->ptr.type)) {
|
||||
PyErr_SetString(PyExc_AttributeError, "bpy_struct: no __getitem__ support for this type");
|
||||
@@ -3565,7 +3565,7 @@ static int pyrna_struct_pydict_contains(PyObject *self, PyObject *pyname)
|
||||
}
|
||||
#endif
|
||||
|
||||
//--------------- setattr-------------------------------------------
|
||||
/* --------------- setattr------------------------------------------- */
|
||||
static int pyrna_is_deferred_prop(const PyObject *value)
|
||||
{
|
||||
return PyTuple_CheckExact(value) &&
|
||||
@@ -3678,7 +3678,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_PEDANTIC_WRITE
|
||||
#endif /* USE_PEDANTIC_WRITE */
|
||||
|
||||
if (name == NULL) {
|
||||
PyErr_SetString(PyExc_AttributeError, "bpy_struct: __setattr__ must be a string");
|
||||
@@ -3829,7 +3829,7 @@ static PyObject *pyrna_prop_collection_getattro(BPy_PropertyRNA *self, PyObject
|
||||
#endif
|
||||
}
|
||||
|
||||
//--------------- setattr-------------------------------------------
|
||||
/* --------------- setattr------------------------------------------- */
|
||||
static int pyrna_prop_collection_setattro(BPy_PropertyRNA *self, PyObject *pyname, PyObject *value)
|
||||
{
|
||||
const char *name = _PyUnicode_AsString(pyname);
|
||||
@@ -3840,7 +3840,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_PEDANTIC_WRITE
|
||||
#endif /* USE_PEDANTIC_WRITE */
|
||||
|
||||
if (name == NULL) {
|
||||
PyErr_SetString(PyExc_AttributeError, "bpy_prop: __setattr__ must be a string");
|
||||
@@ -4275,7 +4275,7 @@ static int foreach_parse_args(BPy_PropertyRNA *self, PyObject *args,
|
||||
foreach_attr_type(self, *attr, raw_type, attr_tot, attr_signed);
|
||||
*size = RNA_raw_type_sizeof(*raw_type);
|
||||
|
||||
#if 0 // works fine but not strictly needed, we could allow RNA_property_collection_raw_* to do the checks
|
||||
#if 0 /* works fine but not strictly needed, we could allow RNA_property_collection_raw_* to do the checks */
|
||||
if ((*attr_tot) < 1)
|
||||
*attr_tot = 1;
|
||||
|
||||
@@ -6044,8 +6044,8 @@ static PyObject *pyrna_srna_ExternalType(StructRNA *srna)
|
||||
fprintf(stderr, "%s: failed to find 'bpy_types' module\n", __func__);
|
||||
return NULL;
|
||||
}
|
||||
bpy_types_dict = PyModule_GetDict(bpy_types); // borrow
|
||||
Py_DECREF(bpy_types); // fairly safe to assume the dict is kept
|
||||
bpy_types_dict = PyModule_GetDict(bpy_types); /* borrow */
|
||||
Py_DECREF(bpy_types); /* fairly safe to assume the dict is kept */
|
||||
}
|
||||
|
||||
newclass = PyDict_GetItemString(bpy_types_dict, idname);
|
||||
@@ -6134,7 +6134,7 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna)
|
||||
/* srna owns one, and the other is owned by the caller */
|
||||
pyrna_subtype_set_rna(newclass, srna);
|
||||
|
||||
// XXX, adding this back segfaults blender on load.
|
||||
/* XXX, adding this back segfaults blender on load. */
|
||||
// Py_DECREF(newclass); /* let srna own */
|
||||
}
|
||||
else {
|
||||
@@ -6291,7 +6291,7 @@ int pyrna_id_FromPyObject(PyObject *obj, ID **id)
|
||||
|
||||
void BPY_rna_init(void)
|
||||
{
|
||||
#ifdef USE_MATHUTILS // register mathutils callbacks, ok to run more then once.
|
||||
#ifdef USE_MATHUTILS /* register mathutils callbacks, ok to run more then once. */
|
||||
mathutils_rna_array_cb_index = Mathutils_RegisterCallback(&mathutils_rna_array_cb);
|
||||
mathutils_rna_matrix_cb_index = Mathutils_RegisterCallback(&mathutils_rna_matrix_cb);
|
||||
#endif
|
||||
@@ -6375,7 +6375,7 @@ PyObject *BPY_rna_doc(void)
|
||||
|
||||
/* pyrna_basetype_* - BPy_BaseTypeRNA is just a BPy_PropertyRNA struct with a different type
|
||||
* the self->ptr and self->prop are always set to the "structs" collection */
|
||||
//---------------getattr--------------------------------------------
|
||||
/* ---------------getattr-------------------------------------------- */
|
||||
static PyObject *pyrna_basetype_getattro(BPy_BaseTypeRNA *self, PyObject *pyname)
|
||||
{
|
||||
PointerRNA newptr;
|
||||
@@ -6750,7 +6750,7 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, v
|
||||
PyObject *base_class = RNA_struct_py_type_get(srna);
|
||||
PyObject *item;
|
||||
int i, flag, arg_count, func_arg_count;
|
||||
const char *py_class_name = ((PyTypeObject *)py_class)->tp_name; // __name__
|
||||
const char *py_class_name = ((PyTypeObject *)py_class)->tp_name; /* __name__ */
|
||||
|
||||
if (srna_base) {
|
||||
if (bpy_class_validate_recursive(dummyptr, srna_base, py_data, have_function) != 0)
|
||||
@@ -7211,10 +7211,10 @@ static void bpy_class_free(void *pyob_ptr)
|
||||
|
||||
gilstate = PyGILState_Ensure();
|
||||
|
||||
// breaks re-registering classes
|
||||
/* breaks re-registering classes */
|
||||
// PyDict_Clear(((PyTypeObject *)self)->tp_dict);
|
||||
//
|
||||
// remove the rna attribute instead.
|
||||
|
||||
/* remove the rna attribute instead. */
|
||||
PyDict_DelItem(((PyTypeObject *)self)->tp_dict, bpy_intern_str_bl_rna);
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Clear();
|
||||
@@ -7279,7 +7279,7 @@ void pyrna_free_types(void)
|
||||
void *py_ptr = RNA_struct_py_type_get(srna);
|
||||
|
||||
if (py_ptr) {
|
||||
#if 0 // XXX - should be able to do this but makes python crash on exit
|
||||
#if 0 /* XXX - should be able to do this but makes python crash on exit */
|
||||
bpy_class_free(py_ptr);
|
||||
#endif
|
||||
RNA_struct_py_type_set(srna, NULL);
|
||||
|
@@ -276,12 +276,12 @@ int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------MATRIX FUNCTIONS--------------------
|
||||
/* ----------------------------------MATRIX FUNCTIONS-------------------- */
|
||||
|
||||
|
||||
/* Utility functions */
|
||||
|
||||
// LomontRRDCompare4, Ever Faster Float Comparisons by Randy Dillon
|
||||
/* LomontRRDCompare4, Ever Faster Float Comparisons by Randy Dillon */
|
||||
#define SIGNMASK(i) (-(int)(((unsigned int)(i)) >> 31))
|
||||
|
||||
int EXPP_FloatsAreEqual(float af, float bf, int maxDiff)
|
||||
|
@@ -35,8 +35,8 @@
|
||||
|
||||
#define COLOR_SIZE 3
|
||||
|
||||
//----------------------------------mathutils.Color() -------------------
|
||||
//makes a new color for you to play with
|
||||
/* ----------------------------------mathutils.Color() ------------------- */
|
||||
/* makes a new color for you to play with */
|
||||
static PyObject *Color_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
float col[3] = {0.0f, 0.0f, 0.0f};
|
||||
@@ -64,7 +64,7 @@ static PyObject *Color_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||
return Color_CreatePyObject(col, Py_NEW, type);
|
||||
}
|
||||
|
||||
//-----------------------------METHODS----------------------------
|
||||
/* -----------------------------METHODS---------------------------- */
|
||||
|
||||
/* note: BaseMath_ReadCallback must be called beforehand */
|
||||
static PyObject *Color_ToTupleExt(ColorObject *self, int ndigits)
|
||||
@@ -113,8 +113,8 @@ static PyObject *Color_deepcopy(ColorObject *self, PyObject *args)
|
||||
return Color_copy(self);
|
||||
}
|
||||
|
||||
//----------------------------print object (internal)--------------
|
||||
//print the object to screen
|
||||
/* ----------------------------print object (internal)-------------- */
|
||||
/* print the object to screen */
|
||||
|
||||
static PyObject *Color_repr(ColorObject *self)
|
||||
{
|
||||
@@ -146,8 +146,8 @@ static PyObject *Color_str(ColorObject *self)
|
||||
return mathutils_dynstr_to_py(ds); /* frees ds */
|
||||
}
|
||||
|
||||
//------------------------tp_richcmpr
|
||||
//returns -1 exception, 0 false, 1 true
|
||||
/* ------------------------tp_richcmpr */
|
||||
/* returns -1 exception, 0 false, 1 true */
|
||||
static PyObject *Color_richcmpr(PyObject *a, PyObject *b, int op)
|
||||
{
|
||||
PyObject *res;
|
||||
@@ -184,15 +184,15 @@ static PyObject *Color_richcmpr(PyObject *a, PyObject *b, int op)
|
||||
return Py_INCREF(res), res;
|
||||
}
|
||||
|
||||
//---------------------SEQUENCE PROTOCOLS------------------------
|
||||
//----------------------------len(object)------------------------
|
||||
//sequence length
|
||||
/* ---------------------SEQUENCE PROTOCOLS------------------------ */
|
||||
/* ----------------------------len(object)------------------------ */
|
||||
/* sequence length */
|
||||
static int Color_len(ColorObject *UNUSED(self))
|
||||
{
|
||||
return COLOR_SIZE;
|
||||
}
|
||||
//----------------------------object[]---------------------------
|
||||
//sequence accessor (get)
|
||||
/* ----------------------------object[]--------------------------- */
|
||||
/* sequence accessor (get) */
|
||||
static PyObject *Color_item(ColorObject *self, int i)
|
||||
{
|
||||
if (i < 0) i = COLOR_SIZE - i;
|
||||
@@ -210,13 +210,13 @@ static PyObject *Color_item(ColorObject *self, int i)
|
||||
return PyFloat_FromDouble(self->col[i]);
|
||||
|
||||
}
|
||||
//----------------------------object[]-------------------------
|
||||
//sequence accessor (set)
|
||||
/* ----------------------------object[]------------------------- */
|
||||
/* sequence accessor (set) */
|
||||
static int Color_ass_item(ColorObject *self, int i, PyObject *value)
|
||||
{
|
||||
float f = PyFloat_AsDouble(value);
|
||||
|
||||
if (f == -1 && PyErr_Occurred()) { // parsed item not a number
|
||||
if (f == -1 && PyErr_Occurred()) { /* parsed item not a number */
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"color[item] = x: "
|
||||
"argument not a number");
|
||||
@@ -238,8 +238,8 @@ static int Color_ass_item(ColorObject *self, int i, PyObject *value)
|
||||
|
||||
return 0;
|
||||
}
|
||||
//----------------------------object[z:y]------------------------
|
||||
//sequence slice (get)
|
||||
/* ----------------------------object[z:y]------------------------ */
|
||||
/* sequence slice (get) */
|
||||
static PyObject *Color_slice(ColorObject *self, int begin, int end)
|
||||
{
|
||||
PyObject *tuple;
|
||||
@@ -260,8 +260,8 @@ static PyObject *Color_slice(ColorObject *self, int begin, int end)
|
||||
|
||||
return tuple;
|
||||
}
|
||||
//----------------------------object[z:y]------------------------
|
||||
//sequence slice (set)
|
||||
/* ----------------------------object[z:y]------------------------ */
|
||||
/* sequence slice (set) */
|
||||
static int Color_ass_slice(ColorObject *self, int begin, int end, PyObject *seq)
|
||||
{
|
||||
int i, size;
|
||||
@@ -361,7 +361,7 @@ static int Color_ass_subscript(ColorObject *self, PyObject *item, PyObject *valu
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------PROTCOL DECLARATIONS--------------------------
|
||||
/* -----------------PROTCOL DECLARATIONS-------------------------- */
|
||||
static PySequenceMethods Color_SeqMethods = {
|
||||
(lenfunc) Color_len, /* sq_length */
|
||||
(binaryfunc) NULL, /* sq_concat */
|
||||
@@ -792,7 +792,7 @@ static PyGetSetDef Color_getseters[] = {
|
||||
};
|
||||
|
||||
|
||||
//-----------------------METHOD DEFINITIONS ----------------------
|
||||
/* -----------------------METHOD DEFINITIONS ---------------------- */
|
||||
static struct PyMethodDef Color_methods[] = {
|
||||
{"copy", (PyCFunction) Color_copy, METH_NOARGS, Color_copy_doc},
|
||||
{"__copy__", (PyCFunction) Color_copy, METH_NOARGS, Color_copy_doc},
|
||||
@@ -800,60 +800,60 @@ static struct PyMethodDef Color_methods[] = {
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
//------------------PY_OBECT DEFINITION--------------------------
|
||||
/* ------------------PY_OBECT DEFINITION-------------------------- */
|
||||
PyDoc_STRVAR(color_doc,
|
||||
"This object gives access to Colors in Blender."
|
||||
);
|
||||
PyTypeObject color_Type = {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"Color", //tp_name
|
||||
sizeof(ColorObject), //tp_basicsize
|
||||
0, //tp_itemsize
|
||||
(destructor)BaseMathObject_dealloc, //tp_dealloc
|
||||
NULL, //tp_print
|
||||
NULL, //tp_getattr
|
||||
NULL, //tp_setattr
|
||||
NULL, //tp_compare
|
||||
(reprfunc) Color_repr, //tp_repr
|
||||
&Color_NumMethods, //tp_as_number
|
||||
&Color_SeqMethods, //tp_as_sequence
|
||||
&Color_AsMapping, //tp_as_mapping
|
||||
NULL, //tp_hash
|
||||
NULL, //tp_call
|
||||
(reprfunc) Color_str, //tp_str
|
||||
NULL, //tp_getattro
|
||||
NULL, //tp_setattro
|
||||
NULL, //tp_as_buffer
|
||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, //tp_flags
|
||||
color_doc, //tp_doc
|
||||
(traverseproc)BaseMathObject_traverse, //tp_traverse
|
||||
(inquiry)BaseMathObject_clear, //tp_clear
|
||||
(richcmpfunc)Color_richcmpr, //tp_richcompare
|
||||
0, //tp_weaklistoffset
|
||||
NULL, //tp_iter
|
||||
NULL, //tp_iternext
|
||||
Color_methods, //tp_methods
|
||||
NULL, //tp_members
|
||||
Color_getseters, //tp_getset
|
||||
NULL, //tp_base
|
||||
NULL, //tp_dict
|
||||
NULL, //tp_descr_get
|
||||
NULL, //tp_descr_set
|
||||
0, //tp_dictoffset
|
||||
NULL, //tp_init
|
||||
NULL, //tp_alloc
|
||||
Color_new, //tp_new
|
||||
NULL, //tp_free
|
||||
NULL, //tp_is_gc
|
||||
NULL, //tp_bases
|
||||
NULL, //tp_mro
|
||||
NULL, //tp_cache
|
||||
NULL, //tp_subclasses
|
||||
NULL, //tp_weaklist
|
||||
NULL //tp_del
|
||||
"Color", /* tp_name */
|
||||
sizeof(ColorObject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
(destructor)BaseMathObject_dealloc, /* tp_dealloc */
|
||||
NULL, /* tp_print */
|
||||
NULL, /* tp_getattr */
|
||||
NULL, /* tp_setattr */
|
||||
NULL, /* tp_compare */
|
||||
(reprfunc) Color_repr, /* tp_repr */
|
||||
&Color_NumMethods, /* tp_as_number */
|
||||
&Color_SeqMethods, /* tp_as_sequence */
|
||||
&Color_AsMapping, /* tp_as_mapping */
|
||||
NULL, /* tp_hash */
|
||||
NULL, /* tp_call */
|
||||
(reprfunc) Color_str, /* tp_str */
|
||||
NULL, /* tp_getattro */
|
||||
NULL, /* tp_setattro */
|
||||
NULL, /* tp_as_buffer */
|
||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */
|
||||
color_doc, /* tp_doc */
|
||||
(traverseproc)BaseMathObject_traverse, /* tp_traverse */
|
||||
(inquiry)BaseMathObject_clear, /* tp_clear */
|
||||
(richcmpfunc)Color_richcmpr, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
NULL, /* tp_iter */
|
||||
NULL, /* tp_iternext */
|
||||
Color_methods, /* tp_methods */
|
||||
NULL, /* tp_members */
|
||||
Color_getseters, /* tp_getset */
|
||||
NULL, /* tp_base */
|
||||
NULL, /* tp_dict */
|
||||
NULL, /* tp_descr_get */
|
||||
NULL, /* tp_descr_set */
|
||||
0, /* tp_dictoffset */
|
||||
NULL, /* tp_init */
|
||||
NULL, /* tp_alloc */
|
||||
Color_new, /* tp_new */
|
||||
NULL, /* tp_free */
|
||||
NULL, /* tp_is_gc */
|
||||
NULL, /* tp_bases */
|
||||
NULL, /* tp_mro */
|
||||
NULL, /* tp_cache */
|
||||
NULL, /* tp_subclasses */
|
||||
NULL, /* tp_weaklist */
|
||||
NULL /* tp_del */
|
||||
};
|
||||
//------------------------Color_CreatePyObject (internal)-------------
|
||||
//creates a new color object
|
||||
/* ------------------------Color_CreatePyObject (internal)------------- */
|
||||
/* creates a new color object */
|
||||
/* pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER
|
||||
* (i.e. it was allocated elsewhere by MEM_mallocN())
|
||||
* pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON
|
||||
|
@@ -46,7 +46,7 @@ typedef struct {
|
||||
* be stored in py_data) or be a wrapper for data allocated through
|
||||
* blender (stored in blend_data). This is an either/or struct not both*/
|
||||
|
||||
//prototypes
|
||||
/* prototypes */
|
||||
PyObject *Color_CreatePyObject(float col[3], int type, PyTypeObject *base_type);
|
||||
PyObject *Color_CreatePyObject_cb(PyObject *cb_user,
|
||||
unsigned char cb_type, unsigned char cb_subtype);
|
||||
|
@@ -39,8 +39,8 @@
|
||||
|
||||
#define EULER_SIZE 3
|
||||
|
||||
//----------------------------------mathutils.Euler() -------------------
|
||||
//makes a new euler for you to play with
|
||||
/* ----------------------------------mathutils.Euler() ------------------- */
|
||||
/* makes a new euler for you to play with */
|
||||
static PyObject *Euler_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
PyObject *seq = NULL;
|
||||
@@ -122,8 +122,8 @@ static PyObject *Euler_ToTupleExt(EulerObject *self, int ndigits)
|
||||
return ret;
|
||||
}
|
||||
|
||||
//-----------------------------METHODS----------------------------
|
||||
//return a quaternion representation of the euler
|
||||
/* -----------------------------METHODS----------------------------
|
||||
* return a quaternion representation of the euler */
|
||||
|
||||
PyDoc_STRVAR(Euler_to_quaternion_doc,
|
||||
".. method:: to_quaternion()\n"
|
||||
@@ -145,7 +145,7 @@ static PyObject *Euler_to_quaternion(EulerObject *self)
|
||||
return Quaternion_CreatePyObject(quat, Py_NEW, NULL);
|
||||
}
|
||||
|
||||
//return a matrix representation of the euler
|
||||
/* return a matrix representation of the euler */
|
||||
PyDoc_STRVAR(Euler_to_matrix_doc,
|
||||
".. method:: to_matrix()\n"
|
||||
"\n"
|
||||
@@ -277,8 +277,8 @@ static PyObject *Euler_make_compatible(EulerObject *self, PyObject *value)
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
//----------------------------Euler.rotate()-----------------------
|
||||
// return a copy of the euler
|
||||
/* ----------------------------Euler.rotate()-----------------------
|
||||
* return a copy of the euler */
|
||||
|
||||
PyDoc_STRVAR(Euler_copy_doc,
|
||||
".. function:: copy()\n"
|
||||
@@ -305,8 +305,8 @@ static PyObject *Euler_deepcopy(EulerObject *self, PyObject *args)
|
||||
return Euler_copy(self);
|
||||
}
|
||||
|
||||
//----------------------------print object (internal)--------------
|
||||
//print the object to screen
|
||||
/* ----------------------------print object (internal)--------------
|
||||
* print the object to screen */
|
||||
|
||||
static PyObject *Euler_repr(EulerObject *self)
|
||||
{
|
||||
@@ -374,15 +374,15 @@ static PyObject *Euler_richcmpr(PyObject *a, PyObject *b, int op)
|
||||
return Py_INCREF(res), res;
|
||||
}
|
||||
|
||||
//---------------------SEQUENCE PROTOCOLS------------------------
|
||||
//----------------------------len(object)------------------------
|
||||
//sequence length
|
||||
/* ---------------------SEQUENCE PROTOCOLS------------------------ */
|
||||
/* ----------------------------len(object)------------------------ */
|
||||
/* sequence length */
|
||||
static int Euler_len(EulerObject *UNUSED(self))
|
||||
{
|
||||
return EULER_SIZE;
|
||||
}
|
||||
//----------------------------object[]---------------------------
|
||||
//sequence accessor (get)
|
||||
/* ----------------------------object[]--------------------------- */
|
||||
/* sequence accessor (get) */
|
||||
static PyObject *Euler_item(EulerObject *self, int i)
|
||||
{
|
||||
if (i < 0) i = EULER_SIZE - i;
|
||||
@@ -400,13 +400,13 @@ static PyObject *Euler_item(EulerObject *self, int i)
|
||||
return PyFloat_FromDouble(self->eul[i]);
|
||||
|
||||
}
|
||||
//----------------------------object[]-------------------------
|
||||
//sequence accessor (set)
|
||||
/* ----------------------------object[]------------------------- */
|
||||
/* sequence accessor (set) */
|
||||
static int Euler_ass_item(EulerObject *self, int i, PyObject *value)
|
||||
{
|
||||
float f = PyFloat_AsDouble(value);
|
||||
|
||||
if (f == -1 && PyErr_Occurred()) { // parsed item not a number
|
||||
if (f == -1 && PyErr_Occurred()) { /* parsed item not a number */
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"euler[attribute] = x: "
|
||||
"argument not a number");
|
||||
@@ -429,8 +429,8 @@ static int Euler_ass_item(EulerObject *self, int i, PyObject *value)
|
||||
|
||||
return 0;
|
||||
}
|
||||
//----------------------------object[z:y]------------------------
|
||||
//sequence slice (get)
|
||||
/* ----------------------------object[z:y]------------------------ */
|
||||
/* sequence slice (get) */
|
||||
static PyObject *Euler_slice(EulerObject *self, int begin, int end)
|
||||
{
|
||||
PyObject *tuple;
|
||||
@@ -451,8 +451,8 @@ static PyObject *Euler_slice(EulerObject *self, int begin, int end)
|
||||
|
||||
return tuple;
|
||||
}
|
||||
//----------------------------object[z:y]------------------------
|
||||
//sequence slice (set)
|
||||
/* ----------------------------object[z:y]------------------------ */
|
||||
/* sequence slice (set) */
|
||||
static int Euler_ass_slice(EulerObject *self, int begin, int end, PyObject *seq)
|
||||
{
|
||||
int i, size;
|
||||
@@ -553,7 +553,7 @@ static int Euler_ass_subscript(EulerObject *self, PyObject *item, PyObject *valu
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------PROTCOL DECLARATIONS--------------------------
|
||||
/* -----------------PROTCOL DECLARATIONS-------------------------- */
|
||||
static PySequenceMethods Euler_SeqMethods = {
|
||||
(lenfunc) Euler_len, /* sq_length */
|
||||
(binaryfunc) NULL, /* sq_concat */
|
||||
@@ -629,7 +629,7 @@ static PyGetSetDef Euler_getseters[] = {
|
||||
};
|
||||
|
||||
|
||||
//-----------------------METHOD DEFINITIONS ----------------------
|
||||
/* -----------------------METHOD DEFINITIONS ---------------------- */
|
||||
static struct PyMethodDef Euler_methods[] = {
|
||||
{"zero", (PyCFunction) Euler_zero, METH_NOARGS, Euler_zero_doc},
|
||||
{"to_matrix", (PyCFunction) Euler_to_matrix, METH_NOARGS, Euler_to_matrix_doc},
|
||||
@@ -643,60 +643,60 @@ static struct PyMethodDef Euler_methods[] = {
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
//------------------PY_OBECT DEFINITION--------------------------
|
||||
/* ------------------PY_OBECT DEFINITION-------------------------- */
|
||||
PyDoc_STRVAR(euler_doc,
|
||||
"This object gives access to Eulers in Blender."
|
||||
);
|
||||
PyTypeObject euler_Type = {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"Euler", //tp_name
|
||||
sizeof(EulerObject), //tp_basicsize
|
||||
0, //tp_itemsize
|
||||
(destructor)BaseMathObject_dealloc, //tp_dealloc
|
||||
NULL, //tp_print
|
||||
NULL, //tp_getattr
|
||||
NULL, //tp_setattr
|
||||
NULL, //tp_compare
|
||||
(reprfunc) Euler_repr, //tp_repr
|
||||
NULL, //tp_as_number
|
||||
&Euler_SeqMethods, //tp_as_sequence
|
||||
&Euler_AsMapping, //tp_as_mapping
|
||||
NULL, //tp_hash
|
||||
NULL, //tp_call
|
||||
(reprfunc) Euler_str, //tp_str
|
||||
NULL, //tp_getattro
|
||||
NULL, //tp_setattro
|
||||
NULL, //tp_as_buffer
|
||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, //tp_flags
|
||||
euler_doc, //tp_doc
|
||||
(traverseproc)BaseMathObject_traverse, //tp_traverse
|
||||
(inquiry)BaseMathObject_clear, //tp_clear
|
||||
(richcmpfunc)Euler_richcmpr, //tp_richcompare
|
||||
0, //tp_weaklistoffset
|
||||
NULL, //tp_iter
|
||||
NULL, //tp_iternext
|
||||
Euler_methods, //tp_methods
|
||||
NULL, //tp_members
|
||||
Euler_getseters, //tp_getset
|
||||
NULL, //tp_base
|
||||
NULL, //tp_dict
|
||||
NULL, //tp_descr_get
|
||||
NULL, //tp_descr_set
|
||||
0, //tp_dictoffset
|
||||
NULL, //tp_init
|
||||
NULL, //tp_alloc
|
||||
Euler_new, //tp_new
|
||||
NULL, //tp_free
|
||||
NULL, //tp_is_gc
|
||||
NULL, //tp_bases
|
||||
NULL, //tp_mro
|
||||
NULL, //tp_cache
|
||||
NULL, //tp_subclasses
|
||||
NULL, //tp_weaklist
|
||||
NULL //tp_del
|
||||
"Euler", /* tp_name */
|
||||
sizeof(EulerObject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
(destructor)BaseMathObject_dealloc, /* tp_dealloc */
|
||||
NULL, /* tp_print */
|
||||
NULL, /* tp_getattr */
|
||||
NULL, /* tp_setattr */
|
||||
NULL, /* tp_compare */
|
||||
(reprfunc) Euler_repr, /* tp_repr */
|
||||
NULL, /* tp_as_number */
|
||||
&Euler_SeqMethods, /* tp_as_sequence */
|
||||
&Euler_AsMapping, /* tp_as_mapping */
|
||||
NULL, /* tp_hash */
|
||||
NULL, /* tp_call */
|
||||
(reprfunc) Euler_str, /* tp_str */
|
||||
NULL, /* tp_getattro */
|
||||
NULL, /* tp_setattro */
|
||||
NULL, /* tp_as_buffer */
|
||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */
|
||||
euler_doc, /* tp_doc */
|
||||
(traverseproc)BaseMathObject_traverse, /* tp_traverse */
|
||||
(inquiry)BaseMathObject_clear, /* tp_clear */
|
||||
(richcmpfunc)Euler_richcmpr, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
NULL, /* tp_iter */
|
||||
NULL, /* tp_iternext */
|
||||
Euler_methods, /* tp_methods */
|
||||
NULL, /* tp_members */
|
||||
Euler_getseters, /* tp_getset */
|
||||
NULL, /* tp_base */
|
||||
NULL, /* tp_dict */
|
||||
NULL, /* tp_descr_get */
|
||||
NULL, /* tp_descr_set */
|
||||
0, /* tp_dictoffset */
|
||||
NULL, /* tp_init */
|
||||
NULL, /* tp_alloc */
|
||||
Euler_new, /* tp_new */
|
||||
NULL, /* tp_free */
|
||||
NULL, /* tp_is_gc */
|
||||
NULL, /* tp_bases */
|
||||
NULL, /* tp_mro */
|
||||
NULL, /* tp_cache */
|
||||
NULL, /* tp_subclasses */
|
||||
NULL, /* tp_weaklist */
|
||||
NULL /* tp_del */
|
||||
};
|
||||
//------------------------Euler_CreatePyObject (internal)-------------
|
||||
//creates a new euler object
|
||||
/* ------------------------Euler_CreatePyObject (internal)------------- */
|
||||
/* creates a new euler object */
|
||||
/* pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER
|
||||
* (i.e. it was allocated elsewhere by MEM_mallocN())
|
||||
* pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON
|
||||
|
@@ -47,7 +47,7 @@ typedef struct {
|
||||
* be stored in py_data) or be a wrapper for data allocated through
|
||||
* blender (stored in blend_data). This is an either/or struct not both */
|
||||
|
||||
//prototypes
|
||||
/* prototypes */
|
||||
PyObject *Euler_CreatePyObject(float *eul, const short order, int type, PyTypeObject *base_type);
|
||||
PyObject *Euler_CreatePyObject_cb(PyObject *cb_user, const short order,
|
||||
unsigned char cb_type, unsigned char cb_subtype);
|
||||
|
@@ -329,9 +329,9 @@ Mathutils_Callback mathutils_matrix_translation_cb = {
|
||||
|
||||
/* matrix column callbacks, this is so you can do matrix.translation = Vector() */
|
||||
|
||||
//----------------------------------mathutils.Matrix() -----------------
|
||||
//mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc.
|
||||
//create a new matrix type
|
||||
/* ----------------------------------mathutils.Matrix() ----------------- */
|
||||
/* mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc. */
|
||||
/* create a new matrix type */
|
||||
static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
if (kwds && PyDict_Size(kwds)) {
|
||||
@@ -410,7 +410,7 @@ static void matrix_3x3_as_4x4(float mat[16])
|
||||
|
||||
/*-----------------------CLASS-METHODS----------------------------*/
|
||||
|
||||
//mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc.
|
||||
/* mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc. */
|
||||
PyDoc_STRVAR(C_Matrix_Identity_doc,
|
||||
".. classmethod:: Identity(size)\n"
|
||||
"\n"
|
||||
@@ -518,7 +518,7 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args)
|
||||
const float angle_cos = cosf(angle);
|
||||
const float angle_sin = sinf(angle);
|
||||
|
||||
//2D rotation matrix
|
||||
/* 2D rotation matrix */
|
||||
mat[0] = angle_cos;
|
||||
mat[1] = angle_sin;
|
||||
mat[2] = -angle_sin;
|
||||
@@ -532,7 +532,7 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args)
|
||||
if (matSize == 4) {
|
||||
matrix_3x3_as_4x4(mat);
|
||||
}
|
||||
//pass to matrix creation
|
||||
/* pass to matrix creation */
|
||||
return Matrix_CreatePyObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls);
|
||||
}
|
||||
|
||||
@@ -556,8 +556,8 @@ static PyObject *C_Matrix_Translation(PyObject *cls, PyObject *value)
|
||||
|
||||
return Matrix_CreatePyObject(&mat[0][0], 4, 4, Py_NEW, (PyTypeObject *)cls);
|
||||
}
|
||||
//----------------------------------mathutils.Matrix.Scale() -------------
|
||||
//mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc.
|
||||
/* ----------------------------------mathutils.Matrix.Scale() ------------- */
|
||||
/* mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc. */
|
||||
PyDoc_STRVAR(C_Matrix_Scale_doc,
|
||||
".. classmethod:: Scale(factor, size, axis)\n"
|
||||
"\n"
|
||||
@@ -601,7 +601,7 @@ static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (vec == NULL) { //scaling along axis
|
||||
if (vec == NULL) { /* scaling along axis */
|
||||
if (matSize == 2) {
|
||||
mat[0] = factor;
|
||||
mat[3] = factor;
|
||||
@@ -645,11 +645,11 @@ static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args)
|
||||
if (matSize == 4) {
|
||||
matrix_3x3_as_4x4(mat);
|
||||
}
|
||||
//pass to matrix creation
|
||||
/* pass to matrix creation */
|
||||
return Matrix_CreatePyObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls);
|
||||
}
|
||||
//----------------------------------mathutils.Matrix.OrthoProjection() ---
|
||||
//mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc.
|
||||
/* ----------------------------------mathutils.Matrix.OrthoProjection() --- */
|
||||
/* mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc. */
|
||||
PyDoc_STRVAR(C_Matrix_OrthoProjection_doc,
|
||||
".. classmethod:: OrthoProjection(axis, size)\n"
|
||||
"\n"
|
||||
@@ -685,7 +685,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (PyUnicode_Check(axis)) { //ortho projection onto cardinal plane
|
||||
if (PyUnicode_Check(axis)) { /* ortho projection onto cardinal plane */
|
||||
Py_ssize_t plane_len;
|
||||
const char *plane = _PyUnicode_AsStringAndSize(axis, &plane_len);
|
||||
if (matSize == 2) {
|
||||
@@ -726,7 +726,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args)
|
||||
}
|
||||
}
|
||||
else {
|
||||
//arbitrary plane
|
||||
/* arbitrary plane */
|
||||
|
||||
int vec_size = (matSize == 2 ? 2 : 3);
|
||||
float tvec[4];
|
||||
@@ -737,7 +737,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//normalize arbitrary axis
|
||||
/* normalize arbitrary axis */
|
||||
for (x = 0; x < vec_size; x++) {
|
||||
norm += tvec[x] * tvec[x];
|
||||
}
|
||||
@@ -766,7 +766,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args)
|
||||
if (matSize == 4) {
|
||||
matrix_3x3_as_4x4(mat);
|
||||
}
|
||||
//pass to matrix creation
|
||||
/* pass to matrix creation */
|
||||
return Matrix_CreatePyObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls);
|
||||
}
|
||||
|
||||
@@ -869,7 +869,7 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args)
|
||||
if (matSize == 4) {
|
||||
matrix_3x3_as_4x4(mat);
|
||||
}
|
||||
//pass to matrix creation
|
||||
/* pass to matrix creation */
|
||||
return Matrix_CreatePyObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls);
|
||||
}
|
||||
|
||||
@@ -2335,8 +2335,8 @@ PyTypeObject matrix_Type = {
|
||||
NULL, /*tp_as_buffer*/
|
||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
|
||||
matrix_doc, /*tp_doc*/
|
||||
(traverseproc)BaseMathObject_traverse, //tp_traverse
|
||||
(inquiry)BaseMathObject_clear, //tp_clear
|
||||
(traverseproc)BaseMathObject_traverse, /* tp_traverse */
|
||||
(inquiry)BaseMathObject_clear, /*tp_clear*/
|
||||
(richcmpfunc)Matrix_richcmpr, /*tp_richcompare*/
|
||||
0, /*tp_weaklistoffset*/
|
||||
NULL, /*tp_iter*/
|
||||
@@ -2635,8 +2635,8 @@ PyTypeObject matrix_access_Type = {
|
||||
NULL, /*tp_as_buffer*/
|
||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
|
||||
NULL, /*tp_doc*/
|
||||
(traverseproc)MatrixAccess_traverse, //tp_traverse
|
||||
(inquiry)MatrixAccess_clear, //tp_clear
|
||||
(traverseproc)MatrixAccess_traverse,/*tp_traverse*/
|
||||
(inquiry)MatrixAccess_clear, /*tp_clear*/
|
||||
NULL /* (richcmpfunc)MatrixAccess_richcmpr */ /* TODO*/, /*tp_richcompare*/
|
||||
0, /*tp_weaklistoffset*/
|
||||
(getiterfunc)MatrixAccess_iter, /* getiterfunc tp_iter; */
|
||||
|
@@ -44,7 +44,7 @@ static void quat__axis_angle_sanitize(float axis[3], float *angle);
|
||||
static PyObject *Quaternion_copy(QuaternionObject *self);
|
||||
static PyObject *Quaternion_deepcopy(QuaternionObject *self, PyObject *args);
|
||||
|
||||
//-----------------------------METHODS------------------------------
|
||||
/* -----------------------------METHODS------------------------------ */
|
||||
|
||||
/* note: BaseMath_ReadCallback must be called beforehand */
|
||||
static PyObject *Quaternion_to_tuple_ext(QuaternionObject *self, int ndigits)
|
||||
@@ -124,7 +124,7 @@ static PyObject *Quaternion_to_euler(QuaternionObject *self, PyObject *args)
|
||||
|
||||
return Euler_CreatePyObject(eul, order, Py_NEW, NULL);
|
||||
}
|
||||
//----------------------------Quaternion.toMatrix()------------------
|
||||
|
||||
PyDoc_STRVAR(Quaternion_to_matrix_doc,
|
||||
".. method:: to_matrix()\n"
|
||||
"\n"
|
||||
@@ -144,7 +144,6 @@ static PyObject *Quaternion_to_matrix(QuaternionObject *self)
|
||||
return Matrix_CreatePyObject(mat, 3, 3, Py_NEW, NULL);
|
||||
}
|
||||
|
||||
//----------------------------Quaternion.toMatrix()------------------
|
||||
PyDoc_STRVAR(Quaternion_to_axis_angle_doc,
|
||||
".. method:: to_axis_angle()\n"
|
||||
"\n"
|
||||
@@ -176,8 +175,6 @@ static PyObject *Quaternion_to_axis_angle(QuaternionObject *self)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------Quaternion.cross(other)------------------
|
||||
PyDoc_STRVAR(Quaternion_cross_doc,
|
||||
".. method:: cross(other)\n"
|
||||
"\n"
|
||||
@@ -205,7 +202,6 @@ static PyObject *Quaternion_cross(QuaternionObject *self, PyObject *value)
|
||||
return Quaternion_CreatePyObject(quat, Py_NEW, Py_TYPE(self));
|
||||
}
|
||||
|
||||
//----------------------------Quaternion.dot(other)------------------
|
||||
PyDoc_STRVAR(Quaternion_dot_doc,
|
||||
".. method:: dot(other)\n"
|
||||
"\n"
|
||||
@@ -335,8 +331,8 @@ static PyObject *Quaternion_rotate(QuaternionObject *self, PyObject *value)
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
//----------------------------Quaternion.normalize()----------------
|
||||
//normalize the axis of rotation of [theta, vector]
|
||||
/* ----------------------------Quaternion.normalize()---------------- */
|
||||
/* normalize the axis of rotation of [theta, vector] */
|
||||
PyDoc_STRVAR(Quaternion_normalize_doc,
|
||||
".. function:: normalize()\n"
|
||||
"\n"
|
||||
@@ -365,7 +361,6 @@ static PyObject *Quaternion_normalized(QuaternionObject *self)
|
||||
return quat__apply_to_copy((PyNoArgsFunction)Quaternion_normalize, self);
|
||||
}
|
||||
|
||||
//----------------------------Quaternion.invert()------------------
|
||||
PyDoc_STRVAR(Quaternion_invert_doc,
|
||||
".. function:: invert()\n"
|
||||
"\n"
|
||||
@@ -394,7 +389,6 @@ static PyObject *Quaternion_inverted(QuaternionObject *self)
|
||||
return quat__apply_to_copy((PyNoArgsFunction)Quaternion_invert, self);
|
||||
}
|
||||
|
||||
//----------------------------Quaternion.identity()-----------------
|
||||
PyDoc_STRVAR(Quaternion_identity_doc,
|
||||
".. function:: identity()\n"
|
||||
"\n"
|
||||
@@ -413,7 +407,7 @@ static PyObject *Quaternion_identity(QuaternionObject *self)
|
||||
(void)BaseMath_WriteCallback(self);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
//----------------------------Quaternion.negate()-------------------
|
||||
|
||||
PyDoc_STRVAR(Quaternion_negate_doc,
|
||||
".. function:: negate()\n"
|
||||
"\n"
|
||||
@@ -432,7 +426,7 @@ static PyObject *Quaternion_negate(QuaternionObject *self)
|
||||
(void)BaseMath_WriteCallback(self);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
//----------------------------Quaternion.conjugate()----------------
|
||||
|
||||
PyDoc_STRVAR(Quaternion_conjugate_doc,
|
||||
".. function:: conjugate()\n"
|
||||
"\n"
|
||||
@@ -461,7 +455,6 @@ static PyObject *Quaternion_conjugated(QuaternionObject *self)
|
||||
return quat__apply_to_copy((PyNoArgsFunction)Quaternion_conjugate, self);
|
||||
}
|
||||
|
||||
//----------------------------Quaternion.copy()----------------
|
||||
PyDoc_STRVAR(Quaternion_copy_doc,
|
||||
".. function:: copy()\n"
|
||||
"\n"
|
||||
@@ -487,8 +480,7 @@ static PyObject *Quaternion_deepcopy(QuaternionObject *self, PyObject *args)
|
||||
return Quaternion_copy(self);
|
||||
}
|
||||
|
||||
//----------------------------print object (internal)--------------
|
||||
//print the object to screen
|
||||
/* print the object to screen */
|
||||
static PyObject *Quaternion_repr(QuaternionObject *self)
|
||||
{
|
||||
PyObject *ret, *tuple;
|
||||
@@ -555,15 +547,15 @@ static PyObject *Quaternion_richcmpr(PyObject *a, PyObject *b, int op)
|
||||
return Py_INCREF(res), res;
|
||||
}
|
||||
|
||||
//---------------------SEQUENCE PROTOCOLS------------------------
|
||||
//----------------------------len(object)------------------------
|
||||
//sequence length
|
||||
/* ---------------------SEQUENCE PROTOCOLS------------------------ */
|
||||
/* ----------------------------len(object)------------------------ */
|
||||
/* sequence length */
|
||||
static int Quaternion_len(QuaternionObject *UNUSED(self))
|
||||
{
|
||||
return QUAT_SIZE;
|
||||
}
|
||||
//----------------------------object[]---------------------------
|
||||
//sequence accessor (get)
|
||||
/* ----------------------------object[]--------------------------- */
|
||||
/* sequence accessor (get) */
|
||||
static PyObject *Quaternion_item(QuaternionObject *self, int i)
|
||||
{
|
||||
if (i < 0) i = QUAT_SIZE - i;
|
||||
@@ -581,8 +573,8 @@ static PyObject *Quaternion_item(QuaternionObject *self, int i)
|
||||
return PyFloat_FromDouble(self->quat[i]);
|
||||
|
||||
}
|
||||
//----------------------------object[]-------------------------
|
||||
//sequence accessor (set)
|
||||
/* ----------------------------object[]------------------------- */
|
||||
/* sequence accessor (set) */
|
||||
static int Quaternion_ass_item(QuaternionObject *self, int i, PyObject *ob)
|
||||
{
|
||||
float scalar = (float)PyFloat_AsDouble(ob);
|
||||
@@ -608,8 +600,8 @@ static int Quaternion_ass_item(QuaternionObject *self, int i, PyObject *ob)
|
||||
|
||||
return 0;
|
||||
}
|
||||
//----------------------------object[z:y]------------------------
|
||||
//sequence slice (get)
|
||||
/* ----------------------------object[z:y]------------------------ */
|
||||
/* sequence slice (get) */
|
||||
static PyObject *Quaternion_slice(QuaternionObject *self, int begin, int end)
|
||||
{
|
||||
PyObject *tuple;
|
||||
@@ -630,8 +622,8 @@ static PyObject *Quaternion_slice(QuaternionObject *self, int begin, int end)
|
||||
|
||||
return tuple;
|
||||
}
|
||||
//----------------------------object[z:y]------------------------
|
||||
//sequence slice (set)
|
||||
/* ----------------------------object[z:y]------------------------ */
|
||||
/* sequence slice (set) */
|
||||
static int Quaternion_ass_slice(QuaternionObject *self, int begin, int end, PyObject *seq)
|
||||
{
|
||||
int i, size;
|
||||
@@ -734,9 +726,9 @@ static int Quaternion_ass_subscript(QuaternionObject *self, PyObject *item, PyOb
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------NUMERIC PROTOCOLS----------------------
|
||||
//------------------------obj + obj------------------------------
|
||||
//addition
|
||||
/* ------------------------NUMERIC PROTOCOLS---------------------- */
|
||||
/* ------------------------obj + obj------------------------------ */
|
||||
/* addition */
|
||||
static PyObject *Quaternion_add(PyObject *q1, PyObject *q2)
|
||||
{
|
||||
float quat[QUAT_SIZE];
|
||||
@@ -758,8 +750,8 @@ static PyObject *Quaternion_add(PyObject *q1, PyObject *q2)
|
||||
add_qt_qtqt(quat, quat1->quat, quat2->quat, 1.0f);
|
||||
return Quaternion_CreatePyObject(quat, Py_NEW, Py_TYPE(q1));
|
||||
}
|
||||
//------------------------obj - obj------------------------------
|
||||
//subtraction
|
||||
/* ------------------------obj - obj------------------------------ */
|
||||
/* subtraction */
|
||||
static PyObject *Quaternion_sub(PyObject *q1, PyObject *q2)
|
||||
{
|
||||
int x;
|
||||
@@ -875,7 +867,7 @@ static PyObject *Quaternion_neg(QuaternionObject *self)
|
||||
}
|
||||
|
||||
|
||||
//-----------------PROTOCOL DECLARATIONS--------------------------
|
||||
/* -----------------PROTOCOL DECLARATIONS-------------------------- */
|
||||
static PySequenceMethods Quaternion_SeqMethods = {
|
||||
(lenfunc) Quaternion_len, /* sq_length */
|
||||
(binaryfunc) NULL, /* sq_concat */
|
||||
@@ -1060,7 +1052,7 @@ static int Quaternion_axis_vector_set(QuaternionObject *self, PyObject *value, v
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------mathutils.Quaternion() --------------
|
||||
/* ----------------------------------mathutils.Quaternion() -------------- */
|
||||
static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
PyObject *seq = NULL;
|
||||
@@ -1140,7 +1132,7 @@ static void quat__axis_angle_sanitize(float axis[3], float *angle)
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------METHOD DEFINITIONS ----------------------
|
||||
/* -----------------------METHOD DEFINITIONS ---------------------- */
|
||||
static struct PyMethodDef Quaternion_methods[] = {
|
||||
/* in place only */
|
||||
{"identity", (PyCFunction) Quaternion_identity, METH_NOARGS, Quaternion_identity_doc},
|
||||
@@ -1190,60 +1182,60 @@ static PyGetSetDef Quaternion_getseters[] = {
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
//------------------PY_OBECT DEFINITION--------------------------
|
||||
/* ------------------PY_OBECT DEFINITION-------------------------- */
|
||||
PyDoc_STRVAR(quaternion_doc,
|
||||
"This object gives access to Quaternions in Blender."
|
||||
);
|
||||
PyTypeObject quaternion_Type = {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"Quaternion", //tp_name
|
||||
sizeof(QuaternionObject), //tp_basicsize
|
||||
0, //tp_itemsize
|
||||
(destructor)BaseMathObject_dealloc, //tp_dealloc
|
||||
NULL, //tp_print
|
||||
NULL, //tp_getattr
|
||||
NULL, //tp_setattr
|
||||
NULL, //tp_compare
|
||||
(reprfunc) Quaternion_repr, //tp_repr
|
||||
&Quaternion_NumMethods, //tp_as_number
|
||||
&Quaternion_SeqMethods, //tp_as_sequence
|
||||
&Quaternion_AsMapping, //tp_as_mapping
|
||||
NULL, //tp_hash
|
||||
NULL, //tp_call
|
||||
(reprfunc) Quaternion_str, //tp_str
|
||||
NULL, //tp_getattro
|
||||
NULL, //tp_setattro
|
||||
NULL, //tp_as_buffer
|
||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, //tp_flags
|
||||
quaternion_doc, //tp_doc
|
||||
(traverseproc)BaseMathObject_traverse, //tp_traverse
|
||||
(inquiry)BaseMathObject_clear, //tp_clear
|
||||
(richcmpfunc)Quaternion_richcmpr, //tp_richcompare
|
||||
0, //tp_weaklistoffset
|
||||
NULL, //tp_iter
|
||||
NULL, //tp_iternext
|
||||
Quaternion_methods, //tp_methods
|
||||
NULL, //tp_members
|
||||
Quaternion_getseters, //tp_getset
|
||||
NULL, //tp_base
|
||||
NULL, //tp_dict
|
||||
NULL, //tp_descr_get
|
||||
NULL, //tp_descr_set
|
||||
0, //tp_dictoffset
|
||||
NULL, //tp_init
|
||||
NULL, //tp_alloc
|
||||
Quaternion_new, //tp_new
|
||||
NULL, //tp_free
|
||||
NULL, //tp_is_gc
|
||||
NULL, //tp_bases
|
||||
NULL, //tp_mro
|
||||
NULL, //tp_cache
|
||||
NULL, //tp_subclasses
|
||||
NULL, //tp_weaklist
|
||||
NULL, //tp_del
|
||||
"Quaternion", /* tp_name */
|
||||
sizeof(QuaternionObject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
(destructor)BaseMathObject_dealloc, /* tp_dealloc */
|
||||
NULL, /* tp_print */
|
||||
NULL, /* tp_getattr */
|
||||
NULL, /* tp_setattr */
|
||||
NULL, /* tp_compare */
|
||||
(reprfunc) Quaternion_repr, /* tp_repr */
|
||||
&Quaternion_NumMethods, /* tp_as_number */
|
||||
&Quaternion_SeqMethods, /* tp_as_sequence */
|
||||
&Quaternion_AsMapping, /* tp_as_mapping */
|
||||
NULL, /* tp_hash */
|
||||
NULL, /* tp_call */
|
||||
(reprfunc) Quaternion_str, /* tp_str */
|
||||
NULL, /* tp_getattro */
|
||||
NULL, /* tp_setattro */
|
||||
NULL, /* tp_as_buffer */
|
||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */
|
||||
quaternion_doc, /* tp_doc */
|
||||
(traverseproc)BaseMathObject_traverse, /* tp_traverse */
|
||||
(inquiry)BaseMathObject_clear, /* tp_clear */
|
||||
(richcmpfunc)Quaternion_richcmpr, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
NULL, /* tp_iter */
|
||||
NULL, /* tp_iternext */
|
||||
Quaternion_methods, /* tp_methods */
|
||||
NULL, /* tp_members */
|
||||
Quaternion_getseters, /* tp_getset */
|
||||
NULL, /* tp_base */
|
||||
NULL, /* tp_dict */
|
||||
NULL, /* tp_descr_get */
|
||||
NULL, /* tp_descr_set */
|
||||
0, /* tp_dictoffset */
|
||||
NULL, /* tp_init */
|
||||
NULL, /* tp_alloc */
|
||||
Quaternion_new, /* tp_new */
|
||||
NULL, /* tp_free */
|
||||
NULL, /* tp_is_gc */
|
||||
NULL, /* tp_bases */
|
||||
NULL, /* tp_mro */
|
||||
NULL, /* tp_cache */
|
||||
NULL, /* tp_subclasses */
|
||||
NULL, /* tp_weaklist */
|
||||
NULL, /* tp_del */
|
||||
};
|
||||
//------------------------Quaternion_CreatePyObject (internal)-------------
|
||||
//creates a new quaternion object
|
||||
/* ------------------------Quaternion_CreatePyObject (internal)------------- */
|
||||
/* creates a new quaternion object */
|
||||
/*pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER
|
||||
* (i.e. it was allocated elsewhere by MEM_mallocN())
|
||||
* pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON
|
||||
@@ -1266,7 +1258,7 @@ PyObject *Quaternion_CreatePyObject(float *quat, int type, PyTypeObject *base_ty
|
||||
}
|
||||
else if (type == Py_NEW) {
|
||||
self->quat = PyMem_Malloc(QUAT_SIZE * sizeof(float));
|
||||
if (!quat) { //new empty
|
||||
if (!quat) { /* new empty */
|
||||
unit_qt(self->quat);
|
||||
}
|
||||
else {
|
||||
|
@@ -44,7 +44,7 @@ typedef struct {
|
||||
* be stored in py_data) or be a wrapper for data allocated through
|
||||
* blender (stored in blend_data). This is an either/or struct not both */
|
||||
|
||||
//prototypes
|
||||
/* prototypes */
|
||||
PyObject *Quaternion_CreatePyObject(float *quat, int type, PyTypeObject *base_type);
|
||||
PyObject *Quaternion_CreatePyObject_cb(PyObject *cb_user,
|
||||
unsigned char cb_type, unsigned char cb_subtype);
|
||||
|
@@ -1100,12 +1100,12 @@ static PyObject *Vector_project(VectorObject *self, PyObject *value)
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
//get dot products
|
||||
/* get dot products */
|
||||
for (x = 0; x < size; x++) {
|
||||
dot += (double)(self->vec[x] * tvec[x]);
|
||||
dot2 += (double)(tvec[x] * tvec[x]);
|
||||
}
|
||||
//projection
|
||||
/* projection */
|
||||
dot /= dot2;
|
||||
for (x = 0; x < size; x++) {
|
||||
vec[x] = (float)dot * tvec[x];
|
||||
@@ -2709,7 +2709,7 @@ static int row_vector_multiplication(float r_vec[MAX_DIMENSIONS], VectorObject *
|
||||
memcpy(vec_cpy, vec->vec, vec_size * sizeof(float));
|
||||
|
||||
r_vec[3] = 1.0f;
|
||||
//muliplication
|
||||
/* muliplication */
|
||||
for (col = 0; col < mat->num_col; col++) {
|
||||
double dot = 0.0;
|
||||
for (row = 0; row < mat->num_row; row++) {
|
||||
@@ -2733,7 +2733,7 @@ static PyObject *Vector_negate(VectorObject *self)
|
||||
|
||||
negate_vn(self->vec, self->size);
|
||||
|
||||
(void)BaseMath_WriteCallback(self); // already checked for error
|
||||
(void)BaseMath_WriteCallback(self); /* already checked for error */
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@@ -2829,10 +2829,10 @@ PyTypeObject vector_Type = {
|
||||
/*** Assigned meaning in release 2.0 ***/
|
||||
|
||||
/* call function for all accessible objects */
|
||||
(traverseproc)BaseMathObject_traverse, //tp_traverse
|
||||
(traverseproc)BaseMathObject_traverse, /* tp_traverse */
|
||||
|
||||
/* delete references to contained objects */
|
||||
(inquiry)BaseMathObject_clear, //tp_clear
|
||||
(inquiry)BaseMathObject_clear, /* tp_clear */
|
||||
|
||||
/*** Assigned meaning in release 2.1 ***/
|
||||
/*** rich comparisons ***/
|
||||
|
@@ -51,7 +51,7 @@ PyDoc_STRVAR(M_Geometry_doc,
|
||||
"The Blender geometry module"
|
||||
);
|
||||
|
||||
//---------------------------------INTERSECTION FUNCTIONS--------------------
|
||||
/* ---------------------------------INTERSECTION FUNCTIONS-------------------- */
|
||||
|
||||
PyDoc_STRVAR(M_Geometry_intersect_ray_tri_doc,
|
||||
".. function:: intersect_ray_tri(v1, v2, v3, ray, orig, clip=True)\n"
|
||||
@@ -251,10 +251,6 @@ static PyObject *M_Geometry_intersect_line_line(PyObject *UNUSED(self), PyObject
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//----------------------------geometry.normal() -------------------
|
||||
PyDoc_STRVAR(M_Geometry_normal_doc,
|
||||
".. function:: normal(v1, v2, v3, v4=None)\n"
|
||||
"\n"
|
||||
@@ -338,7 +334,7 @@ static PyObject *M_Geometry_normal(PyObject *UNUSED(self), PyObject *args)
|
||||
return Vector_CreatePyObject(n, 3, Py_NEW, NULL);
|
||||
}
|
||||
|
||||
//--------------------------------- AREA FUNCTIONS--------------------
|
||||
/* --------------------------------- AREA FUNCTIONS-------------------- */
|
||||
|
||||
PyDoc_STRVAR(M_Geometry_area_tri_doc,
|
||||
".. function:: area_tri(v1, v2, v3)\n"
|
||||
|
Reference in New Issue
Block a user