Ejemplo n.º 1
0
int RE_engine_render(Render *re, int do_all)
{
	RenderEngineType *type= RE_engines_find(re->r.engine);
	RenderEngine *engine;

	/* verify if we can render */
	if (!type->render)
		return 0;
	if ((re->r.scemode & R_PREVIEWBUTS) && !(type->flag & RE_USE_PREVIEW))
		return 0;
	if (do_all && !(type->flag & RE_USE_POSTPROCESS))
		return 0;
	if (!do_all && (type->flag & RE_USE_POSTPROCESS))
		return 0;

	/* create render result */
	BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
	if (re->result==NULL || !(re->r.scemode & R_PREVIEWBUTS)) {
		if (re->result)
			render_result_free(re->result);
		re->result= render_result_new(re, &re->disprect, 0, 0);
	}
	BLI_rw_mutex_unlock(&re->resultmutex);
	
	if (re->result==NULL)
		return 1;

	/* set render info */
	re->i.cfra= re->scene->r.cfra;
	BLI_strncpy(re->i.scenename, re->scene->id.name+2, sizeof(re->i.scenename));
	re->i.totface=re->i.totvert=re->i.totstrand=re->i.totlamp=re->i.tothalo= 0;

	/* render */
	engine = RE_engine_create(type);
	engine->re= re;

	if (re->flag & R_ANIMATION)
		engine->flag |= RE_ENGINE_ANIMATION;
	if (re->r.scemode & R_PREVIEWBUTS)
		engine->flag |= RE_ENGINE_PREVIEW;
	engine->camera_override = re->camera_override;

	if ((re->r.scemode & (R_NO_FRAME_UPDATE|R_PREVIEWBUTS))==0)
		scene_update_for_newframe(re->main, re->scene, re->lay);

	if (type->update)
		type->update(engine, re->main, re->scene);
	if (type->render)
		type->render(engine, re->scene);

	render_result_free_list(&engine->fullresult, engine->fullresult.first);

	RE_engine_free(engine);

	if (BKE_reports_contain(re->reports, RPT_ERROR))
		G.afbreek = 1;
	
	return 1;
}
Ejemplo n.º 2
0
/* update scene for current frame */
static void motionpaths_calc_update_scene(Scene *scene)
{
#if 1 // 'production' optimisations always on
	Base *base, *last=NULL;
	
	/* only stuff that moves or needs display still */
	DAG_scene_update_flags(G.main, scene, scene->lay, TRUE);
	
	/* find the last object with the tag 
	 *	- all those afterwards are assumed to not be relevant for our calculations
	 */
	// optimize further by moving out...
	for (base=scene->base.first; base; base=base->next) {
		if (base->object->flag & BA_TEMP_TAG)
			last = base;
	}
	
	/* perform updates for tagged objects */
	// XXX: this will break if rigs depend on scene or other data that 
	// is animated but not attached to/updatable from objects
	for (base=scene->base.first; base; base=base->next) {
		/* update this object */
		object_handle_update(scene, base->object);
		
		/* if this is the last one we need to update, let's stop to save some time */
		if (base == last)
			break;
	}
#else // original, 'always correct' version
	/* do all updates 
	 *	- if this is too slow, resort to using a more efficient way 
	 * 	  that doesn't force complete update, but for now, this is the
	 *	  most accurate way!
	 */
	scene_update_for_newframe(G.main, scene, scene->lay); // XXX this is the best way we can get anything moving
#endif
}