[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13445] branches/cloth/blender/source/ blender: WIP commit, many debug outputs, extensive log comes after bug is killed

Daniel Genrich daniel.genrich at gmx.net
Tue Jan 29 03:24:50 CET 2008


Revision: 13445
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13445
Author:   genscher
Date:     2008-01-29 03:24:37 +0100 (Tue, 29 Jan 2008)

Log Message:
-----------
WIP commit, many debug outputs, extensive log comes after bug is killed

Modified Paths:
--------------
    branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h
    branches/cloth/blender/source/blender/blenkernel/CMakeLists.txt
    branches/cloth/blender/source/blender/blenkernel/intern/cloth.c
    branches/cloth/blender/source/blender/blenkernel/intern/collision.c
    branches/cloth/blender/source/blender/blenkernel/intern/modifier.c
    branches/cloth/blender/source/blender/src/buttons_editing.c
    branches/cloth/blender/source/blender/src/buttons_object.c
    branches/cloth/blender/source/blender/src/editmesh.c

Modified: branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h	2008-01-29 00:12:34 UTC (rev 13444)
+++ branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h	2008-01-29 02:24:37 UTC (rev 13445)
@@ -62,9 +62,7 @@
 #define CLOTH_MAX_THREAD 2
 
 /**
- * Pin and unpin frames are the frames on which the vertices stop moving.
- * They will assume the position they had prior to pinFrame until unpinFrame
- * is reached.
+ * The definition of a cloth vertex.
  */
 typedef struct ClothVertex
 {
@@ -87,7 +85,6 @@
 }
 ClothVertex;
 
-
 /**
  * The definition of a spring.
  */
@@ -106,7 +103,6 @@
 }
 ClothSpring;
 
-
 /* goal defines */
 #define SOFTGOALSNAP  0.999f
 

Modified: branches/cloth/blender/source/blender/blenkernel/CMakeLists.txt
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/CMakeLists.txt	2008-01-29 00:12:34 UTC (rev 13444)
+++ branches/cloth/blender/source/blender/blenkernel/CMakeLists.txt	2008-01-29 02:24:37 UTC (rev 13445)
@@ -34,7 +34,7 @@
   ../python ../render/extern/include ../../../intern/decimation/extern
   ../imbuf ../avi ../../../intern/elbeem/extern ../../../intern/opennl/extern
   ../../../intern/iksolver/extern ../blenloader ../quicktime
-  ../../../intern/bmfont
+  ../../../intern/bmfont ../../../extern/bullet2/src
   ../nodes
   ${SDL_INC}
   ${ZLIB_INC}

Modified: branches/cloth/blender/source/blender/blenkernel/intern/cloth.c
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/intern/cloth.c	2008-01-29 00:12:34 UTC (rev 13444)
+++ branches/cloth/blender/source/blender/blenkernel/intern/cloth.c	2008-01-29 02:24:37 UTC (rev 13445)
@@ -125,7 +125,7 @@
 static void cloth_from_mesh ( Object *ob, ClothModifierData *clmd, DerivedMesh *dm );
 static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *dm, float framenr);
 int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm );
-static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm, short vgroup, int mode );
+static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm );
 
 
 /******************************************************************************
@@ -162,12 +162,12 @@
 	clmd->sim_parms->vgroup_mass = 0;
 	clmd->sim_parms->lastcachedframe = 0;
 	clmd->sim_parms->editedframe = 0;
-	clmd->sim_parms->autoprotect = 10;
+	clmd->sim_parms->autoprotect = 25;
 	
 	clmd->coll_parms->self_friction = 5.0;
 	clmd->coll_parms->friction = 10.0;
-	clmd->coll_parms->loop_count = 5;
-	clmd->coll_parms->epsilon = 0.01f;
+	clmd->coll_parms->loop_count = 3;
+	clmd->coll_parms->epsilon = 0.015f;
 	clmd->coll_parms->flags = CLOTH_COLLSETTINGS_FLAG_ENABLED;
 
 	/* These defaults are copied from softbody.c's
@@ -182,8 +182,6 @@
 	clmd->sim_parms->defgoal = 0.0f;
 	clmd->sim_parms->goalspring = 100.0f;
 	clmd->sim_parms->goalfrict = 0.0f;
-
-	clmd->sim_parms->cache = NULL;
 }
 
 
@@ -521,18 +519,39 @@
 		}
 		
 		fclose(fp);
+		
+		/*
+		// belongs to another location ?!?
+		if((clmd->sim_parms->solver_type == 0) && (ret!=0))
+		{
+		implicit_set_positions(clmd);
+		}
+		*/
+		
+		if(clmd->sim_parms->lastcachedframe < framenr)
+		{
+			printf("cloth_read_cache problem: lnex - f#: %f, lastCF: %d\n", framenr, clmd->sim_parms->lastcachedframe);
+		}
 	}
 	
-	if(clmd->sim_parms->solver_type == 0)
-		implicit_set_positions(clmd);
-		
+	printf("cloth_read_cache: %f\n", framenr);
+	
 	return ret;
 }
 
 void cloth_clear_cache(Object *ob, ClothModifierData *clmd, float framenr)
 {
 	int stack_index = -1;
+	printf("cloth_clear_cache: %f\n", framenr);
 	
+	/*
+	// belongs to another location ?!?
+	if(framenr>0)
+	{
+		cloth_read_cache(ob, clmd, framenr);
+	}
+	*/
+	
 	/* clear cache if specific frame cleaning requested or cache is not protected */
 	if((!(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_CCACHE_PROTECT)) || (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_CCACHE_FFREE))
 	{
@@ -541,13 +560,13 @@
 		BKE_ptcache_id_clear((ID *)ob, PTCACHE_CLEAR_AFTER, framenr, stack_index);
 	}
 	
-	if(framenr>0)
-	{
-		cloth_read_cache(ob, clmd, framenr);
-	}
+	/* update last cached frame # */
+	clmd->sim_parms->lastcachedframe = framenr;
 	
 	/* delete cache free request */
 	clmd->sim_parms->flags &= ~CLOTH_SIMSETTINGS_FLAG_CCACHE_FFREE;
+	
+	
 }
 void cloth_write_cache(Object *ob, ClothModifierData *clmd, float framenr)
 {
@@ -556,8 +575,11 @@
 	unsigned int a;
 	Cloth *cloth = clmd->clothObject;
 	
+	printf("cloth_write_cache: %f\n", framenr);
+	
 	if(!cloth)
 	{
+		printf("cloth_write_cache: no cloth\n");
 		return;
 	}
 	
@@ -566,6 +588,7 @@
 	fp = BKE_ptcache_id_fopen((ID *)ob, 'w', framenr, stack_index);
 	if(!fp)
 	{
+		printf("cloth_write_cache: no fp\n");
 		return;
 	}
 	
@@ -578,6 +601,8 @@
 	
 	clmd->sim_parms->lastcachedframe = MAX2(clmd->sim_parms->lastcachedframe, framenr);
 	
+	printf("lcf: %d, framenr: %f\n", clmd->sim_parms->lastcachedframe, framenr);
+
 	fclose(fp);
 }
 
@@ -591,7 +616,7 @@
 {
 	unsigned int i;
 	Cloth *cloth = clmd->clothObject;
-	unsigned int framenr = ( float ) G.scene->r.cfra;
+	float framenr = G.scene->r.cfra;
 	float current_time = bsystem_time ( ob, ( float ) G.scene->r.cfra, 0.0 );
 	ListBase *effectors = NULL;
 	ClothVertex *verts = NULL;
@@ -604,6 +629,8 @@
 	MFace *mface = NULL;
 	DerivedMesh *result = NULL;
 	
+	printf("clothModifier_do start\n");
+	
 	result = CDDM_copy(dm);
 	
 	if(!result)
@@ -614,134 +641,182 @@
 	numverts = result->getNumVerts(result);
 	numedges = result->getNumEdges(result);
 	numfaces = result->getNumFaces(result);
-	mvert = CDDM_get_verts(result);
-	medge = CDDM_get_edges(result);
-	mface = CDDM_get_faces(result);
+	mvert = dm->getVertArray(result);
+	medge = dm->getEdgeArray(result);
+	mface = dm->getFaceArray(result);
 	
-	// only be active during a specific period:
-	// that's "first frame" and "last frame" on GUI
-	if ( current_time < clmd->sim_parms->firstframe )
-	{
-		return result;
-	}
-	else if ( current_time > clmd->sim_parms->lastframe )
-	{
-		int stack_index = modifiers_indexInObject(ob, (ModifierData *)clmd);
-		
-		if(BKE_ptcache_id_exist((ID *)ob, clmd->sim_parms->lastcachedframe, stack_index))
-		{
-			if(cloth_read_cache(ob, clmd, framenr))
-			{
-				// Copy the result back to the object.
-				cloth_to_object (ob, clmd, result);
-			}
-		}
-		return result;
-	}
-	
-	// unused in the moment, calculated seperately in implicit.c
-	clmd->sim_parms->dt = 1.0f / clmd->sim_parms->stepsPerFrame;
-
-	clmd->sim_parms->sim_time = current_time;
-	
 	/* check if cache is active / if file is already saved */
+	/*
 	if ((!G.relbase_valid) && ( deltaTime != 1.0f ))
 	{
 		clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_RESET;
 	}
-
+	*/
+	
 	if(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_RESET)
 	{	
 		cloth_free_modifier (ob, clmd);
+		printf("clothModifier_do CLOTH_SIMSETTINGS_FLAG_RESET\n");
 	}
 	
-	// sanity check for correctness of GUI values
-	if(clmd->sim_parms->max_struct<clmd->sim_parms->structural)
-		clmd->sim_parms->max_struct=clmd->sim_parms->structural;
-	if(clmd->sim_parms->max_bend<clmd->sim_parms->bending)
-		clmd->sim_parms->max_struct=clmd->sim_parms->bending;
-	if(clmd->sim_parms->max_shear<clmd->sim_parms->shear)
-		clmd->sim_parms->max_shear=clmd->sim_parms->shear;
-
-	if ( deltaTime == 1.0f )
+	// unused in the moment, calculated seperately in implicit.c
+	clmd->sim_parms->dt = 1.0f / clmd->sim_parms->stepsPerFrame;
+	
+	if ( ( clmd->clothObject == NULL ) || (clmd->clothObject && (numverts != clmd->clothObject->numverts )) )
 	{
-		if ( ( clmd->clothObject == NULL ) || ( numverts != clmd->clothObject->numverts ) )
+		/* only force free the cache if we have a different number of verts */
+		if(clmd->clothObject && (numverts != clmd->clothObject->numverts ))
 		{
-			cloth_clear_cache(ob, clmd, 0);
+			clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_CCACHE_FFREE;
+			cloth_free_modifier ( ob, clmd );
+		}
+		
+		cloth_clear_cache(ob, clmd, 0);
+				
+		if ( !cloth_from_object ( ob, clmd, result, framenr ) )
+			return result;
+	
+		if ( clmd->clothObject == NULL )
+			return result;
+	
+		cloth = clmd->clothObject;
+		
+		if(!cloth_read_cache(ob, clmd, framenr))
+		{
+			/* save first frame in case we have a reseted object 
+			and we move one frame forward.
+			In that case we would only start with the SECOND frame
+			if we don't save the current state before 
+			TODO PROBLEM: IMHO we can't track external movement from the
+			first frame in this case! */
+			/*
+			if ( deltaTime == 1.0f )
+				cloth_write_cache(ob, clmd, framenr-1.0);
+			*/
+			printf("cloth_from_object NO cloth_read_cache cloth_write_cache\n");
+		}
+		else
+		{
+			printf("cloth_from_object cloth_read_cache\n");
 			
-			// printf("v1: %d, v2: %d\n", numverts, clmd->clothObject->numverts);
-			
-			if ( !cloth_from_object ( ob, clmd, result, framenr ) )
-				return result;
-
-			if ( clmd->clothObject == NULL )
-				return result;
-
-			cloth = clmd->clothObject;
+			implicit_set_positions(clmd);
 		}
+		
+		clmd->sim_parms->sim_time = current_time;
+	}
+	
+	// only be active during a specific period:
+	// that's "first frame" and "last frame" on GUI
+	/*
+	// TODO: enable later again after refactoring
+	if ( current_time < clmd->sim_parms->firstframe )
+	{
+	return result;
+}
+	else if ( current_time > clmd->sim_parms->lastframe )
+	{
+	int stack_index = modifiers_indexInObject(ob, (ModifierData *)clmd);
+		
+	if(BKE_ptcache_id_exist((ID *)ob, clmd->sim_parms->lastcachedframe, stack_index))
+	{
+	if(cloth_read_cache(ob, clmd, framenr))
+	{
+				// Copy the result back to the object.
+	cloth_to_object (ob, clmd, result);
+}
+}
+	return result;
+}
+	*/
+	
+	/* nice moving one frame forward */
+	if ( deltaTime == 1.0f )
+	{
+		clmd->sim_parms->sim_time = current_time;
+		
+		printf("clothModifier_do deltaTime=1\n");
+		
+		if(!cloth_read_cache(ob, clmd, framenr))
+		{
+			verts = cloth->verts;
 
-		clmd->clothObject->old_solver_type = clmd->sim_parms->solver_type;
-
-		// Insure we have a clmd->clothObject, in case allocation failed.
-		if ( clmd->clothObject != NULL )
-		{
-			if(!cloth_read_cache(ob, clmd, framenr))
+			// Force any pinned verts to their constrained location.
+			for ( i = 0; i < clmd->clothObject->numverts; i++, verts++ )
 			{
-				verts = cloth->verts;
+				// Save the previous position.

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list