diff options
author | Geoffrey Bantle <hairbat@yahoo.com> | 2007-06-04 23:18:19 +0400 |
---|---|---|
committer | Geoffrey Bantle <hairbat@yahoo.com> | 2007-06-04 23:18:19 +0400 |
commit | ba958bea0f4b49f87644fdf02cbc2ebba826a6b8 (patch) | |
tree | c77b55535bcedafc71b11e279c9c00f5256f7d31 /source/blender/blenkernel | |
parent | d5ee6fc865f16bd3abe1ad7d2fe6aa0be43576a9 (diff) |
-> Custom Properties for Mesh entities
In order to give import/export script authors the ability to add properties
to inidividual faces, vertices and edges in the same manner as they are able
to do with ID structures three new custom data types have been added to blender
for floats, integers and strings.
Things to note:
-Since property Layers are custom data, they are added to all verts, edges
or faces at once.
-Only one property layer for each unique property name may exist. In other
words, you cannot have a float layer as well as an integer layer
both with the same name.
-No user interface for this exists at the moment.
The following methods and attributes have been added to the Blender.Mesh
Python module and it's object types:
->MVert/Edge/FaceSeq:
addPropertyLayer(name, type)
removePropertyLayer(name)
renamePropertyLayer(original name, new name)
properties(readonly list.)
->MVert/Edge/Face
getProperty(name)
setProperty(name, value)
->Mesh module
PropertyTypes (readonly dictionary)
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/customdata.c | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index e239583c4eb..2c8199f90f3 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -367,20 +367,24 @@ const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { /* 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(MFloatProperty), "MFloatProperty",1,"Float",NULL,NULL,NULL,NULL}, + {sizeof(MIntProperty), "MIntProperty",1,"Int",NULL,NULL,NULL,NULL}, + {sizeof(MStringProperty), "MStringProperty",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","CDMFloatProperty","CDMIntProperty","CDMStringProperty"}; const CustomDataMask CD_MASK_BAREMESH = CD_MASK_MVERT | CD_MASK_MEDGE | CD_MASK_MFACE; const CustomDataMask CD_MASK_MESH = CD_MASK_MVERT | CD_MASK_MEDGE | CD_MASK_MFACE | - CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE | CD_MASK_MCOL; + CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE | CD_MASK_MCOL | + CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR; 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; @@ -1335,6 +1339,13 @@ const char *CustomData_layertype_name(int type) return layerType_getName(type); } +static int CustomData_is_property_layer(int type) +{ + if((type == CD_PROP_FLT) || (type == CD_PROP_INT) || (type == CD_PROP_STR)) + return 1; + return 0; +} + void CustomData_set_layer_unique_name(CustomData *data, int index) { char tempname[64]; @@ -1355,9 +1366,17 @@ void CustomData_set_layer_unique_name(CustomData *data, int index) /* see if there is a duplicate */ for(i=0; i<data->totlayer; i++) { layer = &data->layers[i]; - - if(i!=index && layer->type==type && strcmp(layer->name, name)==0) - break; + + if(CustomData_is_property_layer(type)){ + if(i!=index && CustomData_is_property_layer(layer->type) && + 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 +1392,16 @@ void CustomData_set_layer_unique_name(CustomData *data, int index) for(i=0; i<data->totlayer; i++) { layer = &data->layers[i]; - if(i!=index && layer->type==type && strcmp(layer->name, tempname)==0) + if(CustomData_is_property_layer(type)){ + if(i!=index && CustomData_is_property_layer(layer->type) && + strcmp(layer->name, tempname)==0) + break; + } + else{ + if(i!=index && layer->type==type && strcmp(layer->name, tempname)==0) + break; + } } if(i == data->totlayer) { |