Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-12-29 01:59:09 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-12-29 01:59:09 +0300
commitd741b3723633f68c960d5fb1ff677f7a72e652ac (patch)
tree491dea84e04b6220ca66a8ab3a4e7b98e4ad9987 /source/blender/python/intern/bpy_rna.c
parent54d64c47632adb4b88ba07ab351239cbedd9dfa4 (diff)
flag to make rna props 'thick wrapped', so returning a property wont try maintain a reference to the original rna property with callbacks.
also needed for functions that return vectors/matrix's
Diffstat (limited to 'source/blender/python/intern/bpy_rna.c')
-rw-r--r--source/blender/python/intern/bpy_rna.c69
1 files changed, 53 insertions, 16 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 4351f69a44a..7c4e49e93e3 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -145,6 +145,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
#ifdef USE_MATHUTILS
int subtype, totdim;
int len;
+ int is_thick;
/* disallow dynamic sized arrays to be wrapped since the size could change
* to a size mathutils does not support */
@@ -154,9 +155,11 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
len= RNA_property_array_length(ptr, prop);
subtype= RNA_property_subtype(prop);
totdim= RNA_property_array_dimension(ptr, prop, NULL);
+ is_thick = (RNA_property_flag(prop) & PROP_THICK_WRAP);
if (totdim == 1 || (totdim == 2 && subtype == PROP_MATRIX)) {
- ret = pyrna_prop_CreatePyObject(ptr, prop); /* owned by the Mathutils PyObject */
+ if(!is_thick)
+ ret = pyrna_prop_CreatePyObject(ptr, prop); /* owned by the Mathutils PyObject */
switch(RNA_property_subtype(prop)) {
case PROP_TRANSLATION:
@@ -166,40 +169,74 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
case PROP_XYZ:
case PROP_XYZ|PROP_UNIT_LENGTH:
if(len>=2 && len <= 4) {
- PyObject *vec_cb= newVectorObject_cb(ret, len, mathutils_rna_array_cb_index, FALSE);
- Py_DECREF(ret); /* the vector owns now */
- ret= vec_cb; /* return the vector instead */
+ if(is_thick) {
+ ret= newVectorObject(NULL, len, Py_NEW, NULL);
+ RNA_property_float_get_array(ptr, prop, ((VectorObject *)ret)->vec);
+ }
+ else {
+ PyObject *vec_cb= newVectorObject_cb(ret, len, mathutils_rna_array_cb_index, FALSE);
+ Py_DECREF(ret); /* the vector owns now */
+ ret= vec_cb; /* return the vector instead */
+ }
}
break;
case PROP_MATRIX:
if(len==16) {
- PyObject *mat_cb= newMatrixObject_cb(ret, 4,4, mathutils_rna_matrix_cb_index, FALSE);
- Py_DECREF(ret); /* the matrix owns now */
- ret= mat_cb; /* return the matrix instead */
+ if(is_thick) {
+ ret= newMatrixObject(NULL, 4, 4, Py_NEW, NULL);
+ RNA_property_float_get_array(ptr, prop, ((MatrixObject *)ret)->contigPtr);
+ }
+ else {
+ PyObject *mat_cb= newMatrixObject_cb(ret, 4,4, mathutils_rna_matrix_cb_index, FALSE);
+ Py_DECREF(ret); /* the matrix owns now */
+ ret= mat_cb; /* return the matrix instead */
+ }
}
else if (len==9) {
- PyObject *mat_cb= newMatrixObject_cb(ret, 3,3, mathutils_rna_matrix_cb_index, FALSE);
- Py_DECREF(ret); /* the matrix owns now */
- ret= mat_cb; /* return the matrix instead */
+ if(is_thick) {
+ ret= newMatrixObject(NULL, 3, 3, Py_NEW, NULL);
+ RNA_property_float_get_array(ptr, prop, ((MatrixObject *)ret)->contigPtr);
+ }
+ else {
+ PyObject *mat_cb= newMatrixObject_cb(ret, 3,3, mathutils_rna_matrix_cb_index, FALSE);
+ Py_DECREF(ret); /* the matrix owns now */
+ ret= mat_cb; /* return the matrix instead */
+ }
}
break;
case PROP_EULER:
case PROP_QUATERNION:
if(len==3) { /* euler */
- PyObject *eul_cb= newEulerObject_cb(ret, mathutils_rna_array_cb_index, FALSE);
- Py_DECREF(ret); /* the matrix owns now */
- ret= eul_cb; /* return the matrix instead */
+ if(is_thick) {
+ ret= newEulerObject(NULL, Py_NEW, NULL);
+ RNA_property_float_get_array(ptr, prop, ((EulerObject *)ret)->eul);
+ }
+ else {
+ PyObject *eul_cb= newEulerObject_cb(ret, mathutils_rna_array_cb_index, FALSE);
+ Py_DECREF(ret); /* the matrix owns now */
+ ret= eul_cb; /* return the matrix instead */
+ }
}
else if (len==4) {
- PyObject *quat_cb= newQuaternionObject_cb(ret, mathutils_rna_array_cb_index, FALSE);
- Py_DECREF(ret); /* the matrix owns now */
- ret= quat_cb; /* return the matrix instead */
+ if(is_thick) {
+ ret= newQuaternionObject(NULL, Py_NEW, NULL);
+ RNA_property_float_get_array(ptr, prop, ((QuaternionObject *)ret)->quat);
+ }
+ else {
+ PyObject *quat_cb= newQuaternionObject_cb(ret, mathutils_rna_array_cb_index, FALSE);
+ Py_DECREF(ret); /* the matrix owns now */
+ ret= quat_cb; /* return the matrix instead */
+ }
}
break;
default:
break;
}
}
+
+ if(ret==NULL)
+ ret = pyrna_prop_CreatePyObject(ptr, prop); /* TODO, convert to a python list */
+
#endif
return ret;