diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2014-09-26 11:33:51 +0400 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2015-01-20 11:30:03 +0300 |
commit | 43424a639b1d6b6884afc6db1cf93bd817ab5d92 (patch) | |
tree | 56b327f258f3675ffa9dbd09f99ef8e598fca92e /source/blender/blenkernel/intern/particle_system.c | |
parent | d613c381717d480d71259bcdab1db32c47f85778 (diff) |
Fix for outdated root array size when changing the particle amount
during simulation.
Diffstat (limited to 'source/blender/blenkernel/intern/particle_system.c')
-rw-r--r-- | source/blender/blenkernel/intern/particle_system.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index a840b740068..6474e3e37ac 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -4030,6 +4030,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim) float hairmat[4][4]; float (*deformedVerts)[3]; float max_length; + bool realloc_roots; if (!psys->clmd) { psys->clmd = (ClothModifierData*)modifier_new(eModifierType_Cloth); @@ -4057,20 +4058,24 @@ static void do_hair_dynamics(ParticleSimulationData *sim) totedge = totpoint; totpoint += psys->totpart; + realloc_roots = false; /* whether hair root info array has to be reallocated */ if (dm && (totpoint != dm->getNumVerts(dm) || totedge != dm->getNumEdges(dm))) { dm->release(dm); dm = psys->hair_in_dm = NULL; - MEM_freeN(psys->clmd->roots); - psys->clmd->roots = NULL; + realloc_roots = true; } if (!dm) { dm = psys->hair_in_dm = CDDM_new(totpoint, totedge, 0, 0, 0); DM_add_vert_layer(dm, CD_MDEFORMVERT, CD_CALLOC, NULL); + + realloc_roots = true; } - if (!psys->clmd->roots) { + if (!psys->clmd->roots || realloc_roots) { + if (psys->clmd->roots) + MEM_freeN(psys->clmd->roots); psys->clmd->roots = MEM_mallocN(sizeof(ClothHairRoot) * totpoint, "hair roots"); } |