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
diff options
context:
space:
mode:
authorDaniel Genrich <daniel.genrich@gmx.net>2008-01-25 11:55:27 +0300
committerDaniel Genrich <daniel.genrich@gmx.net>2008-01-25 11:55:27 +0300
commite7f5d077810004467066d627f34d433a61e68fb2 (patch)
treea9c9aff9f0875fc8431587eba62f42cef08c42f1 /source/blender/blenkernel/intern/cloth.c
parent7054664d2a52c89bc3d03f518aa0fd1d22990dd9 (diff)
New: load cached data on file load; Fixed: Don't destroy cache on fileload, calculate normals correctly, don't reset all data when pressing partial free, making also cache free buttons available when cache is protected, duplicating cloth with shift-d should work properly now
Diffstat (limited to 'source/blender/blenkernel/intern/cloth.c')
-rw-r--r--source/blender/blenkernel/intern/cloth.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index f22fd28d96e..70c6857f14b 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -153,7 +153,7 @@ void cloth_init ( ClothModifierData *clmd )
clmd->sim_parms->mass = 1.0f;
clmd->sim_parms->stepsPerFrame = 5;
clmd->sim_parms->sim_time = 1.0;
- clmd->sim_parms->flags = CLOTH_SIMSETTINGS_FLAG_RESET;
+ clmd->sim_parms->flags = CLOTH_SIMSETTINGS_FLAG_NEW;
clmd->sim_parms->solver_type = 0;
clmd->sim_parms->preroll = 0;
clmd->sim_parms->maxspringlen = 10;
@@ -166,7 +166,7 @@ void cloth_init ( ClothModifierData *clmd )
clmd->coll_parms->friction = 10.0;
clmd->coll_parms->loop_count = 1;
clmd->coll_parms->epsilon = 0.01f;
- clmd->coll_parms->flags = CLOTH_COLLISIONSETTINGS_FLAG_ENABLED;
+ clmd->coll_parms->flags = CLOTH_COLLSETTINGS_FLAG_ENABLED;
/* These defaults are copied from softbody.c's
* softbody_calc_forces() function.
@@ -533,7 +533,8 @@ void cloth_clear_cache(Object *ob, ClothModifierData *clmd, float framenr)
{
int stack_index = -1;
- if(!(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_CCACHE_PROTECT))
+ /* 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))
{
stack_index = modifiers_indexInObject(ob, (ModifierData *)clmd);
@@ -635,8 +636,6 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd,Object *ob, DerivedMesh *d
return result;
}
- // printf("ct: %f, st: %f, r.cfra: %f, dt: %f\n", current_time, clmd->sim_parms->sim_time, ( float ) G.scene->r.cfra, deltaTime);
-
// unused in the moment, calculated seperately in implicit.c
clmd->sim_parms->dt = 1.0f / clmd->sim_parms->stepsPerFrame;
@@ -659,6 +658,8 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd,Object *ob, DerivedMesh *d
{
cloth_clear_cache(ob, clmd, 0);
+ // printf("v1: %d, v2: %d\n", numverts, clmd->clothObject->numverts);
+
if ( !cloth_from_object ( ob, clmd, result, framenr ) )
return result;
@@ -718,6 +719,9 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd,Object *ob, DerivedMesh *d
else
{
cloth_clear_cache(ob, clmd, 0);
+
+ if ( !cloth_from_object ( ob, clmd, result, framenr ) )
+ return result;
}
}
@@ -743,9 +747,9 @@ void cloth_free_modifier ( Object *ob, ClothModifierData *clmd )
cloth_clear_cache ( ob, clmd, 0 );
// If our solver provides a free function, call it
- if ( cloth->old_solver_type < 255 && solvers [cloth->old_solver_type].free )
+ if ( solvers [clmd->sim_parms->solver_type].free )
{
- solvers [cloth->old_solver_type].free ( clmd );
+ solvers [clmd->sim_parms->solver_type].free ( clmd );
}
// Free the verts.
@@ -805,9 +809,9 @@ void cloth_free_modifier_extern ( ClothModifierData *clmd )
if ( cloth )
{
// If our solver provides a free function, call it
- if ( cloth->old_solver_type < 255 && solvers [cloth->old_solver_type].free )
+ if ( solvers [clmd->sim_parms->solver_type].free )
{
- solvers [cloth->old_solver_type].free ( clmd );
+ solvers [clmd->sim_parms->solver_type].free ( clmd );
}
// Free the verts.
@@ -972,7 +976,9 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
// If we have a clothObject, free it.
if ( clmd->clothObject != NULL )
+ {
cloth_free_modifier ( ob, clmd );
+ }
// Allocate a new cloth object.
clmd->clothObject = MEM_callocN ( sizeof ( Cloth ), "cloth" );
@@ -1041,8 +1047,9 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
solvers [clmd->sim_parms->solver_type].init ( ob, clmd );
clmd->clothObject->tree = bvh_build_from_cloth ( clmd, clmd->coll_parms->epsilon );
-
- cloth_write_cache(ob, clmd, framenr-1);
+
+ if(!cloth_read_cache(ob, clmd, framenr))
+ cloth_write_cache(ob, clmd, framenr);
return 1;
}