[Bf-blender-cvs] [2bba04f] master: Cloth: replace EdgeHash with EdgeSet

Campbell Barton noreply at git.blender.org
Fri Apr 4 05:17:13 CEST 2014


Commit: 2bba04f1b0c3fa3ebee7958706147e07fb413f56
Author: Campbell Barton
Date:   Fri Apr 4 14:15:57 2014 +1100
https://developer.blender.org/rB2bba04f1b0c3fa3ebee7958706147e07fb413f56

Cloth: replace EdgeHash with EdgeSet

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

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

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

diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h
index 1e7ac28..757d63e 100644
--- a/source/blender/blenkernel/BKE_cloth.h
+++ b/source/blender/blenkernel/BKE_cloth.h
@@ -80,7 +80,7 @@ typedef struct Cloth {
 	struct MFace 		*mfaces;
 	struct Implicit_Data	*implicit; 		/* our implicit solver connects to this pointer */
 	struct Implicit_Data	*implicitEM; 		/* our implicit solver connects to this pointer */
-	struct EdgeHash 	*edgehash; 		/* used for selfcollisions (currently used as a 'set', value is ignored) */
+	struct EdgeSet	 	*edgeset; 		/* used for selfcollisions */
 	int last_frame, pad4;
 } Cloth;
 
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 220ceb8..f5c7f9e 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -621,8 +621,8 @@ void cloth_free_modifier(ClothModifierData *clmd )
 		if ( cloth->mfaces )
 			MEM_freeN ( cloth->mfaces );
 		
-		if (cloth->edgehash)
-			BLI_edgehash_free ( cloth->edgehash, NULL );
+		if (cloth->edgeset)
+			BLI_edgeset_free(cloth->edgeset);
 		
 		
 		/*
@@ -690,8 +690,8 @@ void cloth_free_modifier_extern(ClothModifierData *clmd )
 		if ( cloth->mfaces )
 			MEM_freeN ( cloth->mfaces );
 
-		if (cloth->edgehash)
-			BLI_edgehash_free ( cloth->edgehash, NULL );
+		if (cloth->edgeset)
+			BLI_edgeset_free(cloth->edgeset);
 
 
 		/*
@@ -854,7 +854,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
 		clmd->clothObject->old_solver_type = 255;
 		// clmd->clothObject->old_collision_type = 255;
 		cloth = clmd->clothObject;
-		clmd->clothObject->edgehash = NULL;
+		clmd->clothObject->edgeset = NULL;
 	}
 	else if (!clmd->clothObject) {
 		modifier_setError(&(clmd->modifier), "Out of memory on allocating clmd->clothObject");
@@ -1062,9 +1062,9 @@ static void cloth_free_errorsprings(Cloth *cloth,  LinkNode **edgelist)
 
 	cloth_free_edgelist(edgelist, cloth->numverts);
 	
-	if (cloth->edgehash) {
-		BLI_edgehash_free(cloth->edgehash, NULL);
-		cloth->edgehash = NULL;
+	if (cloth->edgeset) {
+		BLI_edgeset_free(cloth->edgeset);
+		cloth->edgeset = NULL;
 	}
 }
 
@@ -1123,20 +1123,20 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
 	MFace *mface = dm->getTessFaceArray (dm);
 	int index2 = 0; // our second vertex index
 	LinkNode **edgelist = NULL;
-	EdgeHash *edgehash = NULL;
+	EdgeSet *edgeset = NULL;
 	LinkNode *search = NULL, *search2 = NULL;
 	
 	// error handling
 	if ( numedges==0 )
 		return 0;
 
-	/* NOTE: handling ownership of springs and edgehash is quite sloppy
+	/* NOTE: handling ownership of springs and edgeset is quite sloppy
 	 * currently they are never initialized but assert just to be sure */
 	BLI_assert(cloth->springs == NULL);
-	BLI_assert(cloth->edgehash == NULL);
+	BLI_assert(cloth->edgeset == NULL);
 
 	cloth->springs = NULL;
-	cloth->edgehash = NULL;
+	cloth->edgeset = NULL;
 
 	edgelist = MEM_callocN ( sizeof (LinkNode *) * numverts, "cloth_edgelist_alloc" );
 	
@@ -1240,8 +1240,8 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
 		BLI_linklist_prepend ( &cloth->springs, spring );
 	}
 
-	edgehash = BLI_edgehash_new_ex(__func__, numedges);
-	cloth->edgehash = edgehash;
+	edgeset = BLI_edgeset_new_ex(__func__, numedges);
+	cloth->edgeset = edgeset;
 
 	if (numfaces) {
 		// bending springs
@@ -1259,7 +1259,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
 				// check for existing spring
 				// check also if startpoint is equal to endpoint
 				if ((index2 != tspring2->ij) &&
-				    !BLI_edgehash_haskey(edgehash, tspring2->ij, index2))
+				    !BLI_edgeset_haskey(edgeset, tspring2->ij, index2))
 				{
 					spring = (ClothSpring *)MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
 
@@ -1272,7 +1272,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
 					spring->restlen = len_v3v3(cloth->verts[spring->kl].xrest, cloth->verts[spring->ij].xrest);
 					spring->type = CLOTH_SPRING_TYPE_BENDING;
 					spring->stiffness = (cloth->verts[spring->kl].bend_stiff + cloth->verts[spring->ij].bend_stiff) / 2.0f;
-					BLI_edgehash_insert(edgehash, spring->ij, spring->kl, NULL);
+					BLI_edgeset_insert(edgeset, spring->ij, spring->kl);
 					bend_springs++;
 
 					BLI_linklist_prepend ( &cloth->springs, spring );
@@ -1321,16 +1321,16 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
 	
 	/* note: the edges may already exist so run reinsert */
 
-	/* insert other near springs in edgehash AFTER bending springs are calculated (for selfcolls) */
+	/* insert other near springs in edgeset AFTER bending springs are calculated (for selfcolls) */
 	for (i = 0; i < numedges; i++) { /* struct springs */
-		BLI_edgehash_reinsert(edgehash, medge[i].v1, medge[i].v2, NULL);
+		BLI_edgeset_reinsert(edgeset, medge[i].v1, medge[i].v2);
 	}
 
 	for (i = 0; i < numfaces; i++) { /* edge springs */
 		if (mface[i].v4) {
-			BLI_edgehash_reinsert(edgehash, mface[i].v1, mface[i].v3, NULL);
+			BLI_edgeset_reinsert(edgeset, mface[i].v1, mface[i].v3);
 			
-			BLI_edgehash_reinsert(edgehash, mface[i].v2, mface[i].v4, NULL);
+			BLI_edgeset_reinsert(edgeset, mface[i].v2, mface[i].v4);
 		}
 	}
 	
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index 3936321..f7e5228 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -863,7 +863,7 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData *clmd, float step, floa
 	
 						if ( ( ABS ( temp[0] ) > mindistance ) || ( ABS ( temp[1] ) > mindistance ) || ( ABS ( temp[2] ) > mindistance ) ) continue;
 	
-						if (BLI_edgehash_haskey(cloth->edgehash, i, j)) {
+						if (BLI_edgeset_haskey(cloth->edgeset, i, j)) {
 							continue;
 						}




More information about the Bf-blender-cvs mailing list