Beispiel #1
0
/* helper - add NLA Tracks to empty (and selected) AnimData blocks */
bool nlaedit_add_tracks_empty(bAnimContext *ac)
{
	ListBase anim_data = {NULL, NULL};
	bAnimListElem *ale;
	int filter;
	bool added = false;
	
	/* get a list of the selected AnimData blocks in the NLA */
	filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS);
	ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
	
	/* check if selected AnimData blocks are empty, and add tracks if so... */
	for (ale = anim_data.first; ale; ale = ale->next) {
		AnimData *adt = ale->adt;
		
		/* sanity check */
		BLI_assert(adt->flag & ADT_UI_SELECTED);
		
		/* ensure it is empty */
		if (BLI_listbase_is_empty(&adt->nla_tracks)) {
			/* add new track to this AnimData block then */
			add_nlatrack(adt, NULL);
			added = true;
		}
	}
	
	/* cleanup */
	ANIM_animdata_freelist(&anim_data);
	
	return added;
}
Beispiel #2
0
/* needs wrapper function to push notifier */
static NlaTrack *rna_NlaTrack_new(AnimData *adt, bContext *C, NlaTrack *track)
{
	NlaTrack *new_track = add_nlatrack(adt, track);

	WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, NULL);

	return new_track;
}
Beispiel #3
0
/* helper - add NLA Tracks alongside existing ones */
bool nlaedit_add_tracks_existing(bAnimContext *ac, bool above_sel)
{
	ListBase anim_data = {NULL, NULL};
	bAnimListElem *ale;
	int filter;
	AnimData *lastAdt = NULL;
	bool added = false;
	
	/* get a list of the (selected) NLA Tracks being shown in the NLA */
	filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS);
	ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
	
	/* add tracks... */
	for (ale = anim_data.first; ale; ale = ale->next) {
		if (ale->type == ANIMTYPE_NLATRACK) {
			NlaTrack *nlt = (NlaTrack *)ale->data;
			AnimData *adt = ale->adt;
			
			/* check if just adding a new track above this one,
			 * or whether we're adding a new one to the top of the stack that this one belongs to
			 */
			if (above_sel) {
				/* just add a new one above this one */
				add_nlatrack(adt, nlt);
				added = true;
			}
			else if ((lastAdt == NULL) || (adt != lastAdt)) {
				/* add one track to the top of the owning AnimData's stack, then don't add anymore to this stack */
				add_nlatrack(adt, NULL);
				lastAdt = adt;
				added = true;
			}
		}
	}
	
	/* free temp data */
	ANIM_animdata_freelist(&anim_data);
	
	return added;
}