Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-04-06 13:07:27 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-04-16 20:55:33 +0300
commit34ab90f546f097cada951b2c9ca22bf271996980 (patch)
treeebcdb3d37120ac1d8fb16462b9104badd1800329 /source/blender/blenkernel/intern/effect.c
parent0c495005dd83913864acb510c1d4194a2275dbb0 (diff)
Depsgraph: remove EvaluationContext, pass Depsgraph instead.
The depsgraph was always created within a fixed evaluation context. Passing both risks the depsgraph and evaluation context not matching, and it complicates the Python API where we'd have to expose both which is not so easy to understand. This also removes the global evaluation context in main, which assumed there to be a single active scene and view layer. Differential Revision: https://developer.blender.org/D3152
Diffstat (limited to 'source/blender/blenkernel/intern/effect.c')
-rw-r--r--source/blender/blenkernel/intern/effect.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index a919353644d..8bdc74edffd 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -74,6 +74,7 @@
#include "BKE_smoke.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "RE_render_ext.h"
#include "RE_shader_ext.h"
@@ -148,10 +149,10 @@ void free_partdeflect(PartDeflect *pd)
MEM_freeN(pd);
}
-static EffectorCache *new_effector_cache(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, ParticleSystem *psys, PartDeflect *pd)
+static EffectorCache *new_effector_cache(struct Depsgraph *depsgraph, Scene *scene, Object *ob, ParticleSystem *psys, PartDeflect *pd)
{
EffectorCache *eff = MEM_callocN(sizeof(EffectorCache), "EffectorCache");
- eff->eval_ctx = eval_ctx;
+ eff->depsgraph = depsgraph;
eff->scene = scene;
eff->ob = ob;
eff->psys = psys;
@@ -159,7 +160,7 @@ static EffectorCache *new_effector_cache(const struct EvaluationContext *eval_ct
eff->frame = -1;
return eff;
}
-static void add_object_to_effectors(ListBase **effectors, const struct EvaluationContext *eval_ctx, Scene *scene, EffectorWeights *weights, Object *ob, Object *ob_src, bool for_simulation)
+static void add_object_to_effectors(ListBase **effectors, struct Depsgraph *depsgraph, Scene *scene, EffectorWeights *weights, Object *ob, Object *ob_src, bool for_simulation)
{
EffectorCache *eff = NULL;
@@ -177,14 +178,14 @@ static void add_object_to_effectors(ListBase **effectors, const struct Evaluatio
if (*effectors == NULL)
*effectors = MEM_callocN(sizeof(ListBase), "effectors list");
- eff = new_effector_cache(eval_ctx, scene, ob, NULL, ob->pd);
+ eff = new_effector_cache(depsgraph, scene, ob, NULL, ob->pd);
/* make sure imat is up to date */
invert_m4_m4(ob->imat, ob->obmat);
BLI_addtail(*effectors, eff);
}
-static void add_particles_to_effectors(ListBase **effectors, const struct EvaluationContext *eval_ctx, Scene *scene, EffectorWeights *weights, Object *ob, ParticleSystem *psys, ParticleSystem *psys_src, bool for_simulation)
+static void add_particles_to_effectors(ListBase **effectors, struct Depsgraph *depsgraph, Scene *scene, EffectorWeights *weights, Object *ob, ParticleSystem *psys, ParticleSystem *psys_src, bool for_simulation)
{
ParticleSettings *part= psys->part;
@@ -198,20 +199,20 @@ static void add_particles_to_effectors(ListBase **effectors, const struct Evalua
if (*effectors == NULL)
*effectors = MEM_callocN(sizeof(ListBase), "effectors list");
- BLI_addtail(*effectors, new_effector_cache(eval_ctx, scene, ob, psys, part->pd));
+ BLI_addtail(*effectors, new_effector_cache(depsgraph, scene, ob, psys, part->pd));
}
if (part->pd2 && part->pd2->forcefield && (!for_simulation || weights->weight[part->pd2->forcefield] != 0.0f)) {
if (*effectors == NULL)
*effectors = MEM_callocN(sizeof(ListBase), "effectors list");
- BLI_addtail(*effectors, new_effector_cache(eval_ctx, scene, ob, psys, part->pd2));
+ BLI_addtail(*effectors, new_effector_cache(depsgraph, scene, ob, psys, part->pd2));
}
}
/* returns ListBase handle with objects taking part in the effecting */
ListBase *pdInitEffectors(
- const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob_src, ParticleSystem *psys_src,
+ struct Depsgraph *depsgraph, Scene *scene, Object *ob_src, ParticleSystem *psys_src,
EffectorWeights *weights, bool for_simulation)
{
ViewLayer *view_layer;
@@ -222,11 +223,11 @@ ListBase *pdInitEffectors(
view_layer = weights->group->view_layer;
}
/* TODO(mai): the check for view_layer shouldnt be needed, remove when render engine api is updated for this */
- else if (eval_ctx && eval_ctx->view_layer) {
- view_layer = eval_ctx->view_layer;
+ else if (depsgraph && DEG_get_evaluated_view_layer(depsgraph)) {
+ view_layer = DEG_get_evaluated_view_layer(depsgraph);
}
else {
- /* eval_ctx is NULL during deg build */
+ /* depsgraph is NULL during deg build */
view_layer = BKE_view_layer_context_active_PLACEHOLDER(scene);
}
@@ -236,20 +237,20 @@ ListBase *pdInitEffectors(
}
if (base->object->pd && base->object->pd->forcefield) {
- add_object_to_effectors(&effectors, eval_ctx, scene, weights, base->object, ob_src, for_simulation);
+ add_object_to_effectors(&effectors, depsgraph, scene, weights, base->object, ob_src, for_simulation);
}
if (base->object->particlesystem.first) {
ParticleSystem *psys= base->object->particlesystem.first;
for (; psys; psys=psys->next) {
- add_particles_to_effectors(&effectors, eval_ctx, scene, weights, base->object, psys, psys_src, for_simulation);
+ add_particles_to_effectors(&effectors, depsgraph, scene, weights, base->object, psys, psys_src, for_simulation);
}
}
}
if (for_simulation) {
- pdPrecalculateEffectors(eval_ctx, effectors);
+ pdPrecalculateEffectors(depsgraph, effectors);
}
return effectors;
@@ -271,7 +272,7 @@ void pdEndEffectors(ListBase **effectors)
}
}
-static void precalculate_effector(const struct EvaluationContext *eval_ctx, EffectorCache *eff)
+static void precalculate_effector(struct Depsgraph *depsgraph, EffectorCache *eff)
{
unsigned int cfra = (unsigned int)(eff->scene->r.cfra >= 0 ? eff->scene->r.cfra : -eff->scene->r.cfra);
if (!eff->pd->rng)
@@ -283,7 +284,7 @@ static void precalculate_effector(const struct EvaluationContext *eval_ctx, Effe
Curve *cu= eff->ob->data;
if (cu->flag & CU_PATH) {
if (eff->ob->curve_cache == NULL || eff->ob->curve_cache->path==NULL || eff->ob->curve_cache->path->data==NULL)
- BKE_displist_make_curveTypes(eval_ctx, eff->scene, eff->ob, 0);
+ BKE_displist_make_curveTypes(depsgraph, eff->scene, eff->ob, 0);
if (eff->ob->curve_cache->path && eff->ob->curve_cache->path->data) {
where_on_path(eff->ob, 0.0, eff->guide_loc, eff->guide_dir, NULL, &eff->guide_radius, NULL);
@@ -304,19 +305,19 @@ static void precalculate_effector(const struct EvaluationContext *eval_ctx, Effe
if (eff->ob) {
float old_vel[3];
- BKE_object_where_is_calc_time(eval_ctx, eff->scene, eff->ob, cfra - 1.0f);
+ BKE_object_where_is_calc_time(depsgraph, eff->scene, eff->ob, cfra - 1.0f);
copy_v3_v3(old_vel, eff->ob->obmat[3]);
- BKE_object_where_is_calc_time(eval_ctx, eff->scene, eff->ob, cfra);
+ BKE_object_where_is_calc_time(depsgraph, eff->scene, eff->ob, cfra);
sub_v3_v3v3(eff->velocity, eff->ob->obmat[3], old_vel);
}
}
-void pdPrecalculateEffectors(const struct EvaluationContext *eval_ctx, ListBase *effectors)
+void pdPrecalculateEffectors(struct Depsgraph *depsgraph, ListBase *effectors)
{
if (effectors) {
EffectorCache *eff = effectors->first;
for (; eff; eff=eff->next)
- precalculate_effector(eval_ctx, eff);
+ precalculate_effector(depsgraph, eff);
}
}
@@ -615,7 +616,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
}
else {
ParticleSimulationData sim= {NULL};
- sim.eval_ctx = eff->eval_ctx;
+ sim.depsgraph = eff->depsgraph;
sim.scene= eff->scene;
sim.ob= eff->ob;
sim.psys= eff->psys;