[Bf-blender-cvs] [d3c08b1aa62] blender2.8: Depsgraph: Fix missing point cache reset when physics changes

Sergey Sharybin noreply at git.blender.org
Wed Nov 14 14:09:25 CET 2018


Commit: d3c08b1aa62d0e6b373621cbd2da7342796f9625
Author: Sergey Sharybin
Date:   Wed Nov 14 11:24:54 2018 +0100
Branches: blender2.8
https://developer.blender.org/rBd3c08b1aa62d0e6b373621cbd2da7342796f9625

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.

===================================================================

M	source/blender/blenkernel/BKE_object.h
M	source/blender/blenkernel/intern/object_update.c
M	source/blender/depsgraph/DEG_depsgraph.h
M	source/blender/depsgraph/DEG_depsgraph_build.h
M	source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M	source/blender/depsgraph/intern/builder/deg_builder_nodes.h
M	source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M	source/blender/depsgraph/intern/builder/deg_builder_relations.h
M	source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
M	source/blender/depsgraph/intern/depsgraph.h
M	source/blender/depsgraph/intern/depsgraph_build.cc
M	source/blender/depsgraph/intern/depsgraph_eval.cc
M	source/blender/depsgraph/intern/depsgraph_physics.cc
M	source/blender/depsgraph/intern/depsgraph_tag.cc
M	source/blender/depsgraph/intern/depsgraph_type_defines.cc
M	source/blender/depsgraph/intern/depsgraph_types.h
M	source/blender/depsgraph/intern/eval/deg_eval_flush.cc
M	source/blender/depsgraph/intern/nodes/deg_node.h
M	source/blender/depsgraph/intern/nodes/deg_node_component.cc
M	source/blender/depsgraph/intern/nodes/deg_node_component.h
M	source/blender/depsgraph/intern/nodes/deg_node_id.cc
M	source/blender/depsgraph/intern/nodes/deg_node_id.h
M	source/blender/depsgraph/intern/nodes/deg_node_operation.cc
M	source/blender/depsgraph/intern/nodes/deg_node_operation.h
M	source/blender/depsgraph/intern/nodes/deg_node_time.cc
M	source/blender/depsgraph/intern/nodes/deg_node_time.h

===================================================================

diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 8085c541600..6d950ec01f6 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -245,7 +245,7 @@ void BKE_object_eval_uber_data(
         struct Scene *scene,
         struct Object *ob);
 
-void BKE_object_eval_cloth(
+void BKE_object_eval_ptcache_reset(
         struct Depsgraph *depsgraph,
         struct Scene *scene,
         struct Object *object);
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index 902237d7ac8..267f64aa53f 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -343,9 +343,9 @@ void BKE_object_eval_uber_data(Depsgraph *depsgraph,
 	BKE_object_batch_cache_dirty_tag(ob);
 }
 
-void BKE_object_eval_cloth(Depsgraph *depsgraph,
-                           Scene *scene,
-                           Object *object)
+void BKE_object_eval_ptcache_reset(Depsgraph *depsgraph,
+                                   Scene *scene,
+                                   Object *object)
 {
 	DEG_debug_print_eval(depsgraph, __func__, object->id.name, object);
 	BKE_ptcache_object_reset(scene, object, PTCACHE_RESET_DEPSGRAPH);
diff --git a/source/blender/depsgraph/DEG_depsgraph.h b/source/blender/depsgraph/DEG_depsgraph.h
index 75572a91440..fa2675297bc 100644
--- a/source/blender/depsgraph/DEG_depsgraph.h
+++ b/source/blender/depsgraph/DEG_depsgraph.h
@@ -147,11 +147,12 @@ typedef enum eDepsgraph_Tag {
 	/* Tag shading components for update.
 	 * Only parameters of material changed).
 	 */
-	DEG_TAG_SHADING_UPDATE  = (1 << 9),
-	DEG_TAG_SELECT_UPDATE   = (1 << 10),
-	DEG_TAG_BASE_FLAGS_UPDATE = (1 << 11),
+	DEG_TAG_SHADING_UPDATE       = (1 << 9),
+	DEG_TAG_SELECT_UPDATE        = (1 << 10),
+	DEG_TAG_BASE_FLAGS_UPDATE    = (1 << 11),
+	DEG_TAG_POINT_CACHE_UPDATE   = (1 << 12),
 	/* Only inform editors about the change. Don't modify datablock itself. */
-	DEG_TAG_EDITORS_UPDATE = (1 << 12),
+	DEG_TAG_EDITORS_UPDATE = (1 << 13),
 } eDepsgraph_Tag;
 
 const char *DEG_update_tag_as_string(eDepsgraph_Tag flag);
diff --git a/source/blender/depsgraph/DEG_depsgraph_build.h b/source/blender/depsgraph/DEG_depsgraph_build.h
index 1895b483644..93e9b5be2cc 100644
--- a/source/blender/depsgraph/DEG_depsgraph_build.h
+++ b/source/blender/depsgraph/DEG_depsgraph_build.h
@@ -131,15 +131,15 @@ typedef enum eDepsObjectComponentType {
 	DEG_OB_COMP_CACHE,
 } eDepsObjectComponentType;
 
-void DEG_add_scene_relation(struct DepsNodeHandle *node,
+void DEG_add_scene_relation(struct DepsNodeHandle *node_handle,
                             struct Scene *scene,
                             eDepsSceneComponentType component,
                             const char *description);
-void DEG_add_object_relation(struct DepsNodeHandle *node,
+void DEG_add_object_relation(struct DepsNodeHandle *node_handle,
                              struct Object *object,
                              eDepsObjectComponentType component,
                              const char *description);
-void DEG_add_object_relation_with_customdata(struct DepsNodeHandle *node,
+void DEG_add_object_relation_with_customdata(struct DepsNodeHandle *node_handle,
                                              struct Object *object,
                                              eDepsObjectComponentType component,
                                              uint64_t customdata_mask,
@@ -154,9 +154,18 @@ void DEG_add_object_cache_relation(struct DepsNodeHandle *handle,
                                    eDepsObjectComponentType component,
                                    const char *description);
 
+/* Adds relations from the given component of a given object to the given node
+ * handle AND the component to the point cache component of the node's ID.
+ */
+void DEG_add_object_pointcache_relation(struct DepsNodeHandle *node_handle,
+                                        struct Object *object,
+                                        eDepsObjectComponentType component,
+                                        const char *description);
+
 void DEG_add_special_eval_flag(struct DepsNodeHandle *handle, struct ID *id, uint32_t flag);
 
-struct Depsgraph *DEG_get_graph_from_handle(struct DepsNodeHandle *handle);
+struct ID *DEG_get_id_from_handle(struct DepsNodeHandle *node_handle);
+struct Depsgraph *DEG_get_graph_from_handle(struct DepsNodeHandle *node_handle);
 
 /* ************************************************ */
 
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index e8e3e241ebf..637fd5887a0 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -399,7 +399,10 @@ void DepsgraphNodeBuilder::end_build()
 		if (op_node == NULL) {
 			continue;
 		}
-		op_node->tag_update(graph_);
+		/* Since the tag is coming from a saved copy of entry tags, this means
+		 * that originally node was explicitly tagged for user update.
+		 */
+		op_node->tag_update(graph_, DEG_UPDATE_SOURCE_USER_EDIT);
 	}
 }
 
@@ -818,6 +821,22 @@ void DepsgraphNodeBuilder::build_object_constraints(Object *object)
 	                   DEG_OPCODE_TRANSFORM_CONSTRAINTS);
 }
 
+void DepsgraphNodeBuilder::build_object_pointcache(Object *object)
+{
+	if (!BKE_ptcache_object_has(scene_, object, 0)) {
+		return;
+	}
+	Scene *scene_cow = get_cow_datablock(scene_);
+	Object *object_cow = get_cow_datablock(object);
+	add_operation_node(&object->id,
+	                   DEG_NODE_TYPE_POINT_CACHE,
+	                   function_bind(BKE_object_eval_ptcache_reset,
+	                                 _1,
+	                                 scene_cow,
+	                                 object_cow),
+	                   DEG_OPCODE_POINT_CACHE_RESET);
+}
+
 /**
  * Build graph nodes for AnimData block
  * \param id: ID-Block which hosts the AnimData
@@ -1123,15 +1142,6 @@ void DepsgraphNodeBuilder::build_particles(Object *object,
 				break;
 		}
 	}
-
-	/* TODO(sergey): Do we need a point cache operations here? */
-	add_operation_node(&object->id,
-	                   DEG_NODE_TYPE_CACHE,
-	                   function_bind(BKE_ptcache_object_reset,
-	                                 scene_cow,
-	                                 ob_cow,
-	                                 PTCACHE_RESET_DEPSGRAPH),
-	                   DEG_OPCODE_POINT_CACHE_RESET);
 }
 
 void DepsgraphNodeBuilder::build_particle_settings(ParticleSettings *part) {
@@ -1147,19 +1157,6 @@ void DepsgraphNodeBuilder::build_particle_settings(ParticleSettings *part) {
 	                   DEG_OPCODE_PARTICLE_SETTINGS_EVAL);
 }
 
-void DepsgraphNodeBuilder::build_cloth(Object *object)
-{
-	Scene *scene_cow = get_cow_datablock(scene_);
-	Object *object_cow = get_cow_datablock(object);
-	add_operation_node(&object->id,
-	                   DEG_NODE_TYPE_CACHE,
-	                   function_bind(BKE_object_eval_cloth,
-	                                 _1,
-	                                 scene_cow,
-	                                 object_cow),
-	                   DEG_OPCODE_GEOMETRY_CLOTH_MODIFIER);
-}
-
 /* Shapekeys */
 void DepsgraphNodeBuilder::build_shapekeys(Key *key)
 {
@@ -1204,13 +1201,6 @@ void DepsgraphNodeBuilder::build_object_data_geometry(
 	                             DEG_OPCODE_PLACEHOLDER,
 	                             "Eval Init");
 	op_node->set_as_entry();
-	// TODO: "Done" operation
-	/* Cloth modifier. */
-	LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
-		if (md->type == eModifierType_Cloth) {
-			build_cloth(object);
-		}
-	}
 	/* Materials. */
 	if (object->totcol != 0) {
 		if (object->type == OB_MESH) {
@@ -1221,7 +1211,6 @@ void DepsgraphNodeBuilder::build_object_data_geometry(
 			                                 object_cow),
 			                   DEG_OPCODE_SHADING);
 		}
-
 		for (int a = 1; a <= object->totcol; a++) {
 			Material *ma = give_current_material(object, a);
 			if (ma != NULL) {
@@ -1229,10 +1218,9 @@ void DepsgraphNodeBuilder::build_object_data_geometry(
 			}
 		}
 	}
-	/* Geometry collision. */
-	if (ELEM(object->type, OB_MESH, OB_CURVE, OB_LATTICE)) {
-		// add geometry collider relations
-	}
+	/* Point caches. */
+	build_object_pointcache(object);
+	/* Geometry. */
 	build_object_data_geometry_datablock((ID *)object->data, is_object_visible);
 }
 
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
index b826a2979cc..3c0c5f749ca 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
@@ -183,6 +183,7 @@ struct DepsgraphNodeBuilder {
 	void build_object_data_speaker(Object *object);
 	void build_object_transform(Object *object);
 	void build_object_constraints(Object *object);
+	void build_object_pointcache(Object *object);
 	void build_pose_constraints(Object *object,
 	                            bPoseChannel *pchan,
 	                            int pchan_index,
@@ -190,7 +191,6 @@ struct DepsgraphNodeBuilder {
 	void build_rigidbody(Scene *scene);
 	void build_particles(Object *object, bool is_object_visible);
 	void build_particle_settings(ParticleSettings *part);
-	void build_cloth(Object *object);
 	void build_animdata(ID *id);
 	void build_animdata_nlastrip_targets(ListBase *strips);
 	void build_action(bAction *action);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index d336bfb6188..e66c3a25e33 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -87,6 +87,7 @@ extern "C" {
 #include "BKE_node.h"
 #include "BKE_object.h"
 #include "BKE_particle.h"
+#include "BKE_pointcache.h"
 #include "BKE_rigidbody.h"
 #include "BKE_shader_fx.h"
 #include "BKE_shrinkwrap.h"
@@ -184,9 +185,13 @@ static bool check_id_has_anim_component(ID *i

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list