Commit: 43424a639b1d6b6884afc6db1cf93bd817ab5d92
Author: Lukas Tönne
Date: Fri Sep 26 09:33:51 2014 +0200
Branches: master
https://developer.blender.org/rB43424a639b1d6b6884afc6db1cf93bd817ab5d92
Fix for outdated root array size when changing the particle amount
during simulation.
===================================================================
M source/blender/blenkernel/intern/particle_system.c
===================================================================
diff --git a/source/blender/blenkernel/intern/particle_system.c
b/source/blender/blenkernel/intern/particle_system.c
index a840b74..6474e3e 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");
}
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs