[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24641] trunk/blender: Durian request: Cloth

Daniel Genrich daniel.genrich at gmx.net
Wed Nov 18 14:33:52 CET 2009


Revision: 24641
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24641
Author:   genscher
Date:     2009-11-18 14:33:52 +0100 (Wed, 18 Nov 2009)

Log Message:
-----------
Durian request: Cloth
* structural can be set to 0

* pre-roll now available through GUI and works like following:
a) Pre rolled frames are NOT cached
b) reset cache + cloth on pre roll setting change

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

Modified: trunk/blender/release/scripts/ui/properties_physics_cloth.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_physics_cloth.py	2009-11-18 13:14:49 UTC (rev 24640)
+++ trunk/blender/release/scripts/ui/properties_physics_cloth.py	2009-11-18 13:33:52 UTC (rev 24641)
@@ -83,8 +83,9 @@
 
             col = split.column()
 
-            col.itemL(text="Presets:")
-            col.itemL(text="TODO!")
+            col.itemL(text="Presets: TODO")
+            # col.itemL(text="TODO!")
+            col.itemR(cloth, "pre_roll")
 
             col.itemL(text="Damping:")
             sub = col.column(align=True)

Modified: trunk/blender/source/blender/blenkernel/intern/cloth.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/cloth.c	2009-11-18 13:14:49 UTC (rev 24640)
+++ trunk/blender/source/blender/blenkernel/intern/cloth.c	2009-11-18 13:33:52 UTC (rev 24641)
@@ -131,6 +131,7 @@
 	clmd->sim_parms->avg_spring_len = 0.0;
 	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->coll_parms->self_friction = 5.0;
 	clmd->coll_parms->friction = 5.0;
@@ -450,6 +451,18 @@
 		cache->last_exact= 0;
 		return dm;
 	}
+
+	if(clmd->sim_parms->reset || (framenr == (startframe - clmd->sim_parms->preroll)))
+	{
+		clmd->sim_parms->reset = 0;
+		cache->flag |= PTCACHE_REDO_NEEDED;
+		BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
+		cache->simframe= 0;
+		cache->last_exact= 0;
+		cache->flag |= PTCACHE_SIMULATION_VALID;
+		cache->flag &= ~PTCACHE_REDO_NEEDED;
+		return result;
+	}
 	
 	/* verify we still have the same number of vertices, if not do nothing.
 	 * note that this should only happen if the number of vertices changes
@@ -468,7 +481,7 @@
 	clmd->sim_parms->dt = clmd->sim_parms->timescale / clmd->sim_parms->stepsPerFrame;
 
 	/* handle continuous simulation with the play button */
-	if(BKE_ptcache_get_continue_physics()) {
+	if(BKE_ptcache_get_continue_physics() || ((clmd->sim_parms->preroll > 0) && (framenr > startframe - clmd->sim_parms->preroll) && (framenr < startframe))) {
 		cache->flag &= ~PTCACHE_SIMULATION_VALID;
 		cache->simframe= 0;
 		cache->last_exact= 0;
@@ -503,7 +516,7 @@
 	if(!do_init_cloth(ob, clmd, result, framenr))
 		return result;
 
-	if(framenr == startframe) {
+	if((framenr == startframe) && (clmd->sim_parms->preroll == 0)) {
 		BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
 		do_init_cloth(ob, clmd, result, framenr);
 		cache->simframe= framenr;

Modified: trunk/blender/source/blender/blenkernel/intern/modifier.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/modifier.c	2009-11-18 13:14:49 UTC (rev 24640)
+++ trunk/blender/source/blender/blenkernel/intern/modifier.c	2009-11-18 13:33:52 UTC (rev 24641)
@@ -6008,7 +6008,7 @@
 	collmd->current_x = NULL;
 	collmd->current_xnew = NULL;
 	collmd->current_v = NULL;
-	collmd->time = -1;
+	collmd->time = -1000;
 	collmd->numverts = 0;
 	collmd->bvhtree = NULL;
 }
@@ -6039,7 +6039,7 @@
 		collmd->current_x = NULL;
 		collmd->current_xnew = NULL;
 		collmd->current_v = NULL;
-		collmd->time = -1;
+		collmd->time = -1000;
 		collmd->numverts = 0;
 		collmd->bvhtree = NULL;
 		collmd->mfaces = NULL;
@@ -6089,7 +6089,7 @@
 			if(collmd->x && (numverts != collmd->numverts))
 				collisionModifier_freeData((ModifierData *)collmd);
 			
-			if(collmd->time == -1) // first time
+			if(collmd->time == -1000) // first time
 			{
 				collmd->x = dm->dupVertArray(dm); // frame start position
 				

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c	2009-11-18 13:14:49 UTC (rev 24640)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c	2009-11-18 13:33:52 UTC (rev 24641)
@@ -3781,6 +3781,8 @@
 			if(clmd->sim_parms) {
 				if(clmd->sim_parms->presets > 10)
 					clmd->sim_parms->presets = 0;
+
+				clmd->sim_parms->reset = 0;
 			}
 
 			if(clmd->sim_parms->effector_weights)
@@ -3863,7 +3865,7 @@
 			collmd->current_x = NULL;
 			collmd->current_xnew = NULL;
 			collmd->current_v = NULL;
-			collmd->time = -1;
+			collmd->time = -1000;
 			collmd->numverts = 0;
 			collmd->bvhtree = NULL;
 			collmd->mfaces = NULL;

Modified: trunk/blender/source/blender/makesdna/DNA_cloth_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_cloth_types.h	2009-11-18 13:14:49 UTC (rev 24640)
+++ trunk/blender/source/blender/makesdna/DNA_cloth_types.h	2009-11-18 13:33:52 UTC (rev 24641)
@@ -78,7 +78,7 @@
 	short	vgroup_mass;	/* optional vertexgroup name for assigning weight.*/
 	short	vgroup_struct;  /* vertex group for scaling structural stiffness */
 	short	presets; /* used for presets on GUI */
- 	short 	pad;
+ 	short 	reset;
 
 	struct EffectorWeights *effector_weights;
 } ClothSimSettings;

Modified: trunk/blender/source/blender/makesrna/intern/rna_cloth.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_cloth.c	2009-11-18 13:14:49 UTC (rev 24640)
+++ trunk/blender/source/blender/makesrna/intern/rna_cloth.c	2009-11-18 13:33:52 UTC (rev 24641)
@@ -53,6 +53,18 @@
 	WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
 }
 
+static void rna_cloth_reset(bContext *C, PointerRNA *ptr)
+{
+	Object *ob= (Object*)ptr->id.data;
+	ClothSimSettings *settings = (ClothSimSettings*)ptr->data;
+
+	settings->reset = 1;
+
+	DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
+	WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
+}
+
+
 static void rna_ClothSettings_max_bend_set(struct PointerRNA *ptr, float value)
 {
 	ClothSimSettings *settings = (ClothSimSettings*)ptr->data;
@@ -272,7 +284,7 @@
 	
 	prop= RNA_def_property(srna, "structural_stiffness", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "structural");
-	RNA_def_property_range(prop, 1.0f, 10000.0f);
+	RNA_def_property_range(prop, 0.0f, 10000.0f);
 	RNA_def_property_ui_text(prop, "Structural Stiffness", "Overall stiffness of structure.");
 	RNA_def_property_update(prop, 0, "rna_cloth_update");
 
@@ -311,6 +323,13 @@
 	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 	RNA_def_property_ui_text(prop, "Effector Weights", "");
 
+	prop= RNA_def_property(srna, "pre_roll", PROP_INT, PROP_NONE);
+	RNA_def_property_int_sdna(prop, NULL, "preroll");
+	RNA_def_property_range(prop, 0, 200);
+	RNA_def_property_ui_text(prop, "Pre Roll", "Simulation starts on this frame.");
+	RNA_def_property_update(prop, 0, "rna_cloth_reset");
+
+
 	/* unused */
 
 	/* unused still
@@ -338,12 +357,6 @@
 	RNA_def_property_ui_text(prop, "Effector Wind Scale", ""); */
 	
 	/* unused still
-	prop= RNA_def_property(srna, "pre_roll", PROP_INT, PROP_NONE);
-	RNA_def_property_int_sdna(prop, NULL, "preroll");
-	RNA_def_property_range(prop, 10, 80;
-	RNA_def_property_ui_text(prop, "Pre Roll", "Simulation starts on this frame."); */
-
-	/* unused still
 	prop= RNA_def_property(srna, "tearing", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flags", CLOTH_SIMSETTINGS_FLAG_TEARING);
 	RNA_def_property_ui_text(prop, "Tearing", "");*/





More information about the Bf-blender-cvs mailing list