Revision: 30518
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30518
Author:   joeedh
Date:     2010-07-20 01:56:21 +0200 (Tue, 20 Jul 2010)

Log Message:
-----------
premerge commit

Modified Paths:
--------------
    branches/hairsim/extern/cppad/local/reverse.hpp
    branches/hairsim/source/blender/blenkernel/BKE_cloth.h
    branches/hairsim/source/blender/blenkernel/BKE_pdynamics.h
    branches/hairsim/source/blender/blenkernel/intern/collision.c
    branches/hairsim/source/blender/blenkernel/intern/derivatives.cpp
    branches/hairsim/source/blender/blenkernel/intern/pdynamics.c
    branches/hairsim/source/blender/blenlib/intern/math_geom.c
    branches/hairsim/source/blender/makesrna/intern/rna_cloth.c

Modified: branches/hairsim/extern/cppad/local/reverse.hpp
===================================================================
--- branches/hairsim/extern/cppad/local/reverse.hpp     2010-07-19 23:53:13 UTC 
(rev 30517)
+++ branches/hairsim/extern/cppad/local/reverse.hpp     2010-07-19 23:56:21 UTC 
(rev 30518)
@@ -122,8 +122,8 @@
        // number of dependent variables
        size_t m = dep_taddr_.size();
 
-       Base staticpartial[127];
-       Base *Partial = total_num_var_*p > 127 ? new Base(total_num_var_*p) : 
staticpartial;
+       Base staticpartial[200];
+       Base *Partial = total_num_var_*p > 200 ? new Base(total_num_var_*p+1) : 
staticpartial;
 
        // update maximum memory requirement
        // memoryMax = std::max( memoryMax, 
@@ -201,7 +201,7 @@
        }
        
        if (Partial != staticpartial)
-               delete [] Partial;
+               delete Partial;
 
        return value;
 }

Modified: branches/hairsim/source/blender/blenkernel/BKE_cloth.h
===================================================================
--- branches/hairsim/source/blender/blenkernel/BKE_cloth.h      2010-07-19 
23:53:13 UTC (rev 30517)
+++ branches/hairsim/source/blender/blenkernel/BKE_cloth.h      2010-07-19 
23:56:21 UTC (rev 30518)
@@ -169,7 +169,7 @@
 #define VECSUBMUL(v1,v2,aS)    {*(v1)-= *(v2) * aS; *(v1+1)-= *(v2+1) * aS; 
*(v1+2)-= *(v2+2) * aS;}
 #define VECSUBS(v1,v2,v3,bS)   {*(v1)= *(v2) - *(v3)*bS; *(v1+1)= *(v2+1) - 
*(v3+1)*bS; *(v1+2)= *(v2+2) - *(v3+2)*bS;}
 #define VECSUBSB(v1,v2, v3,bS)         {*(v1)= (*(v2)- *(v3))*bS; *(v1+1)= 
(*(v2+1) - *(v3+1))*bS; *(v1+2)= (*(v2+2) - *(v3+2))*bS;}
-#define VECMULS(v1,aS)         {*(v1)*= aS; *(v1+1)*= aS; *(v1+2)*= *aS;}
+#define VECMULS(v1,aS)         {*(v1)*= aS; *(v1+1)*= aS; *(v1+2)*= aS;}
 #define VECADDMUL(v1,v2,aS)    {*(v1)+= *(v2) * aS; *(v1+1)+= *(v2+1) * aS; 
*(v1+2)+= *(v2+2) * aS;}
 
 /* SIMULATION FLAGS: goal flags,.. */

Modified: branches/hairsim/source/blender/blenkernel/BKE_pdynamics.h
===================================================================
--- branches/hairsim/source/blender/blenkernel/BKE_pdynamics.h  2010-07-19 
23:53:13 UTC (rev 30517)
+++ branches/hairsim/source/blender/blenkernel/BKE_pdynamics.h  2010-07-19 
23:56:21 UTC (rev 30518)
@@ -26,11 +26,11 @@
        pdfloat parentfac[2];
 
        pdfloat tx[3], txstart[3], txold[3], txold2[3], tv[3], tvold[3];
-       pdfloat tanforce[3], springforce[3], goalforce[3];
+       pdfloat cno[3], springforce[3], goalforce[3], norforce[3]; /*cno is 
collision normal*/
        pdfloat txconst[3], txconstold[3];
        pdfloat no[3], mass, goal;
 
-       int pinned;
+        int pinned, totcno;
        intptr_t hash1, hash2;
 } PDVertex;
 
@@ -202,4 +202,4 @@
 #define mul_v3_sl              mul_v3_fl
 #endif
 
-#endif /*_BKE_PDYNAMICS_H*/
\ No newline at end of file
+#endif /*_BKE_PDYNAMICS_H*/

Modified: branches/hairsim/source/blender/blenkernel/intern/collision.c
===================================================================
--- branches/hairsim/source/blender/blenkernel/intern/collision.c       
2010-07-19 23:53:13 UTC (rev 30517)
+++ branches/hairsim/source/blender/blenkernel/intern/collision.c       
2010-07-19 23:56:21 UTC (rev 30518)
@@ -61,6 +61,7 @@
 void collision_move_object ( CollisionModifierData *collmd, float step, float 
prevstep )
 {
        PDVertex *pv;
+       PDTri *pt;
        float tv[3] = {0, 0, 0};
        unsigned int i = 0;
 
@@ -83,6 +84,22 @@
                        VECCOPY(pv->txconst, pv->tx);
                        VECCOPY(pv->txconstold, pv->txold);
                }
+
+               pt = collmd->pdm->tris;
+               for (i=0; i<collmd->pdm->tottri; i++, pt++) {
+                       pdfloat cent[3]={0.0,0.0,0.0}, ocent[3]={0.0,0.0,0.0};
+                       int j;
+
+                       for (j=0; j<3; j++) {
+                               VECADD(cent, cent, pt->verts[j]->tx);
+                               VECADD(ocent, ocent, pt->verts[j]->txold);
+                       }
+
+                       VECMULS(cent, 1.0/3.0);
+                       VECMULS(ocent, 1.0/3.0);
+                       VECCOPY(pt->cent, cent);
+                       VECCOPY(pt->ocent, ocent);
+               }
        }
 
        bvhtree_update_from_mvert ( collmd->bvhtree, collmd->mfaces, 
collmd->numfaces, collmd->current_x, collmd->current_xnew, collmd->numverts, 1 
);

Modified: branches/hairsim/source/blender/blenkernel/intern/derivatives.cpp
===================================================================
--- branches/hairsim/source/blender/blenkernel/intern/derivatives.cpp   
2010-07-19 23:53:13 UTC (rev 30517)
+++ branches/hairsim/source/blender/blenkernel/intern/derivatives.cpp   
2010-07-19 23:56:21 UTC (rev 30518)
@@ -1,15 +1,18 @@
 #include <cstdio>
 #include <cstdlib>
 #include <cstring>
+#include <cfloat>
 #include "BLI_memarena.h"
 #include "BLI_listbase.h"
 
 static MemArena *memarena = NULL;
 
 extern "C" void derivatives_set_memarena(MemArena *arena) {
-       memarena = arena;
+        memarena = arena;
 }
 
+#if 0
+
 /*overload default new operator*/
 void *operator new(size_t size) {
        if (memarena)
@@ -22,7 +25,7 @@
        if (!memarena)
                free(ptr);
 }
-
+#endif
 #define NDEBUG
 #ifdef _OPENMP
 #undef _OPENMP
@@ -93,58 +96,8 @@
                        return y;
                }
 
-               Type TetraVolumeConstraint0(const Type &vars) {
-                       Type a(3), b(3), c(3), ab(3), cb(3), dir1(3), dir2(3), 
i1(3), i2(3);
-                       Type d(1), ret(1), t(3), n(3);
-
-                       c[0] = vars[6] - vars[0];
-                       c[1] = vars[7] - vars[1];
-                       c[2] = vars[8] - vars[2];
-
-                       a[0] = vars[3] - vars[0];
-                       a[1] = vars[4] - vars[1];
-                       a[2] = vars[5] - vars[2];
-
-                       b[0] = vars[9] - vars[6];
-                       b[1] = vars[10] - vars[7];
-                       b[2] = vars[11] - vars[8];
-
-                       t[0] = vars[0] - vars[6];
-                       t[1] = vars[1] - vars[7];
-                       t[2] = vars[2] - vars[8];
-
-                       /* offset between both plane where the lines lies */
-                       cross(n, a, b);
-                       project(t, t, n);
-
-                       /* for the first line, offset the second line until it 
is coplanar */
-                       v3t[0] = vars[6] + t[0];
-                       v3t[1] = vars[7] + t[1];
-                       v3t[2] = vars[8] + t[2];
-
-                       v4t[0] = vars[9] + t[0];
-                       v4t[1] = vars[10] + t[1];
-                       v4t[2] = vars[11] + t[2];
-
-                       sub(c, v3t, v1);
-                       a[0] = vars[3] - vars[0]; a[1] = vars[4] - vars[1]; 
a[2] = vars[5] - vars[2];
-                       sub(b, v4t, v3t);
-
-                       cross(ab, a, b);
-                       cross(cb, c, b);
-
-                       mul_fl(a, dot(cb, ab) / dot(ab, ab));
-                       add(i1, v1, a);
-
-                       /* for the second line, just substract the offset from 
the first intersection point */
-                       ret[0] = CppAD::sqrt(dot(t, t));
-
-                       return ret;
-               }
-
-               /*should work with edge/edge collisions pairs, I think*/
                Type TetraVolumeConstraint(const Type &vars) {
-                       Type v1(3), v2(3), v3(3), v4(3), up(3), n(3), ret(1), 
r1(3);
+                       Type v1(3), v2(3), v3(3), v4(3), v5(3), v6(3), up(3), 
n(3), ret(1), r1(4);
                        int i;
 
                        up[0] = vars[14];
@@ -161,6 +114,10 @@
                        
                        for (i=0; i<3; i++) {
                                v3[i] = vars[i+3] - vars[i+6];
+                               v4[i] = vars[i] - vars[i+9];
+
+                               v5[i] = vars[i+3] - vars[i+9];
+                               v6[i] = vars[i] - vars[i+6];
                        }
 
                        normalize(v1);
@@ -169,14 +126,27 @@
                        normalize(n);
 
                        normalize(v3);
-                       
+                       normalize(v4);
+                       normalize(v5);
+                       normalize(v6);
+
                        r1[0] = 0.0;
                        r1[1] = -1.0;
                        r1[2] = 1.0;
-                       mul_fl(n, CppAD::CondExpGt((dot(n, up)), r1[0], r1[1], 
r1[2]));
-                       
+
+                       mul_fl(n, CppAD::CondExpGt(r1[0], dot(n, up), r1[1], 
r1[2]));
+
+                       r1[0] = dot(n, v4);
+                       r1[1] = dot(n, v5);
+                       r1[2] = dot(n, v6);
+
                        ret[0] = dot(n, v3);
 
+                       ret[0] = CppAD::CondExpGt(ret[0], r1[0], r1[0], ret[0]);
+                       ret[0] = CppAD::CondExpGt(ret[0], r1[1], r1[1], ret[0]);
+                       ret[0] = CppAD::CondExpGt(ret[0], r1[2], r1[2], ret[0]);
+
+                       //ret[0] = CppAD::CondExpGt(r1[0], dot(n, up), ret[0], 
-ret[0]);
                        return ret;
                }
        };

Modified: branches/hairsim/source/blender/blenkernel/intern/pdynamics.c
===================================================================
--- branches/hairsim/source/blender/blenkernel/intern/pdynamics.c       
2010-07-19 23:53:13 UTC (rev 30517)
+++ branches/hairsim/source/blender/blenkernel/intern/pdynamics.c       
2010-07-19 23:56:21 UTC (rev 30518)
@@ -60,7 +60,7 @@
 #include "BLI_ghash.h"
 #include "BLI_mempool.h"
 
-#define EDGE_SCALE     1.01
+#define EDGE_SCALE     1.001
 
 #define SIGN(n) ((n) < 0.0)
 
@@ -139,6 +139,7 @@
        sub_v3_v3v3(vec, v1->tx, v2->tx);
                
        dis = len_v3(vec);
+       return;
 
        if (fabs(dis-scon->restlen) <= DBL_EPSILON) {
                scon->head.result = 0.0;
@@ -198,18 +199,21 @@
        PDVertex *v1=self->v1, *v2=self->v2, *v3=self->v3, *v4=self->v4;
        pdfloat g1[3], g2[3], g3[3], g4[3], n[3], vec1[3], vec2[3], offv1[3], 
offv2[3], l1[3], l2[3], t[4][3];
 
+       //return;
+
        copy_v3_v3(l1, v1->tx);
        copy_v3_v3(l2, v2->tx);
 
-       scale_line_v3(l1, l2, EDGE_SCALE);
+       //scale_line_v3(l1, l2, EDGE_SCALE);
 
        add_v3_v3v3(offv1, v3->tx, self->off);
        add_v3_v3v3(offv2, v4->tx, self->off);
 
-       scale_line_v3(offv1, offv2, EDGE_SCALE);
+       //scale_line_v3(offv1, offv2, EDGE_SCALE);
        
        sub_v3_v3v3(vec1, l1, l2);
        sub_v3_v3v3(vec2, offv1, offv2);
+
        cross_v3_v3v3(n, vec1, vec2);
        normalize_v3(n);
        
@@ -222,16 +226,11 @@
        
        self->coll.head.result = solve_tetra_gradient(l1, l2, offv1, offv2, g1, 
g2, g3, g4, self->coll.no, self->elen1, self->elen2);
        
-       if (self->coll.head.result < -0.2) {
-               self->coll.head.result = 0.0;
-               return;
-       }
+       //if (self->coll.head.result > 0.0) {
+       //      self->coll.head.result = 0.0;
+       //      return;
+       //}
 
-       copy_v3_v3(t[0], v1->tx);
-       copy_v3_v3(t[1], v2->tx);
-       copy_v3_v3(t[2], offv1);
-       copy_v3_v3(t[3], offv2);
-
        if (isnan(g1[0]) || isnan(g2[0]) || isnan(g3[0]) || isnan(g4[0]))
                self->coll.head.result = 0.0;
        
@@ -260,6 +259,7 @@
        copy_v3_v3(con->off, no);
        copy_v3_v3(con->coll.no, no);
        mul_v3_sl(con->off, mindis);
+       mindis *= 1.0001;
 
        con->coll.head.verts[0] = v1;
        con->coll.head.verts[1] = v2;
@@ -286,6 +286,8 @@
        pdfloat g1[3], g2[3], g3[3];
        int v1i, v2i, v3i;
 
+       return;
+
        VECCOPY(co2, con->coll.head.verts[0]->tx);
        if (con->flip) {
                v1i = 3; v2i = 2; v3i = 1;
@@ -354,7 +356,7 @@
 
        con->coll.head.type = CON_POINT;
        con->coll.head.k = 1.0;
-       con->coll.mindis = mindis*1.001;
+       con->coll.mindis = mindis*1.0001;
        con->coll.friction = friction;
 
        con->coll.head.eval = eval_point_constraint;
@@ -561,11 +563,6 @@
        return con;
 }
 
-/***********************************
-Collision modifier code start
-***********************************/
-
-
 static PDEdge *pd_new_edge(PDMesh *pdm, PDVertex *v1, PDVertex *v2)
 {
        PDEdge *ce = BLI_memarena_alloc(pdm->solver->arena, sizeof(PDEdge));
@@ -711,10 +708,10 @@
        sub_v3_v3v3(off, cent, ocent);
        if (off[0] != 0.0 || off[1] != 0.0 || off[2] != 0.0) {
                normalize_v3(off);
-               mul_v3_sl(off, MAX2(thickness, 0.01));
+               mul_v3_sl(off, MAX2(thickness, 0.001));
        } else {
                copy_v3_v3(off, no);
-               mul_v3_sl(off, MAX2(thickness, 0.01));
+               mul_v3_sl(off, MAX2(thickness, 0.001));
        }
 
        eps = 1.0001; // + DBL_EPSILON*2;
@@ -928,64 +925,62 @@
 
 static void calc_edge_normal(PDEdge *e, PDEdge *e2, pdfloat no[3])
 {
-       pdfloat vec1[3], vec2[3];
+       pdfloat vec1[3], vec2[3], tno[3] = {0.0, 0.0, 0.0};
 
-       if (!e->t1) {           

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to