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-03-20 21:28:40 +0300
committerDaniel Genrich <daniel.genrich@gmx.net>2008-03-20 21:28:40 +0300
commitaf8c68ddc4a67b9c329d15b540a1bc0f07d98838 (patch)
treed75f48c789b39b3feb9b8fa3b2fb56109dabb6dd /source/blender/blenkernel
parent9362772ffda053186780e5f976d43a99f7cfd699 (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.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_collision.h3
-rw-r--r--source/blender/blenkernel/intern/collision.c14
-rw-r--r--source/blender/blenkernel/intern/implicit.c2
-rw-r--r--source/blender/blenkernel/intern/modifier.c29
4 files changed, 27 insertions, 21 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;