Page MenuHome

Particles: Allow python to write hair keys

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



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.


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

Diff Detail

rB Blender
hair_from_mesh (branched from master)
Build Status
Buildable 10079
Build 10079: arc lint + arc unit

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.

combin -> combing

This revision is now accepted and ready to land.Sep 10 2020, 1:35 PM

Objecy->Object? :D