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:
authorKen Hughes <khughes@pacific.edu>2006-02-05 10:19:37 +0300
committerKen Hughes <khughes@pacific.edu>2006-02-05 10:19:37 +0300
commiteb185d7032231b5bde9c83b055236e7f63a70be3 (patch)
treee83a301f9591b9f8c94f33ab8782b46d2fe0c2a4 /source
parent3d3f5d1640d5eca8d144d0f348eb08c25298039e (diff)
==Python API==
A couple of bug fixes and enhancements: (1) Setting the UV attributes of a mesh face will create texture faces if they are not already defined. Previously this threw an exception. (2) Setting the image attribute of a mesh face will also set the TEX bit of the face.mode flag (3) When "sticky" vertices are created with mesh.vertexUV, the color is set to white instead of black. (4) Bugfix #3872: copying the mode attribute of one mesh to another would sometimes result in an exception due to unexpected bits being set. I still don't know how these other bits are being set, but this patch will stop the complaint if they are set.
Diffstat (limited to 'source')
-rw-r--r--source/blender/python/api2_2x/Mesh.c47
1 files changed, 32 insertions, 15 deletions
diff --git a/source/blender/python/api2_2x/Mesh.c b/source/blender/python/api2_2x/Mesh.c
index 91b86947a83..a089863ddcf 100644
--- a/source/blender/python/api2_2x/Mesh.c
+++ b/source/blender/python/api2_2x/Mesh.c
@@ -2461,7 +2461,7 @@ static PyObject *MEdgeSeq_extend( BPy_MEdgeSeq * self, PyObject *args )
case 1:
/* if a sequence... */
tmp = PyTuple_GET_ITEM( args, 0 );
- if( PySequence_Check( tmp ) ) {
+ if( PySequence_Check( tmp ) && PySequence_Size( tmp ) == 1 ) {
/* if another sequence, use it */
PyObject *tmp2 = PySequence_ITEM( tmp, 0 );
if( PySequence_Check( tmp2 ) )
@@ -3204,13 +3204,18 @@ static PyObject *MFace_getImage( BPy_MFace *self )
static int MFace_setImage( BPy_MFace *self, PyObject *value )
{
TFace *face;
- if( !self->mesh->tface )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "face has no texture values" );
if( !MFace_get_pointer( self ) )
return -1;
+ if( !self->mesh->tface )
+#if 0
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "face has no texture values" );
+#else
+ make_tfaces( self->mesh );
+#endif
+
face = &self->mesh->tface[self->index];
if( value == Py_None )
face->tpage = NULL; /* should memory be freed? */
@@ -3219,6 +3224,7 @@ static int MFace_setImage( BPy_MFace *self, PyObject *value )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected image object" );
face->tpage = ( ( BPy_Image * ) value )->image;
+ face->mode |= TF_TEX;
}
return 0;
@@ -3449,10 +3455,6 @@ static int MFace_setUV( BPy_MFace * self, PyObject * value )
TFace *face;
int length, i;
- if( !self->mesh->tface )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "face has no texture values" );
-
if( !MFace_get_pointer( self ) )
return -1;
@@ -3466,6 +3468,14 @@ static int MFace_setUV( BPy_MFace * self, PyObject * value )
return EXPP_ReturnIntError( PyExc_TypeError,
"size of vertex and UV sequences differ" );
+ if( !self->mesh->tface )
+#if 0
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "face has no texture values" );
+#else
+ make_tfaces( self->mesh );
+#endif
+
face = &self->mesh->tface[self->index];
for( i=0; i<length; ++i ) {
VectorObject *vector = (VectorObject *)PySequence_ITEM( value, i );
@@ -3525,10 +3535,6 @@ static int MFace_setUVSel( BPy_MFace * self, PyObject * value )
TFace *face;
int length, i, mask;
- if( !self->mesh->tface )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "face has no texture values" );
-
if( !MFace_get_pointer( self ) )
return -1;
@@ -3541,6 +3547,14 @@ static int MFace_setUVSel( BPy_MFace * self, PyObject * value )
return EXPP_ReturnIntError( PyExc_TypeError,
"size of vertex and UV lists differ" );
+ if( !self->mesh->tface )
+#if 0
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "face has no texture values" );
+#else
+ make_tfaces( self->mesh );
+#endif
+
/* set coord select state, one bit at a time */
face = &self->mesh->tface[self->index];
mask = TF_SEL1;
@@ -4014,7 +4028,7 @@ static PyObject *MFaceSeq_extend( BPy_MEdgeSeq * self, PyObject *args )
case 1: /* better be a sequence or a tuple */
/* if a sequence... */
tmp = PyTuple_GET_ITEM( args, 0 );
- if( PySequence_Check( tmp ) ) {
+ if( PySequence_Check( tmp ) && PySequence_Size( tmp ) == 1 ) {
/* if another sequence, use it */
PyObject *tmp2 = PySequence_ITEM( tmp, 0 );
if( PySequence_Check( tmp2 ) )
@@ -6118,8 +6132,9 @@ static int Mesh_setFlag( BPy_Mesh * self, PyObject *value, void *type )
}
} else {
if( !mesh->msticky ) {
- mesh->msticky= MEM_callocN( mesh->totvert*sizeof( MSticky ),
+ mesh->msticky= MEM_mallocN( mesh->totvert*sizeof( MSticky ),
"sticky" );
+ memset( mesh->msticky, 255, mesh->totvert*sizeof( MSticky ) );
/* TODO: rework RE_make_sticky() so we can calculate */
}
}
@@ -6144,7 +6159,9 @@ static PyObject *Mesh_getMode( BPy_Mesh * self )
static int Mesh_setMode( BPy_Mesh *self, PyObject *value )
{
short param;
- static short bitmask = ME_NOPUNOFLIP | ME_TWOSIDED | ME_AUTOSMOOTH;
+ static short bitmask = ME_ISDONE | ME_NOPUNOFLIP | ME_TWOSIDED |
+ ME_UVEFFECT | ME_VCOLEFFECT | ME_AUTOSMOOTH | ME_SMESH |
+ ME_SUBSURF | ME_OPT_EDGES;
if( !PyInt_CheckExact ( value ) ) {
char errstr[128];