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-03-27 12:27:00 +0300
committerBastien Montagne <b.mont29@gmail.com>2020-03-27 12:42:40 +0300
commitba1f7acc3f5091398c0c1f2eaabfd7546dde39f8 (patch)
treebe2e55360ed151a3714ce73e1d29ad3f0d0a46a3 /source/blender/modifiers
parent3441862c96d6d08b87ad00040e5349af6f28dc9e (diff)
Warp modifier: add bone from and bone to options when using armature objects
This commit adds the option to use armature bones for the From and To targets when using armature objects. The changes are based on the UV Warp modifier. Reviewed By: mont29 Differential Revision: https://developer.blender.org/D6820
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r--source/blender/modifiers/intern/MOD_warp.c39
1 files changed, 33 insertions, 6 deletions
diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c
index 4a98afbb91c..3157dddd8fc 100644
--- a/source/blender/modifiers/intern/MOD_warp.c
+++ b/source/blender/modifiers/intern/MOD_warp.c
@@ -32,6 +32,7 @@
#include "BKE_colortools.h"
#include "BKE_deform.h"
+#include "BKE_action.h" /* BKE_pose_channel_find_name */
#include "BKE_editmesh.h"
#include "BKE_lib_id.h"
#include "BKE_lib_query.h"
@@ -85,6 +86,17 @@ static void requiredDataMask(Object *UNUSED(ob),
}
}
+static void matrix_from_obj_pchan(float mat[4][4], float obinv[4][4], Object *ob, const char *bonename)
+{
+ bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, bonename);
+ if (pchan) {
+ mul_m4_m4m4(mat, obinv, pchan->pose_mat);
+ }
+ else {
+ mul_m4_m4m4(mat, obinv, ob->obmat);
+ }
+}
+
static bool dependsOnTime(ModifierData *md)
{
WarpModifierData *wmd = (WarpModifierData *)md;
@@ -135,15 +147,29 @@ static void foreachTexLink(ModifierData *md, Object *ob, TexWalkFunc walk, void
walk(userData, ob, md, "texture");
}
+static void warp_deps_object_bone_new(struct DepsNodeHandle *node,
+ Object *object,
+ const char *bonename)
+{
+ if (bonename[0] && object->type == OB_ARMATURE) {
+ DEG_add_object_relation(node, object, DEG_OB_COMP_EVAL_POSE, "Warp Modifier");
+ }
+ else {
+ DEG_add_object_relation(node, object, DEG_OB_COMP_TRANSFORM, "Warp Modifier");
+ }
+}
+
static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
{
WarpModifierData *wmd = (WarpModifierData *)md;
+
if (wmd->object_from != NULL && wmd->object_to != NULL) {
- DEG_add_modifier_to_transform_relation(ctx->node, "Warplace Modifier");
- DEG_add_object_relation(
- ctx->node, wmd->object_from, DEG_OB_COMP_TRANSFORM, "Warp Modifier from");
- DEG_add_object_relation(ctx->node, wmd->object_to, DEG_OB_COMP_TRANSFORM, "Warp Modifier to");
+ warp_deps_object_bone_new(ctx->node, wmd->object_from, wmd->bone_from);
+ warp_deps_object_bone_new(ctx->node, wmd->object_to, wmd->bone_to);
+
+ DEG_add_modifier_to_transform_relation(ctx->node, "Warp Modifier");
}
+
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");
@@ -197,8 +223,9 @@ static void warpModifier_do(WarpModifierData *wmd,
invert_m4_m4(obinv, ob->obmat);
- mul_m4_m4m4(mat_from, obinv, wmd->object_from->obmat);
- mul_m4_m4m4(mat_to, obinv, wmd->object_to->obmat);
+ /* Checks that the objects/bones are available. */
+ matrix_from_obj_pchan(mat_from, obinv, wmd->object_from, wmd->bone_from);
+ matrix_from_obj_pchan(mat_to, obinv, wmd->object_to, wmd->bone_to);
invert_m4_m4(tmat, mat_from); // swap?
mul_m4_m4m4(mat_final, tmat, mat_to);