Index: source/blender/blenkernel/BKE_customdata.h =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/blenkernel/BKE_customdata.h,v retrieving revision 1.16 diff -u -r1.16 BKE_customdata.h --- source/blender/blenkernel/BKE_customdata.h 2 May 2007 00:01:22 -0000 1.16 +++ source/blender/blenkernel/BKE_customdata.h 7 May 2007 14:20:03 -0000 @@ -40,6 +40,7 @@ extern const CustomDataMask CD_MASK_MESH; extern const CustomDataMask CD_MASK_EDITMESH; extern const CustomDataMask CD_MASK_DERIVEDMESH; +extern const CustomDataMask CD_MASK_PROPS; /* for ORIGINDEX layer type, indicates no original index for this element */ #define ORIGINDEX_NONE -1 Index: source/blender/blenkernel/intern/customdata.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/blenkernel/intern/customdata.c,v retrieving revision 1.21 diff -u -r1.21 customdata.c --- source/blender/blenkernel/intern/customdata.c 2 May 2007 00:01:23 -0000 1.21 +++ source/blender/blenkernel/intern/customdata.c 7 May 2007 14:20:04 -0000 @@ -367,11 +367,14 @@ /* 3 floats per normal vector */ {sizeof(float)*3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL}, {sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, NULL}, + {sizeof(MProp_F), "MProp_F",1,"Float",NULL,NULL,NULL,NULL}, + {sizeof(MProp_I), "MProp_I",1,"Int",NULL,NULL,NULL,NULL}, + {sizeof(MProp_S), "MProp_S",1,"String",NULL,NULL,NULL,NULL}, }; const char *LAYERTYPENAMES[CD_NUMTYPES] = { "CDMVert", "CDMSticky", "CDMDeformVert", "CDMEdge", "CDMFace", "CDMTFace", - "CDMCol", "CDOrigIndex", "CDNormal", "CDFlags"}; + "CDMCol", "CDOrigIndex", "CDNormal", "CDFlags","CDMProp_F","CDMProp_I","CDMProp_S"}; const CustomDataMask CD_MASK_BAREMESH = CD_MASK_MVERT | CD_MASK_MEDGE | CD_MASK_MFACE; @@ -380,10 +383,12 @@ CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE | CD_MASK_MCOL; const CustomDataMask CD_MASK_EDITMESH = CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE | - CD_MASK_MCOL; + CD_MASK_MCOL|CD_MASK_PROP_FLT|CD_MASK_PROP_INT|CD_MASK_PROP_STR; const CustomDataMask CD_MASK_DERIVEDMESH = CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE | CD_MASK_MCOL | CD_MASK_ORIGINDEX; +const CustomDataMask CD_MASK_PROPS= + CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR; static const LayerTypeInfo *layerType_getInfo(int type) { @@ -1355,9 +1360,17 @@ /* see if there is a duplicate */ for(i=0; itotlayer; i++) { layer = &data->layers[i]; - - if(i!=index && layer->type==type && strcmp(layer->name, name)==0) - break; + + if((type == CD_PROP_FLT) || (type == CD_PROP_INT) || (type == CD_PROP_STR)){ + if(i!=index && ((layer->type==CD_PROP_FLT) || (layer->type == CD_PROP_INT) || (layer->type == CD_PROP_STR)) && + strcmp(layer->name, name)==0) + break; + + } + else{ + if(i!=index && layer->type==type && strcmp(layer->name, name)==0) + break; + } } if(i == data->totlayer) @@ -1373,8 +1386,16 @@ for(i=0; itotlayer; i++) { layer = &data->layers[i]; - if(i!=index && layer->type==type && strcmp(layer->name, tempname)==0) + if((type == CD_PROP_FLT) || (type == CD_PROP_INT) || (type == CD_PROP_STR)){ + if(i!=index && ((layer->type==CD_PROP_FLT)||(layer->type==CD_PROP_INT)||(layer->type==CD_PROP_STR)) && + strcmp(layer->name, tempname)==0) + break; + } + else{ + if(i!=index && layer->type==type && strcmp(layer->name, tempname)==0) + break; + } } if(i == data->totlayer) { Index: source/blender/blenkernel/intern/mesh.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/blenkernel/intern/mesh.c,v retrieving revision 1.85 diff -u -r1.85 mesh.c --- source/blender/blenkernel/intern/mesh.c 29 Apr 2007 13:39:45 -0000 1.85 +++ source/blender/blenkernel/intern/mesh.c 7 May 2007 14:20:04 -0000 @@ -261,9 +261,9 @@ } id_us_plus((ID *)men->texcomesh); - CustomData_copy(&me->vdata, &men->vdata, CD_MASK_MESH, CD_DUPLICATE, men->totvert); - CustomData_copy(&me->edata, &men->edata, CD_MASK_MESH, CD_DUPLICATE, men->totedge); - CustomData_copy(&me->fdata, &men->fdata, CD_MASK_MESH, CD_DUPLICATE, men->totface); + CustomData_copy(&me->vdata, &men->vdata, CD_MASK_MESH|CD_MASK_PROPS, CD_DUPLICATE, men->totvert); + CustomData_copy(&me->edata, &men->edata, CD_MASK_MESH|CD_MASK_PROPS, CD_DUPLICATE, men->totedge); + CustomData_copy(&me->fdata, &men->fdata, CD_MASK_MESH|CD_MASK_PROPS, CD_DUPLICATE, men->totface); mesh_update_customdata_pointers(men); /* ensure indirect linked data becomes lib-extern */ Index: source/blender/blenlib/BLI_editVert.h =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/blenlib/BLI_editVert.h,v retrieving revision 1.32 diff -u -r1.32 BLI_editVert.h --- source/blender/blenlib/BLI_editVert.h 27 Jan 2007 18:11:06 -0000 1.32 +++ source/blender/blenlib/BLI_editVert.h 7 May 2007 14:20:04 -0000 @@ -106,6 +106,7 @@ short fast; /* only 0 or 1, for editmesh_fastmalloc */ short fgoni; /* index for fgon, for search */ HashEdge hash; + void *data; /* custom edge data */ } EditEdge; /* note; changing this also might affect the undo copy in editmesh.c */ @@ -171,7 +172,7 @@ struct RetopoPaintData *retopo_paint_data; - CustomData vdata, fdata; + CustomData vdata, edata, fdata; #ifdef WITH_VERSE void *vnode; Index: source/blender/makesdna/DNA_customdata_types.h =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/makesdna/DNA_customdata_types.h,v retrieving revision 1.7 diff -u -r1.7 DNA_customdata_types.h --- source/blender/makesdna/DNA_customdata_types.h 2 May 2007 00:01:23 -0000 1.7 +++ source/blender/makesdna/DNA_customdata_types.h 7 May 2007 14:20:05 -0000 @@ -64,7 +64,10 @@ #define CD_ORIGINDEX 7 #define CD_NORMAL 8 #define CD_FLAGS 9 -#define CD_NUMTYPES 10 +#define CD_PROP_FLT 10 +#define CD_PROP_INT 11 +#define CD_PROP_STR 12 +#define CD_NUMTYPES 13 /* Bits for CustomDataMask */ #define CD_MASK_MVERT (1 << CD_MVERT) @@ -77,6 +80,9 @@ #define CD_MASK_ORIGINDEX (1 << CD_ORIGINDEX) #define CD_MASK_NORMAL (1 << CD_NORMAL) #define CD_MASK_FLAGS (1 << CD_FLAGS) +#define CD_MASK_PROP_FLT (1 << CD_PROP_FLT) +#define CD_MASK_PROP_INT (1 << CD_PROP_INT) +#define CD_MASK_PROP_STR (1 << CD_PROP_STR) /* CustomData.flag */ Index: source/blender/makesdna/DNA_meshdata_types.h =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/makesdna/DNA_meshdata_types.h,v retrieving revision 1.34 diff -u -r1.34 DNA_meshdata_types.h --- source/blender/makesdna/DNA_meshdata_types.h 29 Apr 2007 13:39:45 -0000 1.34 +++ source/blender/makesdna/DNA_meshdata_types.h 7 May 2007 14:20:05 -0000 @@ -86,6 +86,17 @@ short mode, tile, unwrap; } MTFace; +/*seems like a waste...*/ +typedef struct MProp_F{ + float f; +} MProp_F; +typedef struct MProp_I{ + int i; +} MProp_I; +typedef struct MProp_S{ + char s[256]; +} MProp_S; + /* Multiresolution modeling */ typedef struct MultiresCol { float a, r, g, b; Index: source/blender/python/api2_2x/Mesh.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Mesh.c,v retrieving revision 1.140 diff -u -r1.140 Mesh.c --- source/blender/python/api2_2x/Mesh.c 2 May 2007 00:49:40 -0000 1.140 +++ source/blender/python/api2_2x/Mesh.c 7 May 2007 14:20:08 -0000 @@ -313,7 +313,7 @@ int i, count, state, dstindex, totvert; totvert = mesh->totvert - to_delete; - CustomData_copy( &mesh->vdata, &vdata, CD_MASK_MESH, CD_CALLOC, totvert ); + CustomData_copy( &mesh->vdata, &vdata, CD_MASK_MESH|CD_MASK_PROPS, CD_CALLOC, totvert ); /* * do "smart compaction" of the table; find and copy groups of vertices @@ -383,7 +383,7 @@ /* allocate new edge list and populate */ totedge = mesh->totedge - to_delete; - CustomData_copy( &mesh->edata, &edata, CD_MASK_MESH, CD_CALLOC, totedge); + CustomData_copy( &mesh->edata, &edata, CD_MASK_MESH|CD_MASK_PROPS, CD_CALLOC, totedge); /* * do "smart compaction" of the edges; find and copy groups of edges @@ -478,7 +478,7 @@ int count, state, dstindex, totface; totface = mesh->totface - to_delete; - CustomData_copy( &mesh->fdata, &fdata, CD_MASK_MESH, CD_CALLOC, totface ); + CustomData_copy( &mesh->fdata, &fdata, CD_MASK_MESH|CD_MASK_PROPS, CD_CALLOC, totface ); /* * do "smart compaction" of the faces; find and copy groups of faces @@ -1085,6 +1085,8 @@ return newVectorObject( me->msticky[self->index].co, 2, Py_WRAP ); } + + /* * set a vertex's UV coordinates */ @@ -1129,6 +1131,8 @@ return 0; } + + /************************************************************************ * * Python MVert_Type attributes get/set structure @@ -1226,6 +1230,225 @@ return (long)self->index; } + +static PyObject *Mesh_addPropLayer_internal(Mesh *mesh, CustomData *data, int tot, PyObject *args) +{ + char *name=NULL; + int type = -1; + + if( !PyArg_ParseTuple( args, "si", &name, &type) ) + return EXPP_ReturnPyObjError( PyExc_TypeError, + "expected a string and an int" ); + if (strlen(name)>31) + return EXPP_ReturnPyObjError( PyExc_ValueError, + "error, maximum name length is 31"); + if((type != CD_PROP_FLT) && (type != CD_PROP_INT) && (type != CD_PROP_STR)) + return EXPP_ReturnPyObjError( PyExc_ValueError, + "error, unknown layer type"); + if (name) + CustomData_add_layer_named(data, type, CD_DEFAULT, NULL,tot,name); + + mesh_update_customdata_pointers(mesh); + Py_RETURN_NONE; +} + +static PyObject *Mesh_removePropLayer_internal(Mesh *mesh, CustomData *data, int tot,PyObject *args) +{ + CustomDataLayer *layer; + char *name=NULL; + int i; + + if( !PyArg_ParseTuple( args, "s", &name ) ) + return EXPP_ReturnPyObjError( PyExc_TypeError, + "expected string argument" ); + + if (strlen(name)>31) + return EXPP_ReturnPyObjError( PyExc_ValueError, + "error, maximum name length is 31" ); + + i = CustomData_get_named_layer_index(data, CD_PROP_FLT, name); + if(i == -1) i = CustomData_get_named_layer_index(data, CD_PROP_INT, name); + if(i == -1) i = CustomData_get_named_layer_index(data, CD_PROP_STR, name); + if (i==-1) + return EXPP_ReturnPyObjError(PyExc_ValueError, + "No matching layers to remove" ); + layer = &data->layers[i]; + CustomData_free_layer(data, layer->type, tot, i); + mesh_update_customdata_pointers(mesh); + + Py_RETURN_NONE; +} + +static PyObject *Mesh_renamePropLayer_internal(Mesh *mesh, CustomData *data, PyObject *args) +{ + CustomDataLayer *layer; + int i; + char *name_from, *name_to; + + if( !PyArg_ParseTuple( args, "ss", &name_from, &name_to ) ) + return EXPP_ReturnPyObjError( PyExc_TypeError, + "expected 2 strings" ); + + if (strlen(name_from)>31 || strlen(name_to)>31) + return EXPP_ReturnPyObjError( PyExc_ValueError, + "error, maximum name length is 31" ); + + i = CustomData_get_named_layer_index(data, CD_PROP_FLT, name_from); + if(i == -1) i = CustomData_get_named_layer_index(data, CD_PROP_INT, name_from); + if(i == -1) i = CustomData_get_named_layer_index(data, CD_PROP_STR, name_from); + if(i == -1) + return EXPP_ReturnPyObjError(PyExc_ValueError, + "No matching layers to rename" ); + + layer = &data->layers[i]; + + strcpy(layer->name, name_to); /* we alredy know the string sizes are under 32 */ + CustomData_set_layer_unique_name(data, i); + Py_RETURN_NONE; +} + +static PyObject *Mesh_propList_internal(CustomData *data) +{ + CustomDataLayer *layer; + PyObject *list = PyList_New( 0 ); + int i; + for(i=0; itotlayer; i++) { + layer = &data->layers[i]; + if( (layer->type == CD_PROP_FLT) || (layer->type == CD_PROP_INT) || (layer->type == CD_PROP_STR)) { + PyList_Append( list, PyString_FromString(layer->name) ); + } + } + return list; +} + +static PyObject *Mesh_getProperty_internal(CustomData *data, int eindex, PyObject *args) +{ + CustomDataLayer *layer; + char *name=NULL; + int i; + MProp_F *pf; + MProp_I *pi; + MProp_S *ps; + + if(!PyArg_ParseTuple(args, "s", &name)) + return EXPP_ReturnPyObjError( PyExc_TypeError, + "expected an string argument" ); + + if (strlen(name)>31) + return EXPP_ReturnPyObjError( PyExc_ValueError, + "error, maximum name length is 31" ); + + i = CustomData_get_named_layer_index(data, CD_PROP_FLT, name); + if(i == -1) i = CustomData_get_named_layer_index(data, CD_PROP_INT, name); + if(i == -1) i = CustomData_get_named_layer_index(data, CD_PROP_STR, name); + if(i == -1) + return EXPP_ReturnPyObjError(PyExc_ValueError, + "No matching layers" ); + + layer = &data->layers[i]; + + if(layer->type == CD_PROP_FLT){ + pf = layer->data; + return PyFloat_FromDouble(pf[eindex].f); + } + else if(layer->type == CD_PROP_INT){ + pi = layer->data; + return PyInt_FromLong(pi[eindex].i); + + } + else if(layer->type == CD_PROP_STR){ + ps = layer->data; + return PyString_FromString(ps[eindex].s); + } + + Py_RETURN_NONE; +} + +static PyObject *Mesh_setProperty_internal(CustomData *data, int eindex, PyObject *args) +{ + CustomDataLayer *layer; + int i,index, type = -1; + float f; + char *s=NULL, *name=NULL; + MProp_F *pf; + MProp_I *pi; + MProp_S *ps; + + if(PyArg_ParseTuple(args, "sf", &name, &f)) type = CD_PROP_FLT; + else if(PyArg_ParseTuple(args, "si", &name, &i)) type = CD_PROP_INT; + else if(PyArg_ParseTuple(args, "ss", &name, &s)) type = CD_PROP_STR; + else + return EXPP_ReturnPyObjError( PyExc_TypeError, + "expected an name plus either float/int/string" ); + + if (strlen(name)>31) + return EXPP_ReturnPyObjError( PyExc_ValueError, + "error, maximum name length is 31" ); + + i = CustomData_get_named_layer_index(data, type, name); + if(i == -1) + return EXPP_ReturnPyObjError(PyExc_ValueError, + "No matching layers or type mismatch" ); + + layer = &data->layers[i]; + + if(type==CD_PROP_STR){ + if (strlen(s)>255){ + return EXPP_ReturnPyObjError( PyExc_ValueError, + "error, maximum string length is 255"); + } + else{ + ps = layer->data; + strcpy(ps[eindex].s,s); + } + } + else if(type==CD_PROP_FLT){ + pf = layer->data; + pf[eindex].f = f; + } + else{ + pi = layer->data; + pi[eindex].i = i; + } + Py_RETURN_NONE; +} + +static PyObject *MVert_getProp( BPy_MVert *self, PyObject *args) +{ + if( BPy_MVert_Check( self ) ){ + Mesh *me = (Mesh *)self->data; + if(self->index >= me->totvert) + return EXPP_ReturnPyObjError( PyExc_ValueError, + "error, MVert is no longer valid part of mesh!"); + else + return Mesh_getProperty_internal(&(me->vdata), self->index, args); + } + return EXPP_ReturnPyObjError( PyExc_ValueError, + "error, Vertex not part of a mesh!"); +} + +static PyObject *MVert_setProp( BPy_MVert *self, PyObject *args) +{ + if( BPy_MVert_Check( self ) ){ + Mesh *me = (Mesh *)self->data; + if(self->index >= me->totvert) + return EXPP_ReturnPyObjError( PyExc_ValueError, + "error, MVert is no longer valid part of mesh!"); + else + return Mesh_setProperty_internal(&(me->vdata), self->index, args); + } + return EXPP_ReturnPyObjError( PyExc_ValueError, + "error, Vertex not part of a mesh!"); +} + +static struct PyMethodDef BPy_MVert_methods[] = { + {"getProperty", (PyCFunction)MVert_getProp, METH_VARARGS, + "get property indicated by name"}, + {"setProperty", (PyCFunction)MVert_setProp, METH_VARARGS, + "set property indicated by name"}, + {NULL, NULL, 0, NULL} +}; + /************************************************************************ * * Python MVert_Type structure definition @@ -1290,7 +1513,7 @@ NULL, /* iternextfunc tp_iternext; */ /*** Attribute descriptor and subclassing stuff ***/ - NULL, /* struct PyMethodDef *tp_methods; */ + BPy_MVert_methods, /* struct PyMethodDef *tp_methods; */ NULL, /* struct PyMemberDef *tp_members; */ BPy_MVert_getseters, /* struct PyGetSetDef *tp_getset; */ NULL, /* struct _typeobject *tp_base; */ @@ -1389,7 +1612,7 @@ NULL, /* iternextfunc tp_iternext; */ /*** Attribute descriptor and subclassing stuff ***/ - NULL, /* struct PyMethodDef *tp_methods; */ + NULL, /* struct PyMethodDef *tp_methods; */ NULL, /* struct PyMemberDef *tp_members; */ BPy_PVert_getseters, /* struct PyGetSetDef *tp_getset; */ NULL, /* struct _typeobject *tp_base; */ @@ -1719,7 +1942,7 @@ /* create custom vertex data arrays and copy existing vertices into it */ newlen = mesh->totvert + len; - CustomData_copy( &mesh->vdata, &vdata, CD_MASK_MESH, CD_DEFAULT, newlen ); + CustomData_copy( &mesh->vdata, &vdata, CD_MASK_MESH|CD_MASK_PROPS, CD_DEFAULT, newlen ); CustomData_copy_data( &mesh->vdata, &vdata, 0, 0, mesh->totvert ); if ( !CustomData_has_layer( &vdata, CD_MVERT ) ) @@ -1955,6 +2178,37 @@ } return list; } +static PyObject *MVertSeq_add_layertype(BPy_MVertSeq *self, PyObject *args) +{ + Mesh *me = (Mesh*)self->mesh; + return Mesh_addPropLayer_internal(me, &(me->vdata), me->totvert, args); +} +static PyObject *MVertSeq_del_layertype(BPy_MVertSeq *self, PyObject *args) +{ + Mesh *me = (Mesh*)self->mesh; + return Mesh_removePropLayer_internal(me, &(me->vdata), me->totvert, args); +} +static PyObject *MVertSeq_rename_layertype(BPy_MVertSeq *self, PyObject *args) +{ + Mesh *me = (Mesh*)self->mesh; + return Mesh_renamePropLayer_internal(me,&(me->vdata),args); +} +static PyObject *MVertSeq_PropertyList(BPy_MVertSeq *self) +{ + Mesh *me = (Mesh*)self->mesh; + return Mesh_propList_internal(&(me->vdata)); +} +static PyObject *M_Mesh_PropertiesTypeDict(void) +{ + PyObject *Types = PyConstant_New( ); + if(Types) { + BPy_constant *d = (BPy_constant *) Types; + PyConstant_Insert(d, "FLOAT", PyInt_FromLong(CD_PROP_FLT)); + PyConstant_Insert(d, "INT" , PyInt_FromLong(CD_PROP_INT)); + PyConstant_Insert(d, "STRING", PyInt_FromLong(CD_PROP_STR)); + } + return Types; +} static struct PyMethodDef BPy_MVertSeq_methods[] = { {"extend", (PyCFunction)MVertSeq_extend, METH_VARARGS, @@ -1963,9 +2217,25 @@ "delete vertices from mesh"}, {"selected", (PyCFunction)MVertSeq_selected, METH_NOARGS, "returns a list containing indices of selected vertices"}, + {"addPropertyLayer",(PyCFunction)MVertSeq_add_layertype, METH_VARARGS, + "add a new property layer"}, + {"removePropertyLayer",(PyCFunction)MVertSeq_del_layertype, METH_VARARGS, + "removes a property layer"}, + {"renamePropertyLayer",(PyCFunction)MVertSeq_rename_layertype, METH_VARARGS, + "renames an existing property layer"}, {NULL, NULL, 0, NULL} }; +static PyGetSetDef BPy_MVertSeq_getseters[] = { + {"properties", + (getter)MVertSeq_PropertyList, (setter)NULL, + "vertex property layers, read only", + NULL}, + {NULL,NULL,NULL,NULL,NULL} /* Sentinel */ +}; + + + /************************************************************************ * * Python MVertSeq_Type standard operations @@ -2035,7 +2305,7 @@ /*** Attribute descriptor and subclassing stuff ***/ BPy_MVertSeq_methods, /* struct PyMethodDef *tp_methods; */ NULL, /* struct PyMemberDef *tp_members; */ - NULL, /* struct PyGetSetDef *tp_getset; */ + BPy_MVertSeq_getseters, /* struct PyGetSetDef *tp_getset; */ NULL, /* struct _typeobject *tp_base; */ NULL, /* PyObject *tp_dict; */ NULL, /* descrgetfunc tp_descr_get; */ @@ -2057,6 +2327,9 @@ NULL }; + + + /************************************************************************ * * Edge attributes @@ -2453,6 +2726,25 @@ return (long)self->index; } +static PyObject *MEdge_getProp( BPy_MEdge *self, PyObject *args) +{ + Mesh *me = (Mesh *)self->mesh; + return Mesh_getProperty_internal(&(me->edata), self->index, args); +} + +static PyObject *MEdge_setProp( BPy_MEdge *self, PyObject *args) +{ + Mesh *me = (Mesh *)self->mesh; + return Mesh_setProperty_internal(&(me->edata), self->index, args); +} + +static struct PyMethodDef BPy_MEdge_methods[] = { + {"getProperty", (PyCFunction)MEdge_getProp, METH_VARARGS, + "get property indicated by name"}, + {"setProperty", (PyCFunction)MEdge_setProp, METH_VARARGS, + "set property indicated by name"}, + {NULL, NULL, 0, NULL} +}; /************************************************************************ * * Python MEdge_Type structure definition @@ -2517,7 +2809,7 @@ ( iternextfunc ) MEdge_nextIter, /* iternextfunc tp_iternext; */ /*** Attribute descriptor and subclassing stuff ***/ - NULL, /* struct PyMethodDef *tp_methods; */ + BPy_MEdge_methods, /* struct PyMethodDef *tp_methods; */ NULL, /* struct PyMemberDef *tp_members; */ BPy_MEdge_getseters, /* struct PyGetSetDef *tp_getset; */ NULL, /* struct _typeobject *tp_base; */ @@ -2901,7 +3193,7 @@ int totedge = mesh->totedge+good_edges; /* create custom edge data arrays and copy existing edges into it */ - CustomData_copy( &mesh->edata, &edata, CD_MASK_MESH, CD_DEFAULT, totedge ); + CustomData_copy( &mesh->edata, &edata, CD_MASK_MESH|CD_MASK_PROPS, CD_DEFAULT, totedge ); CustomData_copy_data( &mesh->edata, &edata, 0, 0, mesh->totedge ); if ( !CustomData_has_layer( &edata, CD_MEDGE ) ) @@ -3311,6 +3603,28 @@ return list; } +static PyObject *MEdgeSeq_add_layertype(BPy_MEdgeSeq *self, PyObject *args) +{ + Mesh *me = (Mesh*)self->mesh; + return Mesh_addPropLayer_internal(me, &(me->edata), me->totedge, args); +} +static PyObject *MEdgeSeq_del_layertype(BPy_MEdgeSeq *self, PyObject *args) +{ + Mesh *me = (Mesh*)self->mesh; + return Mesh_removePropLayer_internal(me, &(me->edata), me->totedge, args); +} +static PyObject *MEdgeSeq_rename_layertype(BPy_MEdgeSeq *self, PyObject *args) +{ + Mesh *me = (Mesh*)self->mesh; + return Mesh_renamePropLayer_internal(me,&(me->edata),args); +} +static PyObject *MEdgeSeq_PropertyList(BPy_MEdgeSeq *self) +{ + Mesh *me = (Mesh*)self->mesh; + return Mesh_propList_internal(&(me->edata)); +} + + static struct PyMethodDef BPy_MEdgeSeq_methods[] = { {"extend", (PyCFunction)MEdgeSeq_extend, METH_VARARGS, "add edges to mesh"}, @@ -3320,8 +3634,23 @@ "returns a list containing indices of selected edges"}, {"collapse", (PyCFunction)MEdgeSeq_collapse, METH_VARARGS, "collapse one or more edges to a vertex"}, + {"addPropertyLayer",(PyCFunction)MEdgeSeq_add_layertype, METH_VARARGS, + "add a new property layer"}, + {"removePropertyLayer",(PyCFunction)MEdgeSeq_del_layertype, METH_VARARGS, + "removes a property layer"}, + {"renamePropertyLayer",(PyCFunction)MEdgeSeq_rename_layertype, METH_VARARGS, + "renames an existing property layer"}, + {NULL, NULL, 0, NULL} }; +static PyGetSetDef BPy_MEdgeSeq_getseters[] = { + {"properties", + (getter)MEdgeSeq_PropertyList, (setter)NULL, + "edge property layers, read only", + NULL}, + {NULL,NULL,NULL,NULL,NULL} /* Sentinel */ +}; + /************************************************************************ * @@ -3392,7 +3721,7 @@ /*** Attribute descriptor and subclassing stuff ***/ BPy_MEdgeSeq_methods, /* struct PyMethodDef *tp_methods; */ NULL, /* struct PyMemberDef *tp_members; */ - NULL, /* struct PyGetSetDef *tp_getset; */ + BPy_MEdgeSeq_getseters, /* struct PyGetSetDef *tp_getset; */ NULL, /* struct _typeobject *tp_base; */ NULL, /* PyObject *tp_dict; */ NULL, /* descrgetfunc tp_descr_get; */ @@ -4469,6 +4798,25 @@ 0,0,0, }; +static PyObject *MFace_getProp( BPy_MFace *self, PyObject *args) +{ + Mesh *me = (Mesh *)self->mesh; + return Mesh_getProperty_internal(&(me->fdata), self->index, args); +} + +static PyObject *MFace_setProp( BPy_MFace *self, PyObject *args) +{ + Mesh *me = (Mesh *)self->mesh; + return Mesh_setProperty_internal(&(me->fdata), self->index, args); +} + +static struct PyMethodDef BPy_MFace_methods[] = { + {"getProperty", (PyCFunction)MFace_getProp, METH_VARARGS, + "get property indicated by name"}, + {"setProperty", (PyCFunction)MFace_setProp, METH_VARARGS, + "set property indicated by name"}, + {NULL, NULL, 0, NULL} +}; /************************************************************************ * * Python MFace_Type structure definition @@ -4533,7 +4881,7 @@ ( iternextfunc ) MFace_nextIter, /* iternextfunc tp_iternext; */ /*** Attribute descriptor and subclassing stuff ***/ - NULL, /* struct PyMethodDef *tp_methods; */ + BPy_MFace_methods, /* struct PyMethodDef *tp_methods; */ NULL, /* struct PyMemberDef *tp_members; */ BPy_MFace_getseters, /* struct PyGetSetDef *tp_getset; */ NULL, /* struct _typeobject *tp_base; */ @@ -4928,7 +5276,7 @@ int totface = mesh->totface+good_faces; /* new face count */ CustomData fdata; - CustomData_copy( &mesh->fdata, &fdata, CD_MASK_MESH, CD_DEFAULT, totface ); + CustomData_copy( &mesh->fdata, &fdata, CD_MASK_MESH|CD_MASK_PROPS, CD_DEFAULT, totface ); CustomData_copy_data( &mesh->fdata, &fdata, 0, 0, mesh->totface ); if ( !CustomData_has_layer( &fdata, CD_MFACE ) ) @@ -5242,6 +5590,27 @@ return list; } +static PyObject *MFaceSeq_add_layertype(BPy_MFaceSeq *self, PyObject *args) +{ + Mesh *me = (Mesh*)self->mesh; + return Mesh_addPropLayer_internal(me, &(me->fdata), me->totface, args); +} +static PyObject *MFaceSeq_del_layertype(BPy_MFaceSeq *self, PyObject *args) +{ + Mesh *me = (Mesh*)self->mesh; + return Mesh_removePropLayer_internal(me, &(me->fdata), me->totface, args); +} +static PyObject *MFaceSeq_rename_layertype(BPy_MFaceSeq *self, PyObject *args) +{ + Mesh *me = (Mesh*)self->mesh; + return Mesh_renamePropLayer_internal(me,&(me->fdata),args); +} +static PyObject *MFaceSeq_PropertyList(BPy_MFaceSeq *self) +{ + Mesh *me = (Mesh*)self->mesh; + return Mesh_propList_internal(&(me->fdata)); +} + static struct PyMethodDef BPy_MFaceSeq_methods[] = { {"extend", (PyCFunction)MFaceSeq_extend, METH_VARARGS|METH_KEYWORDS, "add faces to mesh"}, @@ -5249,8 +5618,22 @@ "delete faces from mesh"}, {"selected", (PyCFunction)MFaceSeq_selected, METH_NOARGS, "returns a list containing indices of selected faces"}, + {"addPropertyLayer",(PyCFunction)MFaceSeq_add_layertype, METH_VARARGS, + "add a new property layer"}, + {"removePropertyLayer",(PyCFunction)MFaceSeq_del_layertype, METH_VARARGS, + "removes a property layer"}, + {"renamePropertyLayer",(PyCFunction)MFaceSeq_rename_layertype, METH_VARARGS, + "renames an existing property layer"}, {NULL, NULL, 0, NULL} }; +static PyGetSetDef BPy_MFaceSeq_getseters[] = { + {"properties", + (getter)MFaceSeq_PropertyList, (setter)NULL, + "vertex property layers, read only", + NULL}, + {NULL,NULL,NULL,NULL,NULL} /* Sentinel */ +}; + /************************************************************************ * @@ -5321,7 +5704,7 @@ /*** Attribute descriptor and subclassing stuff ***/ BPy_MFaceSeq_methods, /* struct PyMethodDef *tp_methods; */ NULL, /* struct PyMemberDef *tp_members; */ - NULL, /* struct PyGetSetDef *tp_getset; */ + BPy_MFaceSeq_getseters, /* struct PyGetSetDef *tp_getset; */ NULL, /* struct _typeobject *tp_base; */ NULL, /* PyObject *tp_dict; */ NULL, /* descrgetfunc tp_descr_get; */ @@ -8137,6 +8520,7 @@ PyObject *EdgeFlags = M_Mesh_EdgeFlagsDict( ); PyObject *AssignModes = M_Mesh_VertAssignDict( ); PyObject *SelectModes = M_Mesh_SelectModeDict( ); + PyObject *PropertyTypes = M_Mesh_PropertiesTypeDict( ); if( PyType_Ready( &MCol_Type ) < 0 ) return NULL; @@ -8177,7 +8561,8 @@ PyModule_AddObject( submodule, "AssignModes", AssignModes ); if( SelectModes ) PyModule_AddObject( submodule, "SelectModes", SelectModes ); - + if( PropertyTypes ) + PyModule_AddObject( submodule, "PropertyTypes", PropertyTypes ); return submodule; } Index: source/blender/src/editmesh.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/src/editmesh.c,v retrieving revision 1.205 diff -u -r1.205 editmesh.c --- source/blender/src/editmesh.c 29 Apr 2007 13:39:45 -0000 1.205 +++ source/blender/src/editmesh.c 7 May 2007 14:20:11 -0000 @@ -859,6 +859,7 @@ else { MEdge *medge= me->medge; + CustomData_copy(&me->edata, &em->edata, CD_MASK_PROPS, CD_CALLOC, 0); /* make edges */ for(a=0; atotedge; a++, medge++) { eed= addedgelist(evlist[medge->v1], evlist[medge->v2], NULL); @@ -873,6 +874,8 @@ if(medge->flag & ME_HIDE) eed->h |= 1; if(G.scene->selectmode==SCE_SELECT_EDGE) EM_select_edge(eed, eed->f & SELECT); // force edge selection to vertices, seems to be needed ... + + CustomData_to_em_block(&me->edata,&em->edata, a, &eed->data); } } @@ -1013,8 +1016,9 @@ me->totedge= totedge; me->totface= G.totface; - CustomData_copy(&em->vdata, &me->vdata, CD_MASK_MESH, CD_CALLOC, me->totvert); - CustomData_copy(&em->fdata, &me->fdata, CD_MASK_MESH, CD_CALLOC, me->totface); + CustomData_copy(&em->vdata, &me->vdata, CD_MASK_MESH|CD_MASK_PROPS, CD_CALLOC, me->totvert); + CustomData_copy(&em->edata, &me->edata, CD_MASK_PROPS, CD_CALLOC, me->totedge); + CustomData_copy(&em->fdata, &me->fdata, CD_MASK_MESH|CD_MASK_PROPS, CD_CALLOC, me->totface); CustomData_add_layer(&me->vdata, CD_MVERT, CD_ASSIGN, mvert, me->totvert); CustomData_add_layer(&me->edata, CD_MEDGE, CD_ASSIGN, medge, me->totedge); @@ -1071,7 +1075,8 @@ if(eed->h & 1) medge->flag |= ME_HIDE; medge->crease= (char)(255.0*eed->crease); - + CustomData_from_em_block(&em->edata, &me->edata, eed->data, a); + eed->tmp.l = a++; medge++; Index: source/blender/src/meshtools.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/src/meshtools.c,v retrieving revision 1.60 diff -u -r1.60 meshtools.c --- source/blender/src/meshtools.c 22 Apr 2007 22:08:19 -0000 1.60 +++ source/blender/src/meshtools.c 7 May 2007 14:20:11 -0000 @@ -295,7 +295,7 @@ me= base->object->data; if(me->totvert) { - CustomData_merge(&me->vdata, &vdata, CD_MASK_MESH, CD_DEFAULT, totvert); + CustomData_merge(&me->vdata, &vdata, CD_MASK_MESH|CD_MASK_PROPS, CD_DEFAULT, totvert); CustomData_copy_data(&me->vdata, &vdata, 0, vertofs, me->totvert); dvert= CustomData_get(&vdata, vertofs, CD_MDEFORMVERT); @@ -347,7 +347,7 @@ } } - CustomData_merge(&me->fdata, &fdata, CD_MASK_MESH, CD_DEFAULT, totface); + CustomData_merge(&me->fdata, &fdata, CD_MASK_MESH|CD_MASK_PROPS, CD_DEFAULT, totface); CustomData_copy_data(&me->fdata, &fdata, 0, faceofs, me->totface); for(a=0; atotface; a++, mface++) { @@ -363,7 +363,7 @@ } if(me->totedge) { - CustomData_merge(&me->edata, &edata, CD_MASK_MESH, CD_DEFAULT, totedge); + CustomData_merge(&me->edata, &edata, CD_MASK_MESH|CD_MASK_PROPS, CD_DEFAULT, totedge); CustomData_copy_data(&me->edata, &edata, 0, edgeofs, me->totedge); for(a=0; atotedge; a++, medge++) {