From 74aa3ee9ee8516fa56080b38d7ad6d457909bf05 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 11 Mar 2014 22:16:01 +1100 Subject: [PATCH] Fix T39078: crash when increasing hair emission number --- source/blender/blenkernel/intern/object_dupli.c | 10 ++++++++-- source/blender/blenkernel/intern/particle.c | 5 +++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c index b3726eb..75a9825 100644 --- a/source/blender/blenkernel/intern/object_dupli.c +++ b/source/blender/blenkernel/intern/object_dupli.c @@ -964,8 +964,14 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem cpa = &psys->child[a - totpart]; /* pa_num = a; */ /* UNUSED */ - pa_time = psys->particles[cpa->parent].time; - size = psys_get_child_size(psys, cpa, ctime, NULL); + if (cpa->parent < totpart) { + pa_time = psys->particles[cpa->parent].time; + size = psys_get_child_size(psys, cpa, ctime, NULL); + } + else { + printf("invalid index %d of %d\n", cpa->parent, totpart); + continue; + } } /* some hair paths might be non-existent so they can't be used for duplication */ diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 1088976..e79a2d4 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -2397,6 +2397,11 @@ void psys_find_parents(ParticleSimulationData *sim) if ((sim->psys->renderdata || G.is_rendering) && part->child_nbr && part->ren_child_nbr) totparent *= (float)part->child_nbr / (float)part->ren_child_nbr; + /* workaround! - campbell */ + if (sim->psys->totpart < totparent) { + totparent = sim->psys->totpart; + } + tree = BLI_kdtree_new(totparent); for (p = 0, cpa = sim->psys->child; p < totparent; p++, cpa++) { -- 1.9.0