[Bf-blender-cvs] [998900794d] cloth-improvements: Remove self collision quality (integrated with object collision)

Luca Rood noreply at git.blender.org
Fri Jan 20 05:38:43 CET 2017


Commit: 998900794de4fc5e5fed7ab29ed51a1b4c449af4
Author: Luca Rood
Date:   Thu Jan 19 20:10:05 2017 -0200
Branches: cloth-improvements
https://developer.blender.org/rB998900794de4fc5e5fed7ab29ed51a1b4c449af4

Remove self collision quality (integrated with object collision)

Self collisions are now impulse based, and utilize the same solver as
the object collisions. Having separate quality controls would cause
issues when self and object collisions occur simultaneously.

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

M	release/scripts/startup/bl_ui/properties_physics_cloth.py
M	source/blender/blenkernel/intern/cloth.c
M	source/blender/blenkernel/intern/collision.c
M	source/blender/makesdna/DNA_cloth_types.h
M	source/blender/makesrna/intern/rna_cloth.c

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

diff --git a/release/scripts/startup/bl_ui/properties_physics_cloth.py b/release/scripts/startup/bl_ui/properties_physics_cloth.py
index c83d0e243c..f141ae386a 100644
--- a/release/scripts/startup/bl_ui/properties_physics_cloth.py
+++ b/release/scripts/startup/bl_ui/properties_physics_cloth.py
@@ -254,9 +254,6 @@ class PHYSICS_PT_cloth_collision(PhysicButtonsPanel, Panel):
         split = col.split()
 
         split.prop(cloth, "use_self_collision", text="Self Collision:")
-        sub = split.column()
-        sub.active = cloth.use_self_collision
-        sub.prop(cloth, "self_collision_quality", text="Quality")
 
         sub = col.column()
         sub.active = cloth.use_self_collision
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index b51c93b298..2dade1c7ba 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -125,7 +125,6 @@ void cloth_init(ClothModifierData *clmd )
 	clmd->coll_parms->epsilon = 0.015f;
 	clmd->coll_parms->flags = CLOTH_COLLSETTINGS_FLAG_ENABLED;
 	clmd->coll_parms->collision_list = NULL;
-	clmd->coll_parms->self_loop_count = 1.0;
 	clmd->coll_parms->selfepsilon = 0.75;
 	clmd->coll_parms->vgroup_selfcol = 0;
 
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index fcc535c422..caa2cf0ea2 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -1122,52 +1122,44 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData *clmd, float step, floa
 			MEM_freeN(collisions_index);
 		}
 
-		rounds++;
-
 		////////////////////////////////////////////////////////////
 		// Test on selfcollisions
 		////////////////////////////////////////////////////////////
 		if ( clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF ) {
-			/* TODO: This self col stuff is already inside the main col loop,
-			 * this inner loop deticated to self col should either just be removed (i.e. run only once),
-			 * or moved to outside of the main col loop (to be evaluated later...) */
-			for (l = 0; l < (unsigned int)clmd->coll_parms->self_loop_count; l++) {
-				/* TODO: add coll quality rounds again */
-				BVHTreeOverlap *overlap = NULL;
-				unsigned int result = 0;
-				CollPair **collisions, **collisions_index;
+			BVHTreeOverlap *overlap = NULL;
+			unsigned int result = 0;
+			CollPair **collisions, **collisions_index;
 
-				collisions = MEM_callocN(sizeof(CollPair *), "CollPair");
-				collisions_index = MEM_callocN(sizeof(CollPair *), "CollPair");
-	
-				// collisions = 1;
-				verts = cloth->verts; // needed for openMP
-	
-				/* numfaces = cloth->numfaces; */ /* UNUSED */
-				mvert_num = cloth->mvert_num;
-	
-				verts = cloth->verts;
+			collisions = MEM_callocN(sizeof(CollPair *), "CollPair");
+			collisions_index = MEM_callocN(sizeof(CollPair *), "CollPair");
 
-				if ( cloth->bvhselftree ) {
-					// search for overlapping collision pairs
-					overlap = BLI_bvhtree_overlap(cloth->bvhselftree, cloth->bvhselftree, &result, NULL, NULL);
+			// collisions = 1;
+			verts = cloth->verts; // needed for openMP
 
-					if (result && overlap) {
-						cloth_bvh_selfcollisions_nearcheck (clmd, collisions, collisions_index, result, overlap);
+			/* numfaces = cloth->numfaces; */ /* UNUSED */
+			mvert_num = cloth->mvert_num;
 
-						ret += cloth_bvh_selfcollisions_resolve ( clmd, *collisions,  *collisions_index);
-						ret2 += ret;
-					}
+			verts = cloth->verts;
 
-					if ( overlap )
-						MEM_freeN ( overlap );
-				}
+			if ( cloth->bvhselftree ) {
+				// search for overlapping collision pairs
+				overlap = BLI_bvhtree_overlap(cloth->bvhselftree, cloth->bvhselftree, &result, NULL, NULL);
 
-				if ( *collisions ) MEM_freeN ( *collisions );
+				if (result && overlap) {
+					cloth_bvh_selfcollisions_nearcheck (clmd, collisions, collisions_index, result, overlap);
 
-				MEM_freeN(collisions);
-				MEM_freeN(collisions_index);
+					ret += cloth_bvh_selfcollisions_resolve ( clmd, *collisions,  *collisions_index);
+					ret2 += ret;
+				}
+
+				if ( overlap )
+					MEM_freeN ( overlap );
 			}
+
+			if ( *collisions ) MEM_freeN ( *collisions );
+
+			MEM_freeN(collisions);
+			MEM_freeN(collisions_index);
 		}
 
 		if (clmd->coll_parms->flags & (CLOTH_COLLSETTINGS_FLAG_ENABLED | CLOTH_COLLSETTINGS_FLAG_SELF)) {
@@ -1181,6 +1173,8 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData *clmd, float step, floa
 				VECADD ( verts[i].tx, verts[i].txold, verts[i].tv );
 			}
 		}
+
+		rounds++;
 	}
 	while ( ret2 && ( clmd->coll_parms->loop_count>rounds ) );
 	
diff --git a/source/blender/makesdna/DNA_cloth_types.h b/source/blender/makesdna/DNA_cloth_types.h
index 767814c832..b13ba036e8 100644
--- a/source/blender/makesdna/DNA_cloth_types.h
+++ b/source/blender/makesdna/DNA_cloth_types.h
@@ -122,9 +122,8 @@ typedef struct ClothCollSettings {
 	float	damping;	/* Collision restitution on contact with other object.*/
 	float 	selfepsilon; 		/* for selfcollision */
 	int	flags;			/* collision flags defined in BKE_cloth.h */
-	short	self_loop_count;	/* How many iterations for the selfcollision loop	*/
 	short	loop_count;		/* How many iterations for the collision loop.		*/
-	int pad;
+	short pad[3];
 	struct Group *group;	/* Only use colliders from this group of objects */
 	short	vgroup_selfcol; /* vgroup to paint which vertices are used for self collisions */
 	short pad2[3];
diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c
index da7cc7d3fc..0a327f2b8d 100644
--- a/source/blender/makesrna/intern/rna_cloth.c
+++ b/source/blender/makesrna/intern/rna_cloth.c
@@ -850,15 +850,6 @@ static void rna_def_cloth_collision_settings(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Self Friction", "Friction/damping with self contact");
 	RNA_def_property_update(prop, 0, "rna_cloth_update");
 
-	prop = RNA_def_property(srna, "self_collision_quality", PROP_INT, PROP_NONE);
-	RNA_def_property_int_sdna(prop, NULL, "self_loop_count");
-	RNA_def_property_range(prop, 1, SHRT_MAX);
-	RNA_def_property_ui_range(prop, 1, 10, 1, -1);
-	RNA_def_property_ui_text(prop, "Self Collision Quality",
-	                         "How many self collision iterations should be done "
-	                         "(higher is better quality but slower)");
-	RNA_def_property_update(prop, 0, "rna_cloth_update");
-
 	prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
 	RNA_def_property_flag(prop, PROP_EDITABLE);
 	RNA_def_property_ui_text(prop, "Collision Group", "Limit colliders to this Group");




More information about the Bf-blender-cvs mailing list