diff options
author | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2016-01-09 06:37:53 +0300 |
---|---|---|
committer | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2016-01-09 06:37:53 +0300 |
commit | d7da51b7277252d887cd93b1ac26bfe4ee25ad44 (patch) | |
tree | 0bb4c28cf1b42ee5f3ed0a5a478e99bcfb591a13 /source/blender/blenkernel/intern/smoke.c | |
parent | cc0f5bf7ec4a072994633294b4cbea0cd7472a07 (diff) |
Smoke, Dynamic Paint: de-duplicate object subframe update function.
As in the title. In the smoke version, there was also an extra
'for_render' parameter that wasn't used, and wasn't used by the callers
either, so it was removed altogether.
Reviewers: brecht
Reviewed By: brecht
Subscribers: brecht
Differential Revision: https://developer.blender.org/D1718
Diffstat (limited to 'source/blender/blenkernel/intern/smoke.c')
-rw-r--r-- | source/blender/blenkernel/intern/smoke.c | 108 |
1 files changed, 8 insertions, 100 deletions
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index dae4a608031..c3e9d7d793c 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -918,98 +918,6 @@ static void update_obstacles(Scene *scene, Object *ob, SmokeDomainSettings *sds, } } - -/********************************************************** - * Object subframe update method from dynamicpaint.c - **********************************************************/ - -/* set "ignore cache" flag for all caches on this object */ -static void object_cacheIgnoreClear(Object *ob, bool state) -{ - ListBase pidlist; - PTCacheID *pid; - BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0); - - for (pid = pidlist.first; pid; pid = pid->next) { - if (pid->cache) { - if (state) - pid->cache->flag |= PTCACHE_IGNORE_CLEAR; - else - pid->cache->flag &= ~PTCACHE_IGNORE_CLEAR; - } - } - - BLI_freelistN(&pidlist); -} - -static bool subframe_updateObject(Scene *scene, Object *ob, int update_mesh, int parent_recursion, float frame, bool for_render) -{ - SmokeModifierData *smd = (SmokeModifierData *)modifiers_findByType(ob, eModifierType_Smoke); - bConstraint *con; - - /* if other is dynamic paint canvas, don't update */ - if (smd && (smd->type & MOD_SMOKE_TYPE_DOMAIN)) - return true; - - /* if object has parents, update them too */ - if (parent_recursion) { - int recursion = parent_recursion - 1; - bool is_domain = false; - if (ob->parent) is_domain |= subframe_updateObject(scene, ob->parent, 0, recursion, frame, for_render); - if (ob->track) is_domain |= subframe_updateObject(scene, ob->track, 0, recursion, frame, for_render); - - /* skip subframe if object is parented - * to vertex of a dynamic paint canvas */ - if (is_domain && (ob->partype == PARVERT1 || ob->partype == PARVERT3)) - return false; - - /* also update constraint targets */ - for (con = ob->constraints.first; con; con = con->next) { - const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con); - ListBase targets = {NULL, NULL}; - - if (cti && cti->get_constraint_targets) { - bConstraintTarget *ct; - cti->get_constraint_targets(con, &targets); - for (ct = targets.first; ct; ct = ct->next) { - if (ct->tar) - subframe_updateObject(scene, ct->tar, 0, recursion, frame, for_render); - } - /* free temp targets */ - if (cti->flush_constraint_targets) - cti->flush_constraint_targets(con, &targets, 0); - } - } - } - - /* was originally OB_RECALC_ALL - TODO - which flags are really needed??? */ - ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; - BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, frame, ADT_RECALC_ANIM); - if (update_mesh) { - /* ignore cache clear during subframe updates - * to not mess up cache validity */ - object_cacheIgnoreClear(ob, 1); - BKE_object_handle_update(G.main->eval_ctx, scene, ob); - object_cacheIgnoreClear(ob, 0); - } - else - BKE_object_where_is_calc_time(scene, ob, frame); - - /* for curve following objects, parented curve has to be updated too */ - if (ob->type == OB_CURVE) { - Curve *cu = ob->data; - BKE_animsys_evaluate_animdata(scene, &cu->id, cu->adt, frame, ADT_RECALC_ANIM); - } - /* and armatures... */ - if (ob->type == OB_ARMATURE) { - bArmature *arm = ob->data; - BKE_animsys_evaluate_animdata(scene, &arm->id, arm->adt, frame, ADT_RECALC_ANIM); - BKE_pose_where_is(scene, ob); - } - - return false; -} - /********************************************************** * Flow emission code **********************************************************/ @@ -2111,7 +2019,7 @@ BLI_INLINE void apply_inflow_fields(SmokeFlowSettings *sfs, float emission_value } } -static void update_flowsfluids(Scene *scene, Object *ob, SmokeDomainSettings *sds, float dt, bool for_render) +static void update_flowsfluids(Scene *scene, Object *ob, SmokeDomainSettings *sds, float dt) { Object **flowobjs = NULL; EmissionMap *emaps = NULL; @@ -2218,7 +2126,7 @@ static void update_flowsfluids(Scene *scene, Object *ob, SmokeDomainSettings *sd else { /* MOD_SMOKE_FLOW_SOURCE_MESH */ /* update flow object frame */ BLI_mutex_lock(&object_update_lock); - subframe_updateObject(scene, collob, 1, 5, BKE_scene_frame_get(scene), for_render); + BKE_object_modifier_update_subframe(scene, collob, true, 5, BKE_scene_frame_get(scene), eModifierType_Smoke); BLI_mutex_unlock(&object_update_lock); /* apply flow */ @@ -2554,7 +2462,7 @@ static void update_effectors(Scene *scene, Object *ob, SmokeDomainSettings *sds, pdEndEffectors(&effectors); } -static void step(Scene *scene, Object *ob, SmokeModifierData *smd, DerivedMesh *domain_dm, float fps, bool for_render) +static void step(Scene *scene, Object *ob, SmokeModifierData *smd, DerivedMesh *domain_dm, float fps) { SmokeDomainSettings *sds = smd->domain; /* stability values copied from wturbulence.cpp */ @@ -2624,7 +2532,7 @@ static void step(Scene *scene, Object *ob, SmokeModifierData *smd, DerivedMesh * for (substep = 0; substep < totalSubsteps; substep++) { // calc animated obstacle velocities - update_flowsfluids(scene, ob, sds, dtSubdiv, for_render); + update_flowsfluids(scene, ob, sds, dtSubdiv); update_obstacles(scene, ob, sds, dtSubdiv, substep, totalSubsteps); if (sds->total_cells > 1) { @@ -2721,7 +2629,7 @@ static DerivedMesh *createDomainGeometry(SmokeDomainSettings *sds, Object *ob) return result; } -static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm, bool for_render) +static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm) { if ((smd->type & MOD_SMOKE_TYPE_FLOW)) { @@ -2845,7 +2753,7 @@ static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, Object * } - step(scene, ob, smd, dm, scene->r.frs_sec / scene->r.frs_sec_base, for_render); + step(scene, ob, smd, dm, scene->r.frs_sec / scene->r.frs_sec_base); } // create shadows before writing cache so they get stored @@ -2867,13 +2775,13 @@ static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, Object * } } -struct DerivedMesh *smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm, bool for_render) +struct DerivedMesh *smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm) { /* lock so preview render does not read smoke data while it gets modified */ if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) BLI_rw_mutex_lock(smd->domain->fluid_mutex, THREAD_LOCK_WRITE); - smokeModifier_process(smd, scene, ob, dm, for_render); + smokeModifier_process(smd, scene, ob, dm); if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) BLI_rw_mutex_unlock(smd->domain->fluid_mutex); |