[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12607] branches/cloth/blender/source/ blender: Fixed DNA issue, some optional SSE stuff in (experimental, only 2 functions => not likely to be ever in trunk), BE AWARE: not compatible with old cloth files, many fixes in general, deactivated selfcollisions due to WIP

Daniel Genrich daniel.genrich at gmx.net
Fri Nov 16 15:24:44 CET 2007


Revision: 12607
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12607
Author:   genscher
Date:     2007-11-16 15:24:43 +0100 (Fri, 16 Nov 2007)

Log Message:
-----------
Fixed DNA issue, some optional SSE stuff in (experimental, only 2 functions => not likely to be ever in trunk), BE AWARE: not compatible with old cloth files, many fixes in general, deactivated selfcollisions due to WIP

Modified Paths:
--------------
    branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h
    branches/cloth/blender/source/blender/blenkernel/BKE_collisions.h
    branches/cloth/blender/source/blender/blenkernel/intern/cloth.c
    branches/cloth/blender/source/blender/blenkernel/intern/implicit.c
    branches/cloth/blender/source/blender/blenkernel/intern/kdop.c
    branches/cloth/blender/source/blender/blenkernel/intern/modifier.c
    branches/cloth/blender/source/blender/blenloader/intern/readfile.c
    branches/cloth/blender/source/blender/blenloader/intern/writefile.c
    branches/cloth/blender/source/blender/makesdna/DNA_cloth_types.h
    branches/cloth/blender/source/blender/makesdna/DNA_modifier_types.h
    branches/cloth/blender/source/blender/src/buttons_object.c

Modified: branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h	2007-11-16 12:35:48 UTC (rev 12606)
+++ branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h	2007-11-16 14:24:43 UTC (rev 12607)
@@ -57,6 +57,49 @@
 #define CLOTH_MAX_THREAD 2
 
 
+typedef struct ClothVertex {
+	int	flags;		/* General flags per vertex.		*/
+	float 	mass;		/* mass / weight of the vertex		*/
+	float 	goal;		/* goal, from SB			*/
+	float	impulse[3];	/* used in collision.c */
+	unsigned int impulse_count; /* same as above */
+} ClothVertex;
+
+typedef struct ClothSpring {
+	int	ij;		/* Pij from the paper, one end of the spring.	*/
+	int	kl;		/* Pkl from the paper, one end of the spring.	*/
+	float	restlen;	/* The original length of the spring.	*/
+	int	matrix_index; 	/* needed for implicit solver (fast lookup) */
+	int	type;		/* types defined in BKE_cloth.h ("springType") */
+	int	flags; 		/* defined in BKE_cloth.h, e.g. deactivated due to tearing */
+	float dfdx[3][4];
+	float dfdv[3][4];
+	float f[3];
+} ClothSpring;
+
+typedef struct Cloth {
+	struct ClothVertex	*verts;			/* The vertices that represent this cloth. */
+	struct LinkNode		*springs;		/* The springs connecting the mesh. */
+	struct BVH		*tree;		/* collision tree for this cloth object */
+	struct BVH		*selftree;		/* self collision tree for this cloth object */
+	struct MFace 		*mfaces;
+	struct Implicit_Data	*implicit; 	/* our implicit solver connects to this pointer */
+	struct EdgeHash 	*edgehash; /* used for fast checking adjacent points */
+	unsigned int		numverts;		/* The number of verts == m * n. */
+	unsigned int		numsprings;		/* The count of springs. */
+	unsigned int		numfaces;
+	unsigned int 		numothersprings;
+	unsigned int		numspringssave;
+	unsigned int 		old_solver_type;
+	float	 		(*x)[4]; /* The current position of all vertices.*/
+	float 			(*xold)[4]; /* The previous position of all vertices.*/
+	float 			(*current_x)[4]; /* The TEMPORARY current position of all vertices.*/
+	float			(*current_xold)[4]; /* The TEMPORARY previous position of all vertices.*/
+	float 			(*v)[4]; /* the current velocity of all vertices */
+	float			(*current_v)[4];
+	float			(*xconst)[4];
+} Cloth;
+
 /* goal defines */
 #define SOFTGOALSNAP  0.999f
 
@@ -138,7 +181,6 @@
 ////////////////////////////////////////////////
 void cloth_free_modifier ( ClothModifierData *clmd );
 void cloth_init ( ClothModifierData *clmd );
-void cloth_update_normals ( ClothVertex *verts, int nVerts, MFace *face, int totface );
 ////////////////////////////////////////////////
 
 
@@ -178,19 +220,6 @@
 int verlet_free ( ClothModifierData *clmd );
 int verlet_solver ( Object *ob, float frame, ClothModifierData *clmd, ListBase *effectors );
 
-/* used for caching in implicit.c */
-typedef struct Frame
-{
-	ClothVertex *verts;
-	ClothSpring *springs;
-	unsigned int numverts, numsprings;
-	float time; /* we need float since we want to support sub-frames */
-	float (*x)[3];
-	float (*xold)[3];
-	float (*v)[3];
-	float (*current_xold)[3];
-}
-Frame;
 
 /* used for collisions in collision.c */
 /*

Modified: branches/cloth/blender/source/blender/blenkernel/BKE_collisions.h
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/BKE_collisions.h	2007-11-16 12:35:48 UTC (rev 12606)
+++ branches/cloth/blender/source/blender/blenkernel/BKE_collisions.h	2007-11-16 14:24:43 UTC (rev 12607)
@@ -73,6 +73,7 @@
 	CollisionTree 	*leaf_root;	/* Head of the leaf linked list.	*/
 	float 		epsilon; /* epslion is used for inflation of the k-dop	   */
 	int 		flags; /* bvhFlags */
+	
 }
 BVH;
 
@@ -80,6 +81,8 @@
 typedef struct CollisionPair
 {
 	int point_indexA[4], point_indexB[4];
+	float vector[3];
+	float pa[3], pb[3];
 }
 CollisionPair;
 
@@ -93,6 +96,7 @@
 // builds bounding volume hierarchy
 BVH *bvh_build_from_mvert (MFace *mfaces, unsigned int numfaces, MVert *x, unsigned int numverts, float epsilon);
 BVH *bvh_build_from_float3 (MFace *mfaces, unsigned int numfaces, float (*x)[3], unsigned int numverts, float epsilon);
+BVH *bvh_build_from_float4 (MFace *mfaces, unsigned int numfaces, float (*x)[4], unsigned int numverts, float epsilon);
 
 // frees the same
 void bvh_free ( BVH *bvh );
@@ -103,6 +107,7 @@
 // update bounding volumes, needs updated positions in bvh->x
 void bvh_update_from_mvert(BVH * bvh, MVert *x, unsigned int numverts, MVert *xnew, int moving);
 void bvh_update_from_float3(BVH * bvh, float (*x)[3], unsigned int numverts, float (*xnew)[3], int moving);
+void bvh_update_from_float4(BVH * bvh, float (*x)[4], unsigned int numverts, float (*xnew)[4], int moving);
 
 LinkNode *BLI_linklist_append_fast (LinkNode **listp, void *ptr);
 

Modified: branches/cloth/blender/source/blender/blenkernel/intern/cloth.c
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/intern/cloth.c	2007-11-16 12:35:48 UTC (rev 12606)
+++ branches/cloth/blender/source/blender/blenkernel/intern/cloth.c	2007-11-16 14:24:43 UTC (rev 12607)
@@ -141,41 +141,39 @@
 void cloth_init (ClothModifierData *clmd)
 {
 	/* Initialize our new data structure to reasonable values. */
-	clmd->sim_parms.gravity [0] = 0.0;
-	clmd->sim_parms.gravity [1] = 0.0;
-	clmd->sim_parms.gravity [2] = -9.81;
-	clmd->sim_parms.structural = 100.0;
-	clmd->sim_parms.shear = 100.0;
-	clmd->sim_parms.bending = 1.0;
-	clmd->sim_parms.Cdis = 5.0;
-	clmd->sim_parms.Cvi = 1.0;
-	clmd->sim_parms.mass = 1.0f;
-	clmd->sim_parms.stepsPerFrame = 5;
-	clmd->sim_parms.sim_time = 1.0;
-	clmd->sim_parms.flags = CLOTH_SIMSETTINGS_FLAG_RESET;
-	clmd->sim_parms.solver_type = 0; 
-	clmd->sim_parms.preroll = 0;
-	clmd->sim_parms.maxspringlen = 10;
-	clmd->coll_parms.self_friction = 5.0;
-	clmd->coll_parms.friction = 10.0;
-	clmd->coll_parms.loop_count = 1;
-	clmd->coll_parms.epsilon = 0.01;
-	clmd->coll_parms.selfepsilon = 0.1;
+	clmd->sim_parms->gravity [0] = 0.0;
+	clmd->sim_parms->gravity [1] = 0.0;
+	clmd->sim_parms->gravity [2] = -9.81;
+	clmd->sim_parms->structural = 100.0;
+	clmd->sim_parms->shear = 100.0;
+	clmd->sim_parms->bending = 1.0;
+	clmd->sim_parms->Cdis = 5.0;
+	clmd->sim_parms->Cvi = 1.0;
+	clmd->sim_parms->mass = 1.0f;
+	clmd->sim_parms->stepsPerFrame = 5;
+	clmd->sim_parms->sim_time = 1.0;
+	clmd->sim_parms->flags = CLOTH_SIMSETTINGS_FLAG_RESET;
+	clmd->sim_parms->solver_type = 0; 
+	clmd->sim_parms->preroll = 0;
+	clmd->sim_parms->maxspringlen = 10;
+	clmd->coll_parms->self_friction = 5.0;
+	clmd->coll_parms->friction = 10.0;
+	clmd->coll_parms->loop_count = 1;
+	clmd->coll_parms->epsilon = 0.01;
+	clmd->coll_parms->selfepsilon = 0.1;
 	
 	/* These defaults are copied from softbody.c's
 	* softbody_calc_forces() function.
 	*/
-	clmd->sim_parms.eff_force_scale = 1000.0;
-	clmd->sim_parms.eff_wind_scale = 250.0;
+	clmd->sim_parms->eff_force_scale = 1000.0;
+	clmd->sim_parms->eff_wind_scale = 250.0;
 
 	// also from softbodies
-	clmd->sim_parms.maxgoal = 1.0;
-	clmd->sim_parms.mingoal = 0.0;
-	clmd->sim_parms.defgoal = 0.0;
-	clmd->sim_parms.goalspring = 100.0;
-	clmd->sim_parms.goalfrict = 0.0;
-
-	clmd->sim_parms.cache = NULL;
+	clmd->sim_parms->maxgoal = 1.0;
+	clmd->sim_parms->mingoal = 0.0;
+	clmd->sim_parms->defgoal = 0.0;
+	clmd->sim_parms->goalspring = 100.0;
+	clmd->sim_parms->goalfrict = 0.0;
 }
 
 // unused in the moment, cloth needs quads from mesh
@@ -410,7 +408,7 @@
 {
 	int stack_index = -1;
 	
-	if(!(clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_CCACHE_PROTECT))
+	if(!(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_CCACHE_PROTECT))
 	{
 		stack_index = modifiers_indexInObject(ob, (ModifierData *)clmd);
 		
@@ -434,9 +432,9 @@
 	
 	for(a = 0; a < cloth->numverts; a++)
 	{
-		fwrite(&cloth->x[a], sizeof(float),3,fp);
-		fwrite(&cloth->xconst[a], sizeof(float),3,fp);
-		fwrite(&cloth->v[a], sizeof(float),3,fp);
+		fwrite(&cloth->x[a], sizeof(float),4,fp);
+		fwrite(&cloth->xconst[a], sizeof(float),4,fp);
+		fwrite(&cloth->v[a], sizeof(float),4,fp);
 	}
 	
 	fclose(fp);
@@ -459,17 +457,17 @@
 	else {
 		for(a = 0; a < cloth->numverts; a++)
 		{
-			if(fread(&cloth->x[a], sizeof(float), 3, fp) != 3) 
+			if(fread(&cloth->x[a], sizeof(float), 4, fp) != 4) 
 			{
 				ret = 0;
 				break;
 			}
-			if(fread(&cloth->xconst[a], sizeof(float), 3, fp) != 3) 
+			if(fread(&cloth->xconst[a], sizeof(float), 4, fp) != 4) 
 			{
 				ret = 0;
 				break;
 			}
-			if(fread(&cloth->v[a], sizeof(float), 3, fp) != 3) 
+			if(fread(&cloth->v[a], sizeof(float), 4, fp) != 4) 
 			{
 				ret = 0;
 				break;
@@ -501,9 +499,9 @@
 	unsigned int framenr = (float)G.scene->r.cfra;
 	float current_time = bsystem_time(ob, (float)G.scene->r.cfra, 0.0);
 	ListBase *effectors = NULL;
-	float deltaTime = current_time - clmd->sim_parms.sim_time;	
+	float deltaTime = current_time - clmd->sim_parms->sim_time;	
 
-	clmd->sim_parms.dt = 1.0f / (clmd->sim_parms.stepsPerFrame * G.scene->r.frs_sec);
+	clmd->sim_parms->dt = 1.0f / (clmd->sim_parms->stepsPerFrame * G.scene->r.frs_sec);
 
 	result = CDDM_copy(dm);
 	
@@ -519,9 +517,9 @@
 	medge = CDDM_get_edges(result);
 	mface = CDDM_get_faces(result);
 
-	clmd->sim_parms.sim_time = current_time;
+	clmd->sim_parms->sim_time = current_time;
 	
-	if ( current_time < clmd->sim_parms.firstframe )
+	if ( current_time < clmd->sim_parms->firstframe )
 		return result;
 	
 	// only be active during a specific period:
@@ -529,9 +527,9 @@
 	/*
 	if ( clmd->clothObject )
 	{
-		if ( clmd->sim_parms.cache )
+		if ( clmd->sim_parms->cache )
 		{
-			if ( current_time < clmd->sim_parms.firstframe )
+			if ( current_time < clmd->sim_parms->firstframe )
 			{
 				int frametime = cloth_cache_first_frame ( clmd );
 				if ( cloth_cache_search_frame ( clmd, frametime ) )
@@ -541,7 +539,7 @@
 				}
 				return result;
 			}
-			else if ( current_time > clmd->sim_parms.lastframe )
+			else if ( current_time > clmd->sim_parms->lastframe )
 			{
 				int frametime = cloth_cache_last_frame ( clmd );
 				if ( cloth_cache_search_frame ( clmd, frametime ) )
@@ -558,7 +556,7 @@
 					cloth_cache_get_frame ( clmd, framenr );
 					cloth_to_object ( ob, result, clmd );
 				}
-				clmd->sim_parms.sim_time = current_time;
+				clmd->sim_parms->sim_time = current_time;
 				return result;
 			}
 		}
@@ -578,7 +576,7 @@
 			cloth = clmd->clothObject;
 		}
 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list