diff options
author | Luca Rood <dev@lucarood.com> | 2017-07-21 12:53:13 +0300 |
---|---|---|
committer | Luca Rood <dev@lucarood.com> | 2017-07-21 15:47:26 +0300 |
commit | 1c4c288727214fa0588d66556a1cdf71755d70b4 (patch) | |
tree | 1433952be7e88cc7d09e8563831995290e3013ce /source/blender/render | |
parent | 9edb7e49d7e5e69385f3a0434c568c79fad88cd8 (diff) |
Pass EvaluationContext argument everywhere
Note that some little parts of code have been dissabled because eval_ctx
was not available there. This should be resolved once DerivedMesh is
replaced.
Diffstat (limited to 'source/blender/render')
7 files changed, 80 insertions, 28 deletions
diff --git a/source/blender/render/extern/include/RE_engine.h b/source/blender/render/extern/include/RE_engine.h index 3086c9d4fad..a4de7104071 100644 --- a/source/blender/render/extern/include/RE_engine.h +++ b/source/blender/render/extern/include/RE_engine.h @@ -189,5 +189,7 @@ struct RenderData *RE_engine_get_render_data(struct Render *re); void RE_bake_engine_set_engine_parameters( struct Render *re, struct Main *bmain, struct Depsgraph *graph, struct Scene *scene); +struct SceneLayer *RE_engine_get_scene_layer(struct Render *re); + #endif /* __RE_ENGINE_H__ */ diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index 145186548e6..45fb33034b0 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -38,6 +38,7 @@ struct bMovieHandle; struct bNodeTree; struct Depsgraph; +struct EvaluationContext; struct Image; struct ImageFormatData; struct Main; @@ -369,6 +370,7 @@ void RE_DataBase_GetView(struct Render *re, float mat[4][4]); void RE_GetCameraWindow(struct Render *re, struct Object *camera, int frame, float mat[4][4]); void RE_GetCameraModelMatrix(struct Render *re, struct Object *camera, float r_mat[4][4]); struct Scene *RE_GetScene(struct Render *re); +struct EvaluationContext *RE_GetEvalCtx(struct Render *re); bool RE_force_single_renderlayer(struct Scene *scene); bool RE_is_rendering_allowed(struct Scene *scene, struct Object *camera_override, struct ReportList *reports); diff --git a/source/blender/render/extern/include/RE_render_ext.h b/source/blender/render/extern/include/RE_render_ext.h index 2b5d0ca4e14..f296c117495 100644 --- a/source/blender/render/extern/include/RE_render_ext.h +++ b/source/blender/render/extern/include/RE_render_ext.h @@ -41,6 +41,8 @@ struct DerivedMesh; struct ImagePool; struct MTex; struct Scene; +struct SceneLayer; +struct Render; /* render_texture.c */ /* used by particle.c, effect.c, editmesh_modes.c and brush.c, returns 1 if rgb, 0 otherwise */ @@ -70,17 +72,20 @@ struct PointDensity; void RE_point_density_cache( struct Scene *scene, + struct SceneLayer *sl, struct PointDensity *pd, const bool use_render_params); void RE_point_density_minmax( struct Scene *scene, + struct SceneLayer *sl, struct PointDensity *pd, const bool use_render_params, float r_min[3], float r_max[3]); void RE_point_density_sample( struct Scene *scene, + struct SceneLayer *sl, struct PointDensity *pd, const int resolution, const bool use_render_params, diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 42cef07205c..9d2ac76f7e6 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -1350,10 +1350,11 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem if (!(psmd->modifier.mode & eModifierMode_Render)) return 0; - sim.scene= re->scene; - sim.ob= ob; - sim.psys= psys; - sim.psmd= psmd; + sim.eval_ctx = re->eval_ctx; + sim.scene = re->scene; + sim.ob = ob; + sim.psys = psys; + sim.psmd = psmd; if (part->phystype==PART_PHYS_KEYED) psys_count_keyed_targets(&sim); @@ -2600,13 +2601,13 @@ static void init_render_surf(Render *re, ObjectRen *obr, int timeoffset) if (ob->parent && (ob->parent->type==OB_LATTICE)) need_orco= 1; - BKE_displist_make_surf(re->scene, ob, &displist, &dm, 1, 0, 1); + BKE_displist_make_surf(re->eval_ctx, re->scene, ob, &displist, &dm, 1, 0, 1); if (dm) { if (need_orco) { orco = get_object_orco(re, ob); if (!orco) { - orco= BKE_displist_make_orco(re->scene, ob, dm, true, true); + orco= BKE_displist_make_orco(re->eval_ctx, re->scene, ob, dm, true, true); if (orco) { set_object_orco(re, ob, orco); } @@ -2658,7 +2659,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) if (ob->type==OB_FONT && cu->str==NULL) return; else if (ob->type==OB_CURVE && cu->nurb.first==NULL) return; - BKE_displist_make_curveTypes_forRender(re->scene, ob, &disp, &dm, false, true); + BKE_displist_make_curveTypes_forRender(re->eval_ctx, re->scene, ob, &disp, &dm, false, true); dl= disp.first; if (dl==NULL) return; @@ -2685,7 +2686,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) if (need_orco) { orco = get_object_orco(re, ob); if (!orco) { - orco = BKE_displist_make_orco(re->scene, ob, dm, true, true); + orco = BKE_displist_make_orco(re->eval_ctx, re->scene, ob, dm, true, true); if (orco) { set_object_orco(re, ob, orco); } @@ -2699,7 +2700,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) if (need_orco) { orco = get_object_orco(re, ob); if (!orco) { - orco = BKE_curve_make_orco(re->scene, ob, NULL); + orco = BKE_curve_make_orco(re->eval_ctx, re->scene, ob, NULL); set_object_orco(re, ob, orco); } } @@ -3199,9 +3200,9 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) #endif if (re->r.scemode & R_VIEWPORT_PREVIEW) - dm= mesh_create_derived_view(re->scene, ob, mask); + dm= mesh_create_derived_view(re->eval_ctx, re->scene, ob, mask); else - dm= mesh_create_derived_render(re->scene, ob, mask); + dm= mesh_create_derived_render(re->eval_ctx, re->scene, ob, mask); if (dm==NULL) return; /* in case duplicated object fails? */ mvert= dm->getVertArray(dm); @@ -4619,9 +4620,9 @@ static void init_render_object_data(Render *re, ObjectRen *obr, int timeoffset) const CustomDataMask mask = CD_MASK_RENDER_INTERNAL; if (re->r.scemode & R_VIEWPORT_PREVIEW) - dm = mesh_create_derived_view(re->scene, ob, mask); + dm = mesh_create_derived_view(re->eval_ctx, re->scene, ob, mask); else - dm = mesh_create_derived_render(re->scene, ob, mask); + dm = mesh_create_derived_render(re->eval_ctx, re->scene, ob, mask); dm->release(dm); } @@ -4930,7 +4931,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 */ - dm = mesh_create_derived_render(re->scene, ob, CD_MASK_RENDER_INTERNAL); + dm = mesh_create_derived_render(re->eval_ctx, re->scene, ob, CD_MASK_RENDER_INTERNAL); dm->release(dm); for (psys=ob->particlesystem.first; psys; psys=psys->next) @@ -5053,7 +5054,7 @@ static void database_init_objects(Render *re, unsigned int UNUSED(renderlay), in * system need to have render settings set for dupli particles */ dupli_render_particle_set(re, ob, timeoffset, 0, 1); duplilist = object_duplilist(re->eval_ctx, re->scene, ob); - duplilist_apply_data = duplilist_apply(ob, NULL, duplilist); + duplilist_apply_data = duplilist_apply(re->eval_ctx, ob, NULL, duplilist); /* postpone 'dupli_render_particle_set', since RE_addRenderInstance reads * index values from 'dob->persistent_id[0]', referencing 'psys->child' which * may be smaller once the particle system is restored, see: T45563. */ diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c index be6d6459b2f..c2e6d540ad8 100644 --- a/source/blender/render/intern/source/external_engine.c +++ b/source/blender/render/intern/source/external_engine.c @@ -791,3 +791,8 @@ void RE_engine_register_pass(struct RenderEngine *engine, struct Scene *scene, s } } } + +SceneLayer *RE_engine_get_scene_layer(Render *re) +{ + return re->eval_ctx->scene_layer; +} diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index bfc0400e2a9..4b7145bcb99 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -354,6 +354,15 @@ Scene *RE_GetScene(Render *re) return NULL; } +EvaluationContext *RE_GetEvalCtx(Render *re) +{ + if (re) { + return re->eval_ctx; + } + + return NULL; +} + /** * Same as #RE_AcquireResultImage but creating the necessary views to store the result * fill provided result struct with a copy of thew views of what is done so far the diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index fb047aad897..4338feb6353 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -58,6 +58,8 @@ #include "BKE_texture.h" #include "BKE_colortools.h" +#include "DEG_depsgraph.h" + #include "render_types.h" #include "texture.h" #include "pointdensity.h" @@ -167,7 +169,7 @@ static void alloc_point_data(PointDensity *pd) } } -static void pointdensity_cache_psys(Scene *scene, +static void pointdensity_cache_psys(EvaluationContext *eval_ctx, Scene *scene, PointDensity *pd, Object *ob, ParticleSystem *psys, @@ -201,12 +203,12 @@ static void pointdensity_cache_psys(Scene *scene, } if (use_render_params) { - dm = mesh_create_derived_render(scene, + dm = mesh_create_derived_render(eval_ctx, scene, ob, CD_MASK_BAREMESH | CD_MASK_MTFACE | CD_MASK_MCOL); } else { - dm = mesh_get_derived_final(scene, + dm = mesh_get_derived_final(eval_ctx, scene, ob, CD_MASK_BAREMESH | CD_MASK_MTFACE | CD_MASK_MCOL); } @@ -216,6 +218,7 @@ static void pointdensity_cache_psys(Scene *scene, return; } + sim.eval_ctx = eval_ctx; sim.scene = scene; sim.ob = ob; sim.psys = psys; @@ -400,7 +403,7 @@ static void pointdensity_cache_vertex_normal(PointDensity *pd, Object *UNUSED(ob } } -static void pointdensity_cache_object(Scene *scene, +static void pointdensity_cache_object(EvaluationContext *eval_ctx, Scene *scene, PointDensity *pd, Object *ob, const bool use_render_params) @@ -421,10 +424,10 @@ static void pointdensity_cache_object(Scene *scene, } if (use_render_params) { - dm = mesh_create_derived_render(scene, ob, mask); + dm = mesh_create_derived_render(eval_ctx, scene, ob, mask); } else { - dm = mesh_get_derived_final(scene, ob, mask); + dm = mesh_get_derived_final(eval_ctx, scene, ob, mask); } mvert = dm->getVertArray(dm); /* local object space */ @@ -475,7 +478,7 @@ static void pointdensity_cache_object(Scene *scene, } -static void cache_pointdensity_ex(Scene *scene, +static void cache_pointdensity_ex(EvaluationContext *eval_ctx, Scene *scene, PointDensity *pd, float viewmat[4][4], float winmat[4][4], @@ -504,7 +507,8 @@ static void cache_pointdensity_ex(Scene *scene, return; } - pointdensity_cache_psys(scene, + pointdensity_cache_psys(eval_ctx, + scene, pd, ob, psys, @@ -515,13 +519,14 @@ static void cache_pointdensity_ex(Scene *scene, else if (pd->source == TEX_PD_OBJECT) { Object *ob = pd->object; if (ob && ob->type == OB_MESH) - pointdensity_cache_object(scene, pd, ob, use_render_params); + pointdensity_cache_object(eval_ctx, scene, pd, ob, use_render_params); } } void cache_pointdensity(Render *re, PointDensity *pd) { - cache_pointdensity_ex(re->scene, + cache_pointdensity_ex(re->eval_ctx, + re->scene, pd, re->viewmat, re->winmat, re->winx, re->winy, @@ -876,7 +881,8 @@ static void sample_dummy_point_density(int resolution, float *values) memset(values, 0, sizeof(float) * 4 * resolution * resolution * resolution); } -static void particle_system_minmax(Scene *scene, +static void particle_system_minmax(EvaluationContext *eval_ctx, + Scene *scene, Object *object, ParticleSystem *psys, float radius, @@ -903,6 +909,7 @@ static void particle_system_minmax(Scene *scene, psys_render_set(object, psys, mat, mat, 1, 1, 0); } + sim.eval_ctx = eval_ctx; sim.scene = scene; sim.ob = object; sim.psys = psys; @@ -938,19 +945,28 @@ static void particle_system_minmax(Scene *scene, void RE_point_density_cache( Scene *scene, + SceneLayer *sl, PointDensity *pd, const bool use_render_params) { + EvaluationContext eval_ctx = {0}; float mat[4][4]; + + DEG_evaluation_context_init(&eval_ctx, use_render_params ? DAG_EVAL_RENDER : + DAG_EVAL_VIEWPORT); + + eval_ctx.scene_layer = sl; + /* Same matricies/resolution as dupli_render_particle_set(). */ unit_m4(mat); BLI_mutex_lock(&sample_mutex); - cache_pointdensity_ex(scene, pd, mat, mat, 1, 1, use_render_params); + cache_pointdensity_ex(&eval_ctx, scene, pd, mat, mat, 1, 1, use_render_params); BLI_mutex_unlock(&sample_mutex); } void RE_point_density_minmax( struct Scene *scene, + SceneLayer *sl, struct PointDensity *pd, const bool use_render_params, float r_min[3], float r_max[3]) @@ -963,6 +979,8 @@ void RE_point_density_minmax( } if (pd->source == TEX_PD_PSYS) { ParticleSystem *psys; + EvaluationContext eval_ctx = {0}; + if (pd->psys == 0) { zero_v3(r_min); zero_v3(r_max); @@ -974,7 +992,15 @@ void RE_point_density_minmax( zero_v3(r_max); return; } - particle_system_minmax(scene, + + DEG_evaluation_context_init(&eval_ctx, use_render_params ? DAG_EVAL_RENDER : + DAG_EVAL_VIEWPORT); + + eval_ctx.ctime = (float)scene->r.cfra + scene->r.subframe; + eval_ctx.scene_layer = sl; + + particle_system_minmax(&eval_ctx, + scene, object, psys, pd->radius, @@ -1044,6 +1070,7 @@ static void point_density_sample_func(void *data_v, const int iter) */ void RE_point_density_sample( Scene *scene, + SceneLayer *sl, PointDensity *pd, const int resolution, const bool use_render_params, @@ -1063,6 +1090,7 @@ void RE_point_density_sample( BLI_mutex_lock(&sample_mutex); RE_point_density_minmax(scene, + sl, pd, use_render_params, min, |