New particle collisions code:
[blender.git] / source / blender / modifiers / intern / MOD_collision.c
index 2ed66f2374b2091001c1d8be611f98dc54b5ae93..83ba8a12163c63d89b90e251eb9dc6598917e2d3 100644 (file)
@@ -64,7 +64,7 @@ static void initData(ModifierData *md)
        collmd->current_x = NULL;
        collmd->current_xnew = NULL;
        collmd->current_v = NULL;
-       collmd->time = -1000;
+       collmd->time_x = collmd->time_xnew = -1000;
        collmd->numverts = 0;
        collmd->bvhtree = NULL;
 }
@@ -95,7 +95,7 @@ static void freeData(ModifierData *md)
                collmd->current_x = NULL;
                collmd->current_xnew = NULL;
                collmd->current_v = NULL;
-               collmd->time = -1000;
+               collmd->time_x = collmd->time_xnew = -1000;
                collmd->numverts = 0;
                collmd->bvhtree = NULL;
                collmd->mfaces = NULL;
@@ -139,11 +139,11 @@ static void deformVerts(ModifierData *md, Object *ob,
                current_time = BKE_curframe(md->scene);
                
                if(G.rt > 0)
-                       printf("current_time %f, collmd->time %f\n", current_time, collmd->time);
+                       printf("current_time %f, collmd->time_xnew %f\n", current_time, collmd->time_xnew);
                
                numverts = dm->getNumVerts ( dm );
                
-               if((current_time > collmd->time)|| (BKE_ptcache_get_continue_physics()))
+               if((current_time > collmd->time_xnew)|| (BKE_ptcache_get_continue_physics()))
                {
                        unsigned int i;
 
@@ -151,7 +151,7 @@ static void deformVerts(ModifierData *md, Object *ob,
                        if(collmd->x && (numverts != collmd->numverts))
                                freeData((ModifierData *)collmd);
                        
-                       if(collmd->time == -1000) // first time
+                       if(collmd->time_xnew == -1000) // first time
                        {
                                collmd->x = dm->dupVertArray(dm); // frame start position
                                
@@ -174,7 +174,7 @@ static void deformVerts(ModifierData *md, Object *ob,
                                // create bounding box hierarchy
                                collmd->bvhtree = bvhtree_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->x, numverts, ob->pd->pdef_sboft);
                                
-                               collmd->time = current_time;
+                               collmd->time_x = collmd->time_xnew = current_time;
                        }
                        else if(numverts == collmd->numverts)
                        {
@@ -182,6 +182,7 @@ static void deformVerts(ModifierData *md, Object *ob,
                                tempVert = collmd->x;
                                collmd->x = collmd->xnew;
                                collmd->xnew = tempVert;
+                               collmd->time_x = collmd->time_xnew;
                                
                                memcpy(collmd->xnew, dm->getVertArray(dm), numverts*sizeof(MVert));
                                
@@ -216,7 +217,7 @@ static void deformVerts(ModifierData *md, Object *ob,
                                        bvhtree_update_from_mvert ( collmd->bvhtree, collmd->mfaces, collmd->numfaces, collmd->current_x, collmd->current_xnew, collmd->numverts, 1 );
                                }
                                
-                               collmd->time = current_time;
+                               collmd->time_xnew = current_time;
                        }
                        else if(numverts != collmd->numverts)
                        {
@@ -224,7 +225,7 @@ static void deformVerts(ModifierData *md, Object *ob,
                        }
                        
                }
-               else if(current_time < collmd->time)
+               else if(current_time < collmd->time_xnew)
                {       
                        freeData((ModifierData *)collmd);
                }