[Bf-blender-cvs] [f61d166] hair_system: Fix for wrong hair root evaluation: The time value passed to the solver was the end of the time step interval.

Lukas Tönne noreply at git.blender.org
Thu Jul 31 10:38:38 CEST 2014


Commit: f61d166a874772ea948ed00a41ee6d618ef9ddca
Author: Lukas Tönne
Date:   Thu Jul 31 10:31:40 2014 +0200
Branches: hair_system
https://developer.blender.org/rBf61d166a874772ea948ed00a41ee6d618ef9ddca

Fix for wrong hair root evaluation: The time value passed to the solver
was the end of the time step interval.

This causes extrapolation of the hair root location and overshooting
hair.

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

M	source/blender/hair/intern/HAIR_solver.cpp
M	source/blender/modifiers/intern/MOD_hair.c

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

diff --git a/source/blender/hair/intern/HAIR_solver.cpp b/source/blender/hair/intern/HAIR_solver.cpp
index cb250f2..4a6b147 100644
--- a/source/blender/hair/intern/HAIR_solver.cpp
+++ b/source/blender/hair/intern/HAIR_solver.cpp
@@ -224,7 +224,10 @@ static void step(const HairParams &params, const SolverForces &forces, float tim
 		k = 0;
 		point = curve->points;
 		
-		calc_root_animation(t0, t1, time, curve, point->next.co, point->next.vel);
+		/* note: roots are evaluated at the end of the timestep: time + timestep
+		 * so the hair points align perfectly with them
+		 */
+		calc_root_animation(t0, t1, time + timestep, curve, point->next.co, point->next.vel);
 		
 		if (k < numpoints-1) {
 			stretch = calc_stretch_force(params, curve, point, point+1, time);
diff --git a/source/blender/modifiers/intern/MOD_hair.c b/source/blender/modifiers/intern/MOD_hair.c
index ce04401..70af492 100644
--- a/source/blender/modifiers/intern/MOD_hair.c
+++ b/source/blender/modifiers/intern/MOD_hair.c
@@ -97,7 +97,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
 		int s;
 		
 		float dt = 1.0f / (float)hmd->steps_per_second;
-		/*float prev_time = floorf(prev_steps) * dt;*/
+		float prev_time = floorf(prev_steps) * dt;
 		float time = floorf(steps) * dt;
 		
 		if (!hmd->solver) {
@@ -116,9 +116,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
 		
 		if (num_steps < 10000) {
 			struct HAIR_Solver *solver = hmd->solver;
+			float curtime = prev_time;
 			for (s = 0; s < num_steps; ++s) {
-				HAIR_solver_step(solver, time, dt);
-				time += dt;
+				HAIR_solver_step(solver, curtime, dt);
+				curtime += dt;
 			}
 		}




More information about the Bf-blender-cvs mailing list