diff options
-rw-r--r-- | source/blender/editors/include/ED_object.h | 4 | ||||
-rw-r--r-- | source/blender/editors/object/object_hook.c | 32 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_modifier.c | 11 |
3 files changed, 34 insertions, 13 deletions
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index eae2141e527..13fdbf374bb 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -51,6 +51,7 @@ struct Main; struct Mesh; struct MetaElem; struct ModifierData; +struct HookModifierData; struct Nurb; struct Object; struct ReportList; @@ -218,6 +219,9 @@ struct EnumPropertyItem *ED_object_vgroup_selection_itemf_helper( int *free, const unsigned int selection_mask); +/* object_hook.c */ +void ED_object_hook_reset_do(struct Object *ob, struct HookModifierData *hmd); + #ifdef __cplusplus } #endif diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 37656f82b25..d6f3bf0c262 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -65,6 +65,7 @@ #include "ED_curve.h" #include "ED_mesh.h" #include "ED_screen.h" +#include "ED_object.h" #include "WM_types.h" #include "WM_api.h" @@ -689,19 +690,8 @@ void OBJECT_OT_hook_remove(wmOperatorType *ot) ot->prop = prop; } -static int object_hook_reset_exec(bContext *C, wmOperator *op) +void ED_object_hook_reset_do(Object *ob, HookModifierData *hmd) { - PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); - int num = RNA_enum_get(op->ptr, "modifier"); - Object *ob = NULL; - HookModifierData *hmd = NULL; - - object_hook_from_context(C, &ptr, num, &ob, &hmd); - if (hmd == NULL) { - BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier"); - return OPERATOR_CANCELLED; - } - /* reset functionality */ if (hmd->object) { bPoseChannel *pchan = BKE_pose_channel_find_name(hmd->object->pose, hmd->subtarget); @@ -720,7 +710,23 @@ static int object_hook_reset_exec(bContext *C, wmOperator *op) mul_m4_m4m4(hmd->parentinv, hmd->object->imat, ob->obmat); } } - +} + +static int object_hook_reset_exec(bContext *C, wmOperator *op) +{ + PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); + int num = RNA_enum_get(op->ptr, "modifier"); + Object *ob = NULL; + HookModifierData *hmd = NULL; + + object_hook_from_context(C, &ptr, num, &ob, &hmd); + if (hmd == NULL) { + BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier"); + return OPERATOR_CANCELLED; + } + + ED_object_hook_reset_do(ob, hmd); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 34f138cd7c5..ca3ebff5455 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -120,6 +120,8 @@ EnumPropertyItem modifier_type_items[] = { #include "BKE_modifier.h" #include "BKE_particle.h" +#include "ED_object.h" + static void rna_UVProject_projectors_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { UVProjectModifierData *uvp = (UVProjectModifierData *)ptr->data; @@ -536,6 +538,14 @@ static int rna_MultiresModifier_filepath_length(PointerRNA *ptr) return strlen((external) ? external->filename : ""); } +static void rna_HookModifier_object_set(PointerRNA *ptr, PointerRNA value) +{ + HookModifierData *hmd = ptr->data; + + hmd->object = (Object *)value.data; + ED_object_hook_reset_do((Object *)ptr->id.data, hmd); +} + static void modifier_object_set(Object *self, Object **ob_p, int type, PointerRNA value) { Object *ob = value.data; @@ -1434,6 +1444,7 @@ static void rna_def_modifier_hook(BlenderRNA *brna) prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "Object", "Parent Object for hook, also recalculates and clears offset"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); + RNA_def_property_pointer_funcs(prop, NULL, "rna_HookModifier_object_set", NULL, NULL); RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE); |