I’m updating one of my plugins to 2.8.
One of the things it does is set up a particle system, then immediately query it for the locations of particles.
The code looks like this:
bpy.ops.object.particle_system_add()
psys = obj.particle_systems[-1] # type: bpy.types.ParticleSystem
pset = psys.settings
pset.count = particle_count
pset.emit_from = emit_from
pset.distribution = 'RAND'
pset.use_even_distribution = True
# Force depsgraph evaluation (https://developer.blender.org/T58792)
eval_obj = bpy.context.depsgraph.objects.get(obj.name, None)
# Extract locations
particles = eval_obj.particle_systems[-1].particles
locations = [tuple(particle.location) for (index, particle) in particles.items()]
I used to call scene.update()
, now I’m calling depsgraph.objects.get
to force the particles to be generated.
But it’s not working properly: it always uses the default particle system settings, and ignores the values I set for count
and emit_from
.
Can anyone explain how deps graph is meant to work?