Fix for applying the bending randomness factor.
A stupid hack is needed here, changing the way the factor is applied to angular bending springs. In cloth sim the bending factor of individual springs is applied as a mix value between the bending stiffness and a max value, but this max value isn't even used in hair sim so that approach becomes useless. Conflicts: source/blender/physics/intern/BPH_mass_spring.cpp
This commit is contained in:
@@ -3048,7 +3048,7 @@ static void hair_create_input_dm(ParticleSimulationData *sim, int totpoint, int
|
||||
mul_m4_m4m4(root_mat, sim->ob->obmat, hairmat);
|
||||
normalize_m4(root_mat);
|
||||
|
||||
bending_stiffness = 1.0f - part->bending_random * psys_frand(psys, p + 666);
|
||||
bending_stiffness = CLAMPIS(1.0f - part->bending_random * psys_frand(psys, p + 666), 0.0f, 1.0f);
|
||||
|
||||
for (k=0, key=pa->hair; k<pa->totkey; k++,key++) {
|
||||
ClothHairData *hair;
|
||||
|
||||
@@ -2322,7 +2322,7 @@ static void rna_def_particle_settings(BlenderRNA *brna)
|
||||
RNA_def_property_float_sdna(prop, NULL, "bending_random");
|
||||
RNA_def_property_range(prop, 0.0f, 1.0f);
|
||||
RNA_def_property_ui_text(prop, "Random Bending Stiffness", "Random stiffness of hairs");
|
||||
RNA_def_property_update(prop, 0, "rna_Particle_reset");
|
||||
RNA_def_property_update(prop, 0, "rna_Particle_redo");
|
||||
|
||||
/*TODO: not found in UI, readonly? */
|
||||
prop = RNA_def_property(srna, "keys_step", PROP_INT, PROP_NONE);
|
||||
|
||||
@@ -398,7 +398,11 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
|
||||
|
||||
s->flags |= CLOTH_SPRING_FLAG_NEEDED;
|
||||
|
||||
scaling = parms->bending + s->stiffness * fabsf(parms->max_bend - parms->bending);
|
||||
/* XXX WARNING: angular bending springs for hair apply stiffness factor as an overall factor, unlike cloth springs!
|
||||
* this is crap, but needed due to cloth/hair mixing ...
|
||||
* max_bend factor is not even used for hair, so ...
|
||||
*/
|
||||
scaling = s->stiffness * parms->bending;
|
||||
kb = scaling / (20.0f * (parms->avg_spring_len + FLT_EPSILON));
|
||||
|
||||
scaling = parms->bending_damping;
|
||||
|
||||
Reference in New Issue
Block a user