diff options
author | Dalai Felinto <dalai@blender.org> | 2020-12-17 19:39:49 +0300 |
---|---|---|
committer | Dalai Felinto <dalai@blender.org> | 2020-12-17 19:39:49 +0300 |
commit | 42b0389a9b05e51e17ba79540e88cd446b52fae7 (patch) | |
tree | ee17716640f1b1133ae2ab4ca65cd92a63d09f15 /source/blender/blenkernel/intern/particle_system.c | |
parent | c5a17d5ea1ff786cb91cbcf3f12cd02f730c4143 (diff) | |
parent | e7b698327cd91b371ff4fd43d1c117637224fded (diff) |
Merge remote-tracking branch 'origin/master' into geometry-nodesgeometry-nodes
Diffstat (limited to 'source/blender/blenkernel/intern/particle_system.c')
-rw-r--r-- | source/blender/blenkernel/intern/particle_system.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 35265cf8b68..71df28c8b42 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -34,6 +34,7 @@ #include "DNA_anim_types.h" #include "DNA_boid_types.h" +#include "DNA_cloth_types.h" #include "DNA_curve_types.h" #include "DNA_listBase.h" #include "DNA_mesh_types.h" @@ -4978,6 +4979,24 @@ void particle_system_update(struct Depsgraph *depsgraph, /* ID looper */ +/* unfortunately PSys and modifier ID loopers are not directly compatible, so we need this struct + * and the callback below to map the former to the latter (thanks to psys embedding a Cloth + * modifier data struct now, for Hair physics simulations). */ +typedef struct ParticleSystemIDLoopForModifier { + ParticleSystem *psys; + ParticleSystemIDFunc func; + void *userdata; +} ParticleSystemIDLoopForModifier; + +static void particlesystem_modifiersForeachIDLink(void *user_data, + Object *UNUSED(object), + ID **id_pointer, + int cb_flag) +{ + ParticleSystemIDLoopForModifier *data = (ParticleSystemIDLoopForModifier *)user_data; + data->func(data->psys, id_pointer, data->userdata, cb_flag); +} + void BKE_particlesystem_id_loop(ParticleSystem *psys, ParticleSystemIDFunc func, void *userdata) { ParticleTarget *pt; @@ -4986,6 +5005,16 @@ void BKE_particlesystem_id_loop(ParticleSystem *psys, ParticleSystemIDFunc func, func(psys, (ID **)&psys->target_ob, userdata, IDWALK_CB_NOP); func(psys, (ID **)&psys->parent, userdata, IDWALK_CB_NOP); + if (psys->clmd != NULL) { + const ModifierTypeInfo *mti = BKE_modifier_get_info(psys->clmd->modifier.type); + + if (mti->foreachIDLink != NULL) { + ParticleSystemIDLoopForModifier data = {.psys = psys, .func = func, .userdata = userdata}; + mti->foreachIDLink( + &psys->clmd->modifier, NULL, particlesystem_modifiersForeachIDLink, &data); + } + } + for (pt = psys->targets.first; pt; pt = pt->next) { func(psys, (ID **)&pt->ob, userdata, IDWALK_CB_NOP); } |