From 19f6bab818183fdb02a63f8d5035e4bc7056aebf Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 29 Nov 2007 13:34:38 +0000 Subject: [PATCH] Bugfix: Particle edit mode option interpolated for the add brush crashed with no existing particles. --- source/blender/src/editparticle.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/blender/src/editparticle.c b/source/blender/src/editparticle.c index e08ca3279d6..c9cf745fa44 100644 --- a/source/blender/src/editparticle.c +++ b/source/blender/src/editparticle.c @@ -1703,10 +1703,10 @@ static int remove_tagged_elements(Object *ob, ParticleSystem *psys) } } - MEM_freeN(psys->particles); + if(psys->particles) MEM_freeN(psys->particles); psys->particles = new_pars; - MEM_freeN(edit->keys); + if(edit->keys) MEM_freeN(edit->keys); edit->keys = new_keys; if(edit->mirror_cache) { @@ -2256,10 +2256,10 @@ static void brush_add(Object *ob, ParticleSystem *psys, short *mval, short numbe memcpy(new_keys, edit->keys, totpart * sizeof(ParticleEditKey*)); /* change old arrays to new ones */ - MEM_freeN(psys->particles); + if(psys->particles) MEM_freeN(psys->particles); psys->particles = new_pars; - MEM_freeN(edit->keys); + if(edit->keys) MEM_freeN(edit->keys); edit->keys = new_keys; if(edit->mirror_cache) { @@ -2267,8 +2267,6 @@ static void brush_add(Object *ob, ParticleSystem *psys, short *mval, short numbe edit->mirror_cache = NULL; } - psys->totpart = newtotpart; - /* create tree for interpolation */ if(pset->flag & PE_INTERPOLATE_ADDED && psys->totpart){ tree=BLI_kdtree_new(psys->totpart); @@ -2281,6 +2279,8 @@ static void brush_add(Object *ob, ParticleSystem *psys, short *mval, short numbe BLI_kdtree_balance(tree); } + psys->totpart = newtotpart; + /* create new elements */ pa = psys->particles + totpart; key = edit->keys + totpart; @@ -2691,10 +2691,10 @@ void PE_mirror_x(int tagged) memcpy(new_pars, psys->particles, totpart*sizeof(ParticleData)); memcpy(new_keys, edit->keys, totpart*sizeof(ParticleEditKey*)); - MEM_freeN(psys->particles); + if(psys->particles) MEM_freeN(psys->particles); psys->particles= new_pars; - MEM_freeN(edit->keys); + if(edit->keys) MEM_freeN(edit->keys); edit->keys= new_keys; if(edit->mirror_cache) {