コード例 #1
0
static void rna_NlaStrip_remove(NlaTrack *track, bContext *C, ReportList *reports, NlaStrip *strip)
{
	if(BLI_findindex(&track->strips, strip) == -1) {
		BKE_reportf(reports, RPT_ERROR, "NLA's Strip '%s' not found in track '%s'", strip->name, track->name);
		return;
	}
	else {
		free_nlastrip(&track->strips, strip);
		WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_REMOVED, NULL);
	}
}
コード例 #2
0
static NlaStrip *rna_NlaStrip_new(NlaTrack *track, bContext *C, ReportList *reports, const char *UNUSED(name),
                                  int start, bAction *action)
{
	NlaStrip *strip = add_nlastrip(action);
	
	if (strip == NULL) {
		BKE_reportf(reports, RPT_ERROR, "Unable to create new strip");
		return NULL;
	}
	
	strip->end += (start - strip->start);
	strip->start = start;
	
	if (BKE_nlastrips_add_strip(&track->strips, strip) == 0) {
		BKE_reportf(reports, RPT_ERROR,
		            "Unable to add strip. Track doesn't have any space to accommodate this new strip");
		free_nlastrip(NULL, strip);
		return NULL;
	}
	
	/* create dummy AnimData block so that BKE_nlastrip_validate_name()
	 * can be used to ensure a valid name, as we don't have one here...
	 * 	- only the nla_tracks list is needed there, which we aim to reverse engineer here...
	 */
	{
		AnimData adt = {NULL};
		NlaTrack *nlt, *nlt_p;
		
		/* 'first' NLA track is found by going back up chain of given track's parents until we fall off */
		nlt_p = track; nlt = track;
		while ((nlt = nlt->prev) != NULL)
			nlt_p = nlt;
		adt.nla_tracks.first = nlt_p;
		
		/* do the same thing to find the last track */
		nlt_p = track; nlt = track;
		while ((nlt = nlt->next) != NULL)
			nlt_p = nlt;
		adt.nla_tracks.last = nlt_p;
		
		/* now we can just auto-name as usual */
		BKE_nlastrip_validate_name(&adt, strip);
	}
	
	WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_ADDED, NULL);
	
	return strip;
}
コード例 #3
0
ファイル: action_data.c プロジェクト: diekev/blender
void ED_animedit_unlink_action(bContext *C, ID *id, AnimData *adt, bAction *act, ReportList *reports, bool force_delete)
{
	ScrArea *sa = CTX_wm_area(C);
	
	/* If the old action only has a single user (that it's about to lose),
	 * warn user about it
	 *
	 * TODO: Maybe we should just save it for them? But then, there's the problem of
	 *       trying to get rid of stuff that's actually unwanted!
	 */
	if (act->id.us == 1) {
		BKE_reportf(reports, RPT_WARNING,
		            "Action '%s' will not be saved, create Fake User or Stash in NLA Stack to retain",
		            act->id.name + 2);
	}
	
	/* Clear Fake User and remove action stashing strip (if present) */
	if (force_delete) {
		/* Remove stashed strip binding this action to this datablock */
		/* XXX: we cannot unlink it from *OTHER* datablocks that may also be stashing it,
		 * but GE users only seem to use/care about single-object binding for now so this
		 * should be fine
		 */
		if (adt) {
			NlaTrack *nlt, *nlt_next;
			NlaStrip *strip, *nstrip;
			
			for (nlt = adt->nla_tracks.first; nlt; nlt = nlt_next) {
				nlt_next = nlt->next;
				
				if (strstr(nlt->name, DATA_("[Action Stash]"))) {
					for (strip = nlt->strips.first; strip; strip = nstrip) {
						nstrip = strip->next;
						
						if (strip->act == act) {
							/* Remove this strip, and the track too if it doesn't have anything else */
							free_nlastrip(&nlt->strips, strip);
							
							if (nlt->strips.first == NULL) {
								BLI_assert(nstrip == NULL);
								free_nlatrack(&adt->nla_tracks, nlt);
							}
						}
					}
				}
			}
		}
		
		/* Clear Fake User */
		id_fake_user_clear(&act->id);
	}
	
	/* If in Tweak Mode, don't unlink. Instead, this 
	 * becomes a shortcut to exit Tweak Mode instead
	 */
	if ((adt) && (adt->flag & ADT_NLA_EDIT_ON)) {
		/* Exit Tweak Mode */
		BKE_nla_tweakmode_exit(adt);
		
		/* Flush this to the Action Editor (if that's where this change was initiated) */
		if (sa->spacetype == SPACE_ACTION) {
			actedit_change_action(C, NULL);
		}
	}
	else {
		/* Unlink normally - Setting it to NULL should be enough to get the old one unlinked */
		if (sa->spacetype == SPACE_ACTION) {
			/* clear action editor -> action */
			actedit_change_action(C, NULL);
		}
		else {
			/* clear AnimData -> action */
			PointerRNA ptr;
			PropertyRNA *prop;
			
			/* create AnimData RNA pointers */
			RNA_pointer_create(id, &RNA_AnimData, adt, &ptr);
			prop = RNA_struct_find_property(&ptr, "action");
			
			/* clear... */
			RNA_property_pointer_set(&ptr, prop, PointerRNA_NULL);
			RNA_property_update(C, &ptr, prop);
		}
	}
}
コード例 #4
0
static void rna_NlaStrip_remove(NlaTrack *track, bContext *C, ReportList *reports, NlaStrip *strip)
{
	free_nlastrip(&track->strips, strip);

	WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_REMOVED, NULL);
}