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:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2013-01-28 00:17:49 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2013-01-28 00:17:49 +0400
commit156acd3370a4f9090dc1507f275bf2cb695ac371 (patch)
treef19c6234d4ddb2bbf193f49cda2b224fc62d64fb /source/blender/freestyle/intern/python/BPy_Convert.cpp
parent39f8b95443f5dc83a24fb2c85847ea45e018925e (diff)
Freestyle Python API improvements - part 1.
* The API syntax of StrokeVertex and StrokeAttribute was updated by means of getter/setter properties instead of class methods. Python style modules (including the Parameter Editor implementation) were updated accordingly. * Code clean-up was done for a few Python style modules, mostly by removing duplicated definitions of stroke shaders and fixing indentation.
Diffstat (limited to 'source/blender/freestyle/intern/python/BPy_Convert.cpp')
-rw-r--r--source/blender/freestyle/intern/python/BPy_Convert.cpp62
1 files changed, 31 insertions, 31 deletions
diff --git a/source/blender/freestyle/intern/python/BPy_Convert.cpp b/source/blender/freestyle/intern/python/BPy_Convert.cpp
index 01567b18142..87f7c3a6beb 100644
--- a/source/blender/freestyle/intern/python/BPy_Convert.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Convert.cpp
@@ -483,6 +483,8 @@ Vec3f * Vec3f_ptr_from_PyObject( PyObject* obj ) {
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 )) )
@@ -494,6 +496,8 @@ Vec3r * Vec3r_ptr_from_PyObject( PyObject* obj ) {
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 )) )
@@ -502,53 +506,49 @@ Vec3r * Vec3r_ptr_from_PyObject( PyObject* obj ) {
}
Vec2f * Vec2f_ptr_from_Vector( PyObject* obj ) {
- PyObject *v;
if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 2)
return NULL;
- v = PyObject_GetAttrString(obj,"x");
- float x = PyFloat_AsDouble( v );
- Py_DECREF( v );
- v = PyObject_GetAttrString(obj,"y");
- float y = PyFloat_AsDouble( v );
- Py_DECREF( v );
-
- return new Vec2f(x,y);
+ float x = ((VectorObject *)obj)->vec[0];
+ float y = ((VectorObject *)obj)->vec[1];
+ return new Vec2f(x, y);
}
Vec3f * Vec3f_ptr_from_Vector( PyObject* obj ) {
- PyObject *v;
if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 3)
return NULL;
- v = PyObject_GetAttrString(obj,"x");
- float x = PyFloat_AsDouble( v );
- Py_DECREF( v );
- v = PyObject_GetAttrString(obj,"y");
- float y = PyFloat_AsDouble( v );
- Py_DECREF( v );
- v = PyObject_GetAttrString(obj,"z");
- float z = PyFloat_AsDouble( v );
- Py_DECREF( v );
-
+ float x = ((VectorObject *)obj)->vec[0];
+ float y = ((VectorObject *)obj)->vec[1];
+ float z = ((VectorObject *)obj)->vec[2];
return new Vec3f(x,y,z);
}
Vec3r * Vec3r_ptr_from_Vector( PyObject* obj ) {
- PyObject *v;
if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 3)
return NULL;
- v = PyObject_GetAttrString(obj,"x");
- double x = PyFloat_AsDouble( v );
- Py_DECREF( v );
- v = PyObject_GetAttrString(obj,"y");
- double y = PyFloat_AsDouble( v );
- Py_DECREF( v );
- v = PyObject_GetAttrString(obj,"z");
- double z = PyFloat_AsDouble( v );
- Py_DECREF( v );
-
+ real x = ((VectorObject *)obj)->vec[0];
+ real y = ((VectorObject *)obj)->vec[1];
+ real z = ((VectorObject *)obj)->vec[2];
return new Vec3r(x,y,z);
}
+Vec3f * Vec3f_ptr_from_Color( PyObject* obj ) {
+ 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);
+}
+
+Vec3r * Vec3r_ptr_from_Color( PyObject* obj ) {
+ 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);
+}
+
Vec2f * Vec2f_ptr_from_PyList( PyObject* obj ) {
if( !PyList_Check(obj) || PyList_Size(obj) != 2 )
return NULL;