static void copy_particle_edit(Scene *scene, Object *ob, ParticleSystem *psys, ParticleSystem *psys_from)
{
	PTCacheEdit *edit_from = psys_from->edit, *edit;
	ParticleData *pa;
	KEY_K;
	POINT_P;
	
	if (!edit_from)
		return;
	
	edit = MEM_dupallocN(edit_from);
	edit->psys = psys;
	psys->edit = edit;
	
	edit->pathcache = NULL;
	BLI_listbase_clear(&edit->pathcachebufs);
	
	edit->emitter_field = NULL;
	edit->emitter_cosnos = NULL;
	
	BLI_listbase_clear(&edit->undo);
	edit->curundo = NULL;
	
	edit->points = MEM_dupallocN(edit_from->points);
	pa = psys->particles;
	LOOP_POINTS {
		HairKey *hkey = pa->hair;
		
		point->keys= MEM_dupallocN(point->keys);
		LOOP_KEYS {
			key->co = hkey->co;
			key->time = &hkey->time;
			key->flag = hkey->editflag;
			if (!(psys->flag & PSYS_GLOBAL_HAIR)) {
				key->flag |= PEK_USE_WCO;
				hkey->editflag |= PEK_USE_WCO;
			}
			
			hkey++;
		}
		
		pa++;
	}
	update_world_cos(ob, edit);
	
	UI_GetThemeColor3ubv(TH_EDGE_SELECT, edit->sel_col);
	UI_GetThemeColor3ubv(TH_WIRE, edit->nosel_col);
	
	recalc_lengths(edit);
	recalc_emitter_field(ob, psys);
	PE_update_object(scene, ob, true);
	
	PTCacheUndo_clear(edit);
	PE_undo_push(scene, "Original");
}
Exemple #2
0
void ED_undo_push(bContext *C, const char *str)
{
	wmWindowManager *wm = CTX_wm_manager(C);
	Object *obedit = CTX_data_edit_object(C);
	Object *obact = CTX_data_active_object(C);

	if (G.debug & G_DEBUG)
		printf("%s: %s\n", __func__, str);

	if (obedit) {
		if (U.undosteps == 0) return;
		
		if (obedit->type == OB_MESH)
			undo_push_mesh(C, str);
		else if (ELEM(obedit->type, OB_CURVE, OB_SURF))
			undo_push_curve(C, str);
		else if (obedit->type == OB_FONT)
			undo_push_font(C, str);
		else if (obedit->type == OB_MBALL)
			undo_push_mball(C, str);
		else if (obedit->type == OB_LATTICE)
			undo_push_lattice(C, str);
		else if (obedit->type == OB_ARMATURE)
			undo_push_armature(C, str);
	}
	else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) {
		if (U.undosteps == 0) return;

		PE_undo_push(CTX_data_scene(C), str);
	}
	else {
		BKE_write_undo(C, str);
	}

	if (wm->file_saved) {
		wm->file_saved = 0;
		/* notifier that data changed, for save-over warning or header */
		WM_event_add_notifier(C, NC_WM | ND_DATACHANGED, NULL);
	}
}
Exemple #3
0
void ED_undo_push(bContext *C, const char *str)
{
	Object *obedit = CTX_data_edit_object(C);
	Object *obact = CTX_data_active_object(C);

	if (G.debug & G_DEBUG)
		printf("%s: %s\n", __func__, str);

	if (obedit) {
		if (U.undosteps == 0) return;
		
		if (obedit->type == OB_MESH)
			undo_push_mesh(C, str);
		else if (ELEM(obedit->type, OB_CURVE, OB_SURF))
			undo_push_curve(C, str);
		else if (obedit->type == OB_FONT)
			undo_push_font(C, str);
		else if (obedit->type == OB_MBALL)
			undo_push_mball(C, str);
		else if (obedit->type == OB_LATTICE)
			undo_push_lattice(C, str);
		else if (obedit->type == OB_ARMATURE)
			undo_push_armature(C, str);
	}
	else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) {
		if (U.undosteps == 0) return;

		PE_undo_push(CTX_data_scene(C), str);
	}
	else if (obact && obact->mode & OB_MODE_SCULPT) {
		/* do nothing for now */
	}
	else {
		BKE_undo_write(C, str);
	}

	WM_file_tag_modified(C);
}