/*
 * Bake Dynamic Paint image sequence surface
 */
static int dynamicPaint_initBake(struct bContext *C, struct wmOperator *op)
{
	DynamicPaintModifierData *pmd = NULL;
	DynamicPaintCanvasSettings *canvas;
	Object *ob = ED_object_context(C);
	int status = 0;
	double timer = PIL_check_seconds_timer();
	DynamicPaintSurface *surface;

	/*
	 * Get modifier data
	 */
	pmd = (DynamicPaintModifierData *)modifiers_findByType(ob, eModifierType_DynamicPaint);
	if (!pmd) {
		BKE_report(op->reports, RPT_ERROR, "Bake failed: no Dynamic Paint modifier found");
		return 0;
	}

	/* Make sure we're dealing with a canvas */
	canvas = pmd->canvas;
	if (!canvas) {
		BKE_report(op->reports, RPT_ERROR, "Bake failed: invalid canvas");
		return 0;
	}
	surface = get_activeSurface(canvas);

	/* Set state to baking and init surface */
	canvas->error[0] = '\0';
	canvas->flags |= MOD_DPAINT_BAKING;
	G.is_break = FALSE;  /* reset blender_test_break*/

	/*  Bake Dynamic Paint	*/
	status = dynamicPaint_bakeImageSequence(C, surface, ob);
	/* Clear bake */
	canvas->flags &= ~MOD_DPAINT_BAKING;
	WM_cursor_restore(CTX_wm_window(C));
	dynamicPaint_freeSurfaceData(surface);

	/* Bake was successful:
	 *  Report for ended bake and how long it took */
	if (status) {
		/* Format time string */
		char time_str[30];
		double time = PIL_check_seconds_timer() - timer;
		BLI_timestr(time, time_str);

		/* Show bake info */
		BKE_reportf(op->reports, RPT_INFO, "Bake complete! (%s)", time_str);
	}
	else {
		if (strlen(canvas->error)) { /* If an error occurred */
			BKE_reportf(op->reports, RPT_ERROR, "Bake failed: %s", canvas->error);
		}
		else { /* User canceled the bake */
			BKE_report(op->reports, RPT_WARNING, "Baking canceled!");
		}
	}

	return status;
}
Beispiel #2
0
static void eyedropper_exit(bContext *C, wmOperator *op)
{
	WM_cursor_restore(CTX_wm_window(C));
	
	if(op->customdata)
		MEM_freeN(op->customdata);
	op->customdata= NULL;
}
Beispiel #3
0
static void view_zoom_exit(bContext *C, wmOperator *op, int cancel)
{
	SpaceClip *sc = CTX_wm_space_clip(C);
	ViewZoomData *vpd = op->customdata;

	if (cancel) {
		sc->zoom = vpd->zoom;
		ED_region_tag_redraw(CTX_wm_region(C));
	}

	WM_cursor_restore(CTX_wm_window(C));
	MEM_freeN(op->customdata);
}
Beispiel #4
0
static void view_pan_exit(bContext *C, wmOperator *op, int cancel)
{
	ViewPanData *vpd = op->customdata;

	if (cancel) {
		copy_v2_v2(vpd->vec, &vpd->xorig);

		ED_region_tag_redraw(CTX_wm_region(C));
	}

	WM_cursor_restore(CTX_wm_window(C));
	MEM_freeN(op->customdata);
}
Beispiel #5
0
/* to allow usage all over, we do entire WM */
void WM_cursor_wait(bool val)
{
	if (!G.background) {
		wmWindowManager *wm = G.main->wm.first;
		wmWindow *win = wm ? wm->windows.first : NULL;
		
		for (; win; win = win->next) {
			if (val) {
				WM_cursor_modal(win, BC_WAITCURSOR);
			}
			else {
				WM_cursor_restore(win);
			}
		}
	}
}