diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2016-03-13 20:21:30 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-03-18 13:44:22 +0300 |
commit | 6d4f51212ba5a278513e024e009bdb49fea69654 (patch) | |
tree | 5140df48d7efdbdcbb4dd3df153c604b4310e051 /source/blender/blenkernel/intern | |
parent | ab44c20409dbe9b429ec87868992fa69c213d764 (diff) |
Fix T47773: Particle System with Boids Crash.
Problem was, during initialization of boids particles in `dynamics_step()`,
psys of target objects was not obtained with generic `psys_get_target_system()`
as later in code, which could lead to some uninitialized `psys->tree` usage...
Think it's safe enough for 2.77, though not a regression.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/boids.c | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle_system.c | 6 |
2 files changed, 5 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 7ce61ec6fab..b4bc83bf94c 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -310,6 +310,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues * ParticleSystem *epsys = psys_get_target_system(bbd->sim->ob, pt); if (epsys) { + BLI_assert(epsys->tree != NULL); neighbors = BLI_kdtree_range_search__normal( epsys->tree, pa->prev_state.co, pa->prev_state.ave, &ptn, acbr->look_ahead * len_v3(pa->prev_state.vel)); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 01112d42804..4d3e966b896 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3508,8 +3508,10 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) boids_precalc_rules(part, cfra); for (; pt; pt=pt->next) { - if (pt->ob) - psys_update_particle_tree(BLI_findlink(&pt->ob->particlesystem, pt->psys-1), cfra); + ParticleSystem *psys_target = psys_get_target_system(sim->ob, pt); + if (psys_target && psys_target != psys) { + psys_update_particle_tree(psys_target, cfra); + } } break; } |