Python API

----------
Bugfix/enhancement: allow image of mesh's UV faces to be removed/cleared by
"del f.image" or "f.image = None", and handle image user counts correctly
when assigning/clearing images.
This commit is contained in:
Ken Hughes
2006-12-20 22:56:58 +00:00
parent 006647fd22
commit 368928220d
2 changed files with 18 additions and 11 deletions

View File

@@ -3729,6 +3729,10 @@ static int MFace_setImage( BPy_MFace *self, PyObject *value )
if( !MFace_get_pointer( self ) )
return -1;
if( value && value != Py_None && !BPy_Image_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected image object or None" );
if( !self->mesh->mtface )
#if 0
return EXPP_ReturnIntError( PyExc_ValueError,
@@ -3738,17 +3742,19 @@ static int MFace_setImage( BPy_MFace *self, PyObject *value )
#endif
face = &self->mesh->mtface[self->index];
if( value == Py_None )
face->tpage = NULL; /* should memory be freed? */
else {
if( !BPy_Image_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected image object" );
face->tpage = ( ( BPy_Image * ) value )->image;
face->mode |= TF_TEX;
}
return 0;
if( face->tpage )
face->tpage->id.us--;
if( value == NULL || value == Py_None )
face->tpage = NULL; /* should memory be freed? */
else {
face->tpage = ( ( BPy_Image * ) value )->image;
face->tpage->id.us++;
face->mode |= TF_TEX;
}
return 0;
}
#define MFACE_FLAG_BITMASK ( TF_SELECT | TF_ACTIVE | TF_SEL1 | \

View File

@@ -537,7 +537,8 @@ class MFace:
Getting this attribute throw an exception if the mesh does not have
UV faces; use L{Mesh.faceUV} to test.
Assigning an image will automatically set the TEX attribute of the
L{mode} bitfield.
L{mode} bitfield. Use "del f.image" or "f.image = None" to clear the
image assigned to the face.
@type image: Image
@ivar mode: The texture mode bitfield (see L{FaceModes}).
Will throw an exception if the mesh does not have UV faces; use