[Bf-blender-cvs] [a87cd01425] cloth-improvements: Remove a few warnings and some cleanup

Luca Rood noreply at git.blender.org
Sat Mar 4 06:22:40 CET 2017


Commit: a87cd014256ca8991819a81df227de5ee76c46a2
Author: Luca Rood
Date:   Sat Mar 4 01:38:44 2017 -0300
Branches: cloth-improvements
https://developer.blender.org/rBa87cd014256ca8991819a81df227de5ee76c46a2

Remove a few warnings and some cleanup

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

M	source/blender/blenkernel/intern/collision.c

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

diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index 24294dadce..33e4f30708 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -633,7 +633,7 @@ static void collision_compute_barycentric ( float pv[3], float p1[3], float p2[3
 #  pragma GCC diagnostic ignored "-Wdouble-promotion"
 #endif
 
-DO_INLINE void collision_interpolateOnTriangle ( float to[3], float v1[3], float v2[3], float v3[3], double w1, double w2, double w3 )
+DO_INLINE void collision_interpolateOnTriangle (float to[3], float v1[3], float v2[3], float v3[3], double w1, double w2, double w3)
 {
 	zero_v3(to);
 	VECADDMUL(to, v1, w1);
@@ -641,19 +641,19 @@ DO_INLINE void collision_interpolateOnTriangle ( float to[3], float v1[3], float
 	VECADDMUL(to, v3, w3);
 }
 
-static int cloth_collision_response_static (ClothModifierData *clmd, CollisionModifierData *collmd, Object *collob,
-                                            CollPair *collpair, CollPair *collision_end, ImpulseCluster **vert_imp_clusters)
+static int cloth_collision_response_static(ClothModifierData *clmd, CollisionModifierData *collmd, Object *collob,
+                                           CollPair *collpair, CollPair *collision_end, ImpulseCluster **vert_imp_clusters)
 {
 	int result = 0;
 	Cloth *cloth1;
 	float w1, w2, w3, u1, u2, u3;
 	float v1[3], v2[3], relativeVelocity[3];
 	float magrelVel;
-	float epsilon2 = BLI_bvhtree_get_epsilon ( collmd->bvhtree );
+	float epsilon2 = BLI_bvhtree_get_epsilon(collmd->bvhtree);
 
 	cloth1 = clmd->clothObject;
 
-	for ( ; collpair != collision_end; collpair++ ) {
+	for (; collpair != collision_end; collpair++) {
 		float i1[3], i2[3], i3[3];
 
 		zero_v3(i1);
@@ -661,27 +661,28 @@ static int cloth_collision_response_static (ClothModifierData *clmd, CollisionMo
 		zero_v3(i3);
 
 		/* only handle static collisions here */
-		if ( collpair->flag & COLLISION_IN_FUTURE )
+		if (collpair->flag & COLLISION_IN_FUTURE) {
 			continue;
+		}
 
 		/* compute barycentric coordinates for both collision points */
-		collision_compute_barycentric ( collpair->pa,
-			cloth1->verts[collpair->ap1].tx,
-			cloth1->verts[collpair->ap2].tx,
-			cloth1->verts[collpair->ap3].tx,
-			&w1, &w2, &w3 );
+		collision_compute_barycentric(collpair->pa,
+                                      cloth1->verts[collpair->ap1].tx,
+                                      cloth1->verts[collpair->ap2].tx,
+                                      cloth1->verts[collpair->ap3].tx,
+                                      &w1, &w2, &w3);
 
 		/* was: txold */
-		collision_compute_barycentric ( collpair->pb,
-			collmd->current_x[collpair->bp1].co,
-			collmd->current_x[collpair->bp2].co,
-			collmd->current_x[collpair->bp3].co,
-			&u1, &u2, &u3 );
+		collision_compute_barycentric(collpair->pb,
+                                      collmd->current_x[collpair->bp1].co,
+                                      collmd->current_x[collpair->bp2].co,
+                                      collmd->current_x[collpair->bp3].co,
+                                      &u1, &u2, &u3);
 
 		/* Calculate relative "velocity". */
-		collision_interpolateOnTriangle ( v1, cloth1->verts[collpair->ap1].tv, cloth1->verts[collpair->ap2].tv, cloth1->verts[collpair->ap3].tv, w1, w2, w3 );
+		collision_interpolateOnTriangle(v1, cloth1->verts[collpair->ap1].tv, cloth1->verts[collpair->ap2].tv, cloth1->verts[collpair->ap3].tv, w1, w2, w3);
 
-		collision_interpolateOnTriangle ( v2, collmd->current_v[collpair->bp1].co, collmd->current_v[collpair->bp2].co, collmd->current_v[collpair->bp3].co, u1, u2, u3 );
+		collision_interpolateOnTriangle(v2, collmd->current_v[collpair->bp1].co, collmd->current_v[collpair->bp2].co, collmd->current_v[collpair->bp3].co, u1, u2, u3);
 
 		sub_v3_v3v3(relativeVelocity, v2, v1);
 
@@ -714,31 +715,23 @@ static int cloth_collision_response_static (ClothModifierData *clmd, CollisionMo
 			if ( magtangent > ALMOST_ZERO ) {
 				normalize_v3(vrel_t_pre);
 
-				/*impulse = magtangent / ( 1.0f + w1*w1 + w2*w2 + w3*w3 );  2.0 * */
-
-				/* Impulse should be uniform throughout polygon, the scaling used above was wrong */
 				impulse = magtangent / 1.5;
 
-				VECADDMUL ( i1, vrel_t_pre, w1 * impulse );
-				VECADDMUL ( i2, vrel_t_pre, w2 * impulse );
-				VECADDMUL ( i3, vrel_t_pre, w3 * impulse );
+				VECADDMUL(i1, vrel_t_pre, w1 * impulse);
+				VECADDMUL(i2, vrel_t_pre, w2 * impulse);
+				VECADDMUL(i3, vrel_t_pre, w3 * impulse);
 			}
 
-			/* Apply velocity stopping impulse
-			 * I_c = m * v_N / 2.0
-			 * no 2.0 * magrelVel normally, but looks nicer DG */
-			/*impulse =  magrelVel / ( 1.0 + w1*w1 + w2*w2 + w3*w3 );*/
-
-			/* Impulse should be uniform throughout polygon, the scaling used above was wrong */
+			/* Apply velocity stopping impulse */
 			impulse =  magrelVel / 1.5f;
 
-			VECADDMUL ( i1, collpair->normal, w1 * impulse );
+			VECADDMUL(i1, collpair->normal, w1 * impulse);
 			cloth1->verts[collpair->ap1].impulse_count++;
 
-			VECADDMUL ( i2, collpair->normal, w2 * impulse );
+			VECADDMUL(i2, collpair->normal, w2 * impulse);
 			cloth1->verts[collpair->ap2].impulse_count++;
 
-			VECADDMUL ( i3, collpair->normal, w3 * impulse );
+			VECADDMUL(i3, collpair->normal, w3 * impulse);
 			cloth1->verts[collpair->ap3].impulse_count++;
 
 			/* Apply repulse impulse if distance too short
@@ -751,22 +744,21 @@ static int cloth_collision_response_static (ClothModifierData *clmd, CollisionMo
 
 			d = clmd->coll_parms->epsilon*8.0f/9.0f + epsilon2*8.0f/9.0f - collpair->distance;
 
-			if ( ( magrelVel < 0.1f*d*time_multiplier ) && ( d > ALMOST_ZERO ) ) {
-				repulse = MIN2 ( d*1.0f/time_multiplier, 0.1f*d*time_multiplier - magrelVel );
+			if ((magrelVel < 0.1f*d*time_multiplier) && (d > ALMOST_ZERO)) {
+				repulse = MIN2(d*1.0f/time_multiplier, 0.1f*d*time_multiplier - magrelVel);
 
 				/* stay on the safe side and clamp repulse */
-				if ( impulse > ALMOST_ZERO )
-					repulse = min_ff( repulse, 5.0*impulse );
-				repulse = max_ff(impulse, repulse);
+				if (impulse > ALMOST_ZERO) {
+					repulse = min_ff(repulse, 5.0*impulse);
+				}
 
-				/*impulse = repulse / ( 1.0f + w1*w1 + w2*w2 + w3*w3 ); original 2.0 / 0.25 */
+				repulse = max_ff(impulse, repulse);
 
-				/* Impulse should be uniform throughout polygon, the scaling used above was wrong */
 				impulse = repulse / 1.5f;
 
-				VECADDMUL ( i1, collpair->normal,  impulse );
-				VECADDMUL ( i2, collpair->normal,  impulse );
-				VECADDMUL ( i3, collpair->normal,  impulse );
+				VECADDMUL(i1, collpair->normal, impulse);
+				VECADDMUL(i2, collpair->normal, impulse);
+				VECADDMUL(i3, collpair->normal, impulse);
 			}
 
 			result = 1;
@@ -785,15 +777,11 @@ static int cloth_collision_response_static (ClothModifierData *clmd, CollisionMo
 			if ( d > ALMOST_ZERO) {
 				/* stay on the safe side and clamp repulse */
 				float repulse = d*1.0f/time_multiplier;
-
-				/*float impulse = repulse / ( 3.0f * ( 1.0f + w1*w1 + w2*w2 + w3*w3 )); original 2.0 / 0.25 */
-
-				/* Impulse should be uniform throughout polygon, the scaling used above was wrong */
 				float impulse = repulse / 4.5f;
 
-				VECADDMUL ( i1, collpair->normal, w1 * impulse );
-				VECADDMUL ( i2, collpair->normal, w2 * impulse );
-				VECADDMUL ( i3, collpair->normal, w3 * impulse );
+				VECADDMUL(i1, collpair->normal, w1 * impulse);
+				VECADDMUL(i2, collpair->normal, w2 * impulse);
+				VECADDMUL(i3, collpair->normal, w3 * impulse);
 
 				cloth1->verts[collpair->ap1].impulse_count++;
 				cloth1->verts[collpair->ap2].impulse_count++;
@@ -817,6 +805,7 @@ static int cloth_collision_response_static (ClothModifierData *clmd, CollisionMo
 			}
 		}
 	}
+
 	return result;
 }
 
@@ -831,48 +820,47 @@ static int cloth_selfcollision_response_static(ClothModifierData *clmd, CollPair
 
 	cloth1 = clmd->clothObject;
 
-	for ( ; collpair != collision_end; collpair++ ) {
-		float i1[3], i2[3], i3[3], j1[3], j2[3], j3[3]; /* i are impulses for ap and j are impulses for bp */
+	for (; collpair != collision_end; collpair++) {
+		float i1[3], i2[3], i3[3];
 
 		zero_v3(i1);
 		zero_v3(i2);
 		zero_v3(i3);
 
 		/* only handle static collisions here */
-		if ( collpair->flag & COLLISION_IN_FUTURE )
+		if (collpair->flag & COLLISION_IN_FUTURE) {
 			continue;
+		}
 
 		/* compute barycentric coordinates for both collision points */
-		collision_compute_barycentric ( collpair->pa,
-			cloth1->verts[collpair->ap1].tx,
-			cloth1->verts[collpair->ap2].tx,
-			cloth1->verts[collpair->ap3].tx,
-			&w1, &w2, &w3 );
+		collision_compute_barycentric(collpair->pa,
+		                              cloth1->verts[collpair->ap1].tx,
+		                              cloth1->verts[collpair->ap2].tx,
+		                              cloth1->verts[collpair->ap3].tx,
+		                              &w1, &w2, &w3);
 
 		/* was: txold */
-		collision_compute_barycentric ( collpair->pb,
-			cloth1->verts[collpair->bp1].tx,
-			cloth1->verts[collpair->bp2].tx,
-			cloth1->verts[collpair->bp3].tx,
-			&u1, &u2, &u3 );
+		collision_compute_barycentric(collpair->pb,
+		                              cloth1->verts[collpair->bp1].tx,
+		                              cloth1->verts[collpair->bp2].tx,
+		                              cloth1->verts[collpair->bp3].tx,
+		                              &u1, &u2, &u3);
 
 		/* Calculate relative "velocity". */
-		collision_interpolateOnTriangle ( v1, cloth1->verts[collpair->ap1].tv, cloth1->verts[collpair->ap2].tv, cloth1->verts[collpair->ap3].tv, w1, w2, w3 );
+		collision_interpolateOnTriangle(v1, cloth1->verts[collpair->ap1].tv, cloth1->verts[collpair->ap2].tv, cloth1->verts[collpair->ap3].tv, w1, w2, w3);
 
-		collision_interpolateOnTriangle ( v2, cloth1->verts[collpair->bp1].tv, cloth1->verts[collpair->bp2].tv, cloth1->verts[collpair->bp3].tv, u1, u2, u3 );
+		collision_interpolateOnTriangle(v2, cloth1->verts[collpair->bp1].tv, cloth1->verts[collpair->bp2].tv, cloth1->verts[collpair->bp3].tv, u1, u2, u3);
 
 		sub_v3_v3v3(relativeVelocity, v2, v1);
 
 		/* Calculate the normal component of the relative velocity (actually only the magnitude - the direction is stor

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list