[Bf-blender-cvs] [44cd24a9cee] blender2.8: Particles: Remove dedicated recalc field from ParticleSettings

Sergey Sharybin noreply at git.blender.org
Thu Mar 29 12:42:05 CEST 2018


Commit: 44cd24a9cee9ffb14b5d26a622f2158f55e008ba
Author: Sergey Sharybin
Date:   Wed Mar 28 17:32:51 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB44cd24a9cee9ffb14b5d26a622f2158f55e008ba

Particles: Remove dedicated recalc field from ParticleSettings

Use more generic id->recalc flag.

Also sanitize flag flush from settings to particle system.
Need to do such flush before triggering point cache reset, since
point cache reset will do some logic based on what flags are set.

This will solve crash caused by threaded update which will set
some bitflags while point cache reset is in progress.

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

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 2db4126057a..06c74d93e7c 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -485,11 +485,6 @@ typedef struct ParticleRenderData {
 
 struct EvaluationContext;
 
-void BKE_particle_system_settings_eval(const 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_init(const struct EvaluationContext *eval_ctx,
                                    struct Scene *scene,
                                    struct Object *ob);
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index f27a570ca29..b80eca0ed59 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -4417,24 +4417,16 @@ void BKE_particlesystem_id_loop(ParticleSystem *psys, ParticleSystemIDFunc func,
 
 /* **** Depsgraph evaluation **** */
 
-void BKE_particle_system_settings_eval(const struct EvaluationContext *UNUSED(eval_ctx),
-                                       ParticleSystem *psys)
-{
-	DEG_debug_print_eval(__func__, psys->name, psys);
-	psys->recalc |= psys->part->recalc;
-}
-
-void BKE_particle_system_settings_recalc_clear(struct EvaluationContext *UNUSED(eval_ctx),
-                                               ParticleSettings *particle_settings)
-{
-	DEG_debug_print_eval(__func__, particle_settings->id.name, particle_settings);
-	particle_settings->recalc = 0;
-}
-
 void BKE_particle_system_eval_init(const struct EvaluationContext *UNUSED(eval_ctx),
                                    Scene *scene,
                                    Object *ob)
 {
 	DEG_debug_print_eval(__func__, ob->id.name, ob);
+	for (ParticleSystem *psys = ob->particlesystem.first;
+	     psys != NULL;
+	     psys = psys->next)
+	{
+		psys->recalc |= (psys->part->id.recalc & DEG_TAG_PSYS_ALL);
+	}
 	BKE_ptcache_object_reset(scene, ob, 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 e4652812c50..7d606629acb 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -901,13 +901,6 @@ void DepsgraphNodeBuilder::build_particles(Object *object)
 		 * NOTE: The call itself ensures settings are only build once.
 		 */
 		build_particle_settings(part);
-		/* Update on particle settings change. */
-		add_operation_node(psys_comp,
-		                   function_bind(BKE_particle_system_settings_eval,
-		                                 _1,
-		                                 psys),
-		                   DEG_OPCODE_PARTICLE_SETTINGS_EVAL,
-		                   psys->name);
 		/* Particle system evaluation. */
 		add_operation_node(psys_comp,
 		                   NULL,
@@ -951,12 +944,6 @@ 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(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 ddb0f809a53..5e25f60e3ac 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -1430,19 +1430,7 @@ void DepsgraphRelationBuilder::build_particles(Object *object)
 		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(&object->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");
+		add_relation(particle_settings_key, eval_init_key, "Particle Settings Change");
 		add_relation(eval_init_key, psys_key, "Init -> PSys");
 		/* TODO(sergey): Currently particle update is just a placeholder,
 		 * hook it to the ubereval node so particle system is getting updated
@@ -1543,14 +1531,6 @@ 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_particles_visualization_object(
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index 1f643dc9615..8f2f6e258fb 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -199,13 +199,7 @@ void depsgraph_tag_to_component_opcode(const ID *id,
 				 *   component. Will be nice to get this unified with object,
 				 *   but we can survive for now with single exception here.
 				 *   Particles needs reconsideration anyway,
-				 * - We do direct injection of particle settings recalc flag
-				 *   here. This is what we need to do for until particles
-				 *   are switched away from own recalc flag and are using
-				 *   ID->recalc flags instead.
 				 */
-				ParticleSettings *particle_settings = (ParticleSettings *)id;
-				particle_settings->recalc |= (tag & DEG_TAG_PSYS_ALL);
 				*component_type = DEG_NODE_TYPE_PARAMETERS;
 			}
 			else {
diff --git a/source/blender/depsgraph/intern/depsgraph_type_defines.cc b/source/blender/depsgraph/intern/depsgraph_type_defines.cc
index 1ae1b52b8d2..15144a8f31f 100644
--- a/source/blender/depsgraph/intern/depsgraph_type_defines.cc
+++ b/source/blender/depsgraph/intern/depsgraph_type_defines.cc
@@ -119,7 +119,6 @@ static const char *stringify_opcode(eDepsOperation_Code opcode)
 		STRINGIFY_OPCODE(PARTICLE_SYSTEM_EVAL_INIT);
 		STRINGIFY_OPCODE(PARTICLE_SYSTEM_EVAL);
 		STRINGIFY_OPCODE(PARTICLE_SETTINGS_EVAL);
-		STRINGIFY_OPCODE(PARTICLE_SETTINGS_RECALC_CLEAR);
 		/* Point Cache. */
 		STRINGIFY_OPCODE(POINT_CACHE_RESET);
 		/* Batch cache. */
diff --git a/source/blender/depsgraph/intern/depsgraph_types.h b/source/blender/depsgraph/intern/depsgraph_types.h
index b4a0dde1f35..3aa204490eb 100644
--- a/source/blender/depsgraph/intern/depsgraph_types.h
+++ b/source/blender/depsgraph/intern/depsgraph_types.h
@@ -240,7 +240,6 @@ typedef enum eDepsOperation_Code {
 	DEG_OPCODE_PARTICLE_SYSTEM_EVAL_INIT,
 	DEG_OPCODE_PARTICLE_SYSTEM_EVAL,
 	DEG_OPCODE_PARTICLE_SETTINGS_EVAL,
-	DEG_OPCODE_PARTICLE_SETTINGS_RECALC_CLEAR,
 
 	/* Point Cache. ------------------------------------- */
 	DEG_OPCODE_POINT_CACHE_RESET,
diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h
index a7be2e37c4b..5f86ec31d0b 100644
--- a/source/blender/makesdna/DNA_particle_types.h
+++ b/source/blender/makesdna/DNA_particle_types.h
@@ -262,7 +262,7 @@ typedef struct ParticleSettings {
 	short use_modifier_stack;
 
 	short pad5;
-	int recalc;
+	int pad8;
 
 	float twist;
 	float pad6;



More information about the Bf-blender-cvs mailing list