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_tag.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_tag.cc')
-rw-r--r--source/blender/depsgraph/intern/depsgraph_tag.cc22
1 files changed, 16 insertions, 6 deletions
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index e2a87f16408..6374354a154 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -204,6 +204,10 @@ void depsgraph_tag_to_component_opcode(const ID *id,
depsgraph_base_flags_tag_to_component_opcode(id,
component_type,
operation_code);
+ break;
+ case DEG_TAG_POINT_CACHE_UPDATE:
+ *component_type = DEG_NODE_TYPE_POINT_CACHE;
+ break;
case DEG_TAG_EDITORS_UPDATE:
/* There is no such node in depsgraph, this tag is to be handled
* separately.
@@ -249,20 +253,20 @@ void depsgraph_tag_component(Depsgraph *graph,
return;
}
if (operation_code == DEG_OPCODE_OPERATION) {
- component_node->tag_update(graph);
+ component_node->tag_update(graph, DEG_UPDATE_SOURCE_USER_EDIT);
}
else {
OperationDepsNode *operation_node =
component_node->find_operation(operation_code);
if (operation_node != NULL) {
- operation_node->tag_update(graph);
+ operation_node->tag_update(graph, DEG_UPDATE_SOURCE_USER_EDIT);
}
}
/* If component depends on copy-on-write, tag it as well. */
if (component_node->need_tag_cow_before_update()) {
ComponentDepsNode *cow_comp =
id_node->find_component(DEG_NODE_TYPE_COPY_ON_WRITE);
- cow_comp->tag_update(graph);
+ cow_comp->tag_update(graph, DEG_UPDATE_SOURCE_USER_EDIT);
id_node->id_orig->recalc |= ID_RECALC_COPY_ON_WRITE;
}
}
@@ -364,7 +368,7 @@ static void deg_graph_id_tag_update_single_flag(Main *bmain,
}
/* Tag corresponding dependency graph operation for update. */
if (component_type == DEG_NODE_TYPE_ID_REF) {
- id_node->tag_update(graph);
+ id_node->tag_update(graph, DEG_UPDATE_SOURCE_USER_EDIT);
}
else {
depsgraph_tag_component(graph, id_node, component_type, operation_code);
@@ -427,7 +431,7 @@ void deg_graph_node_tag_zero(Main *bmain, Depsgraph *graph, IDDepsNode *id_node)
if (comp_node->type == DEG_NODE_TYPE_ANIMATION) {
continue;
}
- comp_node->tag_update(graph);
+ comp_node->tag_update(graph, DEG_UPDATE_SOURCE_USER_EDIT);
}
GHASH_FOREACH_END();
deg_graph_id_tag_legacy_compat(bmain, graph, id, (eDepsgraph_Tag)0);
@@ -463,6 +467,11 @@ void deg_graph_id_tag_update(Main *bmain, Depsgraph *graph, ID *id, int flag)
}
/* Special case for nested node tree datablocks. */
id_tag_update_ntree_special(bmain, graph, id, flag);
+ /* Direct update tags means that something outside of simulated/cached
+ * physics did change and that cache is to be invalidated.
+ */
+ deg_graph_id_tag_update_single_flag(
+ bmain, graph, id, id_node, DEG_TAG_POINT_CACHE_UPDATE);
}
void deg_id_tag_update(Main *bmain, ID *id, int flag)
@@ -515,7 +524,7 @@ void deg_graph_on_visible_update(Main *bmain, Depsgraph *graph)
deg_graph_id_tag_update(bmain, graph, id_node->id_orig, flag);
if (id_type == ID_SCE) {
/* Make sure collection properties are up to date. */
- id_node->tag_update(graph);
+ id_node->tag_update(graph, DEG_UPDATE_SOURCE_VISIBILITY);
}
/* Now when ID is updated to the new visibility state, prevent it from
* being re-tagged again. Simplest way to do so is to pretend that it
@@ -590,6 +599,7 @@ const char *DEG_update_tag_as_string(eDepsgraph_Tag flag)
case DEG_TAG_SHADING_UPDATE: return "SHADING_UPDATE";
case DEG_TAG_SELECT_UPDATE: return "SELECT_UPDATE";
case DEG_TAG_BASE_FLAGS_UPDATE: return "BASE_FLAGS_UPDATE";
+ case DEG_TAG_POINT_CACHE_UPDATE: return "POINT_CACHE_UPDATE";
case DEG_TAG_EDITORS_UPDATE: return "EDITORS_UPDATE";
}
BLI_assert(!"Unhandled update flag, should never happen!");