[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12050] branches/cloth/blender/source/ blender: New: Min & MaxFrame of simulation; Fixed: Many reset problems gone

Daniel Genrich dgenrich at axlo.de
Mon Sep 17 01:19:03 CEST 2007


Revision: 12050
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12050
Author:   genscher
Date:     2007-09-17 01:19:02 +0200 (Mon, 17 Sep 2007)

Log Message:
-----------
New: Min & MaxFrame of simulation; Fixed: Many reset problems gone

Modified Paths:
--------------
    branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h
    branches/cloth/blender/source/blender/blenkernel/BKE_modifier.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/modifier.c
    branches/cloth/blender/source/blender/include/butspace.h
    branches/cloth/blender/source/blender/makesdna/DNA_cloth_types.h
    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
    branches/cloth/blender/source/blender/src/editobject.c
    branches/cloth/blender/source/blender/src/transform_conversions.c
    branches/cloth/blender/source/blender/src/transform_generics.c
    branches/cloth/blender/source/blender/src/vpaint.c

Modified: branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h	2007-09-16 16:33:42 UTC (rev 12049)
+++ branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h	2007-09-16 23:19:02 UTC (rev 12050)
@@ -107,6 +107,7 @@
 
 // needed for buttons_object.c
 void cloth_cache_free(ClothModifierData *clmd, float time);
+void cloth_free_modifier (ClothModifierData *clmd);
 
 // needed for cloth.c
 void implicit_set_positions (ClothModifierData *clmd);

Modified: branches/cloth/blender/source/blender/blenkernel/BKE_modifier.h
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/BKE_modifier.h	2007-09-16 16:33:42 UTC (rev 12049)
+++ branches/cloth/blender/source/blender/blenkernel/BKE_modifier.h	2007-09-16 23:19:02 UTC (rev 12050)
@@ -277,6 +277,7 @@
                                      int *lastPossibleCageIndex_r);
 
 int           modifiers_isSoftbodyEnabled(struct Object *ob);
+struct ModifierData  *modifiers_isClothEnabled(struct Object *ob);
 struct Object *modifiers_isDeformedByArmature(struct Object *ob);
 struct Object *modifiers_isDeformedByLattice(struct Object *ob);
 int           modifiers_usesArmature(struct Object *ob, struct bArmature *arm);

Modified: branches/cloth/blender/source/blender/blenkernel/intern/cloth.c
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/intern/cloth.c	2007-09-16 16:33:42 UTC (rev 12049)
+++ branches/cloth/blender/source/blender/blenkernel/intern/cloth.c	2007-09-16 23:19:02 UTC (rev 12050)
@@ -119,6 +119,8 @@
 
 #define DEBUG_CLOTH_VERBOSE	1000
 static int	DEBUG_CLOTH = 0;
+
+
 /* ********** cloth engine ******* */
 /* Prototypes for internal functions.
 */
@@ -128,6 +130,8 @@
 static int collobj_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *dm, float (*vertexCos)[3], unsigned int numverts);
 int cloth_build_springs(Cloth *cloth, DerivedMesh *dm);
 static void cloth_apply_vgroup(ClothModifierData *clmd, DerivedMesh *dm, short vgroup);
+
+
 /******************************************************************************
 *
 * External interface called by modifier.c clothModifier functions.
@@ -157,6 +161,8 @@
 	clmd->sim_parms.solver_type = 0; 
 	clmd->sim_parms.preroll = 0;
 	clmd->sim_parms.maxspringlen = 10;
+	clmd->sim_parms.firstframe = 1;
+	clmd->sim_parms.lastframe = 250;
 	clmd->coll_parms.self_friction = 5.0;
 	clmd->coll_parms.friction = 10.0;
 	clmd->coll_parms.loop_count = 1;
@@ -614,9 +620,14 @@
 	Frame *frame = NULL;
 	LinkNode *search = NULL;
 	float deltaTime = current_time - clmd->sim_parms.sim_time;	
-
-	clmd->sim_parms.dt = 1.0f / (clmd->sim_parms.stepsPerFrame * G.scene->r.frs_sec);
 	
+	// only be active during a specific period
+	if((current_time < clmd->sim_parms.firstframe)||(current_time > clmd->sim_parms.lastframe))
+		return;
+	
+	// unused in the moment
+	clmd->sim_parms.dt = 1.0f / clmd->sim_parms.stepsPerFrame;
+	
 	clmd->sim_parms.sim_time = current_time;
 	
 	// check if cloth object was some collision object before and needs freeing now
@@ -707,7 +718,6 @@
 				tstart();
 
 				/* Call the solver. */
-
 				if (solvers [clmd->sim_parms.solver_type].solver)
 					solvers [clmd->sim_parms.solver_type].solver (ob, framenr, clmd, effectors,0,0);
 
@@ -754,9 +764,6 @@
 	clmd->sim_parms.flags |= CSIMSETT_FLAG_CCACHE_FREE_ALL;
 	cloth_cache_free(clmd, 0);
 
-	/* Calls the solver and collision frees first as they
-	* might depend on data in clmd->clothObject. */
-
 	if (cloth) 
 	{	
 		// If our solver provides a free function, call it
@@ -793,11 +800,9 @@
 		MEM_freeN (cloth);
 		clmd->clothObject = NULL;
 	}
-
 }
 
 
-
 /******************************************************************************
 *
 * Internal functions.
@@ -826,8 +831,6 @@
 			Mat4MulVecfl (ob->imat, vertexCos[i]);	/* softbody is in global coords */
 		}
 	}
-	else if (DEBUG_CLOTH)
-		printf ("cloth_to_object: clmd->clothObject was NULL.\n");
 }
 
 
@@ -837,15 +840,20 @@
 **/
 static void cloth_apply_vgroup(ClothModifierData *clmd, DerivedMesh *dm, short vgroup)
 {
-	unsigned int	i;
-	int j;
-	MDeformVert	*dvert = NULL;
-	Cloth		*clothObj;
+	unsigned int i = 0;
+	unsigned int j = 0;
+	MDeformVert *dvert = NULL;
+	Cloth *clothObj = NULL;
 	unsigned int numverts = dm->getNumVerts(dm);
 	float goalfac = 0;
 	ClothVertex *verts = NULL;
 
 	clothObj = clmd->clothObject;
+	
+	if(!dm)
+		return;
+	
+	numverts = dm->getNumVerts(dm);
 
 	/* vgroup is 1 based, decrement so we can match the right group. */
 	--vgroup;

Modified: branches/cloth/blender/source/blender/blenkernel/intern/implicit.c
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/intern/implicit.c	2007-09-16 16:33:42 UTC (rev 12049)
+++ branches/cloth/blender/source/blender/blenkernel/intern/implicit.c	2007-09-16 23:19:02 UTC (rev 12050)
@@ -689,14 +689,15 @@
 	lfVector *X, *V, *Xnew, *Vnew, *olddV, *F, *B, *dV, *z;
 	fmatrix3x3 *A, *dFdV, *dFdX, *S, *P, *Pinv, *bigI; 
 } Implicit_Data;
+
 int implicit_init (Object *ob, ClothModifierData *clmd)
 {
 	unsigned int i = 0;
 	unsigned int pinned = 0;
-	Cloth *cloth;
-	ClothVertex *verts;
-	ClothSpring *springs;
-	Implicit_Data *id;
+	Cloth *cloth = NULL;
+	ClothVertex *verts = NULL;
+	ClothSpring *springs = NULL;
+	Implicit_Data *id = NULL;
 
 	// init memory guard
 	// MEMORY_BASE.first = MEMORY_BASE.last = NULL;
@@ -727,6 +728,7 @@
 	id->B = create_lfvector(cloth->numverts);
 	id->dV = create_lfvector(cloth->numverts);
 	id->z = create_lfvector(cloth->numverts);
+	
 	for(i=0;i<cloth->numverts;i++) 
 	{
 		id->A[i].r = id->A[i].c = id->dFdV[i].r = id->dFdV[i].c = id->dFdX[i].r = id->dFdX[i].c = id->P[i].c = id->P[i].r = id->Pinv[i].c = id->Pinv[i].r = id->bigI[i].c = id->bigI[i].r = i;
@@ -1503,9 +1505,23 @@
 	ClothVertex *verts = cloth->verts;
 	unsigned int numverts = cloth->numverts, i;
 	Implicit_Data *id = cloth->implicit;
+	unsigned int pinned = 0;
+	
+	// reset pinned verts in S matrix to zero
+	// id->S[0].vcount = 0; id->S[0].scount = 0;
+	
 	for(i = 0; i < numverts; i++)
 	{				
 		VECCOPY(id->X[i], verts[i].x);
 		VECCOPY(id->V[i], verts[i].v);
+		/*
+		if(verts [i].flags & CVERT_FLAG_PINNED)
+		{
+			id->S[pinned].pinned = 1;
+			id->S[pinned].c = id->S[pinned].r = i;
+			pinned++;
+		}
+		*/
 	}	
+	// id->S[0].vcount = pinned;
 }

Modified: branches/cloth/blender/source/blender/blenkernel/intern/modifier.c
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/intern/modifier.c	2007-09-16 16:33:42 UTC (rev 12049)
+++ branches/cloth/blender/source/blender/blenkernel/intern/modifier.c	2007-09-16 23:19:02 UTC (rev 12050)
@@ -5233,8 +5233,8 @@
 		mti = INIT_TYPE(Cloth);
 		mti->type = eModifierTypeType_OnlyDeform;
 		mti->initData = clothModifier_initData;
-		mti->flags = eModifierTypeFlag_AcceptsCVs;
-					// | eModifierTypeFlag_RequiresOriginalData;
+		mti->flags = eModifierTypeFlag_AcceptsCVs
+			 | eModifierTypeFlag_RequiresOriginalData;
 		 			// | eModifierTypeFlag_SupportsMapping
 					// | eModifierTypeFlag_SupportsEditmode 
 					// | eModifierTypeFlag_EnableInEditmode;
@@ -5446,6 +5446,13 @@
 	return (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render));
 }
 
+ModifierData * modifiers_isClothEnabled(Object *ob)
+{
+	ModifierData *md = modifiers_findByType(ob, eModifierType_Cloth);
+
+	return md;
+}
+
 LinkNode *modifiers_calcDataMasks(ModifierData *md, CustomDataMask dataMask)
 {
 	LinkNode *dataMasks = NULL;

Modified: branches/cloth/blender/source/blender/include/butspace.h
===================================================================
--- branches/cloth/blender/source/blender/include/butspace.h	2007-09-16 16:33:42 UTC (rev 12049)
+++ branches/cloth/blender/source/blender/include/butspace.h	2007-09-16 23:19:02 UTC (rev 12050)
@@ -289,6 +289,7 @@
 #define B_CLOTH_CLEARCACHEFRAME	        1471
 #define B_CLOTH_CHANGEPREROLL			1472
 #define B_CLOTH_DEL_VG					1473
+#define B_CLOTH_RENEW 	1474
 
 /* *********************** */
 #define B_WORLDBUTS		1600

Modified: branches/cloth/blender/source/blender/makesdna/DNA_cloth_types.h
===================================================================
--- branches/cloth/blender/source/blender/makesdna/DNA_cloth_types.h	2007-09-16 16:33:42 UTC (rev 12049)
+++ branches/cloth/blender/source/blender/makesdna/DNA_cloth_types.h	2007-09-16 23:19:02 UTC (rev 12050)
@@ -106,7 +106,9 @@
 	float	defgoal;
 	int	goalfrict;
 	float	goalspring;
-	int	maxspringlen; /* in percent!; if tearing enabled, a spring will get cut */
+	int	maxspringlen; 	/* in percent!; if tearing enabled, a spring will get cut */
+	int 	lastframe; 	/* frame on which simulation stops */
+	int	firstframe;	/* frame on which simulation starts */
 } SimulationSettings;
 
 
@@ -144,7 +146,7 @@
 	int 			pad4;
 	void			*tree;			/* collision tree for this cloth object */
 	struct MFace 		*mfaces;
-	void			*implicit; 	
+	void			*implicit; 		/* our implicit solver connects to this pointer */
 } Cloth;
 
 #endif

Modified: branches/cloth/blender/source/blender/src/buttons_editing.c
===================================================================
--- branches/cloth/blender/source/blender/src/buttons_editing.c	2007-09-16 16:33:42 UTC (rev 12049)
+++ branches/cloth/blender/source/blender/src/buttons_editing.c	2007-09-16 23:19:02 UTC (rev 12050)
@@ -949,7 +949,7 @@
 		ModifierTypeInfo *mti = modifierType_getInfo(i);
 
 		/* Only allow adding through appropriate other interfaces */
-		if(ELEM(i, eModifierType_Softbody, eModifierType_Hook)) continue;
+		if(ELEM3(i, eModifierType_Softbody, eModifierType_Hook, eModifierType_Cloth)) continue;
 
 		if((mti->flags&eModifierTypeFlag_AcceptsCVs) ||
 		   (ob->type==OB_MESH && (mti->flags&eModifierTypeFlag_AcceptsMesh))) {
@@ -1600,6 +1600,8 @@
 				height += 20;
 		} else if (md->type==eModifierType_Softbody) {
 			height = 26;
+		} else if (md->type==eModifierType_Cloth) {
+			height = 26;
 		} else if (md->type==eModifierType_Boolean) {
 			height = 48;
 		} else if (md->type==eModifierType_Array) {
@@ -1615,7 +1617,7 @@
 			uiBlockBeginAlign(block);
 			but = uiDefBut(block, BUT, B_MODIFIER_RECALC, "Apply",	lx,(cy-=19),60,19, 0, 0, 0, 0, 0, "Apply the current modifier and remove from the stack");

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list