Page MenuHome

Particles: Allow python to write hair keys
ClosedPublic

Authored by Sergey Sharybin (sergey) on Sep 9 2020, 4:06 PM.

Details

Summary

Add a function HairKey.co_object_set() which can be used to modify hair
keys positions in a way that hair strands respects the new coordinates,
without doing extra trickery with edit mode toggle. The naming comes
from existing HairKey.co_object().

The usage is a bit tricky:

  • The function is to be called on the hair key from an original object.
  • The arguments are to be passed from evaluated object.

Basically:

hair_key_orig.co_object_set(object_eval, modifier_eval, particle_eval)

This is required because coordinate space conversion needs to know
evaluated state of the hair system in order to access hair space
matrix. It is a deliberate choice to not pass dependency graph and not
to do lookup of evaluated ID on every call of co_object_set() to keep
performance on a manageable levels.

One requirement is that the hair strands are to be calculated once, by,
for example, toggling particle edit mode. Without this there will be no
particles to access hair keys from in the original object.

Such functionality is something what got lost during 2.80 development
and is something what is needed here at the studio.

Below is the file with more complete example: convert strands from mesh
edges to actual particle system hair strands. The viewport refresh is
sometimes missing, and this does not seem to be related to this specific
change.

Diff Detail

Repository
rB Blender

Event Timeline

Sergey Sharybin (sergey) requested review of this revision.Sep 9 2020, 4:06 PM
Sergey Sharybin (sergey) created this revision.
Brecht Van Lommel (brecht) added inline comments.
source/blender/makesrna/intern/rna_particle.c
377

combin -> combing

This revision is now accepted and ready to land.Sep 10 2020, 1:35 PM
source/blender/makesrna/intern/rna_particle.c
278

Objecy->Object? :D