diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-05-15 21:09:45 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-05-15 21:09:45 +0400 |
commit | a4b5c05aadf5a258fdc4e52596e20c9ca88607f2 (patch) | |
tree | 943b67375877e911750c796841e1f878bb1f66d0 | |
parent | 845376e8d35b99acd4ae1f5a0756e2c83085423a (diff) |
Fixes for blender internal viewport render:
* Particles did not render at viewport resolution like meshes.
* Properties editor preview render of hair was crashing, solution is to have
two separate flags for this preview render and viewport preview render.
-rw-r--r-- | source/blender/editors/render/render_internal.c | 2 | ||||
-rw-r--r-- | source/blender/editors/render/render_preview.c | 2 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_scene_types.h | 3 | ||||
-rw-r--r-- | source/blender/render/intern/source/convertblender.c | 40 | ||||
-rw-r--r-- | source/blender/render/intern/source/external_engine.c | 10 | ||||
-rw-r--r-- | source/blender/render/intern/source/pipeline.c | 8 | ||||
-rw-r--r-- | source/blender/render/intern/source/pointdensity.c | 4 | ||||
-rw-r--r-- | source/blender/render/intern/source/rendercore.c | 2 | ||||
-rw-r--r-- | source/blender/render/intern/source/shadeoutput.c | 2 | ||||
-rw-r--r-- | source/blender/render/intern/source/sss.c | 6 |
10 files changed, 43 insertions, 36 deletions
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 293eba0f658..a172287113f 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -853,7 +853,7 @@ static void render_view3d_startjob(void *customdata, short *stop, short *do_upda rdata = rp->scene->r; rdata.mode &= ~(R_OSA | R_MBLUR | R_BORDER | R_PANORAMA); rdata.scemode &= ~(R_DOSEQ | R_DOCOMP | R_FREE_IMAGE); - rdata.scemode |= R_PREVIEWBUTS; + rdata.scemode |= R_VIEWPORT_PREVIEW; /* we do use layers, but only active */ rdata.scemode |= R_SINGLE_LAYER; diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 34903c26ca0..76fa79029fd 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -273,7 +273,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre if (sce) { /* this flag tells render to not execute depsgraph or ipos etc */ - sce->r.scemode |= R_PREVIEWBUTS; + sce->r.scemode |= R_BUTS_PREVIEW; /* set world always back, is used now */ sce->world = pr_main->world.first; /* now: exposure copy */ diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index eb8c8138e85..bc911f9addc 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1300,7 +1300,7 @@ typedef struct Scene { #define R_BG_RENDER 0x0002 /* passepartout is camera option now, keep this for backward compatibility */ #define R_PASSEPARTOUT 0x0004 -#define R_PREVIEWBUTS 0x0008 +#define R_BUTS_PREVIEW 0x0008 #define R_EXTENSION 0x0010 #define R_MATNODE_PREVIEW 0x0020 #define R_DOCOMP 0x0040 @@ -1316,6 +1316,7 @@ typedef struct Scene { /* #define R_DEPRECATED 0x10000 */ /* #define R_RECURS_PROTECTION 0x20000 */ #define R_TEXNODE_PREVIEW 0x40000 +#define R_VIEWPORT_PREVIEW 0x80000 /* r->stamp */ #define R_STAMP_TIME 0x0001 diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 5721fa3719d..c70ee0e9112 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -1539,7 +1539,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem float random, simplify[2], pa_co[3]; const float cfra= BKE_scene_frame_get(re->scene); int i, a, k, max_k=0, totpart, do_simplify = FALSE, do_surfacecache = FALSE, use_duplimat = FALSE; - int totchild=0; + int totchild=0, step_nbr; int seed, path_nbr=0, orco1=0, num; int totface; char **uv_name=0; @@ -1581,8 +1581,12 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem if (part->type==PART_HAIR && !psys->childcache) totchild= 0; - if (G.is_rendering == FALSE) { /* preview render */ + if (re->r.scemode & R_VIEWPORT_PREVIEW) { /* preview render */ totchild = (int)((float)totchild * (float)part->disp / 100.0f); + step_nbr = part->draw_step; + } + else { + step_nbr = part->ren_step; } psys->flag |= PSYS_DRAWING; @@ -1668,7 +1672,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem /* 2.6 setup strand rendering */ if (part->ren_as == PART_DRAW_PATH && psys->pathcache) { - path_nbr=(int)pow(2.0, (double) part->ren_step); + path_nbr=(int)pow(2.0, (double) step_nbr); if (path_nbr) { if (!ELEM(ma->material_type, MA_TYPE_HALO, MA_TYPE_WIRE)) { @@ -3379,8 +3383,8 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) mask |= CD_MASK_ORIGINDEX | CD_MASK_FREESTYLE_EDGE | CD_MASK_FREESTYLE_FACE; #endif - if (re->r.scemode & R_PREVIEWBUTS) - dm = mesh_get_derived_final(re->scene, ob, mask); + if (re->r.scemode & R_VIEWPORT_PREVIEW) + dm= mesh_create_derived_view(re->scene, ob, mask); else dm= mesh_create_derived_render(re->scene, ob, mask); if (dm==NULL) return; /* in case duplicated object fails? */ @@ -4113,7 +4117,7 @@ static void set_material_lightgroups(Render *re) Material *ma; /* not for preview render */ - if (re->scene->r.scemode & R_PREVIEWBUTS) + if (re->scene->r.scemode & (R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW)) return; for (group= re->main->group.first; group; group=group->id.next) @@ -4689,8 +4693,8 @@ static void init_render_object_data(Render *re, ObjectRen *obr, int timeoffset) /* the emitter mesh wasn't rendered so the modifier stack wasn't * evaluated with render settings */ DerivedMesh *dm; - if (re->r.scemode & R_PREVIEWBUTS) - dm = mesh_get_derived_final(re->scene, ob, CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL); + if (re->r.scemode & R_VIEWPORT_PREVIEW) + dm = mesh_create_derived_view(re->scene, ob, CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL); else dm = mesh_create_derived_render(re->scene, ob, CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL); dm->release(dm); @@ -4735,7 +4739,8 @@ static void add_render_object(Render *re, Object *ob, Object *par, DupliObject * show_emitter= 0; for (psys=ob->particlesystem.first; psys; psys=psys->next) { show_emitter += psys->part->draw & PART_DRAW_EMITTER; - psys_render_set(ob, psys, re->viewmat, re->winmat, re->winx, re->winy, timeoffset); + if (!(re->r.scemode & R_VIEWPORT_PREVIEW)) + psys_render_set(ob, psys, re->viewmat, re->winmat, re->winx, re->winy, timeoffset); } /* if no psys has "show emitter" selected don't render emitter */ @@ -4779,7 +4784,8 @@ static void add_render_object(Render *re, Object *ob, Object *par, DupliObject * if (dob) psys->flag |= PSYS_USE_IMAT; init_render_object_data(re, obr, timeoffset); - psys_render_restore(ob, psys); + if (!(re->r.scemode & R_VIEWPORT_PREVIEW)) + psys_render_restore(ob, psys); psys->flag &= ~PSYS_USE_IMAT; /* only add instance for objects that have not been used for dupli */ @@ -4831,7 +4837,7 @@ void RE_Database_Free(Render *re) /* statistics for debugging render memory usage */ if ((G.debug & G_DEBUG) && (G.is_rendering)) { - if ((re->r.scemode & R_PREVIEWBUTS)==0) { + if ((re->r.scemode & (R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW))==0) { BKE_image_print_memlist(); MEM_printmemlist_stats(); } @@ -4893,7 +4899,7 @@ void RE_Database_Free(Render *re) if (re->scene) if (re->scene->r.scemode & R_FREE_IMAGE) - if ((re->r.scemode & R_PREVIEWBUTS)==0) + if ((re->r.scemode & (R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW))==0) BKE_image_free_all_textures(); if (re->memArena) { @@ -4961,6 +4967,9 @@ static void dupli_render_particle_set(Render *re, Object *ob, int timeoffset, in ParticleSystem *psys; DerivedMesh *dm; + if (re->r.scemode & R_VIEWPORT_PREVIEW) + return; + if (level >= MAX_DUPLI_RECUR) return; @@ -4978,10 +4987,7 @@ static void dupli_render_particle_set(Render *re, Object *ob, int timeoffset, in /* this is to make sure we get render level duplis in groups: * the derivedmesh must be created before init_render_mesh, * since object_duplilist does dupliparticles before that */ - if (re->r.scemode & R_PREVIEWBUTS) - dm = mesh_get_derived_final(re->scene, ob, CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL); - else - dm = mesh_create_derived_render(re->scene, ob, CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL); + dm = mesh_create_derived_render(re->scene, ob, CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL); dm->release(dm); for (psys=ob->particlesystem.first; psys; psys=psys->next) @@ -5245,7 +5251,7 @@ void RE_Database_FromScene(Render *re, Main *bmain, Scene *scene, unsigned int l lay &= 0xFF000000; /* applies changes fully */ - if ((re->r.scemode & (R_NO_FRAME_UPDATE|R_PREVIEWBUTS))==0) + if ((re->r.scemode & (R_NO_FRAME_UPDATE|R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW))==0) BKE_scene_update_for_newframe(re->main, re->scene, lay); /* if no camera, viewmat should have been set! */ diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c index b7cd40043f4..011d48e1994 100644 --- a/source/blender/render/intern/source/external_engine.c +++ b/source/blender/render/intern/source/external_engine.c @@ -258,7 +258,7 @@ void RE_engine_end_result(RenderEngine *engine, RenderResult *result, int cancel if (re->result->do_exr_tile) render_result_exr_file_merge(re->result, result); - else if (!(re->test_break(re->tbh) && (re->r.scemode & R_PREVIEWBUTS))) + else if (!(re->test_break(re->tbh) && (re->r.scemode & R_BUTS_PREVIEW))) render_result_merge(re->result, result); /* draw */ @@ -401,7 +401,7 @@ int RE_engine_render(Render *re, int do_all) /* verify if we can render */ if (!type->render) return 0; - if ((re->r.scemode & R_PREVIEWBUTS) && !(type->flag & RE_USE_PREVIEW)) + if ((re->r.scemode & R_BUTS_PREVIEW) && !(type->flag & RE_USE_PREVIEW)) return 0; if (do_all && !(type->flag & RE_USE_POSTPROCESS)) return 0; @@ -410,7 +410,7 @@ int RE_engine_render(Render *re, int do_all) /* create render result */ BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); - if (re->result == NULL || !(re->r.scemode & R_PREVIEWBUTS)) { + if (re->result == NULL || !(re->r.scemode & R_BUTS_PREVIEW)) { int savebuffers; if (re->result) @@ -444,14 +444,14 @@ int RE_engine_render(Render *re, int do_all) if (re->flag & R_ANIMATION) engine->flag |= RE_ENGINE_ANIMATION; - if (re->r.scemode & R_PREVIEWBUTS) + if (re->r.scemode & R_BUTS_PREVIEW) engine->flag |= RE_ENGINE_PREVIEW; engine->camera_override = re->camera_override; engine->resolution_x = re->winx; engine->resolution_y = re->winy; - if ((re->r.scemode & (R_NO_FRAME_UPDATE | R_PREVIEWBUTS)) == 0) + if ((re->r.scemode & (R_NO_FRAME_UPDATE | R_BUTS_PREVIEW)) == 0) BKE_scene_update_for_newframe(re->main, re->scene, re->lay); RE_parts_init(re, FALSE); diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 8690939fe64..5a672a57237 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -580,7 +580,7 @@ void RE_InitState(Render *re, Render *source, RenderData *rd, SceneRenderLayer * /* if preview render, we try to keep old result */ BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); - if (re->r.scemode & R_PREVIEWBUTS) { + if (re->r.scemode & (R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW)) { if (had_freestyle || (re->r.mode & R_EDGE_FRS)) { /* freestyle manipulates render layers so always have to free */ render_result_free(re->result); @@ -729,7 +729,7 @@ static int render_display_draw_enabled(Render *re) { /* don't show preprocess for previewrender sss */ if (re->sss_points) - return !(re->r.scemode & R_PREVIEWBUTS); + return !(re->r.scemode & (R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW)); else return 1; } @@ -766,7 +766,7 @@ static void *do_part_thread(void *pa_v) } else if (render_display_draw_enabled(&R)) { /* on break, don't merge in result for preview renders, looks nicer */ - if (R.test_break(R.tbh) && (R.r.scemode & R_PREVIEWBUTS)) { + if (R.test_break(R.tbh) && (R.r.scemode & (R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW))) { /* pass */ } else { @@ -947,7 +947,7 @@ static void threaded_tile_processor(Render *re) BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); /* first step; free the entire render result, make new, and/or prepare exr buffer saving */ - if (re->result == NULL || !(re->r.scemode & R_PREVIEWBUTS)) { + if (re->result == NULL || !(re->r.scemode & (R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW))) { render_result_free(re->result); if (re->sss_points && render_display_draw_enabled(re)) diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index d740780ec30..82428f792bb 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -298,7 +298,7 @@ void make_pointdensities(Render *re) { Tex *tex; - if (re->scene->r.scemode & R_PREVIEWBUTS) + if (re->scene->r.scemode & R_BUTS_PREVIEW) return; re->i.infostr = IFACE_("Caching Point Densities"); @@ -318,7 +318,7 @@ void free_pointdensities(Render *re) { Tex *tex; - if (re->scene->r.scemode & R_PREVIEWBUTS) + if (re->scene->r.scemode & R_BUTS_PREVIEW) return; for (tex= re->main->tex.first; tex; tex= tex->id.next) { diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 2d0f575b3e3..fa3cf1cef87 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -1622,7 +1622,7 @@ void zbufshade_sss_tile(RenderPart *pa) VlakRen *vlr; Material *mat= re->sss_mat; float (*co)[3], (*color)[3], *area, *fcol; - int x, y, seed, quad, totpoint, display = !(re->r.scemode & R_PREVIEWBUTS); + int x, y, seed, quad, totpoint, display = !(re->r.scemode & (R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW)); int *ro, *rz, *rp, *rbo, *rbz, *rbp, lay; #if 0 PixStr *ps; diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index 6b48bb79e4d..3eeaebff92d 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -71,7 +71,7 @@ extern struct Render R; ListBase *get_lights(ShadeInput *shi) { - if (R.r.scemode & R_PREVIEWBUTS) + if (R.r.scemode & R_BUTS_PREVIEW) return &R.lights; if (shi->light_override) return &shi->light_override->gobject; diff --git a/source/blender/render/intern/source/sss.c b/source/blender/render/intern/source/sss.c index abce1297783..7a58d20be10 100644 --- a/source/blender/render/intern/source/sss.c +++ b/source/blender/render/intern/source/sss.c @@ -880,14 +880,14 @@ static void sss_create_tree_mat(Render *re, Material *mat) re->sss_mat= mat; re->i.partsdone = FALSE; - if (!(re->r.scemode & R_PREVIEWBUTS)) + if (!(re->r.scemode & (R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW))) re->result= NULL; BLI_rw_mutex_unlock(&re->resultmutex); RE_TileProcessor(re); BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); - if (!(re->r.scemode & R_PREVIEWBUTS)) { + if (!(re->r.scemode & (R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW))) { RE_FreeRenderResult(re->result); re->result= rr; } @@ -937,7 +937,7 @@ static void sss_create_tree_mat(Render *re, Material *mat) float error = mat->sss_error; error= get_render_aosss_error(&re->r, error); - if ((re->r.scemode & R_PREVIEWBUTS) && error < 0.5f) + if ((re->r.scemode & (R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW)) && error < 0.5f) error= 0.5f; sss->ss[0]= scatter_settings_new(mat->sss_col[0], radius[0], ior, cfac, fw, bw); |