diff options
author | Daniel Genrich <daniel.genrich@gmx.net> | 2008-01-25 13:33:19 +0300 |
---|---|---|
committer | Daniel Genrich <daniel.genrich@gmx.net> | 2008-01-25 13:33:19 +0300 |
commit | 589870100dc6734a20c99f572baeb2c401e6509f (patch) | |
tree | b9fd983090dd7fcdfec31ef74d7f8c2a59a78531 /source | |
parent | e7f5d077810004467066d627f34d433a61e68fb2 (diff) |
Fix: clear cache button works again even with protected cache, edited cache doesn't get saved to wrong frame anymore when moving frames forward in editmode
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_cloth.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/cloth.c | 14 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/collision.c | 2 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_cloth_types.h | 2 | ||||
-rw-r--r-- | source/blender/src/buttons_object.c | 5 | ||||
-rw-r--r-- | source/blender/src/editmesh.c | 16 |
6 files changed, 32 insertions, 9 deletions
diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h index 4c017cfaf06..3a3d6612a23 100644 --- a/source/blender/blenkernel/BKE_cloth.h +++ b/source/blender/blenkernel/BKE_cloth.h @@ -134,6 +134,7 @@ typedef enum CLOTH_SIMSETTINGS_FLAG_TEARING = ( 1 << 4 ),// true if tearing is enabled CLOTH_SIMSETTINGS_FLAG_CCACHE_PROTECT = ( 1 << 5 ), // true if tearing is enabled CLOTH_SIMSETTINGS_FLAG_NEW = ( 1 << 6 ), // unsued, true if cloth was just enabled + CLOTH_SIMSETTINGS_FLAG_CCACHE_FFREE = (1 << 7), /* force cache freeing */ } CLOTH_SIMSETTINGS_FLAGS; /* COLLISION FLAGS */ @@ -206,6 +207,7 @@ void bvh_update_from_cloth(ClothModifierData *clmd, int moving); // needed for editmesh.c void cloth_write_cache(Object *ob, ClothModifierData *clmd, float framenr); +int cloth_read_cache(Object *ob, ClothModifierData *clmd, float framenr); // needed for button_object.c void cloth_clear_cache(Object *ob, ClothModifierData *clmd, float framenr); diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 70c6857f14b..e1b97362e08 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -145,9 +145,9 @@ void cloth_init ( ClothModifierData *clmd ) clmd->sim_parms->gravity [0] = 0.0; clmd->sim_parms->gravity [1] = 0.0; clmd->sim_parms->gravity [2] = -9.81; - clmd->sim_parms->structural = 100.0; - clmd->sim_parms->shear = 100.0; - clmd->sim_parms->bending = 1.0; + clmd->sim_parms->structural = 200.0; + clmd->sim_parms->shear = 200.0; + clmd->sim_parms->bending = 0.1; clmd->sim_parms->Cdis = 5.0; clmd->sim_parms->Cvi = 1.0; clmd->sim_parms->mass = 1.0f; @@ -161,6 +161,7 @@ void cloth_init ( ClothModifierData *clmd ) clmd->sim_parms->lastframe = 250; clmd->sim_parms->vgroup_mass = 0; clmd->sim_parms->lastcachedframe = 0; + clmd->sim_parms->editedframe = 0; clmd->coll_parms->self_friction = 5.0; clmd->coll_parms->friction = 10.0; @@ -485,7 +486,7 @@ DerivedMesh *CDDM_create_tearing ( ClothModifierData *clmd, DerivedMesh *dm ) int modifiers_indexInObject(Object *ob, ModifierData *md_seek); -static int cloth_read_cache(Object *ob, ClothModifierData *clmd, float framenr) +int cloth_read_cache(Object *ob, ClothModifierData *clmd, float framenr) { FILE *fp = NULL; int stack_index = -1; @@ -534,7 +535,7 @@ void cloth_clear_cache(Object *ob, ClothModifierData *clmd, float framenr) int stack_index = -1; /* clear cache if specific frame cleaning requested or cache is not protected */ - if((!(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_CCACHE_PROTECT)) || (framenr > 1.0)) + if((!(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_CCACHE_PROTECT)) || (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_CCACHE_FFREE)) { stack_index = modifiers_indexInObject(ob, (ModifierData *)clmd); @@ -545,6 +546,9 @@ void cloth_clear_cache(Object *ob, ClothModifierData *clmd, float framenr) { cloth_read_cache(ob, clmd, framenr); } + + /* delete cache free request */ + clmd->sim_parms->flags &= ~CLOTH_SIMSETTINGS_FLAG_CCACHE_FFREE; } void cloth_write_cache(Object *ob, ClothModifierData *clmd, float framenr) { diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 75201bbcea3..3d967655f70 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -694,7 +694,7 @@ void cloth_collision_static(ClothModifierData *clmd, CollisionModifierData *coll Normalize(collpair->normal); collpair->distance = distance; - BLI_linklist_append(&clmd->coll_parms->collision_list, collpair); + BLI_linklist_prepend(&clmd->coll_parms->collision_list, collpair); } else diff --git a/source/blender/makesdna/DNA_cloth_types.h b/source/blender/makesdna/DNA_cloth_types.h index d24ee2f0eb8..ab47d00d1b5 100644 --- a/source/blender/makesdna/DNA_cloth_types.h +++ b/source/blender/makesdna/DNA_cloth_types.h @@ -77,7 +77,7 @@ typedef struct SimulationSettings int lastframe; /* frame on which simulation stops */ int firstframe; /* frame on which simulation starts */ int lastcachedframe; - int pad3; + int editedframe; /* which frame is in buffer */ } SimulationSettings; diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index 79dc890c462..5ec89c6534e 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -2306,6 +2306,9 @@ void do_object_panels(unsigned short event) ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth); if(clmd) { + /* force freeing because user wants */ + clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_CCACHE_FFREE; + CFRA= 1; update_for_newframe_muted(); DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); @@ -2320,6 +2323,8 @@ void do_object_panels(unsigned short event) ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth); if(clmd) { + /* force freeing because user wants */ + clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_CCACHE_FFREE; cloth_clear_cache(ob, clmd, MAX2(1.0,G.scene->r.cfra)); // MAX2(1.0,G.scene->r.cfra + 1.0) allqueue(REDRAWBUTSOBJECT, 0); diff --git a/source/blender/src/editmesh.c b/source/blender/src/editmesh.c index 7b51d50ae7b..9c00d8b71bc 100644 --- a/source/blender/src/editmesh.c +++ b/source/blender/src/editmesh.c @@ -861,6 +861,8 @@ void make_editMesh() { cloth_enabled = 1; + clmd->sim_parms->editedframe = (float) G.scene->r.cfra; + /* inverse matrix is not uptodate... */ Mat4Invert ( G.obedit->imat, G.obedit->obmat ); } @@ -1092,7 +1094,7 @@ void load_editMesh(void) /* check if we have cache for this frame */ int stack_index = modifiers_indexInObject(G.obedit, (ModifierData *)clmd); - if(BKE_ptcache_id_exist((ID *)G.obedit, (float) G.scene->r.cfra, stack_index)) + if(BKE_ptcache_id_exist((ID *)G.obedit, clmd->sim_parms->editedframe, stack_index)) { cloth_enabled = 1; @@ -1108,9 +1110,11 @@ void load_editMesh(void) if(cloth_enabled) { + VECCOPY(temp, cloth->verts[i].x); VECCOPY(cloth->verts[i].x, eve->co); Mat4MulVecfl ( G.obedit->obmat, cloth->verts[i].x ); + /* // not physical correct but gives nicer results when commented VECSUB(temp, cloth->verts[i].x, temp); @@ -1154,7 +1158,15 @@ void load_editMesh(void) /* burn changes to cache */ if(cloth_enabled) - cloth_write_cache(G.obedit, clmd, (float) G.scene->r.cfra); + { + cloth_write_cache(G.obedit, clmd, clmd->sim_parms->editedframe); + + /* in this case we have to get the data for the requested frame */ + if(clmd->sim_parms->editedframe != (float) G.scene->r.cfra) + { + cloth_read_cache(G.obedit, clmd, (float) G.scene->r.cfra); + } + } /* the edges */ a= 0; |