diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/makesdna/DNA_modifier_types.h | 5 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_modifier.c | 16 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_warp.c | 39 |
3 files changed, 52 insertions, 8 deletions
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 5213dba6c79..405f12d5fb9 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -1324,6 +1324,11 @@ typedef struct WarpModifierData { struct Object *object_from; struct Object *object_to; + /** Optional name of bone target, MAX_ID_NAME-2. */ + char bone_from[64]; + /** Optional name of bone target, MAX_ID_NAME-2. */ + char bone_to[64]; + struct CurveMapping *curfalloff; /** Optional vertexgroup name, MAX_VGROUP_NAME. */ char defgrp_name[64]; diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index e0c9be7ddae..51b50647e1d 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -1795,17 +1795,29 @@ static void rna_def_modifier_warp(BlenderRNA *brna) RNA_def_struct_ui_icon(srna, ICON_MOD_WARP); prop = RNA_def_property(srna, "object_from", PROP_POINTER, PROP_NONE); - RNA_def_property_ui_text(prop, "From", "Object to transform from"); + RNA_def_property_pointer_sdna(prop, NULL, "object_from"); + RNA_def_property_ui_text(prop, "Object From", "Object to transform from"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); + prop = RNA_def_property(srna, "bone_from", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "bone_from"); + RNA_def_property_ui_text(prop, "Bone From", "Bone to transform from"); + RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); + prop = RNA_def_property(srna, "object_to", PROP_POINTER, PROP_NONE); - RNA_def_property_ui_text(prop, "To", "Object to transform to"); + RNA_def_property_pointer_sdna(prop, NULL, "object_to"); + RNA_def_property_ui_text(prop, "Object To", "Object to transform to"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); + prop = RNA_def_property(srna, "bone_to", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "bone_to"); + RNA_def_property_ui_text(prop, "Bone To", "Bone defining offset"); + RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); + prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); RNA_def_property_ui_range(prop, -100, 100, 10, 2); 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); |