diff --git a/source/blender/blenkernel/BKE_collisions.h b/source/blender/blenkernel/BKE_collisions.h index edd86f0f5f6..7c9ced262a8 100644 --- a/source/blender/blenkernel/BKE_collisions.h +++ b/source/blender/blenkernel/BKE_collisions.h @@ -64,8 +64,8 @@ typedef struct BVH { unsigned int numfaces; unsigned int numverts; - MVert *x; // position of verts at time n - MVert *xold; // position of verts at time n-1 + MVert *xnew; // position of verts at time n + MVert *x; // position of verts at time n-1 MFace *mfaces; // just a pointer to the original datastructure struct LinkNode *tree; TreeNode *root; // TODO: saving the root --> is this really needed? YES! diff --git a/source/blender/blenkernel/intern/kdop.c b/source/blender/blenkernel/intern/kdop.c index 8b2540c7d8a..1e17ee4f03e 100644 --- a/source/blender/blenkernel/intern/kdop.c +++ b/source/blender/blenkernel/intern/kdop.c @@ -387,7 +387,7 @@ void bvh_calc_DOP_hull_from_faces(BVH * bvh, Tree **tri, int numfaces, float *bv void bvh_calc_DOP_hull_static(BVH * bvh, Tree **tri, int numfaces, float *bv) { - MVert *tempMVert = bvh->xold; + MVert *tempMVert = bvh->x; MFace *tempMFace = bvh->mfaces; float *tempBV = bv; float newminmax; @@ -426,8 +426,8 @@ void bvh_calc_DOP_hull_static(BVH * bvh, Tree **tri, int numfaces, float *bv) void bvh_calc_DOP_hull_moving(BVH * bvh, Tree **tri, int numfaces, float *bv) { - MVert *tempMVert = bvh->xold; - MVert *tempMVert2 = bvh->x; + MVert *tempMVert = bvh->x; + MVert *tempMVert2 = bvh->xnew; MFace *tempMFace = bvh->mfaces; float *tempBV = bv; float newminmax; @@ -538,7 +538,7 @@ static void bvh_div_env_node(BVH * bvh, TreeNode *tree, Tree **face_list, unsign return; } -BVH *bvh_build (DerivedMesh *dm, MVert *x, MVert *xold, unsigned int numverts, float epsilon) +BVH *bvh_build (DerivedMesh *dm, MVert *x, MVert *xnew, unsigned int numverts, float epsilon) { unsigned int i = 0, j = 0, k = 0; Tree **face_list=NULL; @@ -569,8 +569,8 @@ BVH *bvh_build (DerivedMesh *dm, MVert *x, MVert *xold, unsigned int numverts, f mface = bvh->mfaces = dm->getFaceArray(dm); bvh->numverts = numverts; + bvh->xnew = xnew; bvh->x = x; - bvh->xold = xold; tree = (Tree *)MEM_callocN(sizeof(Tree), "Tree"); // TODO: check succesfull alloc BLI_linklist_append(&bvh->tree, tree); @@ -774,7 +774,7 @@ void bvh_join(Tree * tree) } // update static bvh -// needs new positions in bvh->x, bvh->xold +// needs new positions in bvh->x, bvh->xnew void bvh_update(DerivedMesh *dm, BVH * bvh, int moving) { TreeNode *leaf, *parent; diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 59bd4b8253d..cb7fccd11c1 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -4956,7 +4956,7 @@ static void collisionModifier_initData(ModifierData *md) CollisionModifierData *collmd = (CollisionModifierData*) md; collmd->x = NULL; - collmd->xold = NULL; + collmd->xnew = NULL; collmd->time = -1; collmd->numverts = 0; collmd->tree = NULL; @@ -4972,11 +4972,11 @@ static void collisionModifier_freeData(ModifierData *md) bvh_free(collmd->tree); if(collmd->x) MEM_freeN(collmd->x); - if(collmd->xold) - MEM_freeN(collmd->xold); + if(collmd->xnew) + MEM_freeN(collmd->xnew); collmd->x = NULL; - collmd->xold = NULL; + collmd->xnew = NULL; collmd->time = -1; collmd->numverts = 0; collmd->tree = NULL; @@ -5018,26 +5018,26 @@ static void collisionModifier_deformVerts( if(collmd->time == -1) // first time { collmd->x = dm->dupVertArray(dm); - collmd->xold = dm->dupVertArray(dm); + collmd->xnew = dm->dupVertArray(dm); collmd->numverts = numverts; // TODO: epsilon // create bounding box hierarchy - collmd->tree = bvh_build(dm, collmd->x, collmd->xold, numverts, 0.01); + collmd->tree = bvh_build(dm, collmd->x, collmd->xnew, numverts, 0.01); } else if(numverts == collmd->numverts) { // put positions to old positions - tempVert = collmd->xold; - collmd->xold = collmd->x; - collmd->x = tempVert; + tempVert = collmd->x; + collmd->x = collmd->xnew; + collmd->xnew = tempVert; - memcpy(collmd->x, dm->getVertArray(dm), numverts*sizeof(MVert)); + memcpy(collmd->xnew, dm->getVertArray(dm), numverts*sizeof(MVert)); for ( i = 0; i < numverts; i++ ) { // we save global positions - Mat4MulVecfl ( ob->obmat, collmd->x[i].co ); + Mat4MulVecfl ( ob->obmat, collmd->xnew[i].co ); } bvh_update(dm, collmd->tree, 0); // recalc static bounding boxes diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 83bae60df30..99f0885b435 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2888,6 +2888,15 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) printf ("direct_link_modifiers: read cloth baked_data.\n"); } } + else if (md->type==eModifierType_Collision) { + CollisionModifierData *collmd = (CollisionModifierData*) md; + + collmd->x = NULL; + collmd->xnew = NULL; + collmd->time = -1; + collmd->numverts = 0; + collmd->tree = NULL; + } else if (md->type==eModifierType_Hook) { HookModifierData *hmd = (HookModifierData*) md; diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index e6e73ea7d07..81e27afbac4 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -351,7 +351,7 @@ typedef struct CollisionModifierData { ModifierData modifier; struct MVert *x; - struct MVert *xold; + struct MVert *xnew; unsigned int numverts; float time;