[Bf-blender-cvs] [73b9899c92] cloth-improvements: Move use_normal to col object settings (was in cloth settings)

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


Commit: 73b9899c924609a808252ced54674a61e8b90f65
Author: Luca Rood
Date:   Thu Jan 19 22:10:14 2017 -0200
Branches: cloth-improvements
https://developer.blender.org/rB73b9899c924609a808252ced54674a61e8b90f65

Move use_normal to col object settings (was in cloth settings)

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

M	release/scripts/startup/bl_ui/properties_physics_cloth.py
M	release/scripts/startup/bl_ui/properties_physics_field.py
M	source/blender/blenkernel/BKE_cloth.h
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_cloth.c
M	source/blender/makesrna/intern/rna_object_force.c

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

diff --git a/release/scripts/startup/bl_ui/properties_physics_cloth.py b/release/scripts/startup/bl_ui/properties_physics_cloth.py
index b4283f4682..17acca7823 100644
--- a/release/scripts/startup/bl_ui/properties_physics_cloth.py
+++ b/release/scripts/startup/bl_ui/properties_physics_cloth.py
@@ -240,8 +240,6 @@ class PHYSICS_PT_cloth_collision(PhysicButtonsPanel, Panel):
         sub.prop(cloth, "distance_min", slider=True, text="Distance")
         sub.prop(cloth, "group")
 
-        sub.prop(cloth, "use_normal")
-
         layout.separator()
 
         col = layout.column()
diff --git a/release/scripts/startup/bl_ui/properties_physics_field.py b/release/scripts/startup/bl_ui/properties_physics_field.py
index a946c2fd72..53188b8857 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, "use_normal")
+
             col.prop(settings, "cloth_friction")
 
             col.label(text="Soft Body Damping:")
diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h
index f7cca99be6..67d8973950 100644
--- a/source/blender/blenkernel/BKE_cloth.h
+++ b/source/blender/blenkernel/BKE_cloth.h
@@ -180,7 +180,6 @@ typedef enum {
 typedef enum {
 	CLOTH_COLLSETTINGS_FLAG_ENABLED = ( 1 << 1 ), /* enables cloth - object collisions */
 	CLOTH_COLLSETTINGS_FLAG_SELF = ( 1 << 2 ), /* enables selfcollisions */
-	CLOTH_COLLSETTINGS_FLAG_USE_NORMAL = ( 1 << 3 ), /* enable collision side detection based on normal */
 } CLOTH_COLLISIONSETTINGS_FLAGS;
 
 /* Spring types as defined in the paper.*/
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index 9c7da86c80..dbf6f2f38c 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -226,8 +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, float friction)
+static int cloth_collision_response_static (ClothModifierData *clmd, CollisionModifierData *collmd, Object *collob,
+                                            CollPair *collpair, CollPair *collision_end)
 {
 	int result = 0;
 	Cloth *cloth1;
@@ -266,7 +266,7 @@ static int cloth_collision_response_static (ClothModifierData *clmd, CollisionMo
 			&u1, &u2, &u3 );
 
 		/* compute collision normal */
-		if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_USE_NORMAL) {
+		if (collob->pd->flag & PFIELD_CLOTH_USE_NORMAL) {
 			normal_tri_v3(collider_norm, collmd->current_x[collpair->bp1].co, collmd->current_x[collpair->bp2].co, collmd->current_x[collpair->bp3].co);
 			backside = dot_v3v3(collider_norm, collpair->normal) < 0.0f;
 		}
@@ -305,7 +305,7 @@ static int cloth_collision_response_static (ClothModifierData *clmd, CollisionMo
 
 			/* 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(friction * 0.01f * magrelVel, len_v3(vrel_t_pre));
+			magtangent = min_ff(collob->pd->pdef_cfrict * 0.01f * magrelVel, len_v3(vrel_t_pre));
 
 			/* Apply friction impulse. */
 			if ( magtangent > ALMOST_ZERO ) {
@@ -947,8 +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, float friction)
+static int cloth_bvh_objcollisions_resolve (ClothModifierData * clmd, CollisionModifierData *collmd, Object *collob,
+                                            CollPair *collisions, CollPair *collisions_index)
 {
 	Cloth *cloth = clmd->clothObject;
 	int i=0, j = 0, /*numfaces = 0, */ mvert_num = 0;
@@ -965,7 +965,7 @@ static int cloth_bvh_objcollisions_resolve (ClothModifierData * clmd, CollisionM
 		result = 0;
 
 		if ( collmd->bvhtree ) {
-			result += cloth_collision_response_static (clmd, collmd, collisions, collisions_index, friction);
+			result += cloth_collision_response_static(clmd, collmd, collob, collisions, collisions_index);
 
 			// apply impulses in parallel
 			if (result) {
@@ -1106,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], collob->pd->pdef_cfrict);
+					ret += cloth_bvh_objcollisions_resolve(clmd, collmd, collob, collisions[i],  collisions_index[i]);
 					ret2 += ret;
 				}
 
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index b7e53ad89d..41d59805c2 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -127,7 +127,7 @@ PartDeflect *object_add_collision_fields(int type)
 			pd->f_flow = 1.0f;
 			break;
 	}
-	pd->flag = PFIELD_DO_LOCATION|PFIELD_DO_ROTATION;
+	pd->flag = PFIELD_DO_LOCATION|PFIELD_DO_ROTATION|PFIELD_CLOTH_USE_NORMAL;
 
 	return pd;
 }
diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h
index 987b8a184a..68018dbd16 100644
--- a/source/blender/makesdna/DNA_object_force.h
+++ b/source/blender/makesdna/DNA_object_force.h
@@ -375,6 +375,7 @@ typedef struct SoftBody {
 #define PFIELD_DO_ROTATION		(1<<15)
 #define PFIELD_GUIDE_PATH_WEIGHT (1<<16)	/* apply curve weights */
 #define PFIELD_SMOKE_DENSITY    (1<<17)		/* multiply smoke force by density */
+#define PFIELD_CLOTH_USE_NORMAL (1<<18)		/* enable cloth collision side detection based on normal */
 
 /* pd->falloff */
 #define PFIELD_FALL_SPHERE		0
diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c
index 6812a5d470..9c4b545494 100644
--- a/source/blender/makesrna/intern/rna_cloth.c
+++ b/source/blender/makesrna/intern/rna_cloth.c
@@ -827,11 +827,6 @@ static void rna_def_cloth_collision_settings(BlenderRNA *brna)
 	                         "How many 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, "use_normal", PROP_BOOLEAN, PROP_NONE);
-	RNA_def_property_boolean_sdna(prop, NULL, "flags", CLOTH_COLLSETTINGS_FLAG_USE_NORMAL);
-	RNA_def_property_ui_text(prop, "Single Sided", "Collision acts with respect to the collider normals (improves penetration recovery)");
-	RNA_def_property_update(prop, 0, "rna_cloth_update");
-
 	/* self collision */
 
 	prop = RNA_def_property(srna, "use_self_collision", PROP_BOOLEAN, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c
index 9d21ff7b64..38d6846148 100644
--- a/source/blender/makesrna/intern/rna_object_force.c
+++ b/source/blender/makesrna/intern/rna_object_force.c
@@ -992,6 +992,11 @@ static void rna_def_collision(BlenderRNA *brna)
 	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");
+
+	prop = RNA_def_property(srna, "use_normal", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_CLOTH_USE_NORMAL);
+	RNA_def_property_ui_text(prop, "Single Sided", "Cloth collision acts with respect to the collider normals (improves penetration recovery)");
+	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