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:
authorCampbell Barton <ideasman42@gmail.com>2011-09-08 12:29:49 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-09-08 12:29:49 +0400
commit61b6fcd80443691da77a918c5e50e06cc0998c1b (patch)
tree5d8dbcd1edcfe6ca4a23dd4886ed8eb9f7d0ad6c /source/blender/modifiers
parente7f21e58de3ac1c590a4a1180723a854e2a6e21a (diff)
parent1f0bb0e0353687c17738608d884077dc6779638d (diff)
svn merge -r39991:40034 https://svn.blender.org/svnroot/bf-blender/trunk/blender
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r--source/blender/modifiers/intern/MOD_weightvg_util.c70
-rw-r--r--source/blender/modifiers/intern/MOD_weightvg_util.h52
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgedit.c62
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgmix.c54
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgproximity.c89
5 files changed, 172 insertions, 155 deletions
diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c
index 675f0d76a48..51465cc80b0 100644
--- a/source/blender/modifiers/intern/MOD_weightvg_util.c
+++ b/source/blender/modifiers/intern/MOD_weightvg_util.c
@@ -1,34 +1,34 @@
/*
-* $Id$
-*
-* ***** BEGIN GPL LICENSE BLOCK *****
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*
-* The Original Code is Copyright (C) 2011 by Bastien Montagne.
-* All rights reserved.
-*
-* Contributor(s): None yet.
-*
-* ***** END GPL LICENSE BLOCK *****
-*
-*/
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2011 by Bastien Montagne.
+ * All rights reserved.
+ *
+ * Contributor(s): None yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ */
/*
* XXX I'd like to make modified weights visible in WeightPaint mode,
- * but couldn't figure a way to do this…
+ * but couldn't figure a way to do this...
* Maybe this will need changes in mesh_calc_modifiers (DerivedMesh.c)?
* Or the WeightPaint mode code itself?
*/
@@ -63,16 +63,16 @@
* vertex index (in case the weight tables do not cover the whole vertices...).
* cmap might be NULL, in which case curve mapping mode will return unmodified data.
*/
-void weightvg_do_map(int num, float *new_w, short mode, CurveMapping *cmap)
+void weightvg_do_map(int num, float *new_w, short falloff_type, CurveMapping *cmap)
{
int i;
/* Return immediately, if we have nothing to do! */
/* Also security checks... */
- if(((mode == MOD_WVG_MAPPING_CURVE) && (cmap == NULL))
- || !ELEM7(mode, MOD_WVG_MAPPING_CURVE, MOD_WVG_MAPPING_SHARP, MOD_WVG_MAPPING_SMOOTH,
- MOD_WVG_MAPPING_ROOT, MOD_WVG_MAPPING_SPHERE, MOD_WVG_MAPPING_RANDOM,
- MOD_WVG_MAPPING_STEP))
+ if(((falloff_type == MOD_WVG_MAPPING_CURVE) && (cmap == NULL))
+ || !ELEM7(falloff_type, MOD_WVG_MAPPING_CURVE, MOD_WVG_MAPPING_SHARP, MOD_WVG_MAPPING_SMOOTH,
+ MOD_WVG_MAPPING_ROOT, MOD_WVG_MAPPING_SPHERE, MOD_WVG_MAPPING_RANDOM,
+ MOD_WVG_MAPPING_STEP))
return;
/* Map each weight (vertex) to its new value, accordingly to the chosen mode. */
@@ -81,7 +81,7 @@ void weightvg_do_map(int num, float *new_w, short mode, CurveMapping *cmap)
/* Code borrowed from the warp modifier. */
/* Closely matches PROP_SMOOTH and similar. */
- switch(mode) {
+ switch(falloff_type) {
case MOD_WVG_MAPPING_CURVE:
fac = curvemapping_evaluateF(cmap, 0, fac);
break;
@@ -131,7 +131,7 @@ void weightvg_do_mask(int num, const int *indices, float *org_w, const float *ne
if (texture) {
/* The texture coordinates. */
float (*tex_co)[3];
- /* See mapping note below… */
+ /* See mapping note below... */
MappingInfoModifierData t_map;
float (*v_co)[3];
@@ -158,7 +158,7 @@ void weightvg_do_mask(int num, const int *indices, float *org_w, const float *ne
texres.nor = NULL;
get_texture_value(texture, tex_co[idx], &texres);
- /* Get the good channel value… */
+ /* Get the good channel value... */
switch(tex_use_channel) {
case MOD_WVG_MASK_TEX_USE_INT:
org_w[i] = (new_w[i] * texres.tin * fact) + (org_w[i] * (1.0f - (texres.tin*fact)));
diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.h b/source/blender/modifiers/intern/MOD_weightvg_util.h
index 3afff391943..00c63a3d5d5 100644
--- a/source/blender/modifiers/intern/MOD_weightvg_util.h
+++ b/source/blender/modifiers/intern/MOD_weightvg_util.h
@@ -1,30 +1,30 @@
/*
-* $Id$
-*
-* ***** BEGIN GPL LICENSE BLOCK *****
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*
-* The Original Code is Copyright (C) 2011 by Bastien Montagne.
-* All rights reserved.
-*
-* Contributor(s): None yet.
-*
-* ***** END GPL LICENSE BLOCK *****
-*
-*/
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2011 by Bastien Montagne.
+ * All rights reserved.
+ *
+ * Contributor(s): None yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ */
/** \file blender/modifiers/intern/MOD_util.h
* \ingroup modifiers
diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c
index 19b6ddaddde..b8bbf2a4b6c 100644
--- a/source/blender/modifiers/intern/MOD_weightvgedit.c
+++ b/source/blender/modifiers/intern/MOD_weightvgedit.c
@@ -1,30 +1,30 @@
/*
-* $Id$
-*
-* ***** BEGIN GPL LICENSE BLOCK *****
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*
-* The Original Code is Copyright (C) 2011 by Bastien Montagne.
-* All rights reserved.
-*
-* Contributor(s): None yet.
-*
-* ***** END GPL LICENSE BLOCK *****
-*
-*/
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2011 by Bastien Montagne.
+ * All rights reserved.
+ *
+ * Contributor(s): None yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ */
/*
* XXX I'd like to make modified weights visible in WeightPaint mode,
@@ -62,7 +62,7 @@ static void initData(ModifierData *md)
{
WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md;
wmd->edit_flags = 0;
- wmd->mapping_mode = MOD_WVG_MAPPING_NONE;
+ wmd->falloff_type = MOD_WVG_MAPPING_NONE;
wmd->default_weight = 0.0f;
wmd->cmap_curve = curvemapping_add(1, 0.0, 0.0, 1.0, 1.0);
@@ -90,7 +90,7 @@ static void copyData(ModifierData *md, ModifierData *target)
BLI_strncpy(twmd->defgrp_name, wmd->defgrp_name, sizeof(twmd->defgrp_name));
twmd->edit_flags = wmd->edit_flags;
- twmd->mapping_mode = wmd->mapping_mode;
+ twmd->falloff_type = wmd->falloff_type;
twmd->default_weight = wmd->default_weight;
twmd->cmap_curve = curvemapping_copy(wmd->cmap_curve);
@@ -268,8 +268,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
}
/* Do mapping. */
- if (wmd->mapping_mode != MOD_WVG_MAPPING_NONE) {
- weightvg_do_map(numVerts, new_w, wmd->mapping_mode, wmd->cmap_curve);
+ if (wmd->falloff_type != MOD_WVG_MAPPING_NONE) {
+ weightvg_do_map(numVerts, new_w, wmd->falloff_type, wmd->cmap_curve);
}
/* Do masking. */
@@ -298,7 +298,7 @@ static DerivedMesh *applyModifierEM(ModifierData *md, Object *ob,
ModifierTypeInfo modifierType_WeightVGEdit = {
- /* name */ "WeightVGEdit",
+ /* name */ "VertexWeightEdit",
/* structName */ "WeightVGEditModifierData",
/* structSize */ sizeof(WeightVGEditModifierData),
/* type */ eModifierTypeType_Nonconstructive,
diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c
index 9be92da51be..8139adc5910 100644
--- a/source/blender/modifiers/intern/MOD_weightvgmix.c
+++ b/source/blender/modifiers/intern/MOD_weightvgmix.c
@@ -1,30 +1,30 @@
/*
-* $Id$
-*
-* ***** BEGIN GPL LICENSE BLOCK *****
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*
-* The Original Code is Copyright (C) 2011 by Bastien Montagne.
-* All rights reserved.
-*
-* Contributor(s): None yet.
-*
-* ***** END GPL LICENSE BLOCK *****
-*
-*/
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2011 by Bastien Montagne.
+ * All rights reserved.
+ *
+ * Contributor(s): None yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ */
/*
* XXX I'd like to make modified weights visible in WeightPaint mode,
@@ -438,7 +438,7 @@ static DerivedMesh *applyModifierEM(ModifierData *md, Object *ob,
ModifierTypeInfo modifierType_WeightVGMix = {
- /* name */ "WeightVGMix",
+ /* name */ "VertexWeightMix",
/* structName */ "WeightVGMixModifierData",
/* structSize */ sizeof(WeightVGMixModifierData),
/* type */ eModifierTypeType_Nonconstructive,
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index 7eeec211b41..b0be02c5b27 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -1,30 +1,30 @@
/*
-* $Id$
-*
-* ***** BEGIN GPL LICENSE BLOCK *****
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*
-* The Original Code is Copyright (C) 2011 by Bastien Montagne.
-* All rights reserved.
-*
-* Contributor(s): None yet.
-*
-* ***** END GPL LICENSE BLOCK *****
-*
-*/
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2011 by Bastien Montagne.
+ * All rights reserved.
+ *
+ * Contributor(s): None yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ */
/*
* XXX I'd like to make modified weights visible in WeightPaint mode,
@@ -199,10 +199,24 @@ void do_map(float *weights, const int nidx, const float min_d, const float max_d
{
const float range_inv= 1.0f / (max_d - min_d); /* invert since multiplication is faster */
unsigned int i= nidx;
- while (i-- > 0) {
- if (weights[i] >= max_d) weights[i]= 1.0f; /* most likely case first */
- else if(weights[i] <= min_d) weights[i]= 0.0f;
- else weights[i]= (weights[i] - min_d) * range_inv;
+ if(max_d == min_d) {
+ while (i-- > 0) {
+ weights[i] = (weights[i] >= max_d) ? 1.0f : 0.0f; /* "Step" behavior... */
+ }
+ }
+ else if(max_d > min_d) {
+ while (i-- > 0) {
+ if (weights[i] >= max_d) weights[i]= 1.0f; /* most likely case first */
+ else if(weights[i] <= min_d) weights[i]= 0.0f;
+ else weights[i]= (weights[i] - min_d) * range_inv;
+ }
+ }
+ else {
+ while (i-- > 0) {
+ if (weights[i] <= max_d) weights[i]= 1.0f; /* most likely case first */
+ else if(weights[i] >= min_d) weights[i]= 0.0f;
+ else weights[i]= (weights[i] - min_d) * range_inv;
+ }
}
if(!ELEM(mode, MOD_WVG_MAPPING_NONE, MOD_WVG_MAPPING_CURVE)) {
@@ -220,7 +234,7 @@ 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->falloff_type = MOD_WVG_MAPPING_NONE;
wmd->mask_constant = 1.0f;
wmd->mask_tex_use_channel = MOD_WVG_MASK_TEX_USE_INT; /* Use intensity by default. */
@@ -238,7 +252,7 @@ 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->falloff_type = wmd->falloff_type;
twmd->mask_constant = wmd->mask_constant;
BLI_strncpy(twmd->mask_defgrp_name, wmd->mask_defgrp_name, sizeof(twmd->mask_defgrp_name));
@@ -481,6 +495,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
new_w[i] = dists_e ? minf(dists_e[i], new_w[i]) : new_w[i];
new_w[i] = dists_f ? minf(dists_f[i], new_w[i]) : new_w[i];
}
+ if(dists_v) MEM_freeN(dists_v);
+ if(dists_e) MEM_freeN(dists_e);
+ if(dists_f) MEM_freeN(dists_f);
}
/* Else, fall back to default obj2vert behavior. */
else {
@@ -492,14 +509,14 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
}
}
+ /* Map distances to weights. */
+ do_map(new_w, numIdx, wmd->min_dist, wmd->max_dist, wmd->falloff_type);
+
/* Do masking. */
weightvg_do_mask(numIdx, indices, org_w, new_w, ob, ret, wmd->mask_constant,
wmd->mask_defgrp_name, wmd->mask_texture, wmd->mask_tex_use_channel,
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, 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);
@@ -522,7 +539,7 @@ static DerivedMesh *applyModifierEM(ModifierData *md, Object *ob,
ModifierTypeInfo modifierType_WeightVGProximity = {
- /* name */ "WeightVGProximity",
+ /* name */ "VertexWeightProximity",
/* structName */ "WeightVGProximityModifierData",
/* structSize */ sizeof(WeightVGProximityModifierData),
/* type */ eModifierTypeType_Nonconstructive,