diff options
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r-- | source/blender/editors/object/object_edit.c | 112 | ||||
-rw-r--r-- | source/blender/editors/object/object_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/object/object_ops.c | 2 |
3 files changed, 116 insertions, 0 deletions
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 54fa3f51eb6..e2d714fac0d 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1610,6 +1610,118 @@ void copy_attr_menu(Scene *scene, View3D *v3d) copy_attr(scene, v3d, event); } +/* ********************************************** */ +/* Motion Paths */ + +/* For the object with pose/action: update paths for those that have got them + * This should selectively update paths that exist... + * + * To be called from various tools that do incremental updates + */ +void ED_objects_recalculate_paths(bContext *C, Scene *scene) +{ + ListBase targets = {NULL, NULL}; + + /* loop over objects in scene */ + CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) + { + /* set flag to force recalc, then grab the relevant bones to target */ + ob->avs.recalc |= ANIMVIZ_RECALC_PATHS; + animviz_get_object_motionpaths(ob, &targets); + } + CTX_DATA_END; + + /* recalculate paths, then free */ + animviz_calc_motionpaths(scene, &targets); + BLI_freelistN(&targets); +} + +/* For the object with pose/action: create path curves for selected bones + * This recalculates the WHOLE path within the pchan->pathsf and pchan->pathef range + */ +static int object_calculate_paths_exec (bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + + /* set up path data for bones being calculated */ + CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) + { + /* verify makes sure that the selected bone has a bone with the appropriate settings */ + animviz_verify_motionpaths(scene, ob, NULL); + } + CTX_DATA_END; + + /* calculate the bones that now have motionpaths... */ + // TODO: only make for the selected bones? + ED_objects_recalculate_paths(C, scene); + + /* notifiers for updates */ + WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_paths_calculate (wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Calculate Object Paths"; + ot->idname= "OBJECT_OT_paths_calculate"; + ot->description= "Calculate paths for the selected bones."; + + /* api callbacks */ + ot->exec= object_calculate_paths_exec; + ot->poll= ED_operator_object_active_editable; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +/* --------- */ + +/* for the object with pose/action: clear path curves for selected bones only */ +void ED_objects_clear_paths(bContext *C, Scene *scene) +{ + /* loop over objects in scene */ + CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) + { + if (ob->mpath) { + animviz_free_motionpath(ob->mpath); + ob->mpath= NULL; + } + } + CTX_DATA_END; +} + +/* operator callback for this */ +static int object_clear_paths_exec (bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + + /* use the backend function for this */ + ED_objects_clear_paths(C, scene); + + /* notifiers for updates */ + WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_paths_clear (wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Clear Object Paths"; + ot->idname= "OBJECT_OT_paths_clear"; + ot->description= "Clear path caches for selected bones."; + + /* api callbacks */ + ot->exec= object_clear_paths_exec; + ot->poll= ED_operator_object_active_editable; + + /* flags */ + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; +} + + /********************** Smooth/Flat *********************/ static int shade_smooth_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index cfb4cda2460..a11ead1fe9d 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -79,6 +79,8 @@ void OBJECT_OT_restrictview_clear(struct wmOperatorType *ot); void OBJECT_OT_proxy_make(struct wmOperatorType *ot); void OBJECT_OT_shade_smooth(struct wmOperatorType *ot); void OBJECT_OT_shade_flat(struct wmOperatorType *ot); +void OBJECT_OT_paths_calculate(struct wmOperatorType *ot); +void OBJECT_OT_paths_clear(struct wmOperatorType *ot); /* object_select.c */ void OBJECT_OT_select_all(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 8b29e2ca2ae..80992887e97 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -81,6 +81,8 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_restrictview_set); WM_operatortype_append(OBJECT_OT_shade_smooth); WM_operatortype_append(OBJECT_OT_shade_flat); + WM_operatortype_append(OBJECT_OT_paths_calculate); + WM_operatortype_append(OBJECT_OT_paths_clear); WM_operatortype_append(OBJECT_OT_parent_set); WM_operatortype_append(OBJECT_OT_parent_no_inverse_set); |