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/dynamicpaint.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/dynamicpaint.c')
-rw-r--r-- | source/blender/blenkernel/intern/dynamicpaint.c | 101 |
1 files changed, 6 insertions, 95 deletions
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 0a9a7a33ec6..67a6d067aba 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -103,8 +103,6 @@ static int neighY[8] = {0, 1, 1, 1, 0, -1, -1, -1}; /* subframe_updateObject() flags */ #define SUBFRAME_RECURSION 5 -#define UPDATE_MESH (1 << 1) -#define UPDATE_EVERYTHING (UPDATE_MESH) // | UPDATE_PARENTS /* surface_getBrushFlags() return vals */ #define BRUSH_USES_VELOCITY (1 << 0) /* brush mesh raycast status */ @@ -484,93 +482,6 @@ static float mixColors(float a_color[3], float a_weight, const float b_color[3], return (1.0f - factor) * a_weight + factor * b_weight; } -/* set "ignore cache" flag for all caches on this object */ -static void object_cacheIgnoreClear(Object *ob, int 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 int subframe_updateObject(Scene *scene, Object *ob, int flags, int parent_recursion, float frame) -{ - DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)modifiers_findByType(ob, eModifierType_DynamicPaint); - bConstraint *con; - - /* if other is dynamic paint canvas, don't update */ - if (pmd && pmd->canvas) - return 1; - - /* if object has parents, update them too */ - if (parent_recursion) { - int recursion = parent_recursion - 1; - int is_canvas = 0; - if (ob->parent) is_canvas += subframe_updateObject(scene, ob->parent, 0, recursion, frame); - if (ob->track) is_canvas += subframe_updateObject(scene, ob->track, 0, recursion, frame); - - /* skip subframe if object is parented - * to vertex of a dynamic paint canvas */ - if (is_canvas && (ob->partype == PARVERT1 || ob->partype == PARVERT3)) - return 0; - - /* 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); - } - /* 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 (flags & 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 0; -} - static void scene_setSubframe(Scene *scene, float subframe) { /* dynamic paint subframes must be done on previous frame */ @@ -3156,7 +3067,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(Scene *scene, Object *ob, Dy scene->r.cfra = prev_fra; scene->r.subframe = prev_sfra; - subframe_updateObject(scene, ob, UPDATE_EVERYTHING, SUBFRAME_RECURSION, BKE_scene_frame_get(scene)); + BKE_object_modifier_update_subframe(scene, ob, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint); dm_p = CDDM_copy(brush->dm); numOfVerts_p = dm_p->getNumVerts(dm_p); mvert_p = dm_p->getVertArray(dm_p); @@ -3166,7 +3077,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(Scene *scene, Object *ob, Dy scene->r.cfra = cur_fra; scene->r.subframe = cur_sfra; - subframe_updateObject(scene, ob, UPDATE_EVERYTHING, SUBFRAME_RECURSION, BKE_scene_frame_get(scene)); + BKE_object_modifier_update_subframe(scene, ob, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint); dm_c = brush->dm; numOfVerts_c = dm_c->getNumVerts(dm_c); mvert_c = dm_p->getVertArray(dm_c); @@ -3216,13 +3127,13 @@ static void dynamicPaint_brushObjectCalculateVelocity(Scene *scene, Object *ob, /* previous frame dm */ scene->r.cfra = prev_fra; scene->r.subframe = prev_sfra; - subframe_updateObject(scene, ob, 0, SUBFRAME_RECURSION, BKE_scene_frame_get(scene)); + BKE_object_modifier_update_subframe(scene, ob, false, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint); copy_m4_m4(prev_obmat, ob->obmat); /* current frame dm */ scene->r.cfra = cur_fra; scene->r.subframe = cur_sfra; - subframe_updateObject(scene, ob, 0, SUBFRAME_RECURSION, BKE_scene_frame_get(scene)); + BKE_object_modifier_update_subframe(scene, ob, false, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint); /* calculate speed */ mul_m4_v3(prev_obmat, prev_loc); @@ -4947,7 +4858,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su /* update object data on this subframe */ if (subframe) { scene_setSubframe(scene, subframe); - subframe_updateObject(scene, brushObj, UPDATE_EVERYTHING, SUBFRAME_RECURSION, BKE_scene_frame_get(scene)); + BKE_object_modifier_update_subframe(scene, brushObj, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint); } /* Prepare materials if required */ if (brush_usesMaterial(brush, scene)) @@ -4981,7 +4892,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su if (subframe) { scene->r.cfra = scene_frame; scene->r.subframe = scene_subframe; - subframe_updateObject(scene, brushObj, UPDATE_EVERYTHING, SUBFRAME_RECURSION, BKE_scene_frame_get(scene)); + BKE_object_modifier_update_subframe(scene, brushObj, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint); } /* process special brush effects, like smudge */ |