Commit: af8c0c84f600a8c735fc8e4d514b404c962b5b03
Author: Lukas Tönne
Date:   Tue Nov 18 10:30:11 2014 +0100
Branches: gooseberry
https://developer.blender.org/rBaf8c0c84f600a8c735fc8e4d514b404c962b5b03

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.

===================================================================

M       source/blender/blenkernel/intern/particle_system.c
M       source/blender/makesrna/intern/rna_particle.c
M       source/blender/physics/intern/BPH_mass_spring.cpp

===================================================================

diff --git a/source/blender/blenkernel/intern/particle_system.c 
b/source/blender/blenkernel/intern/particle_system.c
index 3fc7185..b8fb0b4 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -3167,7 +3167,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;
diff --git a/source/blender/makesrna/intern/rna_particle.c 
b/source/blender/makesrna/intern/rna_particle.c
index 6ebfafb..002cf84 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -2404,7 +2404,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);
diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp 
b/source/blender/physics/intern/BPH_mass_spring.cpp
index e7b1029..7bc4941 100644
--- a/source/blender/physics/intern/BPH_mass_spring.cpp
+++ b/source/blender/physics/intern/BPH_mass_spring.cpp
@@ -482,7 +482,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;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to