Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorDaniel Genrich <daniel.genrich@gmx.net>2009-11-18 16:33:52 +0300
committerDaniel Genrich <daniel.genrich@gmx.net>2009-11-18 16:33:52 +0300
commit6a357cabbfd7b2d8856f7f39eb9001a475252260 (patch)
treeeb8a72d596a3e8f12f69355f0fbbda7a5d909445 /source
parenta62b3a534b055307c2bbd9707a1bcba0dbcbdb21 (diff)
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
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/cloth.c17
-rw-r--r--source/blender/blenkernel/intern/modifier.c6
-rw-r--r--source/blender/blenloader/intern/readfile.c4
-rw-r--r--source/blender/makesdna/DNA_cloth_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_cloth.c27
5 files changed, 42 insertions, 14 deletions
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 4a9cb237c01..6c4c7daea7f 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -131,6 +131,7 @@ void cloth_init ( ClothModifierData *clmd )
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 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob,
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 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob,
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 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob,
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;
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index 667b86d1893..ed7fbe58ea4 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -6008,7 +6008,7 @@ static void collisionModifier_initData(ModifierData *md)
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 @@ static void collisionModifier_freeData(ModifierData *md)
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 @@ static void collisionModifier_deformVerts(
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
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 2850fe63415..f146d7f6166 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -3781,6 +3781,8 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
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 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
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;
diff --git a/source/blender/makesdna/DNA_cloth_types.h b/source/blender/makesdna/DNA_cloth_types.h
index 9423e871c77..58f68d0a514 100644
--- a/source/blender/makesdna/DNA_cloth_types.h
+++ b/source/blender/makesdna/DNA_cloth_types.h
@@ -78,7 +78,7 @@ typedef struct ClothSimSettings
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;
diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c
index d78544634bc..0e298c1f6be 100644
--- a/source/blender/makesrna/intern/rna_cloth.c
+++ b/source/blender/makesrna/intern/rna_cloth.c
@@ -53,6 +53,18 @@ static void rna_cloth_update(bContext *C, PointerRNA *ptr)
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 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
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 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
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 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
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", "");*/