[Bf-committers] questions about particles and collisions

David Jeske davidj at gmail.com
Mon May 30 20:31:16 CEST 2016


I am trying to understand why particles (emitter and hair) ignore
collisions with their emitter objects, even if the emitter has a collision
modifier. (because this is very inconvenient)

I'm starting with emitter particles, because the situation there is simpler
and uncovers some of the challenges.

It seems like at least at some point someone thought particle-to-emitter
collisions should work, as evidenced by this code in particle_system.c,
collision_detect(). It is trying to prevent particles from colliding with
their emitter too early in their lifetime. (afaik this code currently does
nothing, because the emitter will never appear in the collision list, see
next)

   for (coll = colliders->first; coll; coll=coll->next) {
       ...
       /* particles should not collide with emitter at birth */
       if (coll->ob == col->emitter && pa->time < col->cfra && pa->time >=
col->old_cfra)
            continue;

I can see that normal emitter particles ignore collisions with their own
emitter object because of this code-line in
particle_system.c:dynamics_step(). The second parameter (sim->ob) causes it
to skip itself when constructing the collider list.

   sim->colliders = get_collider_cache(sim->scene, sim->ob, NULL);

If I change the second parameter to NULL, it (may) include itself in the
collision list (if it has a collision modifier)

   sim->colliders = get_collider_cache(sim->scene, NULL, NULL);

Then placing a collision modifier on a particle emitter seems to cause the
particles to collide with their own emitter -- although there are some
issues.

One issue is that some particles appear to collide with the emitter at
birth (they emit opposite the normal), suggesting the first code-snippet is
insufficient to prevent this problem.

Another problem, is that if the emitter-collision-modifier is set to kill
particles, the first particle it kills seems to kill the entire particle
system. (see [1] below)


Are these the only two issues, or are there other problems?


I'm trying to figure out if this is reasonably fixable, or if it is just a
"bad idea" to pull on this thread. For example, is there something about
particles colliding with their own emitter that violates some expectation
of the modifier stack? Or is this simply a matter of coming up with
appropriate solutions to the odd cases and data interactions so it works
properly?

---

[1] On a related note, at ...
https://wiki.blender.org/index.php/Dev:Source/Physics/Collision_Modifier

It says:

     The collision modifier safes the position of the vertices
    of the object at the corresponding position on the modifier
    stack. It does this for the current and the last position
    using GLOBAL coordinates. The data is only valid as long as

      * you don't skip ahead/back several frames
            [TODO: should be enhanced later]
      * the number of vertices don't change on the
        modifier stack.


Is this related? Does the particle death kill the collision 'safe' (seems
like it would, though i don't understand why this would kill the particle
system)? Does a vertex-count-change invalidate the collision modifer 'safe'
even when verticies are added "after" the collision modifier in the
modifier stack?


More information about the Bf-committers mailing list