[Bf-blender-cvs] [f62b4b1] hair_system: Introduced a rest position vector to hair points.

Lukas Tönne noreply at git.blender.org
Sun Jul 27 19:59:44 CEST 2014


Commit: f62b4b16b8b8068aa87e336dc5d8226bad7703d4
Author: Lukas Tönne
Date:   Sun Jul 27 19:15:47 2014 +0200
Branches: hair_system
https://developer.blender.org/rBf62b4b16b8b8068aa87e336dc5d8226bad7703d4

Introduced a rest position vector to hair points.

This defines the "natural" shapes of a hair when no external forces are
acting on it and the velocity is zero. The internal elastic forces of
the hair will cause it to always return to this rest position if
possible.

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

M	source/blender/editors/physics/hair_ops.c
M	source/blender/hair/HAIR_capi.cpp
M	source/blender/hair/intern/HAIR_curve.cpp
M	source/blender/hair/intern/HAIR_curve.h
M	source/blender/makesdna/DNA_hair_types.h

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

diff --git a/source/blender/editors/physics/hair_ops.c b/source/blender/editors/physics/hair_ops.c
index 35af3cd..09569a7 100644
--- a/source/blender/editors/physics/hair_ops.c
+++ b/source/blender/editors/physics/hair_ops.c
@@ -110,7 +110,8 @@ static void hair_copy_from_particles_psys(Object *ob, HairSystem *hsys, Object *
 			ParticleCacheKey *pa_key = pa_cache + k;
 			HairPoint *point = points + k;
 			
-			mul_v3_m4v3(point->co, mat, pa_key->co);
+			mul_v3_m4v3(point->rest_co, mat, pa_key->co);
+			copy_v3_v3(point->co, point->rest_co);
 			zero_v3(point->vel);
 		}
 	}
diff --git a/source/blender/hair/HAIR_capi.cpp b/source/blender/hair/HAIR_capi.cpp
index ebf6877..8d8210c 100644
--- a/source/blender/hair/HAIR_capi.cpp
+++ b/source/blender/hair/HAIR_capi.cpp
@@ -76,7 +76,9 @@ void HAIR_solver_init(struct HAIR_Solver *csolver, HairSystem *hsys)
 		
 		for (int k = 0; k < hair->totpoints; ++k, ++point) {
 			HairPoint *hair_pt = hair->points + k;
-			*point = Point(hair_pt->co, hair_pt->vel);
+			*point = Point(hair_pt->rest_co);
+			point->cur.co = float3(hair_pt->co);
+			point->cur.vel = float3(hair_pt->vel);
 		}
 	}
 }
diff --git a/source/blender/hair/intern/HAIR_curve.cpp b/source/blender/hair/intern/HAIR_curve.cpp
index 1d9af11..3be4db3 100644
--- a/source/blender/hair/intern/HAIR_curve.cpp
+++ b/source/blender/hair/intern/HAIR_curve.cpp
@@ -32,10 +32,11 @@ Point::Point()
 {
 }
 
-Point::Point(const float3 &co, const float3 &vel)
+Point::Point(const float3 &rest_co) :
+    rest_co(rest_co)
 {
-	cur.co = co;
-	cur.vel = vel;
+	cur.co = rest_co;
+	cur.vel = float3(0.0f, 0.0f, 0.0f);
 }
 
 Curve::Curve(int totpoints, Point *points) :
diff --git a/source/blender/hair/intern/HAIR_curve.h b/source/blender/hair/intern/HAIR_curve.h
index 404dbac..bef25f5 100644
--- a/source/blender/hair/intern/HAIR_curve.h
+++ b/source/blender/hair/intern/HAIR_curve.h
@@ -40,11 +40,13 @@ struct Point {
 	};
 	
 	Point();
-	Point(const float3 &co, const float3 &vel);
+	Point(const float3 &rest_co);
 	
 	State cur;
 	State next;
 	
+	float3 rest_co;
+	
 	HAIR_CXX_CLASS_ALLOC(Point)
 };
 
diff --git a/source/blender/makesdna/DNA_hair_types.h b/source/blender/makesdna/DNA_hair_types.h
index 1e83a75..ad78787 100644
--- a/source/blender/makesdna/DNA_hair_types.h
+++ b/source/blender/makesdna/DNA_hair_types.h
@@ -34,10 +34,10 @@
 #define __DNA_HAIR_TYPES_H__
 
 typedef struct HairPoint {
+	float rest_co[3];           /* rest location in object space */
 	float co[3];                /* location in object space */
-	int pad;
 	float vel[3];               /* velocity */
-	int pad2;
+	int pad[3];
 } HairPoint;
 
 typedef struct HairCurve {




More information about the Bf-blender-cvs mailing list