diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-03-15 13:10:42 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-03-15 13:10:42 +0300 |
commit | 9ad252d157a209e8ba7160e1974690a811fd505f (patch) | |
tree | 0a9987d728f5d16cf3a98ce8621d687c224d29c9 | |
parent | 6a5487e02159835b7017970867d6da639983ff6e (diff) |
Fix T50938: Cache not being reset when changing simulation settings with new depsgraph
The thing i'm really starting to hate is the requirement to specify both
operation code and node type. Seems to be duplicated enums without real
need for that.
6 files changed, 63 insertions, 6 deletions
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 89adbc4338f..b6633ea6198 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -200,6 +200,11 @@ void BKE_object_eval_uber_data(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob); +void BKE_object_eval_cloth(struct EvaluationContext *eval_ctx, + struct Scene *scene, + struct Object *object); + + void BKE_object_handle_data_update(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob); diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c index 5cb704e4737..a531466294e 100644 --- a/source/blender/blenkernel/intern/object_update.c +++ b/source/blender/blenkernel/intern/object_update.c @@ -54,6 +54,7 @@ #include "BKE_editmesh.h" #include "BKE_object.h" #include "BKE_particle.h" +#include "BKE_pointcache.h" #include "BKE_scene.h" #include "BKE_material.h" #include "BKE_image.h" @@ -347,3 +348,9 @@ void BKE_object_eval_uber_data(EvaluationContext *eval_ctx, ob->recalc &= ~(OB_RECALC_DATA | OB_RECALC_TIME); } + +void BKE_object_eval_cloth(EvaluationContext *UNUSED(eval_ctx), Scene *scene, Object *object) +{ + DEBUG_PRINT("%s on %s\n", __func__, object->id.name); + BKE_ptcache_object_reset(scene, object, PTCACHE_RESET_DEPSGRAPH); +} diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index 6b7fb5246ca..0a06689da90 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -734,7 +734,8 @@ void DepsgraphNodeBuilder::build_particles(Scene *scene, Object *ob) */ /* component for all particle systems */ - ComponentDepsNode *psys_comp = add_component_node(&ob->id, DEPSNODE_TYPE_EVAL_PARTICLES); + ComponentDepsNode *psys_comp = + add_component_node(&ob->id, DEPSNODE_TYPE_EVAL_PARTICLES); /* particle systems */ LINKLIST_FOREACH (ParticleSystem *, psys, &ob->particlesystem) { @@ -747,11 +748,12 @@ void DepsgraphNodeBuilder::build_particles(Scene *scene, Object *ob) /* this particle system */ // TODO: for now, this will just be a placeholder "ubereval" node add_operation_node(psys_comp, - DEPSOP_TYPE_EXEC, function_bind(BKE_particle_system_eval, - _1, - scene, - ob, - psys), + DEPSOP_TYPE_EXEC, + function_bind(BKE_particle_system_eval, + _1, + scene, + ob, + psys), DEG_OPCODE_PSYS_EVAL, psys->name); } @@ -760,6 +762,20 @@ void DepsgraphNodeBuilder::build_particles(Scene *scene, Object *ob) // TODO... } +void DepsgraphNodeBuilder::build_cloth(Scene *scene, Object *object) +{ + ComponentDepsNode *cache_comp = add_component_node(&object->id, + DEPSNODE_TYPE_CACHE); + add_operation_node(cache_comp, + DEPSOP_TYPE_EXEC, + function_bind(BKE_object_eval_cloth, + _1, + scene, + object), + DEG_OPCODE_PLACEHOLDER, + "Cloth Modifier"); +} + /* Shapekeys */ void DepsgraphNodeBuilder::build_shapekeys(Key *key) { @@ -821,6 +837,9 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob) md), DEG_OPCODE_GEOMETRY_MODIFIER, md->name); + if (md->type == eModifierType_Cloth) { + build_cloth(scene, ob); + } } /* materials */ diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h index c5035f35f6e..10b586342dd 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h @@ -133,6 +133,7 @@ struct DepsgraphNodeBuilder { void build_pose_constraints(Object *ob, bPoseChannel *pchan); void build_rigidbody(Scene *scene); void build_particles(Scene *scene, Object *ob); + void build_cloth(Scene *scene, Object *object); void build_animdata(ID *id); OperationDepsNode *build_driver(ID *id, FCurve *fcurve); void build_ik_pose(Scene *scene, diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 94cff521edc..e88a6e73862 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -1312,6 +1312,25 @@ void DepsgraphRelationBuilder::build_particles(Scene *scene, Object *ob) // TODO... } +void DepsgraphRelationBuilder::build_cloth(Scene *scene, + Object *object, + ModifierData *md) +{ + OperationKey cache_key(&object->id, + DEPSNODE_TYPE_CACHE, + DEG_OPCODE_PLACEHOLDER, + "Cloth Modifier"); + /* Cache component affects on modifier. */ + OperationKey modifier_key(&object->id, + DEPSNODE_TYPE_GEOMETRY, + DEG_OPCODE_GEOMETRY_MODIFIER, + md->name); + add_relation(cache_key, + modifier_key, + DEPSREL_TYPE_TIME, + "Cloth Cache -> Cloth"); +} + /* Shapekeys */ void DepsgraphRelationBuilder::build_shapekeys(ID *obdata, Key *key) { @@ -1413,6 +1432,10 @@ void DepsgraphRelationBuilder::build_obdata_geom(Main *bmain, Scene *scene, Obje } } + if (md->type == eModifierType_Cloth) { + build_cloth(scene, ob, md); + } + prev_mod_key = mod_key; } } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h index 054e4103290..4ca95bebe3f 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h @@ -58,6 +58,7 @@ struct Main; struct Mask; struct Material; struct MTex; +struct ModifierData; struct MovieClip; struct bNodeTree; struct Object; @@ -205,6 +206,7 @@ struct DepsgraphRelationBuilder void build_world(World *world); void build_rigidbody(Scene *scene); void build_particles(Scene *scene, Object *ob); + void build_cloth(Scene *scene, Object *object, ModifierData *md); void build_ik_pose(Object *ob, bPoseChannel *pchan, bConstraint *con, |