Fix T52156: Hair dynamics broken with density texture

Even strands that were excluded by the density texture were being added
to the DM passed to cloth, but these ended up having some invalid data,
because they were not fully constructed.

This simply excludes `UNEXISTED` particles from the DM generation, as
would be expected.
This commit is contained in:
Luca Rood
2017-07-28 15:24:48 +02:00
parent 05f377805b
commit 9b22dbcc0d

View File

@@ -3042,12 +3042,14 @@ static void hair_create_input_dm(ParticleSimulationData *sim, int totpoint, int
/* calculate maximum segment length */ /* calculate maximum segment length */
max_length = 0.0f; max_length = 0.0f;
LOOP_PARTICLES { LOOP_PARTICLES {
if (!(pa->flag & PARS_UNEXIST)) {
for (k=1, key=pa->hair+1; k<pa->totkey; k++,key++) { for (k=1, key=pa->hair+1; k<pa->totkey; k++,key++) {
float length = len_v3v3(key->co, (key-1)->co); float length = len_v3v3(key->co, (key-1)->co);
if (max_length < length) if (max_length < length)
max_length = length; max_length = length;
} }
} }
}
psys->clmd->sim_parms->vgroup_mass = 1; psys->clmd->sim_parms->vgroup_mass = 1;
@@ -3057,6 +3059,7 @@ static void hair_create_input_dm(ParticleSimulationData *sim, int totpoint, int
/* make vgroup for pin roots etc.. */ /* make vgroup for pin roots etc.. */
hair_index = 1; hair_index = 1;
LOOP_PARTICLES { LOOP_PARTICLES {
if (!(pa->flag & PARS_UNEXIST)) {
float root_mat[4][4]; float root_mat[4][4];
float bending_stiffness; float bending_stiffness;
bool use_hair; bool use_hair;
@@ -3128,6 +3131,7 @@ static void hair_create_input_dm(ParticleSimulationData *sim, int totpoint, int
hair_index += pa->totkey + 1; hair_index += pa->totkey + 1;
} }
}
} }
static void do_hair_dynamics(ParticleSimulationData *sim) static void do_hair_dynamics(ParticleSimulationData *sim)
@@ -3152,10 +3156,12 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
totpoint = 0; totpoint = 0;
totedge = 0; totedge = 0;
LOOP_PARTICLES { LOOP_PARTICLES {
if (!(pa->flag & PARS_UNEXIST)) {
/* "out" dm contains all hairs */ /* "out" dm contains all hairs */
totedge += pa->totkey; totedge += pa->totkey;
totpoint += pa->totkey + 1; /* +1 for virtual root point */ totpoint += pa->totkey + 1; /* +1 for virtual root point */
} }
}
realloc_roots = false; /* whether hair root info array has to be reallocated */ realloc_roots = false; /* whether hair root info array has to be reallocated */
if (psys->hair_in_dm) { if (psys->hair_in_dm) {