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-04-10 15:03:36 +0300
committerBastien Montagne <bastien@blender.org>2020-04-10 22:28:59 +0300
commit4f9a56cbc4e8719ee421a57fd6695bed633c591b (patch)
tree93f85984753bca057c65ac04beaa8e8effa71423 /source/blender/modifiers/intern
parentd6cefef98f87ae8554050052d0fa4f965a2ce809 (diff)
Modifiers: Add Bone option for Texture Mask Object
This patch adds the option to use an armature bone in place of an object for texture mask coordinates. This affects the 3 vertex weight modifiers, the displace modifier, the warp modifier, and the wave modifier. With minor changes from Bastien Montagne (@mont29). Differential Revision: https://developer.blender.org/D7348
Diffstat (limited to 'source/blender/modifiers/intern')
-rw-r--r--source/blender/modifiers/intern/MOD_displace.c10
-rw-r--r--source/blender/modifiers/intern/MOD_util.c20
-rw-r--r--source/blender/modifiers/intern/MOD_warp.c5
-rw-r--r--source/blender/modifiers/intern/MOD_wave.c9
-rw-r--r--source/blender/modifiers/intern/MOD_weightvg_util.c2
-rw-r--r--source/blender/modifiers/intern/MOD_weightvg_util.h1
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgedit.c11
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgmix.c11
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgproximity.c11
9 files changed, 66 insertions, 14 deletions
diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c
index a1b02e201d9..a03167c082f 100644
--- a/source/blender/modifiers/intern/MOD_displace.c
+++ b/source/blender/modifiers/intern/MOD_displace.c
@@ -135,9 +135,15 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
{
DisplaceModifierData *dmd = (DisplaceModifierData *)md;
if (dmd->map_object != NULL && dmd->texmapping == MOD_DISP_MAP_OBJECT) {
+ if (dmd->map_bone[0] && dmd->map_object->type == OB_ARMATURE) {
+ DEG_add_object_relation(
+ ctx->node, dmd->map_object, DEG_OB_COMP_EVAL_POSE, "Displace Modifier");
+ }
+ else {
+ DEG_add_object_relation(
+ ctx->node, dmd->map_object, DEG_OB_COMP_TRANSFORM, "Displace Modifier");
+ }
DEG_add_modifier_to_transform_relation(ctx->node, "Displace Modifier");
- DEG_add_object_relation(
- ctx->node, dmd->map_object, DEG_OB_COMP_TRANSFORM, "Displace Modifier");
}
if (dmd->texmapping == MOD_DISP_MAP_GLOBAL ||
(ELEM(
diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c
index c0014a2c0cd..912b4a871a6 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -36,6 +36,7 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
+#include "BKE_action.h" /* BKE_pose_channel_find_name */
#include "BKE_deform.h"
#include "BKE_editmesh.h"
#include "BKE_image.h"
@@ -81,12 +82,25 @@ void MOD_get_texture_coords(MappingInfoModifierData *dmd,
const int numVerts = mesh->totvert;
int i;
int texmapping = dmd->texmapping;
- float mapob_imat[4][4];
+ float mapref_imat[4][4];
if (texmapping == MOD_DISP_MAP_OBJECT) {
if (dmd->map_object != NULL) {
Object *map_object = dmd->map_object;
- invert_m4_m4(mapob_imat, map_object->obmat);
+ if (dmd->map_bone[0] != '\0') {
+ bPoseChannel *pchan = BKE_pose_channel_find_name(map_object->pose, dmd->map_bone);
+ if (pchan) {
+ float mat_bone_world[4][4];
+ mul_m4_m4m4(mat_bone_world, map_object->obmat, pchan->pose_mat);
+ invert_m4_m4(mapref_imat, mat_bone_world);
+ }
+ else {
+ invert_m4_m4(mapref_imat, map_object->obmat);
+ }
+ }
+ else {
+ invert_m4_m4(mapref_imat, map_object->obmat);
+ }
}
else { /* if there is no map object, default to local */
texmapping = MOD_DISP_MAP_LOCAL;
@@ -145,7 +159,7 @@ void MOD_get_texture_coords(MappingInfoModifierData *dmd,
break;
case MOD_DISP_MAP_OBJECT:
mul_v3_m4v3(*r_texco, ob->obmat, cos != NULL ? *cos : mv->co);
- mul_m4_v3(mapob_imat, *r_texco);
+ mul_m4_v3(mapref_imat, *r_texco);
break;
}
if (cos != NULL) {
diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c
index c3515578e42..732644411b0 100644
--- a/source/blender/modifiers/intern/MOD_warp.c
+++ b/source/blender/modifiers/intern/MOD_warp.c
@@ -176,8 +176,9 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
}
if ((wmd->texmapping == MOD_DISP_MAP_OBJECT) && wmd->map_object != NULL) {
- DEG_add_object_relation(
- ctx->node, wmd->map_object, DEG_OB_COMP_TRANSFORM, "Warp Modifier map");
+ warp_deps_object_bone_new(ctx->node, wmd->map_object, wmd->map_bone);
+
+ DEG_add_modifier_to_transform_relation(ctx->node, "Warp Modifier map");
}
if (wmd->texture != NULL) {
DEG_add_generic_id_relation(ctx->node, &wmd->texture->id, "Warp Modifier");
diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c
index 56b2a81fdb1..024d70bcfda 100644
--- a/source/blender/modifiers/intern/MOD_wave.c
+++ b/source/blender/modifiers/intern/MOD_wave.c
@@ -102,7 +102,14 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
DEG_add_object_relation(ctx->node, wmd->objectcenter, DEG_OB_COMP_TRANSFORM, "Wave Modifier");
}
if (wmd->map_object != NULL) {
- DEG_add_object_relation(ctx->node, wmd->map_object, DEG_OB_COMP_TRANSFORM, "Wave Modifier");
+ if (wmd->map_bone[0] && wmd->map_object->type == OB_ARMATURE) {
+ DEG_add_object_relation(
+ ctx->node, wmd->map_object, DEG_OB_COMP_EVAL_POSE, "Wave Modifier");
+ }
+ else {
+ DEG_add_object_relation(
+ ctx->node, wmd->map_object, DEG_OB_COMP_TRANSFORM, "Wave Modifier");
+ }
}
if (wmd->objectcenter != NULL || wmd->map_object != NULL) {
DEG_add_modifier_to_transform_relation(ctx->node, "Wave Modifier");
diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c
index 23e4da32ed7..633bbb1421b 100644
--- a/source/blender/modifiers/intern/MOD_weightvg_util.c
+++ b/source/blender/modifiers/intern/MOD_weightvg_util.c
@@ -137,6 +137,7 @@ void weightvg_do_mask(const ModifierEvalContext *ctx,
const int tex_use_channel,
const int tex_mapping,
Object *tex_map_object,
+ const char *text_map_bone,
const char *tex_uvlayer_name,
const bool invert_vgroup_mask)
{
@@ -163,6 +164,7 @@ void weightvg_do_mask(const ModifierEvalContext *ctx,
*/
t_map.texture = texture;
t_map.map_object = tex_map_object;
+ BLI_strncpy(t_map.map_bone, text_map_bone, sizeof(t_map.map_bone));
BLI_strncpy(t_map.uvlayer_name, tex_uvlayer_name, sizeof(t_map.uvlayer_name));
t_map.texmapping = tex_mapping;
diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.h b/source/blender/modifiers/intern/MOD_weightvg_util.h
index bcd1076eac6..6a43ac69fe9 100644
--- a/source/blender/modifiers/intern/MOD_weightvg_util.h
+++ b/source/blender/modifiers/intern/MOD_weightvg_util.h
@@ -73,6 +73,7 @@ void weightvg_do_mask(const ModifierEvalContext *ctx,
const int tex_use_channel,
const int tex_mapping,
Object *tex_map_object,
+ const char *text_map_bone,
const char *tex_uvlayer_name,
const bool invert_vgroup_mask);
diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c
index ba1745f7b5e..e304ca31e86 100644
--- a/source/blender/modifiers/intern/MOD_weightvgedit.c
+++ b/source/blender/modifiers/intern/MOD_weightvgedit.c
@@ -135,8 +135,14 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
{
WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md;
if (wmd->mask_tex_map_obj != NULL && wmd->mask_tex_mapping == MOD_DISP_MAP_OBJECT) {
- DEG_add_object_relation(
- ctx->node, wmd->mask_tex_map_obj, DEG_OB_COMP_TRANSFORM, "WeightVGEdit Modifier");
+ if (wmd->mask_tex_map_bone[0] && wmd->mask_tex_map_obj->type == OB_ARMATURE) {
+ DEG_add_object_relation(
+ ctx->node, wmd->mask_tex_map_obj, DEG_OB_COMP_EVAL_POSE, "WeightVGEdit Modifier");
+ }
+ else {
+ DEG_add_object_relation(
+ ctx->node, wmd->mask_tex_map_obj, DEG_OB_COMP_TRANSFORM, "WeightVGEdit Modifier");
+ }
DEG_add_modifier_to_transform_relation(ctx->node, "WeightVGEdit Modifier");
}
else if (wmd->mask_tex_mapping == MOD_DISP_MAP_GLOBAL) {
@@ -261,6 +267,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
wmd->mask_tex_use_channel,
wmd->mask_tex_mapping,
wmd->mask_tex_map_obj,
+ wmd->mask_tex_map_bone,
wmd->mask_tex_uvlayer_name,
invert_vgroup_mask);
diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c
index 4984853d41e..b109d0af5aa 100644
--- a/source/blender/modifiers/intern/MOD_weightvgmix.c
+++ b/source/blender/modifiers/intern/MOD_weightvgmix.c
@@ -181,8 +181,14 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
{
WeightVGMixModifierData *wmd = (WeightVGMixModifierData *)md;
if (wmd->mask_tex_map_obj != NULL && wmd->mask_tex_mapping == MOD_DISP_MAP_OBJECT) {
- DEG_add_object_relation(
- ctx->node, wmd->mask_tex_map_obj, DEG_OB_COMP_TRANSFORM, "WeightVGMix Modifier");
+ if (wmd->mask_tex_map_bone[0] && wmd->mask_tex_map_obj->type == OB_ARMATURE) {
+ DEG_add_object_relation(
+ ctx->node, wmd->mask_tex_map_obj, DEG_OB_COMP_EVAL_POSE, "WeightVGMix Modifier");
+ }
+ else {
+ DEG_add_object_relation(
+ ctx->node, wmd->mask_tex_map_obj, DEG_OB_COMP_TRANSFORM, "WeightVGMix Modifier");
+ }
DEG_add_object_relation(
ctx->node, wmd->mask_tex_map_obj, DEG_OB_COMP_GEOMETRY, "WeightVGMix Modifier");
@@ -395,6 +401,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
wmd->mask_tex_use_channel,
wmd->mask_tex_mapping,
wmd->mask_tex_map_obj,
+ wmd->mask_tex_map_bone,
wmd->mask_tex_uvlayer_name,
invert_vgroup_mask);
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index 7c9242ed900..2cee3878767 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -376,8 +376,14 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
}
}
if (wmd->mask_tex_map_obj != NULL && wmd->mask_tex_mapping == MOD_DISP_MAP_OBJECT) {
- DEG_add_object_relation(
- ctx->node, wmd->mask_tex_map_obj, DEG_OB_COMP_TRANSFORM, "WeightVGProximity Modifier");
+ if (wmd->mask_tex_map_bone[0] && wmd->mask_tex_map_obj->type == OB_ARMATURE) {
+ DEG_add_object_relation(
+ ctx->node, wmd->mask_tex_map_obj, DEG_OB_COMP_EVAL_POSE, "WeightVGProximity Modifier");
+ }
+ else {
+ DEG_add_object_relation(
+ ctx->node, wmd->mask_tex_map_obj, DEG_OB_COMP_TRANSFORM, "WeightVGProximity Modifier");
+ }
DEG_add_object_relation(
ctx->node, wmd->mask_tex_map_obj, DEG_OB_COMP_GEOMETRY, "WeightVGProximity Modifier");
}
@@ -589,6 +595,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
wmd->mask_tex_use_channel,
wmd->mask_tex_mapping,
wmd->mask_tex_map_obj,
+ wmd->mask_tex_map_bone,
wmd->mask_tex_uvlayer_name,
invert_vgroup_mask);