diff options
author | Bastien Montagne <b.mont29@gmail.com> | 2020-03-24 20:28:09 +0300 |
---|---|---|
committer | Bastien Montagne <b.mont29@gmail.com> | 2020-03-24 20:28:55 +0300 |
commit | bb26c1359e4f4bb21ec4ec4ab37e28d1fada20b8 (patch) | |
tree | 1e08863d43915ef90b59b85cd95afe6d279f50dd /source/blender/modifiers/intern/MOD_weightvgproximity.c | |
parent | 26ef4fa85ef4ea0f010f31c93d1086c515c3b5d4 (diff) |
Add invert mapping option to proximity weight edit modifier, and some cleanup.
Diffstat (limited to 'source/blender/modifiers/intern/MOD_weightvgproximity.c')
-rw-r--r-- | source/blender/modifiers/intern/MOD_weightvgproximity.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c index e2e8e732311..7c9242ed900 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.c +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c @@ -239,8 +239,13 @@ static float get_ob2ob_distance(const Object *ob, const Object *obr) /** * Maps distances to weights, with an optional "smoothing" mapping. */ -static void do_map( - Object *ob, float *weights, const int nidx, const float min_d, const float max_d, short mode) +static void do_map(Object *ob, + float *weights, + const int nidx, + const float min_d, + const float max_d, + short mode, + const bool do_invert_mapping) { const float range_inv = 1.0f / (max_d - min_d); /* invert since multiplication is faster */ uint i = nidx; @@ -276,14 +281,15 @@ static void do_map( } } - if (!ELEM(mode, MOD_WVG_MAPPING_NONE, MOD_WVG_MAPPING_CURVE)) { + BLI_assert(mode != MOD_WVG_MAPPING_CURVE); + if (do_invert_mapping || mode != MOD_WVG_MAPPING_NONE) { RNG *rng = NULL; if (mode == MOD_WVG_MAPPING_RANDOM) { rng = BLI_rng_new_srandom(BLI_ghashutil_strhash(ob->id.name + 2)); } - weightvg_do_map(nidx, weights, mode, NULL, rng); + weightvg_do_map(nidx, weights, mode, do_invert_mapping, NULL, rng); if (rng) { BLI_rng_free(rng); @@ -559,7 +565,13 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes } /* Map distances to weights. */ - do_map(ob, new_w, numIdx, wmd->min_dist, wmd->max_dist, wmd->falloff_type); + do_map(ob, + new_w, + numIdx, + wmd->min_dist, + wmd->max_dist, + wmd->falloff_type, + (wmd->proximity_flags & MOD_WVG_PROXIMITY_INVERT_FALLOFF) != 0); /* Do masking. */ struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); |