[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12692] branches/cloth/blender/source/ blender: svn merge -r 12684:12691 https://svn.blender.org/svnroot/ bf-blender/trunk/blender

Daniel Genrich daniel.genrich at gmx.net
Tue Nov 27 14:25:07 CET 2007


Revision: 12692
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12692
Author:   genscher
Date:     2007-11-27 14:25:07 +0100 (Tue, 27 Nov 2007)

Log Message:
-----------
svn merge -r 12684:12691 https://svn.blender.org/svnroot/bf-blender/trunk/blender

Modified Paths:
--------------
    branches/cloth/blender/source/blender/blenkernel/BKE_cloth.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/blenkernel/intern/particle.c
    branches/cloth/blender/source/blender/blenkernel/intern/particle_system.c
    branches/cloth/blender/source/blender/blenkernel/intern/softbody.c
    branches/cloth/blender/source/blender/render/intern/source/convertblender.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/buttons_shading.c
    branches/cloth/blender/source/blender/src/drawobject.c
    branches/cloth/blender/source/blender/src/editparticle.c
    branches/cloth/blender/source/blender/src/editscreen.c
    branches/cloth/blender/source/blender/src/space.c

Modified: branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h	2007-11-27 13:20:51 UTC (rev 12691)
+++ branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h	2007-11-27 13:25:07 UTC (rev 12692)
@@ -68,6 +68,7 @@
 	float	impulse[3];	/* used in collision.c */
 	unsigned int impulse_count; /* same as above */
 	float collball;
+	char octantflag;
 } ClothVertex;
 
 typedef struct ClothSpring {

Modified: branches/cloth/blender/source/blender/blenkernel/intern/cloth.c
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/intern/cloth.c	2007-11-27 13:20:51 UTC (rev 12691)
+++ branches/cloth/blender/source/blender/blenkernel/intern/cloth.c	2007-11-27 13:25:07 UTC (rev 12692)
@@ -125,7 +125,7 @@
 static void cloth_from_mesh (Object *ob, ClothModifierData *clmd, DerivedMesh *dm, float framenr);
 static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *dm, DerivedMesh *olddm, float framenr);
 
-int cloth_build_springs ( Cloth *cloth, DerivedMesh *dm );
+int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm );
 static void cloth_apply_vgroup(ClothModifierData *clmd, DerivedMesh *dm, short vgroup);
 /******************************************************************************
 *
@@ -160,7 +160,7 @@
 	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->coll_parms->selfepsilon = 0.49;
 	
 	/* These defaults are copied from softbody.c's
 	* softbody_calc_forces() function.
@@ -884,7 +884,7 @@
 					VECCOPY ( clmd->clothObject->verts [i].impulse, tnull );
 				}
 				
-				if (!cloth_build_springs (clmd->clothObject, dm) )
+				if (!cloth_build_springs (clmd, dm) )
 				{
 					modifier_setError (&(clmd->modifier), "Can't build springs.");
 					return 0;
@@ -1035,11 +1035,12 @@
 	return 0;
 }
 
-int cloth_build_springs ( Cloth *cloth, DerivedMesh *dm )
+int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
 {
+	Cloth *cloth = clmd->clothObject;
 	ClothSpring *spring = NULL, *tspring = NULL, *tspring2 = NULL;
 	unsigned int struct_springs = 0, shear_springs=0, bend_springs = 0;
-	unsigned int i = 0, j = 0;
+	unsigned int i = 0, j = 0, akku_count;
 	unsigned int numverts = dm->getNumVerts ( dm );
 	unsigned int numedges = dm->getNumEdges ( dm );
 	unsigned int numfaces = dm->getNumFaces ( dm );
@@ -1049,7 +1050,7 @@
 	LinkNode **edgelist = NULL;
 	EdgeHash *edgehash = NULL;
 	LinkNode *search = NULL, *search2 = NULL;
-	float temp[3];
+	float temp[3], akku, min, max;
 	LinkNode *node = NULL, *node2 = NULL;
 	
 	// error handling
@@ -1096,9 +1097,14 @@
 	// calc collision balls *slow*
 	// better: use precalculated list with O(1) index access to all springs of a vertex
 	// missing for structural since it's not needed for building bending springs
-	/*
 	for ( i = 0; i < numverts; i++ )
 	{
+		akku_count = 0;
+		akku = 0.0;
+		cloth->verts[i].collball=0;
+		min = 1e22f;
+		max = -1e22f;
+		
 		search = cloth->springs;
 		for ( j = 0; j < struct_springs; j++ )
 		{
@@ -1109,14 +1115,19 @@
 			
 			if((tspring->ij == i) || (tspring->kl == i))
 			{
-				akku += bs->len;
-				akku_count++,
-				min = MIN2(bs->len,min);
-				max = MAX2(bs->len,max);
+				akku += spring->restlen;
+				akku_count++;
+    				min = MIN2(spring->restlen,min);
+    				max = MAX2(spring->restlen,max);
 			}
 		}
+		
+		if (akku_count > 0) {
+			cloth->verts[i].collball = akku/(float)akku_count*clmd->coll_parms->selfepsilon;
+		}
+		else cloth->verts[i].collball=0;
 	}
-	*/
+	
 	// shear springs
 	for ( i = 0; i < numfaces; i++ )
 	{

Modified: branches/cloth/blender/source/blender/blenkernel/intern/implicit.c
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/intern/implicit.c	2007-11-27 13:20:51 UTC (rev 12691)
+++ branches/cloth/blender/source/blender/blenkernel/intern/implicit.c	2007-11-27 13:25:07 UTC (rev 12692)
@@ -2235,76 +2235,81 @@
 	collisions = 1;
 	count = 0;
 	current_x = cloth->current_x; // needed for openMP
-/*
-#pragma omp parallel for private(i,j, collisions) shared(current_x)
-	for(count = 0; count < 6; count++)
+	
+	// #pragma omp parallel for private(i,j, collisions) shared(current_x)
+	// for ( count = 0; count < 6; count++ )
 	{
-	collisions = 0;
-		
-	for(i = 0; i < cloth->numverts; i++)
-	{
-	for(j = i + 1; j < cloth->numverts; j++)
-	{
-	float temp[3];
-	float length = 0;
-	float mindistance = cloth->selftree->epsilon;
+		collisions = 0;
+	
+		for ( i = 0; i < cloth->numverts; i++ )
+		{
+			float mindistance1 = cloth->verts[i].collball;
+			
+			for ( j = i + 1; j < cloth->numverts; j++ )
+			{
+				float temp[3];
+				float length = 0;
+				
+				float mindistance2 = cloth->verts[j].collball;
+	
+				if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL )
+				{
+					if ( ( cloth->verts [i].goal >= SOFTGOALSNAP )
+					        && ( cloth->verts [j].goal >= SOFTGOALSNAP ) )
+					{
+						continue;
+					}
+				}
+	
+				// check for adjacent points
+				if ( BLI_edgehash_haskey ( cloth->edgehash, i, j ) )
+				{
+					continue;
+				}
+	
+				VECSUB ( temp, current_x[i], current_x[j] );
+	
+				length = Normalize ( temp );
+	
+				if ( length < ((mindistance1 + mindistance2)) )
+				{
+					float correction = ((mindistance1 + mindistance2)) - length;
 					
-	if(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL)
-	{			
-	if((cloth->verts [i].goal >= SOFTGOALSNAP)
-	&& (cloth->verts [j].goal >= SOFTGOALSNAP))
-	{
-	continue;
-}
-}
-					
-					// check for adjacent points
-	if(BLI_edgehash_haskey ( cloth->edgehash, i, j ))
-	{
-	continue;
-}
-					
-	VECSUB(temp, current_x[i], current_x[j]);
-					
-	length = Normalize(temp);
-					
-	if(length < mindistance)
-	{
-	float correction = mindistance - length;
-						
-	if((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (cloth->verts [i].goal >= SOFTGOALSNAP))
-	{
-	VecMulf(temp, -correction);
-	VECADD(current_x[j], current_x[j], temp);
-}
-	else if((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (cloth->verts [j].goal >= SOFTGOALSNAP))
-	{
-	VecMulf(temp, correction);
-	VECADD(current_x[i], current_x[i], temp);
-}
-	else
-	{
-	VecMulf(temp, -correction*0.5);
-	VECADD(current_x[j], current_x[j], temp);
-						
-	VECSUB(current_x[i], current_x[i], temp);	
-}
-					
-	collisions = 1;
-}
-}
-}
-}
-
+					printf("correction: %f\n", correction);
 	
+					if ( ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) && ( cloth->verts [i].goal >= SOFTGOALSNAP ) )
+					{
+						VecMulf ( temp, -correction );
+						VECADD ( current_x[j], current_x[j], temp );
+					}
+					else if ( ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) && ( cloth->verts [j].goal >= SOFTGOALSNAP ) )
+					{
+						VecMulf ( temp, correction );
+						VECADD ( current_x[i], current_x[i], temp );
+					}
+					else
+					{
+						VecMulf ( temp, -correction*0.5 );
+						VECADD ( current_x[j], current_x[j], temp );
+	
+						VECSUB ( current_x[i], current_x[i], temp );
+					}
+	
+					collisions = 1;
+				}
+			}
+		}
+	}
+	
+	
 	//////////////////////////////////////////////
 	// SELFCOLLISIONS: update velocities
 	//////////////////////////////////////////////
-	for(i = 0; i < cloth->numverts; i++)
+	for ( i = 0; i < cloth->numverts; i++ )
 	{
-	VECSUB(cloth->current_v[i], cloth->current_x[i], cloth->current_xold[i]);
-}
+		VECSUB ( cloth->current_v[i], cloth->current_x[i], cloth->current_xold[i] );
+	}
 	//////////////////////////////////////////////
-*/	
+
 	return 1;
 }

Modified: branches/cloth/blender/source/blender/blenkernel/intern/modifier.c
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/intern/modifier.c	2007-11-27 13:20:51 UTC (rev 12691)
+++ branches/cloth/blender/source/blender/blenkernel/intern/modifier.c	2007-11-27 13:25:07 UTC (rev 12692)
@@ -5342,7 +5342,7 @@
 	ParticleSystemModifierData *psmd= (ParticleSystemModifierData*) md;
 	ParticleSystem * psys=0;
 	int totvert=0,totedge=0,totface=0,needsFree=0;
-	
+
 	if(ob->particlesystem.first)
 		psys=psmd->psys;
 	else
@@ -5417,8 +5417,6 @@
 		if(psmd->flag & eParticleSystemFlag_Loaded)
 			psmd->flag &= ~eParticleSystemFlag_Loaded;
 		else{
-			/* TODO PARTICLE - Added this so changing subsurf under hair updates it
-			should it be done elsewhere? - Campbell */
 			psys->recalc |= PSYS_RECALC_HAIR;
 			psys->recalc |= PSYS_DISTR;
 			psmd->flag |= eParticleSystemFlag_DM_changed;
@@ -5432,6 +5430,9 @@
 	}
 }
 
+/* disabled particles in editmode for now, until support for proper derivedmesh
+ * updates is coded */
+#if 0
 static void particleSystemModifier_deformVertsEM(
                 ModifierData *md, Object *ob, EditMesh *editData,
                 DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
@@ -5444,6 +5445,7 @@
 
 	if(!derivedData) dm->release(dm);
 }
+#endif
 
 /* Particle Instance */
 static void particleInstanceModifier_initData(ModifierData *md) 
@@ -7037,13 +7039,18 @@
 		mti = INIT_TYPE(ParticleSystem);
 		mti->type = eModifierTypeType_OnlyDeform;
 		mti->flags = eModifierTypeFlag_AcceptsMesh
-					|eModifierTypeFlag_SupportsEditmode
+					| eModifierTypeFlag_SupportsMapping;
+#if 0
+					| eModifierTypeFlag_SupportsEditmode;
 					|eModifierTypeFlag_EnableInEditmode;
+#endif
 		mti->initData = particleSystemModifier_initData;
 		mti->freeData = particleSystemModifier_freeData;
 		mti->copyData = particleSystemModifier_copyData;
 		mti->deformVerts = particleSystemModifier_deformVerts;
+#if 0
 		mti->deformVertsEM = particleSystemModifier_deformVertsEM;
+#endif
 		mti->requiredDataMask = particleSystemModifier_requiredDataMask;
 
 		mti = INIT_TYPE(ParticleInstance);
@@ -7123,9 +7130,8 @@
 {
 	ModifierTypeInfo *mti = modifierType_getInfo(md->type);
 
-	return (	(mti->flags & eModifierTypeFlag_SupportsEditmode) &&
-				(	(mti->type==eModifierTypeType_OnlyDeform ||
-					(mti->flags & eModifierTypeFlag_SupportsMapping))) );
+	return (mti->type==eModifierTypeType_OnlyDeform ||
+	        (mti->flags & eModifierTypeFlag_SupportsMapping));
 }
 
 ModifierData *modifiers_findByType(Object *ob, ModifierType type)

Modified: branches/cloth/blender/source/blender/blenkernel/intern/particle.c

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list