diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-06-22 15:42:03 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-06-25 14:35:41 +0300 |
commit | a99dcab148ed209409f3b2479ada12d869ae84b6 (patch) | |
tree | 2b7fc55752cbe3538fc05c8f77fd86b18a0d6df7 /source/blender/blenkernel/intern/smoke.c | |
parent | 5b3ff9f7d890554ae87e63095f24ac6d31a36d3c (diff) |
Depsgraph: cache collision relations, for performance and stability.
Same reasoning as effector relations in earlier commit.
Diffstat (limited to 'source/blender/blenkernel/intern/smoke.c')
-rw-r--r-- | source/blender/blenkernel/intern/smoke.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 5ba9b7ce4dc..c9b10e36ed1 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -893,7 +893,7 @@ static void obstacles_from_derivedmesh( } /* Animated obstacles: dx_step = ((x_new - x_old) / totalsteps) * substep */ -static void update_obstacles(Scene *scene, Object *ob, SmokeDomainSettings *sds, float dt, +static void update_obstacles(Depsgraph *depsgraph, Object *ob, SmokeDomainSettings *sds, float dt, int UNUSED(substep), int UNUSED(totalsteps)) { Object **collobjs = NULL; @@ -933,7 +933,7 @@ static void update_obstacles(Scene *scene, Object *ob, SmokeDomainSettings *sds, } - collobjs = get_collisionobjects(scene, ob, sds->coll_group, &numcollobj, eModifierType_Smoke); + collobjs = BKE_collision_objects_create(depsgraph, ob, sds->coll_group, &numcollobj, eModifierType_Smoke); // update obstacle tags in cells for (collIndex = 0; collIndex < numcollobj; collIndex++) @@ -950,8 +950,7 @@ static void update_obstacles(Scene *scene, Object *ob, SmokeDomainSettings *sds, } } - if (collobjs) - MEM_freeN(collobjs); + BKE_collision_objects_free(collobjs); /* obstacle cells should not contain any velocity from the smoke simulation */ for (z = 0; z < sds->res[0] * sds->res[1] * sds->res[2]; z++) @@ -2151,7 +2150,7 @@ static void update_flowsfluids( sds->p1[2] = sds->p0[2] + sds->cell_size[2] * sds->base_res[2]; } - flowobjs = get_collisionobjects(scene, ob, sds->fluid_group, &numflowobj, eModifierType_Smoke); + flowobjs = BKE_collision_objects_create(depsgraph, ob, sds->fluid_group, &numflowobj, eModifierType_Smoke); /* init emission maps for each flow */ emaps = MEM_callocN(sizeof(struct EmissionMap) * numflowobj, "smoke_flow_maps"); @@ -2452,8 +2451,7 @@ static void update_flowsfluids( } } - if (flowobjs) - MEM_freeN(flowobjs); + BKE_collision_objects_free(flowobjs); if (emaps) MEM_freeN(emaps); } @@ -2533,7 +2531,7 @@ static void update_effectors(struct Depsgraph *depsgraph, Scene *scene, Object * ListBase *effectors; /* make sure smoke flow influence is 0.0f */ sds->effector_weights->weight[PFIELD_SMOKEFLOW] = 0.0f; - effectors = BKE_effectors_create(depsgraph, scene, ob, NULL, sds->effector_weights); + effectors = BKE_effectors_create(depsgraph, ob, NULL, sds->effector_weights); if (effectors) { // precalculate wind forces @@ -2636,7 +2634,7 @@ static void step( { // calc animated obstacle velocities update_flowsfluids(depsgraph, scene, ob, sds, dtSubdiv); - update_obstacles(scene, ob, sds, dtSubdiv, substep, totalSubsteps); + update_obstacles(depsgraph, ob, sds, dtSubdiv, substep, totalSubsteps); if (sds->total_cells > 1) { update_effectors(depsgraph, scene, ob, sds, dtSubdiv); // DG TODO? problem --> uses forces instead of velocity, need to check how they need to be changed with variable dt |