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
path: root/source
diff options
context:
space:
mode:
authorStephen Swaney <sswaney@centurytel.net>2005-08-21 19:00:17 +0400
committerStephen Swaney <sswaney@centurytel.net>2005-08-21 19:00:17 +0400
commitbb5ae49992ba1b68d8c041699b12689e56442295 (patch)
treef7121a8a42bdcb62a2d00ee6792cbb2dc307e115 /source
parent4065cdb550a6200e49ef6e243563e6bac035544d (diff)
A large collection of fixes from Ken Hughes including:
- corrections to constants - parameter type checking - correct use of METH_VARARGS vs METH_NOARGS - return objects instead of strings in Scene.getChildren() as per doc. - correct logical operators Thanks, Ken!
Diffstat (limited to 'source')
-rw-r--r--source/blender/python/api2_2x/Font.c2
-rw-r--r--source/blender/python/api2_2x/Image.c4
-rw-r--r--source/blender/python/api2_2x/Material.c40
-rw-r--r--source/blender/python/api2_2x/Object.c2
-rw-r--r--source/blender/python/api2_2x/Scene.c33
-rw-r--r--source/blender/python/api2_2x/Texture.c8
-rw-r--r--source/blender/python/api2_2x/sceneRadio.c2
-rw-r--r--source/blender/python/api2_2x/sceneRender.c4
8 files changed, 56 insertions, 39 deletions
diff --git a/source/blender/python/api2_2x/Font.c b/source/blender/python/api2_2x/Font.c
index 316e7141d15..26fa731e79c 100644
--- a/source/blender/python/api2_2x/Font.c
+++ b/source/blender/python/api2_2x/Font.c
@@ -268,7 +268,7 @@ static PyObject *Font_pack( BPy_Font * self, PyObject * args )
if( !PyArg_ParseTuple( args, "i", &pack ) )
return ( EXPP_ReturnPyObjError
( PyExc_AttributeError,
- "expected string argument" ) );
+ "expected int argument" ) );
if( pack && !self->font->packedfile )
self->font->packedfile = newPackedFile(self->font->name);
else if (self->font->packedfile)
diff --git a/source/blender/python/api2_2x/Image.c b/source/blender/python/api2_2x/Image.c
index 8d451367901..b81fb1aa5d2 100644
--- a/source/blender/python/api2_2x/Image.c
+++ b/source/blender/python/api2_2x/Image.c
@@ -913,7 +913,7 @@ static PyObject *Image_setXRep( BPy_Image * self, PyObject * args )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected int argument in [1,16]" ) );
- if( value >= EXPP_IMAGE_REP_MIN || value <= EXPP_IMAGE_REP_MAX )
+ if( value >= EXPP_IMAGE_REP_MIN && value <= EXPP_IMAGE_REP_MAX )
self->image->xrep = value;
else
return ( EXPP_ReturnPyObjError( PyExc_ValueError,
@@ -930,7 +930,7 @@ static PyObject *Image_setYRep( BPy_Image * self, PyObject * args )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected int argument in [1,16]" ) );
- if( value >= EXPP_IMAGE_REP_MIN || value <= EXPP_IMAGE_REP_MAX )
+ if( value >= EXPP_IMAGE_REP_MIN && value <= EXPP_IMAGE_REP_MAX )
self->image->yrep = value;
else
return ( EXPP_ReturnPyObjError( PyExc_ValueError,
diff --git a/source/blender/python/api2_2x/Material.c b/source/blender/python/api2_2x/Material.c
index 8a57d5765d2..e2755a51aea 100644
--- a/source/blender/python/api2_2x/Material.c
+++ b/source/blender/python/api2_2x/Material.c
@@ -102,9 +102,9 @@
/* Shader spesific settings */
#define EXPP_MAT_SPEC_SHADER_MIN 0
-#define EXPP_MAT_SPEC_SHADER_MAX 3
+#define EXPP_MAT_SPEC_SHADER_MAX 4
#define EXPP_MAT_DIFFUSE_SHADER_MIN 0
-#define EXPP_MAT_DIFFUSE_SHADER_MAX 4
+#define EXPP_MAT_DIFFUSE_SHADER_MAX 3
#define EXPP_MAT_ROUGHNESS_MIN 0.0f
#define EXPP_MAT_ROUGHNESS_MAX 3.140f
@@ -142,7 +142,7 @@
#define EXPP_MAT_SHADER_DIFFUSE_ORENNAYAR MA_DIFF_ORENNAYAR
#define EXPP_MAT_SHADER_DIFFUSE_TOON MA_DIFF_TOON
#define EXPP_MAT_SHADER_DIFFUSE_MINNAERT MA_DIFF_MINNAERT
-/* shader dicts - Specualr */
+/* shader dicts - Specular */
#define EXPP_MAT_SHADER_SPEC_COOKTORR MA_SPEC_COOKTORR
#define EXPP_MAT_SHADER_SPEC_PHONG MA_SPEC_PHONG
#define EXPP_MAT_SHADER_SPEC_BLINN MA_SPEC_BLINN
@@ -734,25 +734,25 @@ static PyMethodDef BPy_Material_methods[] = {
"(f,f,f or [f,f,f]) - Set Material's specular color"},
/* Shader spesific settings */
- {"setSpecShader", ( PyCFunction ) Material_setSpecShader, METH_NOARGS,
+ {"setSpecShader", ( PyCFunction ) Material_setSpecShader, METH_VARARGS,
"(i) - Set the Material's specular shader" },
- {"setDiffuseShader", ( PyCFunction ) Material_setDiffuseShader, METH_NOARGS,
+ {"setDiffuseShader", ( PyCFunction ) Material_setDiffuseShader, METH_VARARGS,
"(i) - Set the Material's diffuse shader" },
- {"setRoughness", ( PyCFunction ) Material_setRoughness, METH_NOARGS,
+ {"setRoughness", ( PyCFunction ) Material_setRoughness, METH_VARARGS,
"(f) - Set the Material's Roughness (applies to the \"Oren Nayar\" Diffuse Shader only)" },
- {"setSpecSize", ( PyCFunction ) Material_setSpecSize, METH_NOARGS,
+ {"setSpecSize", ( PyCFunction ) Material_setSpecSize, METH_VARARGS,
"(f) - Set the Material's size of specular area (applies to the \"Toon\" Specular Shader only)" },
- {"setDiffuseSize", ( PyCFunction ) Material_setDiffuseSize, METH_NOARGS,
+ {"setDiffuseSize", ( PyCFunction ) Material_setDiffuseSize, METH_VARARGS,
"(f) - Set the Material's size of diffuse area (applies to the \"Toon\" Diffuse Shader only)" },
- {"setSpecSmooth", ( PyCFunction ) Material_setSpecSmooth, METH_NOARGS,
+ {"setSpecSmooth", ( PyCFunction ) Material_setSpecSmooth, METH_VARARGS,
"(f) - Set the Material's smoothing of specular area (applies to the \"Toon\" Specular Shader only)" },
- {"setDiffuseSmooth", ( PyCFunction ) Material_setDiffuseSmooth, METH_NOARGS,
+ {"setDiffuseSmooth", ( PyCFunction ) Material_setDiffuseSmooth, METH_VARARGS,
"(f) - Set the Material's smoothing of diffuse area (applies to the \"Toon\" Diffuse Shader only)" },
- {"setDiffuseDarkness", ( PyCFunction ) Material_setDiffuseDarkness, METH_NOARGS,
+ {"setDiffuseDarkness", ( PyCFunction ) Material_setDiffuseDarkness, METH_VARARGS,
"(f) - Set the Material's diffuse darkness (applies to the \"Minnaert\" Diffuse Shader only)" },
- {"setRefracIndex", ( PyCFunction ) Material_setRefracIndex, METH_NOARGS,
+ {"setRefracIndex", ( PyCFunction ) Material_setRefracIndex, METH_VARARGS,
"(f) - Set the Material's Index of Refraction (applies to the \"Blinn\" Specular Shader only)" },
- {"setRms", ( PyCFunction ) Material_setRms, METH_NOARGS,
+ {"setRms", ( PyCFunction ) Material_setRms, METH_VARARGS,
"(f) - Set the Material's standard deviation of surface slope (applies to the \"WardIso\" Specular Shader only)" },
/* End shader settings */
@@ -1445,7 +1445,7 @@ static PyObject *Material_getIOR( BPy_Material * self )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Material.nRings attribute" );
+ "couldn't get Material.IOR attribute" );
}
static PyObject *Material_getTransDepth( BPy_Material * self )
@@ -1457,7 +1457,7 @@ static PyObject *Material_getTransDepth( BPy_Material * self )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Material.nRings attribute" );
+ "couldn't get Material.transDepth attribute" );
}
static PyObject *Material_getFresnelTrans( BPy_Material * self )
@@ -1469,7 +1469,7 @@ static PyObject *Material_getFresnelTrans( BPy_Material * self )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Material.nRings attribute" );
+ "couldn't get Material.fresnelTrans attribute" );
}
static PyObject *Material_getFresnelTransFac( BPy_Material * self )
@@ -1481,7 +1481,7 @@ static PyObject *Material_getFresnelTransFac( BPy_Material * self )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Material.nRings attribute" );
+ "couldn't get Material.fresnelTransFac attribute" );
}
static PyObject *Material_getTextures( BPy_Material * self )
@@ -1504,8 +1504,8 @@ static PyObject *Material_getTextures( BPy_Material * self )
}
/* turn the array into a tuple */
- tuple = Py_BuildValue( "NNNNNNNN", t[0], t[1], t[2], t[3],
- t[4], t[5], t[6], t[7] );
+ tuple = Py_BuildValue( "NNNNNNNNNN", t[0], t[1], t[2], t[3],
+ t[4], t[5], t[6], t[7], t[8], t[9] );
if( !tuple )
return EXPP_ReturnPyObjError( PyExc_MemoryError,
"Material_getTextures: couldn't create PyTuple" );
@@ -2071,7 +2071,7 @@ static PyObject *Material_setSpec( BPy_Material * self, PyObject * args )
if( !PyArg_ParseTuple( args, "f", &value ) )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected float argument in [0.0, 1.0]" ) );
+ "expected float argument in [0.0, 2.0]" ) );
self->material->spec = EXPP_ClampFloat( value, EXPP_MAT_SPEC_MIN,
EXPP_MAT_SPEC_MAX );
diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c
index 4864cba1506..49e4f66a401 100644
--- a/source/blender/python/api2_2x/Object.c
+++ b/source/blender/python/api2_2x/Object.c
@@ -323,7 +323,7 @@ automatic when the script finishes."},
"Returns the object's parent object"},
{"getParentBoneName", ( PyCFunction ) Object_getParentBoneName, METH_NOARGS,
"Returns None, or the 'sub-name' of the parent (eg. Bone name)"},
- {"getSize", ( PyCFunction ) Object_getSize, METH_VARARGS,
+ {"getSize", ( PyCFunction ) Object_getSize, METH_NOARGS,
"Returns the object's size (x, y, z)"},
{"getTimeOffset", ( PyCFunction ) Object_getTimeOffset, METH_NOARGS,
"Returns the object's time offset"},
diff --git a/source/blender/python/api2_2x/Scene.c b/source/blender/python/api2_2x/Scene.c
index a6d920002a2..d90b5843540 100644
--- a/source/blender/python/api2_2x/Scene.c
+++ b/source/blender/python/api2_2x/Scene.c
@@ -26,7 +26,7 @@
* This is a new part of Blender.
*
* Contributor(s): Willian P. Germano, Jacques Guignot, Joseph Gilbert,
- * Campbell Barton.
+ * Campbell Barton, Ken Hughes
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
@@ -50,6 +50,7 @@ struct View3D;
#include "mydevice.h" /* for #define REDRAW */
#include "DNA_view3d_types.h"
#include "Object.h"
+#include "Camera.h"
#include "gen_utils.h"
#include "sceneRender.h"
#include "sceneRadio.h"
@@ -822,6 +823,7 @@ static PyObject *Scene_getChildren( BPy_Scene * self )
PyObject *bpy_obj;
Object *object;
Base *base;
+ PyObject *name;
if( !scene )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
@@ -832,9 +834,13 @@ static PyObject *Scene_getChildren( BPy_Scene * self )
while( base ) {
object = base->object;
- bpy_obj = M_Object_Get( Py_None,
- Py_BuildValue( "(s)",
- object->id.name + 2 ) );
+ name = Py_BuildValue( "(s)", object->id.name + 2 );
+ if( !name )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Py_BuildValue() failed" );
+
+ bpy_obj = M_Object_Get( Py_None, name );
+ Py_DECREF ( name );
if( !bpy_obj )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
@@ -891,10 +897,18 @@ static PyObject *Scene_getCurrentCamera( BPy_Scene * self )
cam_obj = scene->camera;
- if( cam_obj ) /* if found, return a wrapper for it */
- return M_Object_Get( Py_None,
- Py_BuildValue( "(s)",
- cam_obj->id.name + 2 ) );
+ if( cam_obj ) { /* if found, return a wrapper for it */
+ PyObject *camera = NULL;
+ PyObject *name = Py_BuildValue( "(s)", cam_obj->id.name + 2 );
+
+ if( !name )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Py_BuildValue() failed" );
+
+ camera = M_Object_Get( Py_None, name );
+ Py_DECREF ( name );
+ return camera;
+ }
Py_INCREF( Py_None ); /* none found */
return Py_None;
@@ -916,6 +930,9 @@ static PyObject *Scene_setCurrentCamera( BPy_Scene * self, PyObject * args )
"expected Camera Object as argument" );
object = cam_obj->object;
+ if( object->type != OB_CAMERA )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "expected Camera Object as argument" );
scene->camera = object; /* set the current Camera */
diff --git a/source/blender/python/api2_2x/Texture.c b/source/blender/python/api2_2x/Texture.c
index a342494d63f..86e6ecc63ee 100644
--- a/source/blender/python/api2_2x/Texture.c
+++ b/source/blender/python/api2_2x/Texture.c
@@ -1068,9 +1068,9 @@ static PyObject *Texture_setContrast( BPy_Texture * self, PyObject * args )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected a float" );
- if( contrast < 0 || contrast > 2 )
+ if( contrast < 0.01 || contrast > 5.0 )
return EXPP_ReturnPyObjError( PyExc_ValueError,
- "contrast must be in range [0,2]" );
+ "contrast must be in range [0.01,5.0]" );
self->texture->contrast = contrast;
@@ -1637,9 +1637,9 @@ static PyObject *Texture_setExp( BPy_Texture * self, PyObject * args )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected a float" );
- if( vn_mexp < 0 || vn_mexp > 10 )
+ if( vn_mexp < 0.01 || vn_mexp > 10.0 )
return EXPP_ReturnPyObjError( PyExc_ValueError,
- "Exp must be in range [0,10]" );
+ "Exp must be in range [0.01,10.0]" );
self->texture->vn_mexp = vn_mexp;
diff --git a/source/blender/python/api2_2x/sceneRadio.c b/source/blender/python/api2_2x/sceneRadio.c
index 607cea2f570..5a1e7c55a8a 100644
--- a/source/blender/python/api2_2x/sceneRadio.c
+++ b/source/blender/python/api2_2x/sceneRadio.c
@@ -62,7 +62,7 @@
#define EXPP_RADIO_elma_MIN 1
#define EXPP_RADIO_elma_MAX 500
#define EXPP_RADIO_elmi_MIN 1
-#define EXPP_RADIO_elmi_MAX 500
+#define EXPP_RADIO_elmi_MAX 100
/* ints */
#define EXPP_RADIO_maxnode_MIN 1
#define EXPP_RADIO_maxnode_MAX 250000
diff --git a/source/blender/python/api2_2x/sceneRender.c b/source/blender/python/api2_2x/sceneRender.c
index 84fa4c06720..3e42aa0d25e 100644
--- a/source/blender/python/api2_2x/sceneRender.c
+++ b/source/blender/python/api2_2x/sceneRender.c
@@ -296,7 +296,7 @@ static PyMethodDef BPy_RenderData_methods[] = {
"(int) - get/set edge intensity for toon shading\n"},
{"setEdgeColor", ( PyCFunction ) RenderData_SetEdgeColor, METH_VARARGS,
"(f,f,f) - set the edge color for toon shading - Red,Green,Blue expected.\n"},
- {"getEdgeColor", ( PyCFunction ) RenderData_GetEdgeColor, METH_VARARGS,
+ {"getEdgeColor", ( PyCFunction ) RenderData_GetEdgeColor, METH_NOARGS,
"() - get the edge color for toon shading - Red,Green,Blue expected.\n"},
{"edgeAntiShift", ( PyCFunction ) RenderData_EdgeAntiShift,
METH_VARARGS,
@@ -474,7 +474,7 @@ static PyMethodDef BPy_RenderData_methods[] = {
METH_VARARGS,
"(f,f,f) - set the red, green, blue component of the bars\n"},
{"getGameFrameColor", ( PyCFunction ) RenderData_GetGameFrameColor,
- METH_VARARGS,
+ METH_NOARGS,
"() - get the red, green, blue component of the bars\n"},
{"gammaLevel", ( PyCFunction ) RenderData_GammaLevel, METH_VARARGS,
"(float) - get/set the gamma value for blending oversampled images (1.0 = no correction\n"},