NLA Editor: Operator to add AnimData to selected objects so that they can appear
This commit introduces an operator in the Add menu - this operator ensures that all selected objects have AnimData attached to them (even if they don't have any actions/drivers yet). By doing this, these objects can at least appear in the NLA Editor, which will allow them to have strips added to them in future without having to create throwaway actions first (NOTE: there's still some stuff coming to allow that). Also, renamed NLA_OT_delete_tracks -> NLA_OT_tracks_delete
This commit is contained in:
@@ -167,6 +167,9 @@ class NLA_MT_add(Menu):
|
||||
layout.separator()
|
||||
layout.operator("nla.tracks_add").above_selected = False
|
||||
layout.operator("nla.tracks_add", text="Add Tracks Above Selected").above_selected = True
|
||||
|
||||
layout.separator()
|
||||
layout.operator("nla.selected_objects_add")
|
||||
|
||||
|
||||
class NLA_MT_edit_transform(Menu):
|
||||
|
||||
@@ -507,11 +507,11 @@ static int nlaedit_delete_tracks_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void NLA_OT_delete_tracks(wmOperatorType *ot)
|
||||
void NLA_OT_tracks_delete(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "Delete Tracks";
|
||||
ot->idname = "NLA_OT_delete_tracks";
|
||||
ot->idname = "NLA_OT_tracks_delete";
|
||||
ot->description = "Delete selected NLA-Tracks and the strips they contain";
|
||||
|
||||
/* api callbacks */
|
||||
@@ -523,3 +523,45 @@ void NLA_OT_delete_tracks(wmOperatorType *ot)
|
||||
}
|
||||
|
||||
/* *********************************************** */
|
||||
/* AnimData Related Operators */
|
||||
|
||||
/* ******************** Include Objects Operator ***************************** */
|
||||
/* Include selected objects in NLA Editor, by giving them AnimData blocks
|
||||
* NOTE: This doesn't help for non-object AnimData, where we do not have any effective
|
||||
* selection mechanism in place. Unfortunately, this means that non-object AnimData
|
||||
* once again becomes a second-class citizen here. However, at least for the most
|
||||
* common use case, we now have a nice shortcut again.
|
||||
*/
|
||||
|
||||
static int nlaedit_objects_add_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
CTX_DATA_BEGIN (C, Object *, ob, selected_objects)
|
||||
{
|
||||
/* ensure that object has AnimData... that's all */
|
||||
BKE_id_add_animdata(&ob->id);
|
||||
}
|
||||
CTX_DATA_END;
|
||||
|
||||
/* set notifier that things have changed */
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
|
||||
|
||||
/* done */
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void NLA_OT_selected_objects_add(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "Include Selected Objects";
|
||||
ot->idname = "NLA_OT_selected_objects_add";
|
||||
ot->description = "Make selected objects in NLA Editor by adding Animation Data";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec = nlaedit_objects_add_exec;
|
||||
ot->poll = nlaop_poll_tweakmode_off;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* *********************************************** */
|
||||
|
||||
@@ -125,7 +125,9 @@ void NLA_OT_fmodifier_paste(wmOperatorType *ot);
|
||||
void NLA_OT_channels_click(wmOperatorType *ot);
|
||||
|
||||
void NLA_OT_tracks_add(wmOperatorType *ot);
|
||||
void NLA_OT_delete_tracks(wmOperatorType *ot);
|
||||
void NLA_OT_tracks_delete(wmOperatorType *ot);
|
||||
|
||||
void NLA_OT_selected_objects_add(wmOperatorType *ot);
|
||||
|
||||
/* **************************************** */
|
||||
/* nla_ops.c */
|
||||
|
||||
@@ -120,7 +120,9 @@ void nla_operatortypes(void)
|
||||
WM_operatortype_append(NLA_OT_channels_click);
|
||||
|
||||
WM_operatortype_append(NLA_OT_tracks_add);
|
||||
WM_operatortype_append(NLA_OT_delete_tracks);
|
||||
WM_operatortype_append(NLA_OT_tracks_delete);
|
||||
|
||||
WM_operatortype_append(NLA_OT_selected_objects_add);
|
||||
|
||||
/* select */
|
||||
WM_operatortype_append(NLA_OT_click_select);
|
||||
@@ -188,8 +190,8 @@ static void nla_keymap_channels(wmKeyMap *keymap)
|
||||
RNA_boolean_set(kmi->ptr, "above_selected", TRUE);
|
||||
|
||||
/* delete tracks */
|
||||
WM_keymap_add_item(keymap, "NLA_OT_delete_tracks", XKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "NLA_OT_delete_tracks", DELKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "NLA_OT_tracks_delete", XKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "NLA_OT_tracks_delete", DELKEY, KM_PRESS, 0, 0);
|
||||
}
|
||||
|
||||
static void nla_keymap_main(wmKeyConfig *keyconf, wmKeyMap *keymap)
|
||||
|
||||
Reference in New Issue
Block a user