From 34ab90f546f097cada951b2c9ca22bf271996980 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 6 Apr 2018 12:07:27 +0200 Subject: 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 --- source/blender/blenkernel/intern/rigidbody.c | 34 ++++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'source/blender/blenkernel/intern/rigidbody.c') diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index ff521260993..ab8f9dcb2e4 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -1237,7 +1237,7 @@ static void rigidbody_update_sim_world(Scene *scene, RigidBodyWorld *rbw) rigidbody_update_ob_array(rbw); } -static void rigidbody_update_sim_ob(const struct EvaluationContext *eval_ctx, Scene *scene, RigidBodyWorld *rbw, Object *ob, RigidBodyOb *rbo) +static void rigidbody_update_sim_ob(struct Depsgraph *depsgraph, Scene *scene, RigidBodyWorld *rbw, Object *ob, RigidBodyOb *rbo) { float loc[3]; float rot[4]; @@ -1285,7 +1285,7 @@ static void rigidbody_update_sim_ob(const struct EvaluationContext *eval_ctx, Sc ListBase *effectors; /* get effectors present in the group specified by effector_weights */ - effectors = pdInitEffectors(eval_ctx, scene, ob, NULL, effector_weights, true); + effectors = pdInitEffectors(depsgraph, scene, ob, NULL, effector_weights, true); if (effectors) { float eff_force[3] = {0.0f, 0.0f, 0.0f}; float eff_loc[3], eff_vel[3]; @@ -1326,7 +1326,7 @@ static void rigidbody_update_sim_ob(const struct EvaluationContext *eval_ctx, Sc * * \param rebuild Rebuild entire simulation */ -static void rigidbody_update_simulation(const struct EvaluationContext *eval_ctx, Scene *scene, RigidBodyWorld *rbw, bool rebuild) +static void rigidbody_update_simulation(struct Depsgraph *depsgraph, Scene *scene, RigidBodyWorld *rbw, bool rebuild) { /* update world */ if (rebuild) @@ -1359,7 +1359,7 @@ static void rigidbody_update_simulation(const struct EvaluationContext *eval_ctx /* validate that we've got valid object set up here... */ RigidBodyOb *rbo = ob->rigidbody_object; /* update transformation matrix of the object so we don't get a frame of lag for simple animations */ - BKE_object_where_is_calc(eval_ctx, scene, ob); + BKE_object_where_is_calc(depsgraph, scene, ob); if (rbo == NULL) { /* Since this object is included in the sim group but doesn't have @@ -1393,7 +1393,7 @@ static void rigidbody_update_simulation(const struct EvaluationContext *eval_ctx } /* update simulation object... */ - rigidbody_update_sim_ob(eval_ctx, scene, rbw, ob, rbo); + rigidbody_update_sim_ob(depsgraph, scene, rbw, ob, rbo); } } FOREACH_GROUP_OBJECT_END; @@ -1407,7 +1407,7 @@ static void rigidbody_update_simulation(const struct EvaluationContext *eval_ctx /* validate that we've got valid object set up here... */ RigidBodyCon *rbc = ob->rigidbody_constraint; /* update transformation matrix of the object so we don't get a frame of lag for simple animations */ - BKE_object_where_is_calc(eval_ctx, scene, ob); + BKE_object_where_is_calc(depsgraph, scene, ob); if (rbc == NULL) { /* Since this object is included in the group but doesn't have @@ -1563,7 +1563,7 @@ void BKE_rigidbody_cache_reset(RigidBodyWorld *rbw) /* Rebuild rigid body world */ /* NOTE: this needs to be called before frame update to work correctly */ -void BKE_rigidbody_rebuild_world(const struct EvaluationContext *eval_ctx, Scene *scene, float ctime) +void BKE_rigidbody_rebuild_world(struct Depsgraph *depsgraph, Scene *scene, float ctime) { RigidBodyWorld *rbw = scene->rigidbody_world; PointCache *cache; @@ -1582,7 +1582,7 @@ void BKE_rigidbody_rebuild_world(const struct EvaluationContext *eval_ctx, Scene if (ctime == startframe + 1 && rbw->ltime == startframe) { if (cache->flag & PTCACHE_OUTDATED) { BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED); - rigidbody_update_simulation(eval_ctx, scene, rbw, true); + rigidbody_update_simulation(depsgraph, scene, rbw, true); BKE_ptcache_validate(cache, (int)ctime); cache->last_exact = 0; cache->flag &= ~PTCACHE_REDO_NEEDED; @@ -1591,7 +1591,7 @@ void BKE_rigidbody_rebuild_world(const struct EvaluationContext *eval_ctx, Scene } /* Run RigidBody simulation for the specified physics world */ -void BKE_rigidbody_do_simulation(const struct EvaluationContext *eval_ctx, Scene *scene, float ctime) +void BKE_rigidbody_do_simulation(struct Depsgraph *depsgraph, Scene *scene, float ctime) { float timestep; RigidBodyWorld *rbw = scene->rigidbody_world; @@ -1636,7 +1636,7 @@ void BKE_rigidbody_do_simulation(const struct EvaluationContext *eval_ctx, Scene } /* update and validate simulation */ - rigidbody_update_simulation(eval_ctx, scene, rbw, false); + rigidbody_update_simulation(depsgraph, scene, rbw, false); /* calculate how much time elapsed since last step in seconds */ timestep = 1.0f / (float)FPS * (ctime - rbw->ltime) * rbw->time_scale; @@ -1680,8 +1680,8 @@ void BKE_rigidbody_sync_transforms(RigidBodyWorld *rbw, Object *ob, float ctime) void BKE_rigidbody_aftertrans_update(Object *ob, float loc[3], float rot[3], float quat[4], float rotAxis[3], float rotAngle) {} bool BKE_rigidbody_check_sim_running(RigidBodyWorld *rbw, float ctime) { return false; } void BKE_rigidbody_cache_reset(RigidBodyWorld *rbw) {} -void BKE_rigidbody_rebuild_world(const struct EvaluationContext *eval_ctx, Scene *scene, float ctime) {} -void BKE_rigidbody_do_simulation(const struct EvaluationContext *eval_ctx, Scene *scene, float ctime) {} +void BKE_rigidbody_rebuild_world(struct Depsgraph *depsgraph, Scene *scene, float ctime) {} +void BKE_rigidbody_do_simulation(struct Depsgraph *depsgraph, Scene *scene, float ctime) {} #ifdef __GNUC__ # pragma GCC diagnostic pop @@ -1692,29 +1692,29 @@ void BKE_rigidbody_do_simulation(const struct EvaluationContext *eval_ctx, Scene /* -------------------- */ /* Depsgraph evaluation */ -void BKE_rigidbody_rebuild_sim(const struct EvaluationContext *eval_ctx, +void BKE_rigidbody_rebuild_sim(struct Depsgraph *depsgraph, Scene *scene) { float ctime = BKE_scene_frame_get(scene); DEG_debug_print_eval_time(__func__, scene->id.name, scene, ctime); /* rebuild sim data (i.e. after resetting to start of timeline) */ if (BKE_scene_check_rigidbody_active(scene)) { - BKE_rigidbody_rebuild_world(eval_ctx, scene, ctime); + BKE_rigidbody_rebuild_world(depsgraph, scene, ctime); } } -void BKE_rigidbody_eval_simulation(const struct EvaluationContext *eval_ctx, +void BKE_rigidbody_eval_simulation(struct Depsgraph *depsgraph, Scene *scene) { float ctime = BKE_scene_frame_get(scene); DEG_debug_print_eval_time(__func__, scene->id.name, scene, ctime); /* evaluate rigidbody sim */ if (BKE_scene_check_rigidbody_active(scene)) { - BKE_rigidbody_do_simulation(eval_ctx, scene, ctime); + BKE_rigidbody_do_simulation(depsgraph, scene, ctime); } } -void BKE_rigidbody_object_sync_transforms(const struct EvaluationContext *UNUSED(eval_ctx), +void BKE_rigidbody_object_sync_transforms(struct Depsgraph *UNUSED(depsgraph), Scene *scene, Object *ob) { -- cgit v1.2.3