diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-05-08 16:57:18 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-05-08 16:57:18 +0400 |
commit | df664fa6d54ff2bd0d8f218466985986ce522718 (patch) | |
tree | 6e60de963bd52981412a488a36873eac1d149aca /source/blender/blenkernel/intern | |
parent | 4daf1958cf44d5183dbf15756f88be46d6e52d7e (diff) |
use bool for customdata functions.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/customdata.c | 73 |
1 files changed, 37 insertions, 36 deletions
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 2118bbcd42b..b0ecec21049 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -130,7 +130,7 @@ typedef struct LayerTypeInfo { void (*set_default)(void *data, int count); /** functions necessary for geometry collapse */ - int (*equal)(void *data1, void *data2); + bool (*equal)(void *data1, void *data2); void (*multiply)(void *data, float fac); void (*initminmax)(void *min, void *max); void (*add)(void *data1, void *data2); @@ -608,7 +608,7 @@ static void layerCopyValue_mloopcol(void *source, void *dest) m2->a = m1->a; } -static int layerEqual_mloopcol(void *data1, void *data2) +static bool layerEqual_mloopcol(void *data1, void *data2) { MLoopCol *m1 = data1, *m2 = data2; float r, g, b, a; @@ -736,7 +736,7 @@ static void layerCopyValue_mloopuv(void *source, void *dest) copy_v2_v2(luv2->uv, luv1->uv); } -static int layerEqual_mloopuv(void *data1, void *data2) +static bool layerEqual_mloopuv(void *data1, void *data2) { MLoopUV *luv1 = data1, *luv2 = data2; @@ -808,7 +808,7 @@ static void layerCopyValue_mloop_origspace(void *source, void *dest) copy_v2_v2(luv2->uv, luv1->uv); } -static int layerEqual_mloop_origspace(void *data1, void *data2) +static bool layerEqual_mloop_origspace(void *data1, void *data2) { OrigSpaceLoop *luv1 = data1, *luv2 = data2; @@ -1714,7 +1714,7 @@ void *CustomData_add_layer_named(CustomData *data, int type, int alloctype, } -int CustomData_free_layer(CustomData *data, int type, int totelem, int index) +bool CustomData_free_layer(CustomData *data, int type, int totelem, int index) { int i; @@ -1748,7 +1748,7 @@ int CustomData_free_layer(CustomData *data, int type, int totelem, int index) return 1; } -int CustomData_free_layer_active(CustomData *data, int type, int totelem) +bool CustomData_free_layer_active(CustomData *data, int type, int totelem) { int index = 0; index = CustomData_get_active_layer_index(data, type); @@ -1763,7 +1763,7 @@ void CustomData_free_layers(CustomData *data, int type, int totelem) CustomData_free_layer_active(data, type, totelem); } -int CustomData_has_layer(const CustomData *data, int type) +bool CustomData_has_layer(const CustomData *data, int type) { return (CustomData_get_layer_index(data, type) != -1); } @@ -1844,7 +1844,7 @@ void *CustomData_duplicate_referenced_layer_named(struct CustomData *data, return layer->data; } -int CustomData_is_referenced_layer(struct CustomData *data, int type) +bool CustomData_is_referenced_layer(struct CustomData *data, int type) { CustomDataLayer *layer; int layer_index; @@ -2129,17 +2129,17 @@ int CustomData_get_n_offset(const CustomData *data, int type, int n) return data->layers[layer_index].offset; } -int CustomData_set_layer_name(const CustomData *data, int type, int n, const char *name) +bool CustomData_set_layer_name(const CustomData *data, int type, int n, const char *name) { /* get the layer index of the first layer of type */ int layer_index = CustomData_get_layer_index_n(data, type, n); - if (layer_index < 0) return 0; - if (!name) return 0; + if (layer_index < 0) return false; + if (!name) return false; BLI_strncpy(data->layers[layer_index].name, name, sizeof(data->layers[layer_index].name)); - return 1; + return true; } void *CustomData_set_layer(const CustomData *data, int type, void *ptr) @@ -2514,56 +2514,56 @@ void *CustomData_bmesh_get_layer_n(const CustomData *data, void *block, int n) return (char *)block + data->layers[n].offset; } -int CustomData_layer_has_math(struct CustomData *data, int layer_n) +bool CustomData_layer_has_math(struct CustomData *data, int layer_n) { const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[layer_n].type); if (typeInfo->equal && typeInfo->add && typeInfo->multiply && typeInfo->initminmax && typeInfo->dominmax) { - return TRUE; + return true; } - return FALSE; + return false; } -int CustomData_layer_has_interp(struct CustomData *data, int layer_n) +bool 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 true; } - return FALSE; + return false; } -int CustomData_has_math(struct CustomData *data) +bool CustomData_has_math(struct CustomData *data) { int i; /* interpolates a layer at a time */ for (i = 0; i < data->totlayer; ++i) { if (CustomData_layer_has_math(data, i)) { - return TRUE; + return true; } } - return FALSE; + return false; } -int CustomData_has_interp(struct CustomData *data) +bool 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 true; } } - return FALSE; + return false; } /* copies the "value" (e.g. mloopuv uv or mloopcol colors) from one block to @@ -2580,7 +2580,7 @@ void CustomData_data_copy_value(int type, void *source, void *dest) memcpy(dest, source, typeInfo->size); } -int CustomData_data_equals(int type, void *data1, void *data2) +bool CustomData_data_equals(int type, void *data1, void *data2) { const LayerTypeInfo *typeInfo = layerType_getInfo(type); @@ -2861,17 +2861,17 @@ const char *CustomData_layertype_name(int type) /** * Can only ever be one of these. */ -int CustomData_layertype_is_singleton(int type) +bool CustomData_layertype_is_singleton(int type) { const LayerTypeInfo *typeInfo = layerType_getInfo(type); return typeInfo->defaultname == NULL; } -static int CustomData_is_property_layer(int type) +static bool CustomData_is_property_layer(int type) { if ((type == CD_PROP_FLT) || (type == CD_PROP_INT) || (type == CD_PROP_STR)) - return 1; - return 0; + return true; + return false; } static bool cd_layer_find_dupe(CustomData *data, const char *name, int type, int index) @@ -2941,14 +2941,15 @@ void CustomData_validate_layer_name(const CustomData *data, int type, const char } } -int CustomData_verify_versions(struct CustomData *data, int index) +bool CustomData_verify_versions(struct CustomData *data, int index) { const LayerTypeInfo *typeInfo; CustomDataLayer *layer = &data->layers[index]; - int i, keeplayer = 1; + bool keeplayer = true; + int i; if (layer->type >= CD_NUMTYPES) { - keeplayer = 0; /* unknown layer type from future version */ + keeplayer = false; /* unknown layer type from future version */ } else { typeInfo = layerType_getInfo(layer->type); @@ -2956,7 +2957,7 @@ int CustomData_verify_versions(struct CustomData *data, int index) if (!typeInfo->defaultname && (index > 0) && data->layers[index - 1].type == layer->type) { - keeplayer = 0; /* multiple layers of which we only support one */ + keeplayer = false; /* multiple layers of which we only support one */ } } @@ -3229,16 +3230,16 @@ void CustomData_external_remove(CustomData *data, ID *id, int type, int totelem) } } -int CustomData_external_test(CustomData *data, int type) +bool CustomData_external_test(CustomData *data, int type) { CustomDataLayer *layer; int layer_index; layer_index = CustomData_get_active_layer_index(data, type); - if (layer_index < 0) return 0; + if (layer_index < 0) return false; layer = &data->layers[layer_index]; - return (layer->flag & CD_FLAG_EXTERNAL); + return (layer->flag & CD_FLAG_EXTERNAL) != 0; } #if 0 |