Exemplo n.º 1
0
bAction *rna_Main_actions_new(Main *UNUSED(bmain), const char *name)
{
	bAction *act= add_empty_action(name);
	id_us_min(&act->id);
	act->id.flag &= ~LIB_FAKEUSER;
	return act;
}
Exemplo n.º 2
0
static int act_new_exec(bContext *C, wmOperator *op)
{
	bAction *action;
	PointerRNA ptr, idptr;
	PropertyRNA *prop;

	// XXX need to restore behaviour to copy old actions...
	action= add_empty_action("Action");

	/* hook into UI */
	uiIDContextProperty(C, &ptr, &prop);

	if(prop) {
		/* when creating new ID blocks, use is already 1, but RNA
		 * pointer se also increases user, so this compensates it */
		action->id.us--;

		RNA_id_pointer_create(&action->id, &idptr);
		RNA_property_pointer_set(&ptr, prop, idptr);
		RNA_property_update(C, &ptr, prop);
	}

	/* set notifier that keyframes have changed */
	WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL);
	
	return OPERATOR_FINISHED;
}
Exemplo n.º 3
0
/* Initialise a new poselib (whether it is needed or not) */
static bAction *poselib_init_new (Object *ob)
{
	/* sanity checks - only for armatures */
	if (ELEM(NULL, ob, ob->pose))
		return NULL;
	
	/* init object's poselib action (unlink old one if there) */
	if (ob->poselib)
		id_us_min(&ob->poselib->id);
	ob->poselib= add_empty_action("PoseLib");
	
	return ob->poselib;
}
Exemplo n.º 4
0
static int act_new_exec(bContext *C, wmOperator *UNUSED(op))
{
	PointerRNA ptr, idptr;
	PropertyRNA *prop;

	/* hook into UI */
	uiIDContextProperty(C, &ptr, &prop);
	
	if (prop) {
		bAction *action = NULL, *oldact = NULL;
		PointerRNA oldptr;
		
		/* create action - the way to do this depends on whether we've got an
		 * existing one there already, in which case we make a copy of it
		 * (which is useful for "versioning" actions within the same file)
		 */
		oldptr = RNA_property_pointer_get(&ptr, prop);
		oldact = (bAction *)oldptr.id.data;
		
		if (oldact && GS(oldact->id.name) == ID_AC) {
			/* make a copy of the existing action */
			action = BKE_action_copy(oldact);
		}
		else {
			Main *bmain = CTX_data_main(C);

			/* just make a new (empty) action */
			action = add_empty_action(bmain, "Action");
		}
		
		/* when creating new ID blocks, use is already 1 (fake user), 
		 * but RNA pointer use also increases user, so this compensates it 
		 */
		action->id.us--;
		
		RNA_id_pointer_create(&action->id, &idptr);
		RNA_property_pointer_set(&ptr, prop, idptr);
		RNA_property_update(C, &ptr, prop);
	}
	
	/* set notifier that keyframes have changed */
	WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
	
	return OPERATOR_FINISHED;
}
Exemplo n.º 5
0
/* Create new action */
static bAction *action_create_new(bContext *C, bAction *oldact)
{
	ScrArea *sa = CTX_wm_area(C);
	bAction *action;
	
	/* create action - the way to do this depends on whether we've got an
	 * existing one there already, in which case we make a copy of it
	 * (which is useful for "versioning" actions within the same file)
	 */
	if (oldact && GS(oldact->id.name) == ID_AC) {
		/* make a copy of the existing action */
		action = BKE_action_copy(CTX_data_main(C), oldact);
	}
	else {
		/* just make a new (empty) action */
		action = add_empty_action(CTX_data_main(C), "Action");
	}
	
	/* when creating new ID blocks, there is already 1 user (as for all new datablocks), 
	 * but the RNA pointer code will assign all the proper users instead, so we compensate
	 * for that here
	 */
	BLI_assert(action->id.us == 1);
	id_us_min(&action->id);
	
	/* set ID-Root type */
	if (sa->spacetype == SPACE_ACTION) {
		SpaceAction *saction = (SpaceAction *)sa->spacedata.first;
		
		if (saction->mode == SACTCONT_SHAPEKEY)
			action->idroot = ID_KE;
		else
			action->idroot = ID_OB;
	}
	
	return action;
}