[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43627] trunk/blender: Cloth: Add " velocity damping" to damping options.

Daniel Genrich daniel.genrich at gmx.net
Mon Jan 23 02:35:25 CET 2012


Revision: 43627
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43627
Author:   genscher
Date:     2012-01-23 01:35:14 +0000 (Mon, 23 Jan 2012)
Log Message:
-----------
Cloth: Add "velocity damping" to damping options. This will help with the "cloth wobbling" problem which accurs quite often when having animated characters with cloth.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/properties_physics_cloth.py
    trunk/blender/source/blender/blenkernel/intern/cloth.c
    trunk/blender/source/blender/blenkernel/intern/implicit.c
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/makesdna/DNA_cloth_types.h
    trunk/blender/source/blender/makesdna/DNA_object_force.h
    trunk/blender/source/blender/makesrna/intern/rna_cloth.c

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_physics_cloth.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_physics_cloth.py	2012-01-22 23:15:35 UTC (rev 43626)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_physics_cloth.py	2012-01-23 01:35:14 UTC (rev 43627)
@@ -87,6 +87,7 @@
         col.label(text="Damping:")
         col.prop(cloth, "spring_damping", text="Spring")
         col.prop(cloth, "air_damping", text="Air")
+        col.prop(cloth, "vel_damping", text="Velocity")
 
         col.prop(cloth, "use_pin_cloth", text="Pinning")
         sub = col.column()

Modified: trunk/blender/source/blender/blenkernel/intern/cloth.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/cloth.c	2012-01-22 23:15:35 UTC (rev 43626)
+++ trunk/blender/source/blender/blenkernel/intern/cloth.c	2012-01-23 01:35:14 UTC (rev 43627)
@@ -130,6 +130,7 @@
 	clmd->sim_parms->presets = 2; /* cotton as start setting */
 	clmd->sim_parms->timescale = 1.0f; /* speed factor, describes how fast cloth moves */
 	clmd->sim_parms->reset = 0;
+	clmd->sim_parms->vel_damping = 1.0f; /* 1.0 = no damping, 0.0 = fully dampened */
 	
 	clmd->coll_parms->self_friction = 5.0;
 	clmd->coll_parms->friction = 5.0;

Modified: trunk/blender/source/blender/blenkernel/intern/implicit.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/implicit.c	2012-01-22 23:15:35 UTC (rev 43626)
+++ trunk/blender/source/blender/blenkernel/intern/implicit.c	2012-01-23 01:35:14 UTC (rev 43627)
@@ -1852,6 +1852,9 @@
 	
 	while(step < tf)
 	{	
+		// damping velocity for artistic reasons
+		mul_lfvectorS(id->V, id->V, clmd->sim_parms->vel_damping, numverts);
+
 		// calculate forces
 		cloth_calc_force(clmd, frame, id->F, id->X, id->V, id->dFdV, id->dFdX, effectors, step, id->M);
 		

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c	2012-01-22 23:15:35 UTC (rev 43626)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c	2012-01-23 01:35:14 UTC (rev 43627)
@@ -13038,6 +13038,20 @@
 	
 	/* put compatibility code here until next subversion bump */
 	{
+		{
+			Object *ob;
+			for(ob=main->object.first; ob; ob= ob->id.next) {
+				ModifierData *md;
+
+				for (md=ob->modifiers.first; md; md=md->next) {
+					if (md->type==eModifierType_Cloth) {
+						ClothModifierData *clmd = (ClothModifierData*) md;
+						if(clmd->sim_parms)
+							clmd->sim_parms->vel_damping = 1.0f;
+					}
+				}
+			}
+		}
 	}
 
 	/* WATCH IT!!!: pointers from libdata have not been converted yet here! */

Modified: trunk/blender/source/blender/makesdna/DNA_cloth_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_cloth_types.h	2012-01-22 23:15:35 UTC (rev 43626)
+++ trunk/blender/source/blender/makesdna/DNA_cloth_types.h	2012-01-23 01:35:14 UTC (rev 43627)
@@ -70,6 +70,7 @@
 	float	goalfrict;
 	float	velocity_smooth; /* smoothing of velocities for hair */
 	float	collider_friction; /* friction with colliders */
+	float	vel_damping; /* damp the velocity to speed up getting to the resting position */
 
 	int 	stepsPerFrame;	/* Number of time steps per frame.		*/
 	int	flags;		/* flags, see CSIMSETT_FLAGS enum above.	*/
@@ -82,7 +83,7 @@
 	short	shapekey_rest;  /* vertex group for scaling structural stiffness */
 	short	presets; /* used for presets on GUI */
 	short 	reset;
-	short	pad[3];
+	short	pad;
 
 	struct EffectorWeights *effector_weights;
 } ClothSimSettings;

Modified: trunk/blender/source/blender/makesdna/DNA_object_force.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_object_force.h	2012-01-22 23:15:35 UTC (rev 43626)
+++ trunk/blender/source/blender/makesdna/DNA_object_force.h	2012-01-23 01:35:14 UTC (rev 43627)
@@ -186,6 +186,8 @@
 	int endframe;	/* simulation end frame */
 	int editframe;	/* frame being edited (runtime only) */
 	int last_exact; /* last exact frame that's cached */
+	int last_valid; /* used for editing cache - what is the last baked frame */
+	int pad;
 
 	/* for external cache files */
 	int totpoint;   /* number of cached points */

Modified: trunk/blender/source/blender/makesrna/intern/rna_cloth.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_cloth.c	2012-01-22 23:15:35 UTC (rev 43626)
+++ trunk/blender/source/blender/makesrna/intern/rna_cloth.c	2012-01-23 01:35:14 UTC (rev 43627)
@@ -289,6 +289,12 @@
 	RNA_def_property_ui_text(prop, "Air Damping", "Air has normally some thickness which slows falling things down");
 	RNA_def_property_update(prop, 0, "rna_cloth_update");
 
+	prop= RNA_def_property(srna, "vel_damping", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "vel_damping");
+	RNA_def_property_range(prop, 0.0f, 1.0f);
+	RNA_def_property_ui_text(prop, "Velocity Damping", "Damp velocity to help cloth reach the resting position faster. [1.0 = no damping, 0.0 = fully dampened]");
+	RNA_def_property_update(prop, 0, "rna_cloth_update");
+
 	prop= RNA_def_property(srna, "use_pin_cloth", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flags", CLOTH_SIMSETTINGS_FLAG_GOAL);
 	RNA_def_property_ui_text(prop, "Pin Cloth", "Enable pinning of cloth vertices to other objects/positions");



More information about the Bf-blender-cvs mailing list