static int render_view3d_changed(RenderEngine *engine, const bContext *C)
{
	ARegion *ar = CTX_wm_region(C);
	Render *re;
	int update = 0;
	char name[32];
	
	sprintf(name, "View3dPreview %p", (void *)ar);
	re = RE_GetRender(name);

	if (re) {
		RegionView3D *rv3d = CTX_wm_region_view3d(C);
		View3D *v3d = CTX_wm_view3d(C);
		Scene *scene = CTX_data_scene(C);
		rctf viewplane, viewplane1;
		rcti disprect, disprect1;
		float mat[4][4];
		float clipsta, clipend;
		bool orth;

		if (engine->update_flag & RE_ENGINE_UPDATE_MA)
			update |= PR_UPDATE_MATERIAL;
		
		if (engine->update_flag & RE_ENGINE_UPDATE_OTHER)
			update |= PR_UPDATE_MATERIAL;
		
		engine->update_flag = 0;
		
		if (engine->resolution_x != ar->winx || engine->resolution_y != ar->winy)
			update |= PR_UPDATE_RENDERSIZE;

		RE_GetView(re, mat);
		if (compare_m4m4(mat, rv3d->viewmat, 0.00001f) == 0) {
			update |= PR_UPDATE_VIEW;
		}
		
		render_view3d_get_rects(ar, v3d, rv3d, &viewplane, engine, &clipsta, &clipend, NULL, &orth);
		RE_GetViewPlane(re, &viewplane1, &disprect1);
		
		if (BLI_rctf_compare(&viewplane, &viewplane1, 0.00001f) == 0)
			update |= PR_UPDATE_VIEW;
		
		render_view3d_disprect(scene, ar, v3d, rv3d, &disprect);
		if (BLI_rcti_compare(&disprect, &disprect1) == 0)
			update |= PR_UPDATE_RENDERSIZE;
		
		if (update)
			engine->flag |= RE_ENGINE_DO_UPDATE;
		//if (update)
		//	printf("changed ma %d res %d view %d\n", update & PR_UPDATE_MATERIAL, update & PR_UPDATE_RENDERSIZE, update & PR_UPDATE_VIEW);
	}
	
	return update;
}
Esempio n. 2
0
static bool ui_editsource_uibut_match(uiBut *but_a, uiBut *but_b)
{
#  if 0
  printf("matching buttons: '%s' == '%s'\n", but_a->drawstr, but_b->drawstr);
#  endif

  /* this just needs to be a 'good-enough' comparison so we can know beyond
   * reasonable doubt that these buttons are the same between redraws.
   * if this fails it only means edit-source fails - campbell */
  if (BLI_rctf_compare(&but_a->rect, &but_b->rect, FLT_EPSILON) && (but_a->type == but_b->type) &&
      (but_a->rnaprop == but_b->rnaprop) && (but_a->optype == but_b->optype) &&
      (but_a->unit_type == but_b->unit_type) &&
      STREQLEN(but_a->drawstr, but_b->drawstr, UI_MAX_DRAW_STR)) {
    return true;
  }
  else {
    return false;
  }
}
Esempio n. 3
0
static bool render_view3d_flag_changed(RenderEngine *engine, const bContext *C)
{
	RegionView3D *rv3d = CTX_wm_region_view3d(C);
	View3D *v3d = CTX_wm_view3d(C);
	ARegion *ar = CTX_wm_region(C);
	Scene *scene = CTX_data_scene(C);
	Render *re;
	rctf viewplane;
	rcti disprect;
	float clipsta, clipend;
	bool orth;
	int job_update_flag = 0;
	char name[32];
	
	/* ensure render engine exists */
	re = engine->re;

	if (!re) {
		sprintf(name, "View3dPreview %p", (void *)ar);
		re = engine->re = RE_GetRender(name);
		if (!re)
			re = engine->re = RE_NewRender(name);

		engine->update_flag |= RE_ENGINE_UPDATE_DATABASE;
	}

	/* check update_flag */
	if (engine->update_flag & RE_ENGINE_UPDATE_MA)
		job_update_flag |= PR_UPDATE_MATERIAL;
	
	if (engine->update_flag & RE_ENGINE_UPDATE_OTHER)
		job_update_flag |= PR_UPDATE_MATERIAL;
	
	if (engine->update_flag & RE_ENGINE_UPDATE_DATABASE) {
		job_update_flag |= PR_UPDATE_DATABASE;

		/* load editmesh */
		if (scene->obedit)
			ED_object_editmode_load(scene->obedit);
	}
	
	engine->update_flag = 0;
	
	/* check if viewport changed */
	if (engine->last_winx != ar->winx || engine->last_winy != ar->winy) {
		engine->last_winx = ar->winx;
		engine->last_winy = ar->winy;
		job_update_flag |= PR_UPDATE_RENDERSIZE;
	}

	if (compare_m4m4(engine->last_viewmat, rv3d->viewmat, 0.00001f) == 0) {
		copy_m4_m4(engine->last_viewmat, rv3d->viewmat);
		job_update_flag |= PR_UPDATE_VIEW;
	}
	
	render_view3d_get_rects(ar, v3d, rv3d, &viewplane, engine, &clipsta, &clipend, NULL, &orth);
	
	if (BLI_rctf_compare(&viewplane, &engine->last_viewplane, 0.00001f) == 0) {
		engine->last_viewplane = viewplane;
		job_update_flag |= PR_UPDATE_VIEW;
	}
	
	render_view3d_disprect(scene, ar, v3d, rv3d, &disprect);
	if (BLI_rcti_compare(&disprect, &engine->last_disprect) == 0) {
		engine->last_disprect = disprect;
		job_update_flag |= PR_UPDATE_RENDERSIZE;
	}

	/* any changes? go ahead and rerender */
	if (job_update_flag) {
		engine->job_update_flag |= job_update_flag;
		return true;
	}

	return false;
}