diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-10-20 21:39:56 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-10-20 21:39:56 +0400 |
commit | eee64aeccf64f95f6657571a53ca5226b52ebbc8 (patch) | |
tree | e0ff6b7be7802770697cdf9907795c152fb2f824 /source/blender | |
parent | 8944dab58a4f9efed28bc40ea45f3555026d0f0b (diff) |
bmesh-decimate now only does CustomData_has_math for loop layers, add CustomData_has_interp() for vert & edges.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_customdata.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/customdata.c | 25 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_decimate.c | 8 |
3 files changed, 31 insertions, 4 deletions
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index 883850d8dac..e387fc5f97c 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -80,11 +80,13 @@ void customData_mask_layers__print(CustomDataMask mask); * the below operations. */ int CustomData_layer_has_math(struct CustomData *data, int layer_n); +int CustomData_layer_has_interp(struct CustomData *data, int layer_n); /** * Checks if any of the customdata layers has math. */ int CustomData_has_math(struct CustomData *data); +int CustomData_has_interp(struct CustomData *data); /* copies the "value" (e.g. mloopuv uv or mloopcol colors) from one block to * another, while not overwriting anything else (e.g. flags). probably only diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 6c9cf510405..2c9ad38c305 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -2483,6 +2483,17 @@ int CustomData_layer_has_math(struct CustomData *data, int layer_n) return FALSE; } +int CustomData_layer_has_interp(struct CustomData *data, int layer_n) +{ + const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[layer_n].type); + + if (typeInfo->interp) { + return TRUE; + } + + return FALSE; +} + int CustomData_has_math(struct CustomData *data) { int i; @@ -2497,6 +2508,20 @@ int CustomData_has_math(struct CustomData *data) return FALSE; } +int CustomData_has_interp(struct CustomData *data) +{ + int i; + + /* interpolates a layer at a time */ + for (i = 0; i < data->totlayer; ++i) { + if (CustomData_layer_has_interp(data, i)) { + return TRUE; + } + } + + return FALSE; +} + /* copies the "value" (e.g. mloopuv uv or mloopcol colors) from one block to * another, while not overwriting anything else (e.g. flags)*/ void CustomData_data_copy_value(int type, void *source, void *dest) diff --git a/source/blender/bmesh/intern/bmesh_decimate.c b/source/blender/bmesh/intern/bmesh_decimate.c index 2b513f02d6b..cd05df11d77 100644 --- a/source/blender/bmesh/intern/bmesh_decimate.c +++ b/source/blender/bmesh/intern/bmesh_decimate.c @@ -697,10 +697,10 @@ void BM_mesh_decimate(BMesh *bm, const float factor) #ifdef USE_CUSTOMDATA - /* initialize customdata flag */ - if (CustomData_has_math(&bm->vdata)) customdata_flag |= CD_DO_VERT; - if (CustomData_has_math(&bm->edata)) customdata_flag |= CD_DO_EDGE; - if (CustomData_has_math(&bm->ldata)) customdata_flag |= CD_DO_LOOP; + /* initialize customdata flag, we only need math for loops */ + if (CustomData_has_interp(&bm->vdata)) customdata_flag |= CD_DO_VERT; + if (CustomData_has_interp(&bm->edata)) customdata_flag |= CD_DO_EDGE; + if (CustomData_has_math(&bm->ldata)) customdata_flag |= CD_DO_LOOP; #endif /* iterative edge collapse and maintain the eheap */ |