[Bf-blender-cvs] [34fe03c] master: Fix T47773: Particle System with Boids Crash.
Bastien Montagne
noreply at git.blender.org
Sun Mar 13 18:25:14 CET 2016
Commit: 34fe03c7f25cd06876a79af418ced9f4cfa91226
Author: Bastien Montagne
Date: Sun Mar 13 18:21:30 2016 +0100
Branches: master
https://developer.blender.org/rB34fe03c7f25cd06876a79af418ced9f4cfa91226
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.
===================================================================
M source/blender/blenkernel/intern/boids.c
M source/blender/blenkernel/intern/particle_system.c
===================================================================
diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c
index 7ce61ec..b4bc83b 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 616dd6f..e9ce532 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -3510,8 +3510,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;
}
More information about the Bf-blender-cvs
mailing list