Esempio n. 1
0
/* flush any temp data from object editing to DNA before writing files,
 * rendering, copying, etc. */
bool ED_editors_flush_edits(const bContext *C, bool for_render)
{
	bool has_edited = false;
	Object *ob;
	Main *bmain = CTX_data_main(C);

	/* loop through all data to find edit mode or object mode, because during
	 * exiting we might not have a context for edit object and multiple sculpt
	 * objects can exist at the same time */
	for (ob = bmain->object.first; ob; ob = ob->id.next) {
		if (ob->mode & OB_MODE_SCULPT) {
			/* flush multires changes (for sculpt) */
			multires_force_update(ob);
			has_edited = true;

			if (for_render) {
				/* flush changes from dynamic topology sculpt */
				BKE_sculptsession_bm_to_me_for_render(ob);
			}
			else {
				/* Set reorder=false so that saving the file doesn't reorder
			 * the BMesh's elements */
				BKE_sculptsession_bm_to_me(ob, false);
			}
		}
		else if (ob->mode & OB_MODE_EDIT) {
			/* get editmode results */
			has_edited = true;
			ED_object_editmode_load(ob);
		}
	}

	return has_edited;
}
Esempio n. 2
0
/* flush any temp data from object editing to DNA before writing files,
 * rendering, copying, etc. */
bool ED_editors_flush_edits(const bContext *C, bool for_render)
{
	bool has_edited = false;
	Object *ob;
	Main *bmain = CTX_data_main(C);

	/* loop through all data to find edit mode or object mode, because during
	 * exiting we might not have a context for edit object and multiple sculpt
	 * objects can exist at the same time */
	for (ob = bmain->object.first; ob; ob = ob->id.next) {
		if (ob->mode & OB_MODE_SCULPT) {
			/* Don't allow flushing while in the middle of a stroke (frees data in use).
			 * Auto-save prevents this from happening but scripts may cause a flush on saving: T53986. */
			if ((ob->sculpt && ob->sculpt->cache) == 0) {
				/* flush multires changes (for sculpt) */
				multires_force_update(ob);
				has_edited = true;

				if (for_render) {
					/* flush changes from dynamic topology sculpt */
					BKE_sculptsession_bm_to_me_for_render(ob);
				}
				else {
					/* Set reorder=false so that saving the file doesn't reorder
					 * the BMesh's elements */
					BKE_sculptsession_bm_to_me(ob, false);
				}
			}
		}
		else if (ob->mode & OB_MODE_EDIT) {
			/* get editmode results */
			has_edited = true;
			ED_object_editmode_load(bmain, ob);
		}
	}

	return has_edited;
}