Merge branch 'master' into blender2.8
authorCampbell Barton <ideasman42@gmail.com>
Fri, 30 Nov 2018 21:17:00 +0000 (08:17 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 30 Nov 2018 21:19:38 +0000 (08:19 +1100)
1  2 
source/blender/physics/intern/BPH_mass_spring.cpp
source/blender/physics/intern/hair_volume.cpp
source/blender/physics/intern/implicit.h
source/blender/physics/intern/implicit_blender.c

@@@ -967,15 -973,14 +967,15 @@@ int BPH_cloth_solve(Depsgraph *depsgrap
         * Collision detection and volumetrics work differently then.
         * Bad design, TODO
         */
 +      Scene *scene = DEG_get_evaluated_scene(depsgraph);
        const bool is_hair = (clmd->hairdata != NULL);
  
-       unsigned int i=0;
-       float step=0.0f, tf=clmd->sim_parms->timescale;
+       unsigned int i = 0;
+       float step = 0.0f, tf = clmd->sim_parms->timescale;
        Cloth *cloth = clmd->clothObject;
-       ClothVertex *verts = cloth->verts/*, *cv*/;
+       ClothVertex *verts = cloth->verts /*, *cv*/;
        unsigned int mvert_num = cloth->mvert_num;
 -      float dt = clmd->sim_parms->timescale / clmd->sim_parms->stepsPerFrame;
 +      float dt = clmd->sim_parms->dt * clmd->sim_parms->timescale;
        Implicit_Data *id = cloth->implicit;
        ColliderContacts *contacts = NULL;
        int totcolliders = 0;
@@@ -108,24 -107,19 +108,24 @@@ void BPH_mass_spring_force_drag(struct 
  /* Custom external force */
  void BPH_mass_spring_force_extern(struct Implicit_Data *data, int i, const float f[3], float dfdx[3][3], float dfdv[3][3]);
  /* Wind force, acting on a face */
- void BPH_mass_spring_force_face_wind(struct Implicit_Data *data, int v1, int v2, int v3, const float (*winvec)[3]);
+ void BPH_mass_spring_force_face_wind(struct Implicit_Data *data, int v1, int v2, int v3, const float(*winvec)[3]);
  /* Wind force, acting on an edge */
- void BPH_mass_spring_force_edge_wind(struct Implicit_Data *data, int v1, int v2, float radius1, float radius2, const float (*winvec)[3]);
+ void BPH_mass_spring_force_edge_wind(struct Implicit_Data *data, int v1, int v2, float radius1, float radius2, const float(*winvec)[3]);
  /* Wind force, acting on a vertex */
- void BPH_mass_spring_force_vertex_wind(struct Implicit_Data *data, int v, float radius, const float (*winvec)[3]);
+ void BPH_mass_spring_force_vertex_wind(struct Implicit_Data *data, int v, float radius, const float(*winvec)[3]);
  /* Linear spring force between two points */
  bool BPH_mass_spring_force_spring_linear(struct Implicit_Data *data, int i, int j, float restlen,
 -                                         float stiffness, float damping, bool no_compress, float clamp_force);
 +                                         float stiffness_tension, float damping_tension,
 +                                         float stiffness_compression, float damping_compression,
 +                                         bool resist_compress, bool new_compress, float clamp_force);
 +/* Angular spring force between two polygons */
 +bool BPH_mass_spring_force_spring_angular(struct Implicit_Data *data, int i, int j, int *i_a, int *i_b, int len_a, int len_b,
 +                                          float restang, float stiffness, float damping);
  /* Bending force, forming a triangle at the base of two structural springs */
  bool BPH_mass_spring_force_spring_bending(struct Implicit_Data *data, int i, int j, float restlen, float kb, float cb);
  /* Angular bending force based on local target vectors */
 -bool BPH_mass_spring_force_spring_bending_angular(struct Implicit_Data *data, int i, int j, int k,
 -                                                  const float target[3], float stiffness, float damping);
 +bool BPH_mass_spring_force_spring_bending_hair(struct Implicit_Data *data, int i, int j, int k,
-                                                   const float target[3], float stiffness, float damping);
++                                               const float target[3], float stiffness, float damping);
  /* Global goal spring */
  bool BPH_mass_spring_force_spring_goal(struct Implicit_Data *data, int i, const float goal_x[3], const float goal_v[3],
                                         float stiffness, float damping);
@@@ -610,10 -603,8 +610,10 @@@ DO_INLINE void mul_bfmatrix_lfvector(fl
        {
  #pragma omp section
                {
-                       for (i = from[0].vcount; i < from[0].vcount+from[0].scount; i++) {
+                       for (i = from[0].vcount; i < from[0].vcount + from[0].scount; i++) {
 -                              muladd_fmatrix_fvector(to[from[i].c], from[i].m, fLongVector[from[i].r]);
 +                              /* This is the lower triangle of the sparse matrix,
 +                               * therefore multiplication occurs with transposed submatrices. */
 +                              muladd_fmatrixT_fvector(to[from[i].c], from[i].m, fLongVector[from[i].r]);
                        }
                }
  #pragma omp section
@@@ -1802,11 -1671,11 +1802,11 @@@ BLI_INLINE void spring_grad_dir(Implici
        }
  }
  
 -BLI_INLINE void spring_angbend_forces(Implicit_Data *data, int i, int j, int k,
 -                                      const float goal[3],
 -                                      float stiffness, float damping,
 -                                      int q, const float dx[3], const float dv[3],
 -                                      float r_f[3])
 +BLI_INLINE void spring_hairbend_forces(Implicit_Data *data, int i, int j, int k,
-                                       const float goal[3],
-                                       float stiffness, float damping,
-                                       int q, const float dx[3], const float dv[3],
-                                       float r_f[3])
++                                       const float goal[3],
++                                       float stiffness, float damping,
++                                       int q, const float dx[3], const float dv[3],
++                                       float r_f[3])
  {
        float edge_ij[3], dir_ij[3];
        float edge_jk[3], dir_jk[3];
  }
  
  /* Finite Differences method for estimating the jacobian of the force */
 -BLI_INLINE void spring_angbend_estimate_dfdx(Implicit_Data *data, int i, int j, int k,
 -                                             const float goal[3],
 -                                             float stiffness, float damping,
 -                                             int q, float dfdx[3][3])
 +BLI_INLINE void spring_hairbend_estimate_dfdx(Implicit_Data *data, int i, int j, int k,
-                                              const float goal[3],
-                                              float stiffness, float damping,
-                                              int q, float dfdx[3][3])
++                                              const float goal[3],
++                                              float stiffness, float damping,
++                                              int q, float dfdx[3][3])
  {
        const float delta = 0.00001f; // TODO find a good heuristic for this
        float dvec_null[3][3], dvec_pos[3][3], dvec_neg[3][3];
        /* XXX TODO offset targets to account for position dependency */
  
        for (a = 0; a < 3; ++a) {
 -              spring_angbend_forces(data, i, j, k, goal, stiffness, damping,
 -                                    q, dvec_pos[a], dvec_null[a], f);
 +              spring_hairbend_forces(data, i, j, k, goal, stiffness, damping,
-                                     q, dvec_pos[a], dvec_null[a], f);
++                                     q, dvec_pos[a], dvec_null[a], f);
                copy_v3_v3(dfdx[a], f);
  
 -              spring_angbend_forces(data, i, j, k, goal, stiffness, damping,
 -                                    q, dvec_neg[a], dvec_null[a], f);
 +              spring_hairbend_forces(data, i, j, k, goal, stiffness, damping,
-                                     q, dvec_neg[a], dvec_null[a], f);
++                                     q, dvec_neg[a], dvec_null[a], f);
                sub_v3_v3(dfdx[a], f);
  
                for (b = 0; b < 3; ++b) {
  }
  
  /* Finite Differences method for estimating the jacobian of the force */
 -BLI_INLINE void spring_angbend_estimate_dfdv(Implicit_Data *data, int i, int j, int k,
 -                                             const float goal[3],
 -                                             float stiffness, float damping,
 -                                             int q, float dfdv[3][3])
 +BLI_INLINE void spring_hairbend_estimate_dfdv(Implicit_Data *data, int i, int j, int k,
-                                              const float goal[3],
-                                              float stiffness, float damping,
-                                              int q, float dfdv[3][3])
++                                              const float goal[3],
++                                              float stiffness, float damping,
++                                              int q, float dfdv[3][3])
  {
        const float delta = 0.00001f; // TODO find a good heuristic for this
        float dvec_null[3][3], dvec_pos[3][3], dvec_neg[3][3];
        /* XXX TODO offset targets to account for position dependency */
  
        for (a = 0; a < 3; ++a) {
 -              spring_angbend_forces(data, i, j, k, goal, stiffness, damping,
 -                                    q, dvec_null[a], dvec_pos[a], f);
 +              spring_hairbend_forces(data, i, j, k, goal, stiffness, damping,
-                                     q, dvec_null[a], dvec_pos[a], f);
++                                     q, dvec_null[a], dvec_pos[a], f);
                copy_v3_v3(dfdv[a], f);
  
 -              spring_angbend_forces(data, i, j, k, goal, stiffness, damping,
 -                                    q, dvec_null[a], dvec_neg[a], f);
 +              spring_hairbend_forces(data, i, j, k, goal, stiffness, damping,
-                                     q, dvec_null[a], dvec_neg[a], f);
++                                     q, dvec_null[a], dvec_neg[a], f);
                sub_v3_v3(dfdv[a], f);
  
                for (b = 0; b < 3; ++b) {
  /* Angular spring that pulls the vertex toward the local target
   * See "Artistic Simulation of Curly Hair" (Pixar technical memo #12-03a)
   */
 -bool BPH_mass_spring_force_spring_bending_angular(Implicit_Data *data, int i, int j, int k,
 -                                                  const float target[3], float stiffness, float damping)
 +bool BPH_mass_spring_force_spring_bending_hair(Implicit_Data *data, int i, int j, int k,
-                                                   const float target[3], float stiffness, float damping)
++                                               const float target[3], float stiffness, float damping)
  {
        float goal[3];
        float fj[3], fk[3];