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
This commit is contained in:
parent
6cd4363c0c
commit
20605c4b51
Notes:
blender-bot
2023-02-14 08:29:54 +01:00
Referenced by issue #74024, Faces missing, weird faces added
|
@ -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:")
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue