diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:17:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:21:24 +0300 |
commit | e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch) | |
tree | 8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c | |
parent | b3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff) |
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.
For details on usage and instructions for migrating branches
without conflicts, see:
https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c')
-rw-r--r-- | source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c | 279 |
1 files changed, 142 insertions, 137 deletions
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c index c66580cd5d4..9cff37f21bf 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c @@ -21,7 +21,6 @@ * \ingroup bke */ - #include <stdio.h> #include "MEM_guardedalloc.h" @@ -54,155 +53,161 @@ void gpencil_modifier_type_init(GpencilModifierTypeInfo *types[]) { -#define INIT_GP_TYPE(typeName) (types[eGpencilModifierType_##typeName] = &modifierType_Gpencil_##typeName) - INIT_GP_TYPE(Noise); - INIT_GP_TYPE(Subdiv); - INIT_GP_TYPE(Simplify); - INIT_GP_TYPE(Thick); - INIT_GP_TYPE(Tint); - INIT_GP_TYPE(Color); - INIT_GP_TYPE(Array); - INIT_GP_TYPE(Build); - INIT_GP_TYPE(Opacity); - INIT_GP_TYPE(Lattice); - INIT_GP_TYPE(Mirror); - INIT_GP_TYPE(Smooth); - INIT_GP_TYPE(Hook); - INIT_GP_TYPE(Offset); - INIT_GP_TYPE(Armature); - INIT_GP_TYPE(Time); +#define INIT_GP_TYPE(typeName) \ + (types[eGpencilModifierType_##typeName] = &modifierType_Gpencil_##typeName) + INIT_GP_TYPE(Noise); + INIT_GP_TYPE(Subdiv); + INIT_GP_TYPE(Simplify); + INIT_GP_TYPE(Thick); + INIT_GP_TYPE(Tint); + INIT_GP_TYPE(Color); + INIT_GP_TYPE(Array); + INIT_GP_TYPE(Build); + INIT_GP_TYPE(Opacity); + INIT_GP_TYPE(Lattice); + INIT_GP_TYPE(Mirror); + INIT_GP_TYPE(Smooth); + INIT_GP_TYPE(Hook); + INIT_GP_TYPE(Offset); + INIT_GP_TYPE(Armature); + INIT_GP_TYPE(Time); #undef INIT_GP_TYPE } /* verify if valid layer and pass index */ -bool is_stroke_affected_by_modifier( - Object *ob, char *mlayername, int mpassindex, int gpl_passindex, int minpoints, - bGPDlayer *gpl, bGPDstroke *gps, bool inv1, bool inv2, bool inv3) +bool is_stroke_affected_by_modifier(Object *ob, + char *mlayername, + int mpassindex, + int gpl_passindex, + int minpoints, + bGPDlayer *gpl, + bGPDstroke *gps, + bool inv1, + bool inv2, + bool inv3) { - MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, gps->mat_nr + 1); - - /* omit if filter by layer */ - if (mlayername[0] != '\0') { - if (inv1 == false) { - if (!STREQ(mlayername, gpl->info)) { - return false; - } - } - else { - if (STREQ(mlayername, gpl->info)) { - return false; - } - } - } - /* verify layer pass */ - if (gpl_passindex > 0) { - if (inv3 == false) { - if (gpl->pass_index != gpl_passindex) { - return false; - } - } - else { - if (gpl->pass_index == gpl_passindex) { - return false; - } - } - } - /* verify material pass */ - if (mpassindex > 0) { - if (inv2 == false) { - if (gp_style->index != mpassindex) { - return false; - } - } - else { - if (gp_style->index == mpassindex) { - return false; - } - } - } - /* need to have a minimum number of points */ - if ((minpoints > 0) && (gps->totpoints < minpoints)) { - return false; - } - - return true; + MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, gps->mat_nr + 1); + + /* omit if filter by layer */ + if (mlayername[0] != '\0') { + if (inv1 == false) { + if (!STREQ(mlayername, gpl->info)) { + return false; + } + } + else { + if (STREQ(mlayername, gpl->info)) { + return false; + } + } + } + /* verify layer pass */ + if (gpl_passindex > 0) { + if (inv3 == false) { + if (gpl->pass_index != gpl_passindex) { + return false; + } + } + else { + if (gpl->pass_index == gpl_passindex) { + return false; + } + } + } + /* verify material pass */ + if (mpassindex > 0) { + if (inv2 == false) { + if (gp_style->index != mpassindex) { + return false; + } + } + else { + if (gp_style->index == mpassindex) { + return false; + } + } + } + /* need to have a minimum number of points */ + if ((minpoints > 0) && (gps->totpoints < minpoints)) { + return false; + } + + return true; } /* verify if valid vertex group *and return weight */ float get_modifier_point_weight(MDeformVert *dvert, bool inverse, int def_nr) { - float weight = 1.0f; - - if ((dvert != NULL) && (def_nr != -1)) { - MDeformWeight *dw = defvert_find_index(dvert, def_nr); - weight = dw ? dw->weight : -1.0f; - if ((weight >= 0.0f) && (inverse == 1)) { - return -1.0f; - } - - if ((weight < 0.0f) && (inverse == 0)) { - return -1.0f; - } - - /* if inverse, weight is always 1 */ - if ((weight < 0.0f) && (inverse == 1)) { - return 1.0f; - } - - } - - /* handle special empty groups */ - if ((dvert == NULL) && (def_nr != -1)) { - if (inverse == 1) { - return 1.0f; - } - else { - return -1.0f; - } - } - - return weight; + float weight = 1.0f; + + if ((dvert != NULL) && (def_nr != -1)) { + MDeformWeight *dw = defvert_find_index(dvert, def_nr); + weight = dw ? dw->weight : -1.0f; + if ((weight >= 0.0f) && (inverse == 1)) { + return -1.0f; + } + + if ((weight < 0.0f) && (inverse == 0)) { + return -1.0f; + } + + /* if inverse, weight is always 1 */ + if ((weight < 0.0f) && (inverse == 1)) { + return 1.0f; + } + } + + /* handle special empty groups */ + if ((dvert == NULL) && (def_nr != -1)) { + if (inverse == 1) { + return 1.0f; + } + else { + return -1.0f; + } + } + + return weight; } /* set material when apply modifiers (used in tint and color modifier) */ void gpencil_apply_modifier_material( - Main *bmain, Object *ob, Material *mat, - GHash *gh_color, bGPDstroke *gps, bool crt_material) + Main *bmain, Object *ob, Material *mat, GHash *gh_color, bGPDstroke *gps, bool crt_material) { - MaterialGPencilStyle *gp_style = mat->gp_style; - - /* look for color */ - if (crt_material) { - Material *newmat = BLI_ghash_lookup(gh_color, mat->id.name); - if (newmat == NULL) { - BKE_object_material_slot_add(bmain, ob); - newmat = BKE_material_copy(bmain, mat); - newmat->preview = NULL; - - assign_material(bmain, ob, newmat, ob->totcol, BKE_MAT_ASSIGN_USERPREF); - - copy_v4_v4(newmat->gp_style->stroke_rgba, gps->runtime.tmp_stroke_rgba); - copy_v4_v4(newmat->gp_style->fill_rgba, gps->runtime.tmp_fill_rgba); - - BLI_ghash_insert(gh_color, mat->id.name, newmat); - DEG_id_tag_update(&newmat->id, ID_RECALC_COPY_ON_WRITE); - } - /* reasign color index */ - int idx = BKE_gpencil_object_material_get_index(ob, newmat); - gps->mat_nr = idx - 1; - } - else { - /* reuse existing color (but update only first time) */ - if (BLI_ghash_lookup(gh_color, mat->id.name) == NULL) { - copy_v4_v4(gp_style->stroke_rgba, gps->runtime.tmp_stroke_rgba); - copy_v4_v4(gp_style->fill_rgba, gps->runtime.tmp_fill_rgba); - BLI_ghash_insert(gh_color, mat->id.name, mat); - } - /* update previews (icon and thumbnail) */ - if (mat->preview != NULL) { - mat->preview->flag[ICON_SIZE_ICON] |= PRV_CHANGED; - mat->preview->flag[ICON_SIZE_PREVIEW] |= PRV_CHANGED; - } - DEG_id_tag_update(&mat->id, ID_RECALC_COPY_ON_WRITE); - } + MaterialGPencilStyle *gp_style = mat->gp_style; + + /* look for color */ + if (crt_material) { + Material *newmat = BLI_ghash_lookup(gh_color, mat->id.name); + if (newmat == NULL) { + BKE_object_material_slot_add(bmain, ob); + newmat = BKE_material_copy(bmain, mat); + newmat->preview = NULL; + + assign_material(bmain, ob, newmat, ob->totcol, BKE_MAT_ASSIGN_USERPREF); + + copy_v4_v4(newmat->gp_style->stroke_rgba, gps->runtime.tmp_stroke_rgba); + copy_v4_v4(newmat->gp_style->fill_rgba, gps->runtime.tmp_fill_rgba); + + BLI_ghash_insert(gh_color, mat->id.name, newmat); + DEG_id_tag_update(&newmat->id, ID_RECALC_COPY_ON_WRITE); + } + /* reasign color index */ + int idx = BKE_gpencil_object_material_get_index(ob, newmat); + gps->mat_nr = idx - 1; + } + else { + /* reuse existing color (but update only first time) */ + if (BLI_ghash_lookup(gh_color, mat->id.name) == NULL) { + copy_v4_v4(gp_style->stroke_rgba, gps->runtime.tmp_stroke_rgba); + copy_v4_v4(gp_style->fill_rgba, gps->runtime.tmp_fill_rgba); + BLI_ghash_insert(gh_color, mat->id.name, mat); + } + /* update previews (icon and thumbnail) */ + if (mat->preview != NULL) { + mat->preview->flag[ICON_SIZE_ICON] |= PRV_CHANGED; + mat->preview->flag[ICON_SIZE_PREVIEW] |= PRV_CHANGED; + } + DEG_id_tag_update(&mat->id, ID_RECALC_COPY_ON_WRITE); + } } |