[Bf-committers] splitting (off) hair

Lukas Tönne lukas.toenne at googlemail.com
Tue Jun 28 14:25:06 CEST 2011


As you know, i have been working on substantial improvements to the
particle system buffers for quite some time now, with the goal of
making particle buffers better suited for dynamic emission and adding
the possibility to create custom particle data to be used in future
node-based simulation.

The current state of this project is nearing feature completeness *on
the side of actual particles*, i.e. most existing features work nicely
with new the rate-based emission mode. But a remaining problem is the
tight integration of "hair particles" into the particle systems. IMHO
using particles as the basis for hair is a bad design decision. These
two features, though sharing *some* common characteristics are too
different to be efficiently maintained in the same subsystem.

Basically each hair is interpreted as the path (!) of a particle over
the first 100 frames (at least for defining it's initial state). Apart
from the fact that this is an arbitrary number, the distinction
between two different particle "modes" causes far too many problems
and too few benefits to be justified. From discussion with Janne Karhu
i take it that the motivation for this design is that particles and
hair share a bunch of different features, namely

* distribution on mesh surfaces (for particles this is only emission
location - already an important difference! particles may also be
emitted elsewhere in future)
* child particles/hairs (another difference: interpolation of child
particles between parents doesn't make much sense, only used for hair)
* path cache and editing (as pointed out above, this means
interpretation of hair as paths - but one is in space, the other over
time!)
* physical effectors influence both (but only at first glance, hair
"growing" by 100-frame-animation and effectors only might be useful
for grass or fur, actual hair dynamics are done as cloth sim even!)

Even with the old fixed-size buffer system the particle system code
was complicated a lot by hair, which needs special handling and hacks
all over the place. It becomes even more ridiculous with the new
dynamically sized paged buffers, which require even more checks and
stoppers to avoid resizing the buffers in hair mode.

I'm reluctant to spend more time trying to fix a system that is broken
by design (and intended for general redesign anyway) ... I would
rather try to separate hair code from particle code, so the two
systems don't interfere with each other so much. When/if someone picks
up the task of implementing an improved hair system some day this will
also be much easier with a self-contained system.
As there are some parts in both systems that work in a similar fashion
(see above), those parts should be included in a generic set of
functions in blenlib, e.g. generic functions for sampling mesh
surfaces (and volumes for particles). This way code duplication can be
largely avoided, while both particles and hair become a lot easier to
maintain. Janne basically agreed on this in irc discussion, but i want
to give everybody a chance to comment on it.

Now fire away!  :)

Lukas Tönne


More information about the Bf-committers mailing list