Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2018-11-14 13:24:54 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-11-14 16:08:39 +0300
commitd3c08b1aa62d0e6b373621cbd2da7342796f9625 (patch)
treee15edd7504ebb004611dff1fa2b283d306f88748 /source/blender/depsgraph/intern/depsgraph_build.cc
parent1d8db50538c4ba933d0a5faf97807ace1a9f6386 (diff)
Depsgraph: Fix missing point cache reset when physics changes
Among all the lines moved around, the general idea is quite simple. Actually, there are two ideas implemented there. First one, is when object itself is tagged for update, we tag its point cache component for evaluation, which makes it so point cache is properly reset. We do it implicitly because otherwise we'll need to go everywhere and add explicit tag in almost all the properties. Second thing is, we link all collider and force fields to a point cache component using special type of link. This type of link only allows flush if change is caused by a user update. This way reset does not happen when change is caused due to animation, but will properly happen when user causes indirect change to the objects which are part of physics simulation.
Diffstat (limited to 'source/blender/depsgraph/intern/depsgraph_build.cc')
-rw-r--r--source/blender/depsgraph/intern/depsgraph_build.cc107
1 files changed, 65 insertions, 42 deletions
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc
index f5b84b91dbe..64adfa1ceea 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build.cc
@@ -99,38 +99,38 @@ static DEG::eDepsNode_Type deg_build_object_component_type(
return DEG::DEG_NODE_TYPE_UNDEFINED;
}
-static DEG::DepsNodeHandle *get_handle(DepsNodeHandle *handle)
+static DEG::DepsNodeHandle *get_node_handle(DepsNodeHandle *node_handle)
{
- return reinterpret_cast<DEG::DepsNodeHandle *>(handle);
+ return reinterpret_cast<DEG::DepsNodeHandle *>(node_handle);
}
-void DEG_add_scene_relation(DepsNodeHandle *handle,
+void DEG_add_scene_relation(DepsNodeHandle *node_handle,
Scene *scene,
eDepsSceneComponentType component,
const char *description)
{
DEG::eDepsNode_Type type = deg_build_scene_component_type(component);
DEG::ComponentKey comp_key(&scene->id, type);
- DEG::DepsNodeHandle *deg_handle = get_handle(handle);
- deg_handle->builder->add_node_handle_relation(comp_key,
- deg_handle,
- description);
+ DEG::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle);
+ deg_node_handle->builder->add_node_handle_relation(comp_key,
+ deg_node_handle,
+ description);
}
-void DEG_add_object_relation(DepsNodeHandle *handle,
+void DEG_add_object_relation(DepsNodeHandle *node_handle,
Object *object,
eDepsObjectComponentType component,
const char *description)
{
DEG::eDepsNode_Type type = deg_build_object_component_type(component);
DEG::ComponentKey comp_key(&object->id, type);
- DEG::DepsNodeHandle *deg_handle = get_handle(handle);
- deg_handle->builder->add_node_handle_relation(comp_key,
- deg_handle,
- description);
+ DEG::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle);
+ deg_node_handle->builder->add_node_handle_relation(comp_key,
+ deg_node_handle,
+ description);
}
-void DEG_add_object_relation_with_customdata(DepsNodeHandle *handle,
+void DEG_add_object_relation_with_customdata(DepsNodeHandle *node_handle,
Object *object,
eDepsObjectComponentType component,
uint64_t customdata_mask,
@@ -138,29 +138,29 @@ void DEG_add_object_relation_with_customdata(DepsNodeHandle *handle,
{
DEG::eDepsNode_Type type = deg_build_object_component_type(component);
DEG::ComponentKey comp_key(&object->id, type);
- DEG::DepsNodeHandle *deg_handle = get_handle(handle);
- deg_handle->builder->add_node_handle_relation(comp_key,
- deg_handle,
- description);
+ DEG::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle);
+ deg_node_handle->builder->add_node_handle_relation(comp_key,
+ deg_node_handle,
+ description);
if (object->type == OB_MESH) {
- deg_handle->builder->add_customdata_mask(comp_key, customdata_mask);
+ deg_node_handle->builder->add_customdata_mask(comp_key, customdata_mask);
}
}
-void DEG_add_object_cache_relation(DepsNodeHandle *handle,
+void DEG_add_object_cache_relation(DepsNodeHandle *node_handle,
CacheFile *cache_file,
eDepsObjectComponentType component,
const char *description)
{
DEG::eDepsNode_Type type = deg_build_object_component_type(component);
DEG::ComponentKey comp_key(&cache_file->id, type);
- DEG::DepsNodeHandle *deg_handle = get_handle(handle);
- deg_handle->builder->add_node_handle_relation(comp_key,
- deg_handle,
- description);
+ DEG::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle);
+ deg_node_handle->builder->add_node_handle_relation(comp_key,
+ deg_node_handle,
+ description);
}
-void DEG_add_bone_relation(DepsNodeHandle *handle,
+void DEG_add_bone_relation(DepsNodeHandle *node_handle,
Object *object,
const char *bone_name,
eDepsObjectComponentType component,
@@ -168,25 +168,50 @@ void DEG_add_bone_relation(DepsNodeHandle *handle,
{
DEG::eDepsNode_Type type = deg_build_object_component_type(component);
DEG::ComponentKey comp_key(&object->id, type, bone_name);
- DEG::DepsNodeHandle *deg_handle = get_handle(handle);
- /* XXX: "Geometry Eval" might not always be true, but this only gets called
- * from modifier building now.
- */
- deg_handle->builder->add_node_handle_relation(comp_key,
- deg_handle,
- description);
+ DEG::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle);
+ deg_node_handle->builder->add_node_handle_relation(comp_key,
+ deg_node_handle,
+ description);
+}
+
+void DEG_add_object_pointcache_relation(struct DepsNodeHandle *node_handle,
+ struct Object *object,
+ eDepsObjectComponentType component,
+ const char *description)
+{
+ DEG::eDepsNode_Type type = deg_build_object_component_type(component);
+ DEG::ComponentKey comp_key(&object->id, type);
+ DEG::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle);
+ DEG::DepsgraphRelationBuilder *relation_builder = deg_node_handle->builder;
+ /* Add relation from source to the node handle. */
+ relation_builder->add_node_handle_relation(
+ comp_key, deg_node_handle, description);
+ /* Node deduct point cache component and connect source to it. */
+ ID *id = DEG_get_id_from_handle(node_handle);
+ DEG::ComponentKey point_cache_key(id, DEG::DEG_NODE_TYPE_POINT_CACHE);
+ DEG::DepsRelation *rel = relation_builder->add_relation(
+ comp_key, point_cache_key, "Point Cache");
+ rel->flag |= DEG::DEPSREL_FLAG_FLUSH_USER_EDIT_ONLY;
}
-void DEG_add_special_eval_flag(struct DepsNodeHandle *handle, ID *id, uint32_t flag)
+void DEG_add_special_eval_flag(struct DepsNodeHandle *node_handle,
+ ID *id,
+ uint32_t flag)
{
- DEG::DepsNodeHandle *deg_handle = get_handle(handle);
- deg_handle->builder->add_special_eval_flag(id, flag);
+ DEG::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle);
+ deg_node_handle->builder->add_special_eval_flag(id, flag);
}
-struct Depsgraph *DEG_get_graph_from_handle(struct DepsNodeHandle *handle)
+struct ID *DEG_get_id_from_handle(struct DepsNodeHandle *node_handle)
{
- DEG::DepsNodeHandle *deg_handle = get_handle(handle);
- DEG::DepsgraphRelationBuilder *relation_builder = deg_handle->builder;
+ DEG::DepsNodeHandle *deg_handle = get_node_handle(node_handle);
+ return deg_handle->node->owner->owner->id_orig;
+}
+
+struct Depsgraph *DEG_get_graph_from_handle(struct DepsNodeHandle *node_handle)
+{
+ DEG::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle);
+ DEG::DepsgraphRelationBuilder *relation_builder = deg_node_handle->builder;
return reinterpret_cast<Depsgraph *>(relation_builder->getGraph());
}
@@ -267,11 +292,9 @@ void DEG_graph_tag_relations_update(Depsgraph *graph)
* TODO(sergey): Try to make it so we don't flush updates
* to the whole depsgraph.
*/
- {
- DEG::IDDepsNode *id_node = deg_graph->find_id_node(&deg_graph->scene->id);
- if (id_node != NULL) {
- id_node->tag_update(deg_graph);
- }
+ DEG::IDDepsNode *id_node = deg_graph->find_id_node(&deg_graph->scene->id);
+ if (id_node != NULL) {
+ id_node->tag_update(deg_graph, DEG::DEG_UPDATE_SOURCE_RELATIONS);
}
}