Revision: 14356
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14356
Author:   genscher
Date:     2008-04-08 14:55:35 +0200 (Tue, 08 Apr 2008)

Log Message:
-----------
Cloth bugfix: used old dm instead of new created result derivedmesh; Code 
cleanup + deactivation of unsued selfcollision code in kdop.c + little speedup 
there

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

Modified: trunk/blender/source/blender/blenkernel/intern/cloth.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/cloth.c      2008-04-08 
11:57:10 UTC (rev 14355)
+++ trunk/blender/source/blender/blenkernel/intern/cloth.c      2008-04-08 
12:55:35 UTC (rev 14356)
@@ -423,9 +423,9 @@
        numverts = result->getNumVerts(result);
        numedges = result->getNumEdges(result);
        numfaces = result->getNumFaces(result);
-       mvert = dm->getVertArray(result);
-       medge = dm->getEdgeArray(result);
-       mface = dm->getFaceArray(result);
+       mvert = result->getVertArray(result);
+       medge = result->getEdgeArray(result);
+       mface = result->getFaceArray(result);
        
        /* check if cache is active / if file is already saved */
        /*

Modified: trunk/blender/source/blender/blenkernel/intern/collision.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/collision.c  2008-04-08 
11:57:10 UTC (rev 14355)
+++ trunk/blender/source/blender/blenkernel/intern/collision.c  2008-04-08 
12:55:35 UTC (rev 14356)
@@ -1,6 +1,6 @@
-/*  collision.c      
-* 
+/*  collision.c
 *
+*
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
 *
 * This program is free software; you can redistribute it and/or
@@ -36,7 +36,7 @@
 
 #include "DNA_group_types.h"
 #include "DNA_object_types.h"
-#include "DNA_cloth_types.h"   
+#include "DNA_cloth_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_scene_types.h"
 
@@ -57,70 +57,70 @@
 ***********************************/
 
 /* step is limited from 0 (frame start position) to 1 (frame end position) */
-void collision_move_object(CollisionModifierData *collmd, float step, float 
prevstep)
+void collision_move_object ( CollisionModifierData *collmd, float step, float 
prevstep )
 {
        float tv[3] = {0,0,0};
        unsigned int i = 0;
-       
+
        for ( i = 0; i < collmd->numverts; i++ )
        {
-               VECSUB(tv, collmd->xnew[i].co, collmd->x[i].co);
-               VECADDS(collmd->current_x[i].co, collmd->x[i].co, tv, prevstep);
-               VECADDS(collmd->current_xnew[i].co, collmd->x[i].co, tv, step);
-               VECSUB(collmd->current_v[i].co, collmd->current_xnew[i].co, 
collmd->current_x[i].co);
+               VECSUB ( tv, collmd->xnew[i].co, collmd->x[i].co );
+               VECADDS ( collmd->current_x[i].co, collmd->x[i].co, tv, 
prevstep );
+               VECADDS ( collmd->current_xnew[i].co, collmd->x[i].co, tv, step 
);
+               VECSUB ( collmd->current_v[i].co, collmd->current_xnew[i].co, 
collmd->current_x[i].co );
        }
-       bvh_update_from_mvert(collmd->bvh, collmd->current_x, collmd->numverts, 
collmd->current_xnew, 1);
+       bvh_update_from_mvert ( collmd->bvh, collmd->current_x, 
collmd->numverts, collmd->current_xnew, 1 );
 }
 
 /* build bounding volume hierarchy from mverts (see kdop.c for whole BVH code) 
*/
-BVH *bvh_build_from_mvert (MFace *mfaces, unsigned int numfaces, MVert *x, 
unsigned int numverts, float epsilon)
+BVH *bvh_build_from_mvert ( MFace *mfaces, unsigned int numfaces, MVert *x, 
unsigned int numverts, float epsilon )
 {
        BVH *bvh=NULL;
-       
-       bvh = MEM_callocN(sizeof(BVH), "BVH");
-       if (bvh == NULL) 
+
+       bvh = MEM_callocN ( sizeof ( BVH ), "BVH" );
+       if ( bvh == NULL )
        {
-               printf("bvh: Out of memory.\n");
+               printf ( "bvh: Out of memory.\n" );
                return NULL;
        }
-       
+
        // in the moment, return zero if no faces there
-       if(!numfaces)
+       if ( !numfaces )
                return NULL;
 
        bvh->epsilon = epsilon;
        bvh->numfaces = numfaces;
        bvh->mfaces = mfaces;
-       
+
        // we have no faces, we save seperate points
-       if(!mfaces)
+       if ( !mfaces )
        {
                bvh->numfaces = numverts;
        }
 
        bvh->numverts = numverts;
-       bvh->current_x = MEM_dupallocN(x);
-       
-       bvh_build(bvh);
-       
+       bvh->current_x = MEM_dupallocN ( x );
+
+       bvh_build ( bvh );
+
        return bvh;
 }
 
-void bvh_update_from_mvert(BVH * bvh, MVert *x, unsigned int numverts, MVert 
*xnew, int moving)
+void bvh_update_from_mvert ( BVH * bvh, MVert *x, unsigned int numverts, MVert 
*xnew, int moving )
 {
-       if(!bvh)
+       if ( !bvh )
                return;
-       
-       if(numverts!=bvh->numverts)
+
+       if ( numverts!=bvh->numverts )
                return;
-       
-       if(x)
-               memcpy(bvh->current_xold, x, sizeof(MVert) * numverts);
-       
-       if(xnew)
-               memcpy(bvh->current_x, xnew, sizeof(MVert) * numverts);
-       
-       bvh_update(bvh, moving);
+
+       if ( x )
+               memcpy ( bvh->current_xold, x, sizeof ( MVert ) * numverts );
+
+       if ( xnew )
+               memcpy ( bvh->current_x, xnew, sizeof ( MVert ) * numverts );
+
+       bvh_update ( bvh, moving );
 }
 
 /***********************************
@@ -136,10 +136,10 @@
 /* DG: debug hint! don't forget that all functions were "fabs", "sinf", etc 
before */
 #define mySWAP(a,b) { float tmp = b ; b = a ; a = tmp ; }
 
-int gsl_poly_solve_cubic (float a, float b, float c, float *x0, float *x1, 
float *x2)
+int gsl_poly_solve_cubic ( float a, float b, float c, float *x0, float *x1, 
float *x2 )
 {
-       float q = (a * a - 3 * b);
-       float r = (2 * a * a * a - 9 * a * b + 27 * c);
+       float q = ( a * a - 3 * b );
+       float r = ( 2 * a * a * a - 9 * a * b + 27 * c );
 
        float Q = q / 9;
        float R = r / 54;
@@ -150,25 +150,25 @@
        float CR2 = 729 * r * r;
        float CQ3 = 2916 * q * q * q;
 
-       if (R == 0 && Q == 0)
+       if ( R == 0 && Q == 0 )
        {
                *x0 = - a / 3 ;
                *x1 = - a / 3 ;
                *x2 = - a / 3 ;
                return 3 ;
        }
-       else if (CR2 == CQ3) 
+       else if ( CR2 == CQ3 )
        {
-         /* this test is actually R2 == Q3, written in a form suitable
-               for exact computation with integers */
+               /* this test is actually R2 == Q3, written in a form suitable
+                 for exact computation with integers */
 
-         /* Due to finite precision some float roots may be missed, and
-               considered to be a pair of complex roots z = x +/- epsilon i
-               close to the real axis. */
+               /* Due to finite precision some float roots may be missed, and
+                 considered to be a pair of complex roots z = x +/- epsilon i
+                 close to the real axis. */
 
-               float sqrtQ = sqrt (Q);
+               float sqrtQ = sqrt ( Q );
 
-               if (R > 0)
+               if ( R > 0 )
                {
                        *x0 = -2 * sqrtQ  - a / 3;
                        *x1 = sqrtQ - a / 3;
@@ -182,35 +182,35 @@
                }
                return 3 ;
        }
-       else if (CR2 < CQ3) /* equivalent to R2 < Q3 */
+       else if ( CR2 < CQ3 ) /* equivalent to R2 < Q3 */
        {
-               float sqrtQ = sqrt (Q);
+               float sqrtQ = sqrt ( Q );
                float sqrtQ3 = sqrtQ * sqrtQ * sqrtQ;
-               float theta = acos (R / sqrtQ3);
+               float theta = acos ( R / sqrtQ3 );
                float norm = -2 * sqrtQ;
-               *x0 = norm * cos (theta / 3) - a / 3;
-               *x1 = norm * cos ((theta + 2.0 * M_PI) / 3) - a / 3;
-               *x2 = norm * cos ((theta - 2.0 * M_PI) / 3) - a / 3;
-      
+               *x0 = norm * cos ( theta / 3 ) - a / 3;
+               *x1 = norm * cos ( ( theta + 2.0 * M_PI ) / 3 ) - a / 3;
+               *x2 = norm * cos ( ( theta - 2.0 * M_PI ) / 3 ) - a / 3;
+
                /* Sort *x0, *x1, *x2 into increasing order */
 
-               if (*x0 > *x1)
-                       mySWAP(*x0, *x1) ;
-      
-               if (*x1 > *x2)
+               if ( *x0 > *x1 )
+                       mySWAP ( *x0, *x1 ) ;
+
+               if ( *x1 > *x2 )
                {
-                       mySWAP(*x1, *x2) ;
-          
-                       if (*x0 > *x1)
-                               mySWAP(*x0, *x1) ;
+                       mySWAP ( *x1, *x2 ) ;
+
+                       if ( *x0 > *x1 )
+                               mySWAP ( *x0, *x1 ) ;
                }
-      
+
                return 3;
        }
        else
        {
-               float sgnR = (R >= 0 ? 1 : -1);
-               float A = -sgnR * pow (ABS (R) + sqrt (R2 - Q3), 1.0/3.0);
+               float sgnR = ( R >= 0 ? 1 : -1 );
+               float A = -sgnR * pow ( ABS ( R ) + sqrt ( R2 - Q3 ), 1.0/3.0 );
                float B = Q / A ;
                *x0 = A + B - a / 3;
                return 1;
@@ -223,31 +223,31 @@
  *
  * copied from GSL
  */
-int gsl_poly_solve_quadratic (float a, float b, float c,  float *x0, float *x1)
+int gsl_poly_solve_quadratic ( float a, float b, float c,  float *x0, float 
*x1 )
 {
        float disc = b * b - 4 * a * c;
 
-       if (disc > 0)
+       if ( disc > 0 )
        {
-               if (b == 0)
+               if ( b == 0 )
                {
-                       float r = ABS (0.5 * sqrt (disc) / a);
+                       float r = ABS ( 0.5 * sqrt ( disc ) / a );
                        *x0 = -r;
                        *x1 =  r;
                }
                else
                {
-                       float sgnb = (b > 0 ? 1 : -1);
-                       float temp = -0.5 * (b + sgnb * sqrt (disc));
+                       float sgnb = ( b > 0 ? 1 : -1 );
+                       float temp = -0.5 * ( b + sgnb * sqrt ( disc ) );
                        float r1 = temp / a ;
                        float r2 = c / temp ;
 
-                       if (r1 < r2) 
+                       if ( r1 < r2 )
                        {
                                *x0 = r1 ;
                                *x1 = r2 ;
-                       } 
-                       else 
+                       }
+                       else
                        {
                                *x0 = r2 ;
                                *x1 = r1 ;
@@ -255,7 +255,7 @@
                }
                return 2;
        }
-       else if (disc == 0) 
+       else if ( disc == 0 )
        {
                *x0 = -0.5 * b / a ;
                *x1 = -0.5 * b / a ;
@@ -274,56 +274,56 @@
  *     page 4, left column
  */
 
-int cloth_get_collision_time(float a[3], float b[3], float c[3], float d[3], 
float e[3], float f[3], float solution[3]) 
+int cloth_get_collision_time ( float a[3], float b[3], float c[3], float d[3], 
float e[3], float f[3], float solution[3] )
 {
        int num_sols = 0;
-       
+
        float g = -a[2] * c[1] * e[0] + a[1] * c[2] * e[0] +
-                       a[2] * c[0] * e[1] - a[0] * c[2] * e[1] -
-                       a[1] * c[0] * e[2] + a[0] * c[1] * e[2];
+                 a[2] * c[0] * e[1] - a[0] * c[2] * e[1] -
+                 a[1] * c[0] * e[2] + a[0] * c[1] * e[2];
 
        float h = -b[2] * c[1] * e[0] + b[1] * c[2] * e[0] - a[2] * d[1] * e[0] 
+
-                       a[1] * d[2] * e[0] + b[2] * c[0] * e[1] - b[0] * c[2] * 
e[1] +
-                       a[2] * d[0] * e[1] - a[0] * d[2] * e[1] - b[1] * c[0] * 
e[2] +
-                       b[0] * c[1] * e[2] - a[1] * d[0] * e[2] + a[0] * d[1] * 
e[2] -
-                       a[2] * c[1] * f[0] + a[1] * c[2] * f[0] + a[2] * c[0] * 
f[1] -
-                       a[0] * c[2] * f[1] - a[1] * c[0] * f[2] + a[0] * c[1] * 
f[2];
+                 a[1] * d[2] * e[0] + b[2] * c[0] * e[1] - b[0] * c[2] * e[1] +
+                 a[2] * d[0] * e[1] - a[0] * d[2] * e[1] - b[1] * c[0] * e[2] +
+                 b[0] * c[1] * e[2] - a[1] * d[0] * e[2] + a[0] * d[1] * e[2] -
+                 a[2] * c[1] * f[0] + a[1] * c[2] * f[0] + a[2] * c[0] * f[1] -
+                 a[0] * c[2] * f[1] - a[1] * c[0] * f[2] + a[0] * c[1] * f[2];
 
        float i = -b[2] * d[1] * e[0] + b[1] * d[2] * e[0] +
-                       b[2] * d[0] * e[1] - b[0] * d[2] * e[1] -
-                       b[1] * d[0] * e[2] + b[0] * d[1] * e[2] -
-                       b[2] * c[1] * f[0] + b[1] * c[2] * f[0] -
-                       a[2] * d[1] * f[0] + a[1] * d[2] * f[0] +
-                       b[2] * c[0] * f[1] - b[0] * c[2] * f[1] + 
-                       a[2] * d[0] * f[1] - a[0] * d[2] * f[1] -
-                       b[1] * c[0] * f[2] + b[0] * c[1] * f[2] -
-                       a[1] * d[0] * f[2] + a[0] * d[1] * f[2];
+                 b[2] * d[0] * e[1] - b[0] * d[2] * e[1] -
+                 b[1] * d[0] * e[2] + b[0] * d[1] * e[2] -
+                 b[2] * c[1] * f[0] + b[1] * c[2] * f[0] -
+                 a[2] * d[1] * f[0] + a[1] * d[2] * f[0] +
+                 b[2] * c[0] * f[1] - b[0] * c[2] * f[1] +
+                 a[2] * d[0] * f[1] - a[0] * d[2] * f[1] -
+                 b[1] * c[0] * f[2] + b[0] * c[1] * f[2] -
+                 a[1] * d[0] * f[2] + a[0] * d[1] * f[2];
 
        float j = -b[2] * d[1] * f[0] + b[1] * d[2] * f[0] +

@@ Diff output truncated at 10240 characters. @@

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

Reply via email to