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:
authorSergej Reich <sergej.reich@googlemail.com>2013-11-23 20:17:12 +0400
committerSergej Reich <sergej.reich@googlemail.com>2013-11-23 20:17:12 +0400
commit39dc956f593b3406bf1d81fb83c557b7b51f5327 (patch)
tree50b59815aad48902a6563aefc8b944daf34c401e /source/blender/freestyle/intern/python/BPy_Convert.cpp
parent5d5176095e82b34499e15d74f1fb76d56f4d9508 (diff)
parentd846c9a3b75c3d6f20bc7ab7d2da6cdd18bbbef2 (diff)
Merge branch 'master' into soc-2013-rigid_body_simsoc-2013-rigid_body_sim
Conflicts: intern/rigidbody/CMakeLists.txt release/datafiles/splash.png source/blender/editors/space_view3d/drawobject.c source/blender/makesdna/DNA_view3d_types.h
Diffstat (limited to 'source/blender/freestyle/intern/python/BPy_Convert.cpp')
-rw-r--r--source/blender/freestyle/intern/python/BPy_Convert.cpp202
1 files changed, 117 insertions, 85 deletions
diff --git a/source/blender/freestyle/intern/python/BPy_Convert.cpp b/source/blender/freestyle/intern/python/BPy_Convert.cpp
index 3b1232c51af..56c096a1eae 100644
--- a/source/blender/freestyle/intern/python/BPy_Convert.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Convert.cpp
@@ -512,93 +512,100 @@ Nature::EdgeNature EdgeNature_from_BPy_Nature(PyObject *obj)
return static_cast<Nature::EdgeNature>(PyLong_AsLong(obj));
}
-Vec2f *Vec2f_ptr_from_PyObject(PyObject *obj)
-{
- Vec2f *v;
- if ((v = Vec2f_ptr_from_Vector(obj)))
- return v;
- if ((v = Vec2f_ptr_from_PyList(obj)))
- return v;
- if ((v = Vec2f_ptr_from_PyTuple(obj)))
- return v;
- return NULL;
+bool Vec2f_ptr_from_PyObject(PyObject *obj, Vec2f *vec)
+{
+ if (Vec2f_ptr_from_Vector(obj, vec))
+ return true;
+ if (Vec2f_ptr_from_PyList(obj, vec))
+ return true;
+ if (Vec2f_ptr_from_PyTuple(obj, vec))
+ return true;
+ return false;
}
-Vec3f *Vec3f_ptr_from_PyObject(PyObject *obj)
+bool Vec3f_ptr_from_PyObject(PyObject *obj, Vec3f *vec)
{
- Vec3f *v;
- if ((v = Vec3f_ptr_from_Vector(obj)))
- return v;
- if ((v = Vec3f_ptr_from_Color(obj)))
- return v;
- if ((v = Vec3f_ptr_from_PyList(obj)))
- return v;
- if ((v = Vec3f_ptr_from_PyTuple(obj)))
- return v;
- return NULL;
+ if (Vec3f_ptr_from_Vector(obj, vec))
+ return true;
+ if (Vec3f_ptr_from_Color(obj, vec))
+ return true;
+ if (Vec3f_ptr_from_PyList(obj, vec))
+ return true;
+ if (Vec3f_ptr_from_PyTuple(obj, vec))
+ return true;
+ return false;
}
-Vec3r *Vec3r_ptr_from_PyObject(PyObject *obj)
+bool Vec3r_ptr_from_PyObject(PyObject *obj, Vec3r *vec)
{
- Vec3r *v;
- if ((v = Vec3r_ptr_from_Vector(obj)))
- return v;
- if ((v = Vec3r_ptr_from_Color(obj)))
- return v;
- if ((v = Vec3r_ptr_from_PyList(obj)))
- return v;
- if ((v = Vec3r_ptr_from_PyTuple(obj)))
- return v;
- return NULL;
+ if (Vec3r_ptr_from_Vector(obj, vec))
+ return true;
+ if (Vec3r_ptr_from_Color(obj, vec))
+ return true;
+ if (Vec3r_ptr_from_PyList(obj, vec))
+ return true;
+ if (Vec3r_ptr_from_PyTuple(obj, vec))
+ return true;
+ return false;
}
-Vec2f *Vec2f_ptr_from_Vector(PyObject *obj)
+bool Vec2f_ptr_from_Vector(PyObject *obj, Vec2f *vec)
{
if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 2)
- return NULL;
- float x = ((VectorObject *)obj)->vec[0];
- float y = ((VectorObject *)obj)->vec[1];
- return new Vec2f(x, y);
+ return false;
+ if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1)
+ return false;
+ vec[0] = ((VectorObject *)obj)->vec[0];
+ vec[1] = ((VectorObject *)obj)->vec[1];
+ return true;
}
-Vec3f *Vec3f_ptr_from_Vector(PyObject *obj)
+bool Vec3f_ptr_from_Vector(PyObject *obj, Vec3f *vec)
{
if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 3)
- return NULL;
- float x = ((VectorObject *)obj)->vec[0];
- float y = ((VectorObject *)obj)->vec[1];
- float z = ((VectorObject *)obj)->vec[2];
- return new Vec3f(x, y, z);
+ return false;
+ if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1)
+ return false;
+ vec[0] = ((VectorObject *)obj)->vec[0];
+ vec[1] = ((VectorObject *)obj)->vec[1];
+ vec[2] = ((VectorObject *)obj)->vec[2];
+ return true;
}
-Vec3r *Vec3r_ptr_from_Vector(PyObject *obj)
+bool Vec3r_ptr_from_Vector(PyObject *obj, Vec3r *vec)
{
if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 3)
- return NULL;
- real x = ((VectorObject *)obj)->vec[0];
- real y = ((VectorObject *)obj)->vec[1];
- real z = ((VectorObject *)obj)->vec[2];
- return new Vec3r(x, y, z);
+ return false;
+ if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1)
+ return false;
+ vec[0] = ((VectorObject *)obj)->vec[0];
+ vec[1] = ((VectorObject *)obj)->vec[1];
+ vec[2] = ((VectorObject *)obj)->vec[2];
+ return true;
}
-Vec3f *Vec3f_ptr_from_Color(PyObject *obj)
+bool Vec3f_ptr_from_Color(PyObject *obj, Vec3f *vec)
{
if (!ColorObject_Check(obj))
- return NULL;
- float r = ((ColorObject *)obj)->col[0];
- float g = ((ColorObject *)obj)->col[1];
- float b = ((ColorObject *)obj)->col[2];
- return new Vec3f(r, g, b);
+ return false;
+ if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1)
+ return false;
+ vec[0] = ((ColorObject *)obj)->col[0];
+ vec[1] = ((ColorObject *)obj)->col[1];
+ vec[2] = ((ColorObject *)obj)->col[2];
+ return true;
}
-Vec3r *Vec3r_ptr_from_Color(PyObject *obj)
+bool Vec3r_ptr_from_Color(PyObject *obj, Vec3r *vec)
{
if (!ColorObject_Check(obj))
- return NULL;
- real r = ((ColorObject *)obj)->col[0];
- real g = ((ColorObject *)obj)->col[1];
- real b = ((ColorObject *)obj)->col[2];
- return new Vec3r(r, g, b);
+ return false;
+ if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1)
+ return false;
+ vec[0] = ((ColorObject *)obj)->col[0];
+ vec[1] = ((ColorObject *)obj)->col[1];
+ vec[2] = ((ColorObject *)obj)->col[2];
+ return true;
}
static int float_array_from_PyList(PyObject *obj, float *v, int n)
@@ -613,37 +620,45 @@ static int float_array_from_PyList(PyObject *obj, float *v, int n)
return 1;
}
-Vec2f *Vec2f_ptr_from_PyList(PyObject *obj)
+bool Vec2f_ptr_from_PyList(PyObject *obj, Vec2f *vec)
{
float v[2];
if (!PyList_Check(obj) || PyList_Size(obj) != 2)
- return NULL;
+ return false;
if (!float_array_from_PyList(obj, v, 2))
- return NULL;
- return new Vec2f(v[0], v[1]);
+ return false;
+ vec[0] = v[0];
+ vec[1] = v[1];
+ return true;
}
-Vec3f *Vec3f_ptr_from_PyList(PyObject *obj)
+bool Vec3f_ptr_from_PyList(PyObject *obj, Vec3f *vec)
{
float v[3];
if (!PyList_Check(obj) || PyList_Size(obj) != 3)
- return NULL;
+ return false;
if (!float_array_from_PyList(obj, v, 3))
- return NULL;
- return new Vec3f(v[0], v[1], v[2]);
+ return false;
+ vec[0] = v[0];
+ vec[1] = v[1];
+ vec[2] = v[2];
+ return true;
}
-Vec3r *Vec3r_ptr_from_PyList(PyObject *obj)
+bool Vec3r_ptr_from_PyList(PyObject *obj, Vec3r *vec)
{
float v[3];
if (!PyList_Check(obj) || PyList_Size(obj) != 3)
- return NULL;
+ return false;
if (!float_array_from_PyList(obj, v, 3))
- return NULL;
- return new Vec3r(v[0], v[1], v[2]);
+ return false;
+ vec[0] = v[0];
+ vec[1] = v[1];
+ vec[2] = v[2];
+ return true;
}
static int float_array_from_PyTuple(PyObject *obj, float *v, int n)
@@ -658,37 +673,45 @@ static int float_array_from_PyTuple(PyObject *obj, float *v, int n)
return 1;
}
-Vec2f *Vec2f_ptr_from_PyTuple(PyObject *obj)
+bool Vec2f_ptr_from_PyTuple(PyObject *obj, Vec2f *vec)
{
float v[2];
if (!PyTuple_Check(obj) || PyTuple_Size(obj) != 2)
- return NULL;
+ return false;
if (!float_array_from_PyTuple(obj, v, 2))
- return NULL;
- return new Vec2f(v[0], v[1]);
+ return false;
+ vec[0] = v[0];
+ vec[1] = v[1];
+ return true;
}
-Vec3f *Vec3f_ptr_from_PyTuple(PyObject *obj)
+bool Vec3f_ptr_from_PyTuple(PyObject *obj, Vec3f *vec)
{
float v[3];
if (!PyTuple_Check(obj) || PyTuple_Size(obj) != 3)
- return NULL;
+ return false;
if (!float_array_from_PyTuple(obj, v, 3))
- return NULL;
- return new Vec3f(v[0], v[1], v[2]);
+ return false;
+ vec[0] = v[0];
+ vec[1] = v[1];
+ vec[2] = v[2];
+ return true;
}
-Vec3r *Vec3r_ptr_from_PyTuple(PyObject *obj)
+bool Vec3r_ptr_from_PyTuple(PyObject *obj, Vec3r *vec)
{
float v[3];
if (!PyTuple_Check(obj) || PyTuple_Size(obj) != 3)
- return NULL;
+ return false;
if (!float_array_from_PyTuple(obj, v, 3))
- return NULL;
- return new Vec3r(v[0], v[1], v[2]);
+ return false;
+ vec[0] = v[0];
+ vec[1] = v[1];
+ vec[2] = v[2];
+ return true;
}
// helper for argument parsing
@@ -696,10 +719,19 @@ Vec3r *Vec3r_ptr_from_PyTuple(PyObject *obj)
int float_array_from_PyObject(PyObject *obj, float *v, int n)
{
if (VectorObject_Check(obj) && ((VectorObject *)obj)->size == n) {
+ if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1)
+ return 0;
for (int i = 0; i < n; i++)
v[i] = ((VectorObject *)obj)->vec[i];
return 1;
}
+ else if (ColorObject_Check(obj) && n == 3) {
+ if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1)
+ return 0;
+ for (int i = 0; i < n; i++)
+ v[i] = ((ColorObject *)obj)->col[i];
+ return 1;
+ }
else if (PyList_Check(obj) && PyList_Size(obj) == n) {
return float_array_from_PyList(obj, v, n);
}