[Bf-blender-cvs] [8759ec4eae] cloth-improvements: Move fricion to collider object settings

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


Commit: 8759ec4eae7adfe2102cd86eef724ad4b65552db
Author: Luca Rood
Date:   Thu Jan 19 12:38:07 2017 -0200
Branches: cloth-improvements
https://developer.blender.org/rB8759ec4eae7adfe2102cd86eef724ad4b65552db

Move fricion to collider object settings

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

M	release/scripts/startup/bl_ui/properties_physics_field.py
M	source/blender/blenkernel/intern/collision.c
M	source/blender/blenkernel/intern/effect.c
M	source/blender/makesdna/DNA_object_force.h
M	source/blender/makesrna/intern/rna_object_force.c

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

diff --git a/release/scripts/startup/bl_ui/properties_physics_field.py b/release/scripts/startup/bl_ui/properties_physics_field.py
index 1cebc0496b..a946c2fd72 100644
--- a/release/scripts/startup/bl_ui/properties_physics_field.py
+++ b/release/scripts/startup/bl_ui/properties_physics_field.py
@@ -222,6 +222,8 @@ class PHYSICS_PT_collision(PhysicButtonsPanel, Panel):
             sub.prop(settings, "thickness_outer", text="Outer", slider=True)
             sub.prop(settings, "thickness_inner", text="Inner", slider=True)
 
+            col.prop(settings, "cloth_friction")
+
             col.label(text="Soft Body Damping:")
             col.prop(settings, "damping", text="Factor", slider=True)
 
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index 6f4e635a7b..5c50c0290d 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -226,7 +226,8 @@ 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, CollPair *collpair, CollPair *collision_end )
+static int cloth_collision_response_static (ClothModifierData *clmd, CollisionModifierData *collmd,
+                                            CollPair *collpair, CollPair *collision_end, float friction)
 {
 	int result = 0;
 	Cloth *cloth1;
@@ -304,7 +305,7 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM
 
 			/* Decrease in magnitude of relative tangential velocity due to coulomb friction
 			 * in original formula "magrelVel" should be the "change of relative velocity in normal direction" */
-			magtangent = min_ff(clmd->coll_parms->friction * 0.01f * magrelVel, len_v3(vrel_t_pre));
+			magtangent = min_ff(friction * 0.01f * magrelVel, len_v3(vrel_t_pre));
 
 			/* Apply friction impulse. */
 			if ( magtangent > ALMOST_ZERO ) {
@@ -946,7 +947,8 @@ static void cloth_bvh_selfcollisions_nearcheck (ClothModifierData * clmd, CollPa
 	}
 }
 
-static int cloth_bvh_objcollisions_resolve ( ClothModifierData * clmd, CollisionModifierData *collmd, CollPair *collisions, CollPair *collisions_index)
+static int cloth_bvh_objcollisions_resolve (ClothModifierData * clmd, CollisionModifierData *collmd,
+                                            CollPair *collisions, CollPair *collisions_index, float friction)
 {
 	Cloth *cloth = clmd->clothObject;
 	int i=0, j = 0, /*numfaces = 0, */ mvert_num = 0;
@@ -963,7 +965,7 @@ static int cloth_bvh_objcollisions_resolve ( ClothModifierData * clmd, Collision
 		result = 0;
 
 		if ( collmd->bvhtree ) {
-			result += cloth_collision_response_static ( clmd, collmd, collisions, collisions_index );
+			result += cloth_collision_response_static (clmd, collmd, collisions, collisions_index, friction);
 
 			// apply impulses in parallel
 			if (result) {
@@ -1104,7 +1106,7 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData *clmd, float step, floa
 						&collisions_index[i], result, overlap, dt/(float)clmd->coll_parms->loop_count);
 
 					// resolve nearby collisions
-					ret += cloth_bvh_objcollisions_resolve ( clmd, collmd, collisions[i],  collisions_index[i]);
+					ret += cloth_bvh_objcollisions_resolve ( clmd, collmd, collisions[i],  collisions_index[i], collob->pd->pdef_cfrict);
 					ret2 += ret;
 				}
 
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index 7e6897a285..b7e53ad89d 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -106,6 +106,7 @@ PartDeflect *object_add_collision_fields(int type)
 	pd->pdef_sbdamp = 0.1f;
 	pd->pdef_sbift  = 0.2f;
 	pd->pdef_sboft  = 0.02f;
+	pd->pdef_cfrict = 5.0f;
 	pd->seed = ((unsigned int)(ceil(PIL_check_seconds_timer()))+1) % 128;
 	pd->f_strength = 1.0f;
 	pd->f_damp = 1.0f;
diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h
index 59acefeffe..987b8a184a 100644
--- a/source/blender/makesdna/DNA_object_force.h
+++ b/source/blender/makesdna/DNA_object_force.h
@@ -99,6 +99,9 @@ typedef struct PartDeflect {
 	float pdef_sbift;	/* inner face thickness for softbody deflection */
 	float pdef_sboft;	/* outer face thickness for softbody deflection */
 
+	float pdef_cfrict;	/* Friction of cloth collisions */
+	char pad[4];
+
 	/* guide curve, same as for particle child effects */
 	float clump_fac, clump_pow;
 	float kink_freq, kink_shape, kink_amp, free_end;
diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c
index 1d89f7535c..9d21ff7b64 100644
--- a/source/blender/makesrna/intern/rna_object_force.c
+++ b/source/blender/makesrna/intern/rna_object_force.c
@@ -986,6 +986,12 @@ static void rna_def_collision(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Absorption",
 	                         "How much of effector force gets lost during collision with this object (in percent)");
 	RNA_def_property_update(prop, 0, "rna_CollisionSettings_update");
+
+	prop = RNA_def_property(srna, "cloth_friction", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "pdef_cfrict");
+	RNA_def_property_range(prop, 0.0f, 80.0f);
+	RNA_def_property_ui_text(prop, "Friction", "Friction for cloth collisions");
+	RNA_def_property_update(prop, 0, "rna_CollisionSettings_update");
 }
 
 static void rna_def_effector_weight(BlenderRNA *brna)




More information about the Bf-blender-cvs mailing list