[Bf-blender-cvs] [76e8b63] hair_system: Stretch spring damping implementation.

Lukas Tönne noreply at git.blender.org
Mon Jul 28 19:29:12 CEST 2014


Commit: 76e8b63e87446acf1eaa682815301efbd6c5a02e
Author: Lukas Tönne
Date:   Mon Jul 28 19:27:59 2014 +0200
Branches: hair_system
https://developer.blender.org/rB76e8b63e87446acf1eaa682815301efbd6c5a02e

Stretch spring damping implementation.

This adds viscous damping to the stretching springs. Note that this does
not yet entirely remove the energy from the system: for this we first
need to implement the bending springs as well, which act based on
angles between hair segments.

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

M	source/blender/hair/intern/HAIR_solver.cpp
M	source/blender/makesrna/intern/rna_hair.c

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

diff --git a/source/blender/hair/intern/HAIR_solver.cpp b/source/blender/hair/intern/HAIR_solver.cpp
index 797962a..539204c 100644
--- a/source/blender/hair/intern/HAIR_solver.cpp
+++ b/source/blender/hair/intern/HAIR_solver.cpp
@@ -106,10 +106,12 @@ float3 Solver::calc_stretch(Curve *curve, Point *point0, Point *point1, float ti
 	float3 dir;
 	float rest_length = len_v3(point1->rest_co - point0->rest_co);
 	float length = normalize_v3_v3(dir, point1->cur.co - point0->cur.co);
+	float3 dvel = point1->cur.vel - point0->cur.vel;
 	
-	float3 stretch_acc = m_params.stretch_stiffness * (length - rest_length) * dir;
+	float3 stretch_force = m_params.stretch_stiffness * (length - rest_length) * dir;
+	float3 stretch_damp = m_params.stretch_damping * dot_v3_v3(dvel, dir) * dir;
 	
-	return stretch_acc;
+	return stretch_force + stretch_damp;
 }
 
 float3 Solver::calc_acceleration(Curve *curve, Point *point, float time, float3 prev_stretch, float3 stretch, Point::State &state) const
diff --git a/source/blender/makesrna/intern/rna_hair.c b/source/blender/makesrna/intern/rna_hair.c
index b5a2d93..64ee0d0 100644
--- a/source/blender/makesrna/intern/rna_hair.c
+++ b/source/blender/makesrna/intern/rna_hair.c
@@ -68,7 +68,8 @@ static void rna_def_hair_params(BlenderRNA *brna)
 
 	prop = RNA_def_property(srna, "stretch_damping", PROP_FLOAT, PROP_FACTOR);
 	RNA_def_property_float_sdna(prop, NULL, "stretch_damping");
-	RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.05, 3);
+	RNA_def_property_range(prop, 0.0f, 1.0e6f);
+	RNA_def_property_ui_range(prop, 0.0f, 1.0e5f, 0.1, 2);
 	RNA_def_property_ui_text(prop, "Stretch Damping", "");
 }




More information about the Bf-blender-cvs mailing list