[Bf-blender-cvs] [83b0bf91660] blender2.8: Depsgraph: Solve TODO about more granular particle settings update tagging

Sergey Sharybin noreply at git.blender.org
Thu Jul 20 15:39:22 CEST 2017


Commit: 83b0bf91660c3421fa56a4b7a83f971bf793ffde
Author: Sergey Sharybin
Date:   Thu Jul 20 15:38:48 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB83b0bf91660c3421fa56a4b7a83f971bf793ffde

Depsgraph: Solve TODO about more granular particle settings update tagging

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

M	source/blender/blenkernel/BKE_particle.h
M	source/blender/blenkernel/intern/particle_system.c
M	source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M	source/blender/depsgraph/intern/builder/deg_builder_relations.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/makesdna/DNA_particle_types.h

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

diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index 639aefd029f..f318787d954 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -475,6 +475,8 @@ struct EvaluationContext;
 
 void BKE_particle_system_settings_eval(struct EvaluationContext *eval_ctx,
                                        struct ParticleSystem *psys);
+void BKE_particle_system_settings_recalc_clear(struct EvaluationContext *UNUSED(eval_ctx),
+                                               struct ParticleSettings *particle_settings);
 
 void BKE_particle_system_eval(struct EvaluationContext *eval_ctx,
                               struct Scene *scene,
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 6fb3bdf325d..3a7ca2caaa4 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -4359,8 +4359,16 @@ void BKE_particle_system_settings_eval(struct EvaluationContext *UNUSED(eval_ctx
 	if (G.debug & G_DEBUG_DEPSGRAPH) {
 		printf("%s on %s (%p)\n", __func__, psys->name, psys);
 	}
-	/* TODO(sergey): Need to do something more granular here.  */
-	psys->recalc |= PSYS_RECALC;
+	psys->recalc |= psys->part->recalc;
+}
+
+void BKE_particle_system_settings_recalc_clear(struct EvaluationContext *UNUSED(eval_ctx),
+                                               ParticleSettings *particle_settings)
+{
+	if (G.debug & G_DEBUG_DEPSGRAPH) {
+		printf("%s on %s (%p)\n", __func__, particle_settings->id.name, particle_settings);
+	}
+	particle_settings->recalc = 0;
 }
 
 void BKE_particle_system_eval(struct EvaluationContext *UNUSED(eval_ctx),
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index 7ae7bc97d48..8826c946c73 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -757,6 +757,12 @@ void DepsgraphNodeBuilder::build_particle_settings(ParticleSettings *part) {
 	                   DEG_NODE_TYPE_PARAMETERS,
 	                   NULL,
 	                   DEG_OPCODE_PARTICLE_SETTINGS_EVAL);
+	add_operation_node(part_id,
+	                   DEG_NODE_TYPE_PARAMETERS,
+	                   function_bind(BKE_particle_system_settings_recalc_clear,
+	                                 _1,
+	                                 part),
+	                   DEG_OPCODE_PARTICLE_SETTINGS_RECALC_CLEAR);
 }
 
 void DepsgraphNodeBuilder::build_cloth(Scene *scene, Object *object)
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 4c1d010d0cc..afb89e9f117 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -1265,12 +1265,19 @@ void DepsgraphRelationBuilder::build_particles(Scene *scene, Object *ob)
 		OperationKey particle_settings_key(&part->id,
 		                                   DEG_NODE_TYPE_PARAMETERS,
 		                                   DEG_OPCODE_PARTICLE_SETTINGS_EVAL);
+		OperationKey particle_settings_recalc_clear_key(
+		        &part->id,
+		        DEG_NODE_TYPE_PARAMETERS,
+		        DEG_OPCODE_PARTICLE_SETTINGS_RECALC_CLEAR);
 		OperationKey psys_settings_key(&ob->id,
 		                               DEG_NODE_TYPE_EVAL_PARTICLES,
 		                               DEG_OPCODE_PARTICLE_SETTINGS_EVAL,
 		                               psys->name);
 		add_relation(particle_settings_key, psys_settings_key, "Particle Settings Change");
 		add_relation(psys_settings_key, psys_key, "Particle Settings Update");
+		add_relation(psys_key,
+		             particle_settings_recalc_clear_key,
+		             "Particle Settings Recalc Clear");
 
 		/* XXX: if particle system is later re-enabled, we must do full rebuild? */
 		if (!psys_check_enabled(ob, psys, G.is_rendering))
@@ -1289,10 +1296,22 @@ void DepsgraphRelationBuilder::build_particles(Scene *scene, Object *ob)
 
 		/* collisions */
 		if (part->type != PART_HAIR) {
-			add_collision_relations(psys_key, scene, ob, part->collision_group, true, "Particle Collision");
+			add_collision_relations(psys_key,
+			                        scene,
+			                        ob,
+			                        part->collision_group,
+			                        true,
+			                        "Particle Collision");
 		}
-		else if ((psys->flag & PSYS_HAIR_DYNAMICS) && psys->clmd && psys->clmd->coll_parms) {
-			add_collision_relations(psys_key, scene, ob, psys->clmd->coll_parms->group, true, "Hair Collision");
+		else if ((psys->flag & PSYS_HAIR_DYNAMICS) &&
+		         psys->clmd != NULL &&
+		         psys->clmd->coll_parms != NULL) {
+			add_collision_relations(psys_key,
+			                        scene,
+			                        ob,
+			                        psys->clmd->coll_parms->group,
+			                        true,
+			                        "Hair Collision");
 		}
 
 		/* effectors */
@@ -1350,6 +1369,14 @@ void DepsgraphRelationBuilder::build_particle_settings(ParticleSettings *part)
 
 	/* Animation data relations. */
 	build_animdata(&part->id);
+
+	OperationKey eval_key(part_id,
+	                      DEG_NODE_TYPE_PARAMETERS,
+	                      DEG_OPCODE_PARTICLE_SETTINGS_EVAL);
+	OperationKey recalc_clear_key(part_id,
+	                             DEG_NODE_TYPE_PARAMETERS,
+	                             DEG_OPCODE_PARTICLE_SETTINGS_RECALC_CLEAR);
+	add_relation(eval_key, recalc_clear_key, "Particle Settings Clear Recalc");
 }
 
 void DepsgraphRelationBuilder::build_cloth(Scene * /*scene*/,
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index 67db6ae1467..91b049beabb 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -217,10 +217,12 @@ void id_tag_update_object_time(Depsgraph *graph, IDDepsNode *id_node)
 	/* TODO(sergey): More components to tag here? */
 }
 
-void id_tag_update_particle(Depsgraph *graph, IDDepsNode *id_node)
+void id_tag_update_particle(Depsgraph *graph, IDDepsNode *id_node, int tag)
 {
 	ComponentDepsNode *particle_comp =
 	        id_node->find_component(DEG_NODE_TYPE_PARAMETERS);
+	ParticleSettings *particle_settings = (ParticleSettings *)id_node->id_orig;
+	particle_settings->recalc |= (tag & PSYS_RECALC);
 	if (particle_comp == NULL) {
 #ifdef STRICT_COMPONENT_TAGGING
 		DEG_ERROR_PRINTF("ERROR: Unable to find particle component for %s\n",
@@ -268,8 +270,7 @@ void deg_graph_id_tag_update(Main *bmain, Depsgraph *graph, ID *id, int flag)
 		id_tag_update_object_time(graph, id_node);
 	}
 	if (flag & PSYS_RECALC) {
-		/* TODO(sergey): Differentiate between different particle updates tags. */
-		id_tag_update_particle(graph, id_node);
+		id_tag_update_particle(graph, id_node, flag);
 	}
 #ifdef WITH_COPY_ON_WRITE
 	if (flag & DEG_TAG_COPY_ON_WRITE) {
diff --git a/source/blender/depsgraph/intern/depsgraph_type_defines.cc b/source/blender/depsgraph/intern/depsgraph_type_defines.cc
index cbc4d1b3037..dfffe0e7a79 100644
--- a/source/blender/depsgraph/intern/depsgraph_type_defines.cc
+++ b/source/blender/depsgraph/intern/depsgraph_type_defines.cc
@@ -132,6 +132,7 @@ static const char *stringify_opcode(eDepsOperation_Code opcode)
 		/* Particles. */
 		STRINGIFY_OPCODE(PARTICLE_SYSTEM_EVAL);
 		STRINGIFY_OPCODE(PARTICLE_SETTINGS_EVAL);
+		STRINGIFY_OPCODE(PARTICLE_SETTINGS_RECALC_CLEAR);
 		/* Collections. */
 		STRINGIFY_OPCODE(SCENE_LAYER_INIT);
 		STRINGIFY_OPCODE(SCENE_LAYER_EVAL);
diff --git a/source/blender/depsgraph/intern/depsgraph_types.h b/source/blender/depsgraph/intern/depsgraph_types.h
index af13dc37e2f..32385668f94 100644
--- a/source/blender/depsgraph/intern/depsgraph_types.h
+++ b/source/blender/depsgraph/intern/depsgraph_types.h
@@ -212,6 +212,7 @@ typedef enum eDepsOperation_Code {
 	/* Particle System evaluation. */
 	DEG_OPCODE_PARTICLE_SYSTEM_EVAL,
 	DEG_OPCODE_PARTICLE_SETTINGS_EVAL,
+	DEG_OPCODE_PARTICLE_SETTINGS_RECALC_CLEAR,
 
 	/* Collections. ------------------------------------- */
 	DEG_OPCODE_SCENE_LAYER_INIT,
diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h
index d0dfe18d0c4..ea7905eb2ad 100644
--- a/source/blender/makesdna/DNA_particle_types.h
+++ b/source/blender/makesdna/DNA_particle_types.h
@@ -260,8 +260,9 @@ typedef struct ParticleSettings {
 
 	/* modified dm support */
 	short use_modifier_stack;
-	short pad5[3];
 
+	short pad5;
+	int recalc;
 } ParticleSettings;
 
 typedef struct ParticleSystem {




More information about the Bf-blender-cvs mailing list