[Bf-blender-cvs] [2a9ddc8] master: Cloth: Change ClothVertex::xrest to actually store the rest position.

Alexander Gavrilov noreply at git.blender.org
Fri May 6 11:07:10 CEST 2016


Commit: 2a9ddc808de117786c354a2a6b72c68437d18808
Author: Alexander Gavrilov
Date:   Mon Apr 18 18:48:22 2016 +0300
Branches: master
https://developer.blender.org/rB2a9ddc808de117786c354a2a6b72c68437d18808

Cloth: Change ClothVertex::xrest to actually store the rest position.

Originally the value was only needed when building the springs,
so a pointer to the input data was somewhat ok. However, recalculating
spring length dynamically requires keeping the actual value around.

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

M	source/blender/blenkernel/BKE_cloth.h
M	source/blender/blenkernel/intern/cloth.c

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

diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h
index 28de270..50fcbd8 100644
--- a/source/blender/blenkernel/BKE_cloth.h
+++ b/source/blender/blenkernel/BKE_cloth.h
@@ -115,7 +115,7 @@ typedef struct ClothVertex {
 	float 	mass;		/* mass / weight of the vertex		*/
 	float 	goal;		/* goal, from SB			*/
 	float	impulse[3];	/* used in collision.c */
-	float	*xrest;		/* temporary valid for building springs */
+	float	xrest[3];   /* rest position of the vertex */
 	unsigned int impulse_count; /* same as above */
 	float 	avg_spring_len; /* average length of connected springs */
 	float 	struct_stiff;
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index a133f37..0954ac9 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -819,11 +819,11 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
 			mul_m4_v3(ob->obmat, verts->x);
 
 			if ( shapekey_rest ) {
-				verts->xrest= shapekey_rest[i];
+				copy_v3_v3(verts->xrest, shapekey_rest[i]);
 				mul_m4_v3(ob->obmat, verts->xrest);
 			}
 			else
-				verts->xrest = verts->x;
+				copy_v3_v3(verts->xrest, verts->x);
 		}
 		
 		/* no GUI interface yet */




More information about the Bf-blender-cvs mailing list