Page MenuHome

Fix T44185: Hair density influence bug
ClosedPublic

Authored by Krzysztof Rećko (chrisr) on Apr 1 2015, 7:25 PM.

Details

Summary

This fixes T44185.

Free unexisting particles only after computing texture influence. I don't know if it is a perfect solution, because memory usage went up, and also many more particles are evaluated, but it seems to be a better way to do it than freeing before texture influence.

Diff Detail

Repository
rB Blender

Event Timeline

Krzysztof Rećko (chrisr) retitled this revision from to Fix T44185: Hair density influence bug.
Krzysztof Rećko (chrisr) updated this object.
Krzysztof Rećko (chrisr) set the repository for this revision to rB Blender.
Brecht Van Lommel (brecht) accepted this revision.EditedMay 3 2015, 4:12 PM

Looks good to me except one thing, I'll test it a bit more and commit, thanks!

source/blender/blenkernel/intern/particle_system.c
4155

I think this still needs to happen after the loop below where it does reset_particle which sets PARS_UNEXIST through initialize_particle_texture.

Something like this:

diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 54d01ea..645f403 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -4143,6 +4143,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
                                {
                                        PARTICLE_P;
                                        float disp = psys_get_current_display_percentage(psys);
+                                       bool free_unexisting = false;

                                        /* Particles without dynamics haven't been reset yet because they don't use pointcache */
                                        if (psys->recalc & PSYS_RECALC_RESET)
@@ -4152,7 +4153,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
                                                free_keyed_keys(psys);
                                                distribute_particles(&sim, part->from);
                                                initialize_all_particles(&sim);
-                                               free_unexisting_particles(&sim);
+                                               free_unexisting = true;

                                                /* flag for possible explode modifiers after this system */
                                                sim.psmd->flag |= eParticleSystemFlag_Pars;
@@ -4171,6 +4172,10 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
                                                        pa->flag &= ~PARS_NO_DISP;
                                        }

+                                       /* free unexisting after reset particle */
+                                       if (free_unexisting)
+                                               free_unexisting_particles(&sim);
+
                                        if (part->phystype == PART_PHYS_KEYED) {
                                                psys_count_keyed_targets(&sim);
                                                set_keyed_keys(&sim);
This revision is now accepted and ready to land.May 3 2015, 4:12 PM
This revision was automatically updated to reflect the committed changes.