[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11129] trunk/blender/source/blender/ python/api2_2x: mixed decloration, own Lattice typo's

Campbell Barton cbarton at metavr.com
Sat Jun 30 02:00:04 CEST 2007


Revision: 11129
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11129
Author:   campbellbarton
Date:     2007-06-30 02:00:04 +0200 (Sat, 30 Jun 2007)

Log Message:
-----------
mixed decloration, own Lattice typo's

Modified Paths:
--------------
    trunk/blender/source/blender/python/api2_2x/Lattice.c
    trunk/blender/source/blender/python/api2_2x/Mesh.c

Modified: trunk/blender/source/blender/python/api2_2x/Lattice.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Lattice.c	2007-06-29 23:55:08 UTC (rev 11128)
+++ trunk/blender/source/blender/python/api2_2x/Lattice.c	2007-06-30 00:00:04 UTC (rev 11129)
@@ -89,16 +89,6 @@
 /* In Python these will be written to the console when doing a		 */
 /* Blender.Lattice.__doc__			*/
 /*****************************************************************************/
-static char Lattice_getName_doc[] = "() - Return Lattice Object name";
-
-static char Lattice_setName_doc[] = "(str) - Change Lattice Object name";
-
-static char Lattice_setPartitions_doc[] =
-	"(str) - Set the number of Partitions in x,y,z";
-
-static char Lattice_getPartitions_doc[] =
-	"(str) - Get the number of Partitions in x,y,z";
-
 static char Lattice_getKey_doc[] =
 	"() - Get the Key object attached to this Lattice";
 
@@ -281,38 +271,6 @@
 	return ( mod );
 }
 
-static PyObject *Lattice_setPartitions( BPy_Lattice * self, PyObject * args )
-{
-	int x = 0;
-	int y = 0;
-	int z = 0;
-	Lattice *bl_Lattice;
-
-	if( !PyArg_ParseTuple( args, "iii", &x, &y, &z ) )
-		return ( EXPP_ReturnPyObjError( PyExc_TypeError,
-						"expected int,int,int argument" ) );
-
-	bl_Lattice = self->lattice;
-
-	if( x < 2 || y < 2 || z < 2 )
-		return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
-						"partition values must be 2 or greater" ) );
-
-	resizelattice(bl_Lattice, x, y, z, NULL);
-
-	Py_RETURN_NONE;
-}
-
-static PyObject *Lattice_getPartitions( BPy_Lattice * self )
-{
-	Lattice *bl_Lattice;
-	bl_Lattice = self->lattice;
-
-	return Py_BuildValue( "[i,i,i]", ( int ) bl_Lattice->pntsu,
-			      ( int ) bl_Lattice->pntsv,
-			      ( int ) bl_Lattice->pntsw );
-}
-
 static PyObject *Lattice_getKey( BPy_Lattice * self )
 {
 	Key *key = self->lattice->key;
@@ -623,14 +581,6 @@
 /*****************************************************************************/
 static PyMethodDef BPy_Lattice_methods[] = {
 	/* name, method, flags, doc */
-	{"getName", ( PyCFunction ) GenericLib_getName, METH_NOARGS,
-	 Lattice_getName_doc},
-	{"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS,
-	 Lattice_setName_doc},
-	{"setPartitions", ( PyCFunction ) Lattice_setPartitions, METH_VARARGS,
-	 Lattice_setPartitions_doc},
-	{"getPartitions", ( PyCFunction ) Lattice_getPartitions, METH_NOARGS,
-	 Lattice_getPartitions_doc},
 	{"getKey", ( PyCFunction ) Lattice_getKey, METH_NOARGS,
 	 Lattice_getKey_doc},
 	{"setKeyTypes", ( PyCFunction ) Lattice_setKeyTypes, METH_VARARGS,
@@ -657,23 +607,44 @@
 /*****************************************************************************/
 /* Python attributes get/set functions:                                      */
 /*****************************************************************************/
-static PyObject *Lattice_getWidth(BPy_Lattice * self)
+static PyObject *Lattice_getSubD(BPy_Lattice * self, void * type)
 {
-	return PyInt_FromLong( self->lattice->pntsu );
+	switch ((long)type) {
+	case 0:
+		return PyInt_FromLong( self->lattice->pntsu ); 
+	case 1:
+		return PyInt_FromLong( self->lattice->pntsv );
+	case 2:
+		return PyInt_FromLong( self->lattice->pntsw );
+	}
+	Py_RETURN_NONE;
 }
-static PyObject *Lattice_getHeight(BPy_Lattice * self)
+
+static int Lattice_setSubD(BPy_Lattice * self, PyObject *value, void * type)
 {
-	return PyInt_FromLong( self->lattice->pntsv );
+	short u= self->lattice->pntsu, v= self->lattice->pntsv, w= self->lattice->pntsv;
+	short param = (short)PyInt_AsLong(value);
+	
+	if (!PyInt_Check(value))
+		return EXPP_ReturnIntError( PyExc_ValueError,
+				"extected an int value between 1 and 64" );
+	
+	CLAMP(param,  1, 64);
+	
+	switch ((long)type) {
+	case 0:
+		resizelattice(self->lattice, param, v, w, NULL);
+		break;
+	case 1:
+		resizelattice(self->lattice, u, param, w, NULL);
+		break;
+	case 2:
+		resizelattice(self->lattice, u, v, param, NULL);
+		break;
+	}
+	
+	return 0;
 }
-static PyObject *Lattice_getDepth(BPy_Lattice * self)
-{
-	return PyInt_FromLong( self->lattice->pntsw );
-}
-static PyObject *Lattice_getLatSize(BPy_Lattice * self)
-{
-	return PyInt_FromLong(
-		self->lattice->pntsu * self->lattice->pntsv * self->lattice->pntsw );
-}
 
 
 static PyObject *Lattice_getAxisType(BPy_Lattice * self, void * type)
@@ -707,14 +678,12 @@
 /*****************************************************************************/
 static PyGetSetDef BPy_Lattice_getseters[] = {
 	GENERIC_LIB_GETSETATTR,
-	{"width", (getter)Lattice_getWidth, (setter)NULL,
-	 "lattice U sibdivision ", NULL},
-	{"height", (getter)Lattice_getHeight, (setter)NULL,
-	 "lattice V sibdivision", NULL},
-	{"depth", (getter)Lattice_getDepth, (setter)NULL,
-	 "lattice W sibdivision", NULL},
-	{"latSize", (getter)Lattice_getLatSize, (setter)NULL,
-	 "lattice W sibdivision", NULL},	 
+	{"subdU", (getter)Lattice_getSubD, (setter)Lattice_setSubD,
+	 "lattice U subdivision ", (void *)0},
+	{"subdV", (getter)Lattice_getSubD, (setter)Lattice_setSubD,
+	 "lattice V subdivision", (void *)1},
+	{"subdW", (getter)Lattice_getSubD, (setter)Lattice_setSubD,
+	 "lattice W subdivision", (void *)2},	 
 	 
 	{"widthType", (getter)Lattice_getAxisType, NULL,
 	 "lattice U interpolation type", (void *)0},

Modified: trunk/blender/source/blender/python/api2_2x/Mesh.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Mesh.c	2007-06-29 23:55:08 UTC (rev 11128)
+++ trunk/blender/source/blender/python/api2_2x/Mesh.c	2007-06-30 00:00:04 UTC (rev 11129)
@@ -2541,11 +2541,12 @@
 
 static PyObject *MEdge_getKey( BPy_MEdge * self )
 {
+	PyObject *attr;
 	MEdge *edge = MEdge_get_pointer( self );
 	if (!edge)
 		return NULL; /* error is set */	
 	
-	PyObject *attr = PyTuple_New( 2 );
+	attr = PyTuple_New( 2 );
 	if (edge->v1 > edge->v2) {
 		PyTuple_SET_ITEM( attr, 0, PyInt_FromLong(edge->v2) );
 		PyTuple_SET_ITEM( attr, 1, PyInt_FromLong(edge->v1) );





More information about the Bf-blender-cvs mailing list