[Bf-blender-cvs] [b89a1a6] hair_immediate_fixes: Fix for outdated root array size when changing the particle amount during simulation.
Lukas Tönne
noreply at git.blender.org
Fri Sep 26 09:34:43 CEST 2014
Commit: b89a1a64c53507f1440f03bafcc56042a0e31090
Author: Lukas Tönne
Date: Fri Sep 26 09:33:51 2014 +0200
Branches: hair_immediate_fixes
https://developer.blender.org/rBb89a1a64c53507f1440f03bafcc56042a0e31090
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 9f34c74..3a3a681 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -4048,6 +4048,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);
@@ -4075,20 +4076,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");
}
More information about the Bf-blender-cvs
mailing list