Revision: 15131
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15131
Author:   genscher
Date:     2008-06-05 13:08:51 +0200 (Thu, 05 Jun 2008)

Log Message:
-----------
Collisions: enabling self collision quality setting again (request by Nudel)

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/collision.c

Modified: trunk/blender/source/blender/blenkernel/intern/collision.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/collision.c  2008-06-05 
10:52:52 UTC (rev 15130)
+++ trunk/blender/source/blender/blenkernel/intern/collision.c  2008-06-05 
11:08:51 UTC (rev 15131)
@@ -1399,7 +1399,7 @@
        Cloth *cloth=NULL;
        Object *coll_ob=NULL;
        BVHTree *cloth_bvh=NULL;
-       long i=0, j = 0, k = 0, numfaces = 0, numverts = 0;
+       long i=0, j = 0, k = 0, l = 0, numfaces = 0, numverts = 0;
        int result = 0, rounds = 0; // result counts applied collisions; ic is 
for debug output;
        ClothVertex *verts = NULL;
        int ret = 0, ret2 = 0;
@@ -1499,88 +1499,91 @@
                ////////////////////////////////////////////////////////////
                if ( clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF )
                {
-                       // TODO: add coll quality rounds again
-                       BVHTreeOverlap *overlap = NULL;
-
-                       collisions = 1;
-                       verts = cloth->verts; // needed for openMP
-
-                       numfaces = clmd->clothObject->numfaces;
-                       numverts = clmd->clothObject->numverts;
-
-                       verts = cloth->verts;
-
-                       if ( cloth->bvhselftree )
+                       for(l = 0; l < clmd->coll_parms->self_loop_count; l++)
                        {
-                               // search for overlapping collision pairs 
-                               overlap = BLI_bvhtree_overlap ( 
cloth->bvhselftree, cloth->bvhselftree, &result );
-
-// #pragma omp parallel for private(k, i, j) schedule(static)
-                               for ( k = 0; k < result; k++ )
+                               // TODO: add coll quality rounds again
+                               BVHTreeOverlap *overlap = NULL;
+       
+                               collisions = 1;
+                               verts = cloth->verts; // needed for openMP
+       
+                               numfaces = clmd->clothObject->numfaces;
+                               numverts = clmd->clothObject->numverts;
+       
+                               verts = cloth->verts;
+       
+                               if ( cloth->bvhselftree )
                                {
-                                       float temp[3];
-                                       float length = 0;
-                                       float mindistance;
-
-                                       i = overlap[k].indexA;
-                                       j = overlap[k].indexB;
-
-                                       mindistance = 
clmd->coll_parms->selfepsilon* ( cloth->verts[i].avg_spring_len + 
cloth->verts[j].avg_spring_len );
-
-                                       if ( clmd->sim_parms->flags & 
CLOTH_SIMSETTINGS_FLAG_GOAL )
+                                       // search for overlapping collision 
pairs 
+                                       overlap = BLI_bvhtree_overlap ( 
cloth->bvhselftree, cloth->bvhselftree, &result );
+       
+       // #pragma omp parallel for private(k, i, j) schedule(static)
+                                       for ( k = 0; k < result; k++ )
                                        {
-                                               if ( ( cloth->verts [i].flags & 
CLOTH_VERT_FLAG_PINNED )
-                                                       && ( cloth->verts 
[j].flags & CLOTH_VERT_FLAG_PINNED ) )
+                                               float temp[3];
+                                               float length = 0;
+                                               float mindistance;
+       
+                                               i = overlap[k].indexA;
+                                               j = overlap[k].indexB;
+       
+                                               mindistance = 
clmd->coll_parms->selfepsilon* ( cloth->verts[i].avg_spring_len + 
cloth->verts[j].avg_spring_len );
+       
+                                               if ( clmd->sim_parms->flags & 
CLOTH_SIMSETTINGS_FLAG_GOAL )
                                                {
-                                                       continue;
+                                                       if ( ( cloth->verts 
[i].flags & CLOTH_VERT_FLAG_PINNED )
+                                                               && ( 
cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED ) )
+                                                       {
+                                                               continue;
+                                                       }
                                                }
-                                       }
-
-                                       VECSUB ( temp, verts[i].tx, verts[j].tx 
);
-
-                                       if ( ( ABS ( temp[0] ) > mindistance ) 
|| ( ABS ( temp[1] ) > mindistance ) || ( ABS ( temp[2] ) > mindistance ) ) 
continue;
-
-                                       // check for adjacent points (i must be 
smaller j)
-                                       if ( BLI_edgehash_haskey ( 
cloth->edgehash, MIN2(i, j), MAX2(i, j) ) )
-                                       {
-                                               continue;
-                                       }
-
-                                       length = Normalize ( temp );
-
-                                       if ( length < mindistance )
-                                       {
-                                               float correction = mindistance 
- length;
-
-                                               if ( cloth->verts [i].flags & 
CLOTH_VERT_FLAG_PINNED )
+       
+                                               VECSUB ( temp, verts[i].tx, 
verts[j].tx );
+       
+                                               if ( ( ABS ( temp[0] ) > 
mindistance ) || ( ABS ( temp[1] ) > mindistance ) || ( ABS ( temp[2] ) > 
mindistance ) ) continue;
+       
+                                               // check for adjacent points (i 
must be smaller j)
+                                               if ( BLI_edgehash_haskey ( 
cloth->edgehash, MIN2(i, j), MAX2(i, j) ) )
                                                {
-                                                       VecMulf ( temp, 
-correction );
-                                                       VECADD ( verts[j].tx, 
verts[j].tx, temp );
+                                                       continue;
                                                }
-                                               else if ( cloth->verts 
[j].flags & CLOTH_VERT_FLAG_PINNED )
+       
+                                               length = Normalize ( temp );
+       
+                                               if ( length < mindistance )
                                                {
-                                                       VecMulf ( temp, 
correction );
-                                                       VECADD ( verts[i].tx, 
verts[i].tx, temp );
+                                                       float correction = 
mindistance - length;
+       
+                                                       if ( cloth->verts 
[i].flags & CLOTH_VERT_FLAG_PINNED )
+                                                       {
+                                                               VecMulf ( temp, 
-correction );
+                                                               VECADD ( 
verts[j].tx, verts[j].tx, temp );
+                                                       }
+                                                       else if ( cloth->verts 
[j].flags & CLOTH_VERT_FLAG_PINNED )
+                                                       {
+                                                               VecMulf ( temp, 
correction );
+                                                               VECADD ( 
verts[i].tx, verts[i].tx, temp );
+                                                       }
+                                                       else
+                                                       {
+                                                               VecMulf ( temp, 
-correction*0.5 );
+                                                               VECADD ( 
verts[j].tx, verts[j].tx, temp );
+       
+                                                               VECSUB ( 
verts[i].tx, verts[i].tx, temp );
+                                                       }
+                                                       ret = 1;
+                                                       ret2 += ret;
                                                }
                                                else
                                                {
-                                                       VecMulf ( temp, 
-correction*0.5 );
-                                                       VECADD ( verts[j].tx, 
verts[j].tx, temp );
-
-                                                       VECSUB ( verts[i].tx, 
verts[i].tx, temp );
+                                                       // check for 
approximated time collisions
                                                }
-                                               ret = 1;
-                                               ret2 += ret;
                                        }
-                                       else
-                                       {
-                                               // check for approximated time 
collisions
-                                       }
+       
+                                       if ( overlap )
+                                               MEM_freeN ( overlap );
+       
                                }
-
-                               if ( overlap )
-                                       MEM_freeN ( overlap );
-
                        }
                        
////////////////////////////////////////////////////////////
 


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to