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.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -262,7 +262,7 @@ typedef struct ParticleSettings {
|
||||
short use_modifier_stack;
|
||||
|
||||
short pad5;
|
||||
int recalc;
|
||||
int pad8;
|
||||
|
||||
float twist;
|
||||
float pad6;
|
||||
|
||||
Reference in New Issue
Block a user