Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2011-09-05 20:16:00 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2011-09-05 20:16:00 +0400
commit4393df93202198b5eaaff438e18060c66b98928d (patch)
treee6f045ff5c0e5a6e676cf93cf8bc6c4c41431b50 /source/blender/modifiers/intern/MOD_weightvgproximity.c
parentcc906e0e2a1de9b19c6cefa1167332f348bb9e0f (diff)
VGroup Modifiers: added mapping options to proximity and edit.
*Added Smooth/Sharp/Root/etc. mappings to WeightVGEdit modifier, in addition to custom curve one. *Added Smooth/Sharp/Root/etc. mappings to WeightVGProximity modifier, without the custom curve one! *Factorized the common mapping code into MOD_weightvg_util.
Diffstat (limited to 'source/blender/modifiers/intern/MOD_weightvgproximity.c')
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgproximity.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index 513ba9c815f..35f993e24b6 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -33,10 +33,10 @@
* Or the WeightPaint mode code itself?
*/
-#include "BLI_utildefines.h"
+#include "BLI_editVert.h"
#include "BLI_math.h"
#include "BLI_string.h"
-#include "BLI_editVert.h"
+#include "BLI_utildefines.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
@@ -193,9 +193,9 @@ static float get_ob2ob_distance(const Object* ob, const Object* obr)
}
/**
- * Maps distances to weights.
+ * Maps distances to weights, with an optionnal “smoothing” mapping.
*/
-void do_map(float *weights, const int nidx, const float min_d, const float max_d)
+void do_map(float *weights, const int nidx, const float min_d, const float max_d, short mode)
{
const float range_inv= 1.0f / (max_d - min_d); /* invert since multiplication is faster */
unsigned int i= nidx;
@@ -204,17 +204,12 @@ void do_map(float *weights, const int nidx, const float min_d, const float max_d
else if(weights[i] <= min_d) weights[i]= 0.0f;
else weights[i]= (weights[i] - min_d) * range_inv;
}
-}
-/*a min_d + b = 0.0*/
-/*a max_d + b = 1.0*/
-/*a min_d = -b*/
-/*a = -b / min_d*/
+ if(!ELEM(mode, MOD_WVG_MAPPING_NONE, MOD_WVG_MAPPING_CURVE)) {
+ weightvg_do_map(nidx, weights, mode, NULL);
+ }
+}
-/*max_d(-b/min_d) + b = 1.0*/
-/*b((-max_d/min_d)+1.0) = 1.0*/
-/*b = 1.0 / ((min_d-max_d)/min_d)*/
-/*b = min_d/(min_d-max_d)*/
/**************************************
* Modifiers functions. *
**************************************/
@@ -225,6 +220,8 @@ static void initData(ModifierData *md)
wmd->proximity_mode = MOD_WVG_PROXIMITY_OBJECT;
wmd->proximity_flags = MOD_WVG_PROXIMITY_GEOM_VERTS;
+ wmd->mapping_mode = MOD_WVG_MAPPING_NONE;
+
wmd->mask_constant = 1.0f;
wmd->mask_tex_use_channel = MOD_WVG_MASK_TEX_USE_INT; /* Use intensity by default. */
wmd->mask_tex_mapping = MOD_DISP_MAP_LOCAL;
@@ -241,6 +238,8 @@ static void copyData(ModifierData *md, ModifierData *target)
twmd->proximity_flags = wmd->proximity_flags;
twmd->proximity_ob_target = wmd->proximity_ob_target;
+ twmd->mapping_mode = wmd->mapping_mode;
+
twmd->mask_constant = wmd->mask_constant;
BLI_strncpy(twmd->mask_defgrp_name, wmd->mask_defgrp_name, sizeof(twmd->mask_defgrp_name));
twmd->mask_texture = wmd->mask_texture;
@@ -499,7 +498,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
wmd->mask_tex_mapping, wmd->mask_tex_map_obj, wmd->mask_tex_uvlayer_name);
/* Map distances to weights. */
- do_map(org_w, numIdx, wmd->min_dist, wmd->max_dist);
+ do_map(org_w, numIdx, wmd->min_dist, wmd->max_dist, wmd->mapping_mode);
/* Update vgroup. Note we never add nor remove vertices from vgroup here. */
weightvg_update_vg(dvert, defgrp_idx, numIdx, indices, org_w, 0, 0.0f, 0, 0.0f);