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:
authorCody Winchester <CodyWinch>2020-02-18 20:12:06 +0300
committerBastien Montagne <b.mont29@gmail.com>2020-02-18 20:14:44 +0300
commit20605c4b515e3e93a1557839669e8c6fc02dcbc9 (patch)
treebdc91cd4533f9cf7881dc723efc216e56d1b61f7
parent6cd4363c0c3ee73a0656e84e91ebf9e9c936d6bd (diff)
Modifiers: UVWarp modifier add invert vgroup option
Adds the invert vgroup option to the UVWarp modifier. Adds a flag and char padding to the DNA. Differential Revision: https://developer.blender.org/D6841
-rw-r--r--release/scripts/startup/bl_ui/properties_data_modifier.py4
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h7
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c5
-rw-r--r--source/blender/modifiers/intern/MOD_uvwarp.c7
4 files changed, 20 insertions, 3 deletions
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index ffd42c452f0..5028c78f4c3 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1479,7 +1479,9 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
col = split.column()
col.label(text="Vertex Group:")
- col.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
+ row = col.row(align=True)
+ row.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
+ row.prop(md, "invert_vertex_group", text="", icon='ARROW_LEFTRIGHT')
col = split.column()
col.label(text="UV Map:")
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 2abe1b38a8d..2d625e7006b 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1743,7 +1743,7 @@ typedef struct UVWarpModifierData {
ModifierData modifier;
char axis_u, axis_v;
- char _pad[2];
+ short flag;
/** Used for rotate/scale. */
float center[2];
@@ -1766,6 +1766,11 @@ typedef struct UVWarpModifierData {
char uvlayer_name[64];
} UVWarpModifierData;
+/* UVWarp modifier flags */
+enum {
+ MOD_UVWARP_INVERT_VGROUP = 1 << 0,
+};
+
/* cache modifier */
typedef struct MeshCacheModifierData {
ModifierData modifier;
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 24b7c968707..9a4048e6aaa 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -4659,6 +4659,11 @@ static void rna_def_modifier_uvwarp(BlenderRNA *brna)
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_UVWarpModifier_vgroup_name_set");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
+ prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_UVWARP_INVERT_VGROUP);
+ RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "uvlayer_name");
RNA_def_property_ui_text(prop, "UV Layer", "UV Layer name");
diff --git a/source/blender/modifiers/intern/MOD_uvwarp.c b/source/blender/modifiers/intern/MOD_uvwarp.c
index 2dfb9031c38..973923d1cf4 100644
--- a/source/blender/modifiers/intern/MOD_uvwarp.c
+++ b/source/blender/modifiers/intern/MOD_uvwarp.c
@@ -88,6 +88,7 @@ typedef struct UVWarpData {
int defgrp_index;
float (*warp_mat)[4];
+ bool invert_vgroup;
} UVWarpData;
static void uv_warp_compute(void *__restrict userdata,
@@ -110,7 +111,9 @@ static void uv_warp_compute(void *__restrict userdata,
if (dvert) {
for (l = 0; l < mp->totloop; l++, ml++, mluv++) {
float uv[2];
- const float weight = defvert_find_weight(&dvert[ml->v], defgrp_index);
+ const float weight = data->invert_vgroup ?
+ 1.0f - defvert_find_weight(&dvert[ml->v], defgrp_index) :
+ defvert_find_weight(&dvert[ml->v], defgrp_index);
uv_warp_from_mat4_pair(uv, mluv->uv, warp_mat);
interp_v2_v2v2(mluv->uv, mluv->uv, uv, weight);
@@ -136,6 +139,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
float warp_mat[4][4];
const int axis_u = umd->axis_u;
const int axis_v = umd->axis_v;
+ const bool invert_vgroup = (umd->flag & MOD_UVWARP_INVERT_VGROUP) != 0;
/* make sure there are UV Maps available */
if (!CustomData_has_layer(&mesh->ldata, CD_MLOOPUV)) {
@@ -208,6 +212,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
.dvert = dvert,
.defgrp_index = defgrp_index,
.warp_mat = warp_mat,
+ .invert_vgroup = invert_vgroup,
};
TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);