diff options
author | Daniel Genrich <daniel.genrich@gmx.net> | 2008-03-20 21:28:40 +0300 |
---|---|---|
committer | Daniel Genrich <daniel.genrich@gmx.net> | 2008-03-20 21:28:40 +0300 |
commit | af8c68ddc4a67b9c329d15b540a1bc0f07d98838 (patch) | |
tree | d75f48c789b39b3feb9b8fa3b2fb56109dabb6dd | |
parent | 9362772ffda053186780e5f976d43a99f7cfd699 (diff) |
Cloth structure names update: Sorry about this commit, it will kill all your cloth settings in old files but I had to do it before release because naming convention was really bad in cloth (e.g. using SimulationSettings instead of ClothSimSettings in DNA). Same for some structure in CollisionModifier but with no sideeffects.
-rw-r--r-- | source/blender/blenkernel/BKE_collision.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/collision.c | 14 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/implicit.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/modifier.c | 29 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 15 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 4 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_cloth_types.h | 9 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_modifier_types.h | 10 |
8 files changed, 48 insertions, 38 deletions
diff --git a/source/blender/blenkernel/BKE_collision.h b/source/blender/blenkernel/BKE_collision.h index 463254b8e4f..3889721b8c9 100644 --- a/source/blender/blenkernel/BKE_collision.h +++ b/source/blender/blenkernel/BKE_collision.h @@ -172,7 +172,8 @@ void bvh_free ( BVH * bvh ); // checks two bounding volume hierarchies for potential collisions and returns some list with those -// update bounding volumes, needs updated positions in bvh->x +// update bounding volumes, needs updated positions in bvh->current_xold (static) +// and also bvh->current_x if moving==1 void bvh_update_from_mvert(BVH * bvh, MVert *x, unsigned int numverts, MVert *xnew, int moving); void bvh_update(BVH * bvh, int moving); diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index ef69da0ed86..403762e36bf 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -427,6 +427,7 @@ int cloth_collision_response_static(ClothModifierData *clmd, CollisionModifierDa float w1, w2, w3, u1, u2, u3; float v1[3], v2[3], relativeVelocity[3]; float magrelVel; + float epsilon2 = collmd->bvh->epsilon; cloth1 = clmd->clothObject; @@ -510,7 +511,7 @@ int cloth_collision_response_static(ClothModifierData *clmd, CollisionModifierDa // Apply repulse impulse if distance too short // I_r = -min(dt*kd, m(0,1d/dt - v_n)) - d = clmd->coll_parms->epsilon*8.0/9.0 - collpair->distance; + d = clmd->coll_parms->epsilon*8.0/9.0 + epsilon2*8.0/9.0 - collpair->distance; if((magrelVel < 0.1*d*clmd->sim_parms->stepsPerFrame) && (d > ALMOST_ZERO)) { repulse = MIN2(d*1.0/clmd->sim_parms->stepsPerFrame, 0.1*d*clmd->sim_parms->stepsPerFrame - magrelVel); @@ -557,6 +558,7 @@ void cloth_collision_static(ModifierData *md1, ModifierData *md2, CollisionTree ClothVertex *verts1=NULL; double distance = 0; float epsilon = clmd->coll_parms->epsilon; + float epsilon2 = ((CollisionModifierData *)md2)->bvh->epsilon; unsigned int i = 0; for(i = 0; i < 4; i++) @@ -641,9 +643,9 @@ void cloth_collision_static(ModifierData *md1, ModifierData *md2, CollisionTree verts1[collpair->ap1].txold, verts1[collpair->ap2].txold, verts1[collpair->ap3].txold, collmd->current_x[collpair->bp1].co, collmd->current_x[collpair->bp2].co, collmd->current_x[collpair->bp3].co, collpair->pa,collpair->pb,collpair->vector); #else // just be sure that we don't add anything - distance = 2.0 * (epsilon + ALMOST_ZERO); + distance = 2.0 * (epsilon + epsilon2 + ALMOST_ZERO); #endif - if (distance <= (epsilon + ALMOST_ZERO)) + if (distance <= (epsilon + epsilon2 + ALMOST_ZERO)) { // printf("dist: %f\n", (float)distance); @@ -968,10 +970,10 @@ int cloth_bvh_objcollisions_do(ClothModifierData * clmd, CollisionModifierData * verts = cloth->verts; - if (collmd->tree) + if (collmd->bvh) { /* get pointer to bounding volume hierarchy */ - BVH *coll_bvh = collmd->tree; + BVH *coll_bvh = collmd->bvh; /* move object to position (step) in time */ collision_move_object(collmd, step + dt, step); @@ -991,7 +993,7 @@ int cloth_bvh_objcollisions_do(ClothModifierData * clmd, CollisionModifierData * { result = 0; - if (collmd->tree) + if (collmd->bvh) result += cloth_collision_response_static(clmd, collmd); // apply impulses in parallel diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index f4b1a325712..4c39f36800c 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -37,13 +37,11 @@ #include "DNA_cloth_types.h" #include "DNA_scene_types.h" - #include "BKE_effect.h" #include "BKE_global.h" #include "BKE_cloth.h" #include "BKE_utildefines.h" - #ifdef _WIN32 #include <windows.h> static LARGE_INTEGER _itstart, _itend; diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 358068d5868..4aa69daa6d0 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -5037,8 +5037,8 @@ static void clothModifier_initData(ModifierData *md) { ClothModifierData *clmd = (ClothModifierData*) md; - clmd->sim_parms = MEM_callocN(sizeof(SimulationSettings), "cloth sim parms"); - clmd->coll_parms = MEM_callocN(sizeof(CollisionSettings), "cloth coll parms"); + clmd->sim_parms = MEM_callocN(sizeof(ClothSimSettings), "cloth sim parms"); + clmd->coll_parms = MEM_callocN(sizeof(ClothCollSettings), "cloth coll parms"); /* check for alloc failing */ if(!clmd->sim_parms || !clmd->coll_parms) @@ -5055,7 +5055,12 @@ static DerivedMesh *clothModifier_applyModifier(ModifierData *md, Object *ob, /* check for alloc failing */ if(!clmd->sim_parms || !clmd->coll_parms) - return derivedData; + { + clothModifier_initData(md); + + if(!clmd->sim_parms || !clmd->coll_parms) + return derivedData; + } result = clothModifier_do(clmd, ob, derivedData, useRenderParams, isFinalCalc); @@ -5090,7 +5095,7 @@ static void clothModifier_updateDepgraph( } } } - } + } } CustomDataMask clothModifier_requiredDataMask(ModifierData *md) @@ -5156,7 +5161,7 @@ static void collisionModifier_initData(ModifierData *md) collmd->current_v = NULL; collmd->time = -1; collmd->numverts = 0; - collmd->tree = NULL; + collmd->bvh = NULL; } static void collisionModifier_freeData(ModifierData *md) @@ -5165,8 +5170,8 @@ static void collisionModifier_freeData(ModifierData *md) if (collmd) { - if(collmd->tree) - bvh_free(collmd->tree); + if(collmd->bvh) + bvh_free(collmd->bvh); if(collmd->x) MEM_freeN(collmd->x); if(collmd->xnew) @@ -5188,7 +5193,7 @@ static void collisionModifier_freeData(ModifierData *md) collmd->current_v = NULL; collmd->time = -1; collmd->numverts = 0; - collmd->tree = NULL; + collmd->bvh = NULL; collmd->mfaces = NULL; } } @@ -5258,7 +5263,7 @@ static void collisionModifier_deformVerts( // TODO: epsilon // create bounding box hierarchy - collmd->tree = bvh_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->x, numverts, ob->pd->pdef_sbift); + collmd->bvh = bvh_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->x, numverts, ob->pd->pdef_sboft); collmd->time = current_time; } @@ -5281,14 +5286,14 @@ static void collisionModifier_deformVerts( memcpy(collmd->current_x, collmd->x, numverts*sizeof(MVert)); /* happens on file load (ONLY when i decomment changes in readfile.c */ - if(!collmd->tree) + if(!collmd->bvh) { - collmd->tree = bvh_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->current_x, numverts, ob->pd->pdef_sbift); + collmd->bvh = bvh_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->current_x, numverts, ob->pd->pdef_sboft); } else { // recalc static bounding boxes - bvh_update_from_mvert(collmd->tree, collmd->current_x, numverts, NULL, 0); + bvh_update_from_mvert(collmd->bvh, collmd->current_x, numverts, NULL, 0); } collmd->time = current_time; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index ee4cb66a6e0..330ae84f922 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3051,11 +3051,14 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) clmd->sim_parms= newdataadr(fd, clmd->sim_parms); clmd->coll_parms= newdataadr(fd, clmd->coll_parms); - clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_LOADED; - clmd->sim_parms->flags &= ~CLOTH_SIMSETTINGS_FLAG_EDITMODE; - - if(clmd->sim_parms->presets > 10) - clmd->sim_parms->presets = 0; + if(clmd->sim_parms) + { + clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_LOADED; + clmd->sim_parms->flags &= ~CLOTH_SIMSETTINGS_FLAG_EDITMODE; + + if(clmd->sim_parms->presets > 10) + clmd->sim_parms->presets = 0; + } } else if (md->type==eModifierType_Collision) { @@ -3080,7 +3083,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) collmd->current_v = NULL; collmd->time = -1; collmd->numverts = 0; - collmd->tree = NULL; + collmd->bvh = NULL; collmd->mfaces = NULL; } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index a4c91d77f5e..7979dd0b33f 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -859,8 +859,8 @@ static void write_modifiers(WriteData *wd, ListBase *modbase) else if(md->type==eModifierType_Cloth) { ClothModifierData *clmd = (ClothModifierData*) md; - writestruct(wd, DATA, "SimulationSettings", 1, clmd->sim_parms); - writestruct(wd, DATA, "CollisionSettings", 1, clmd->coll_parms); + writestruct(wd, DATA, "ClothSimSettings", 1, clmd->sim_parms); + writestruct(wd, DATA, "ClothCollSettings", 1, clmd->coll_parms); } else if (md->type==eModifierType_Collision) { diff --git a/source/blender/makesdna/DNA_cloth_types.h b/source/blender/makesdna/DNA_cloth_types.h index 4ba1f4f02e8..53fbd1ff72c 100644 --- a/source/blender/makesdna/DNA_cloth_types.h +++ b/source/blender/makesdna/DNA_cloth_types.h @@ -44,7 +44,8 @@ * as in stepsPerFrame comapred to the time step in the paper, I've used * variables with different names to minimize confusion. **/ -typedef struct SimulationSettings + +typedef struct ClothSimSettings { short vgroup_mass; /* optional vertexgroup name for assigning weight.*/ short vgroup_struct; /* vertex group for scaling structural stiffness */ @@ -87,10 +88,10 @@ typedef struct SimulationSettings short pad; int pad2; } -SimulationSettings; +ClothSimSettings; -typedef struct CollisionSettings +typedef struct ClothCollSettings { float epsilon; /* min distance for collisions. */ float self_friction; /* Fiction/damping with self contact. */ @@ -101,7 +102,7 @@ typedef struct CollisionSettings int flags; /* collision flags defined in BKE_cloth.h */ float selfepsilon; /* for selfcollision */ } -CollisionSettings; +ClothCollSettings; /** diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index dd1d8eb01b3..c62d012643a 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -369,8 +369,8 @@ typedef struct ClothModifierData { ModifierData modifier; struct Cloth *clothObject; /* The internal data structure for cloth. */ - struct SimulationSettings *sim_parms; /* definition is in DNA_cloth_types.h */ - struct CollisionSettings *coll_parms; /* definition is in DNA_cloth_types.h */ + struct ClothSimSettings *sim_parms; /* definition is in DNA_cloth_types.h */ + struct ClothCollSettings *coll_parms; /* definition is in DNA_cloth_types.h */ } ClothModifierData; typedef struct CollisionModifierData { @@ -381,15 +381,15 @@ typedef struct CollisionModifierData { struct MVert *xold; /* unsued atm, but was discussed during sprint */ struct MVert *current_xnew; /* new position at the actual inter-frame step */ struct MVert *current_x; /* position at the actual inter-frame step */ - struct MVert *current_v; /* position at the actual inter-frame step */ + struct MVert *current_v; /* (xnew - x) at the actual inter-frame step */ struct MFace *mfaces; /* object face data */ unsigned int numverts; unsigned int numfaces; int pad; - float time; - struct BVH *tree; /* collision tree for this cloth object */ + float time; /* cfra time of modifier */ + struct BVH *bvh; /* bounding volume hierarchy for this cloth object */ } CollisionModifierData; typedef enum { |