From 95a9646c00a1cbf727f24c506c4aeffe99016352 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 30 Apr 2019 14:41:33 +1000 Subject: Cleanup: comments (long lines) in physics --- source/blender/physics/intern/BPH_mass_spring.cpp | 51 ++++++++++++++-------- .../physics/intern/ConstrainedConjugateGradient.h | 23 +++++----- source/blender/physics/intern/eigen_utils.h | 5 ++- source/blender/physics/intern/hair_volume.cpp | 15 +++++-- source/blender/physics/intern/implicit_blender.c | 15 ++++--- source/blender/physics/intern/implicit_eigen.cpp | 12 ++--- 6 files changed, 77 insertions(+), 44 deletions(-) (limited to 'source/blender/physics') diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp index 8eb22bd57ad..f7a9cadc9cf 100644 --- a/source/blender/physics/intern/BPH_mass_spring.cpp +++ b/source/blender/physics/intern/BPH_mass_spring.cpp @@ -232,7 +232,7 @@ static void cloth_setup_constraints(ClothModifierData *clmd, ColliderContacts *ct = &contacts[i]; for (j = 0; j < ct->totcollisions; ++j) { CollPair *collpair = &ct->collisions[j]; - // float restitution = (1.0f - clmd->coll_parms->damping) * (1.0f - ct->ob->pd->pdef_sbdamp); + // float restitution = (1.0f - clmd->coll_parms->damping) * (1.0f - ct->ob->pd->pdef_sbdamp); float restitution = 0.0f; int v = collpair->face1; float impulse[3]; @@ -334,7 +334,7 @@ static int UNUSED_FUNCTION(cloth_calc_helper_forces)(Object *UNUSED(ob), sub_v3_v3v3(vec, cos[i], cv->tx); mul_v3_fl(vec, cv->mass * dt * 20.0f); add_v3_v3(cv->tv, vec); - //copy_v3_v3(cv->tx, cos[i]); + // copy_v3_v3(cv->tx, cos[i]); } MEM_freeN(cos); @@ -382,8 +382,9 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s) k_tension = scaling_tension / (parms->avg_spring_len + FLT_EPSILON); if (s->type & CLOTH_SPRING_TYPE_SEWING) { - // TODO: verify, half verified (couldn't see error) - // sewing springs usually have a large distance at first so clamp the force so we don't get tunnelling through colission objects + /* TODO: verify, half verified (couldn't see error) + * sewing springs usually have a large distance at first so clamp the force so we don't get + * tunnelling through colission objects */ BPH_mass_spring_force_spring_linear(data, s->ij, s->kl, @@ -459,9 +460,9 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s) s->flags |= CLOTH_SPRING_FLAG_NEEDED; - /* XXX WARNING: angular bending springs for hair apply stiffness factor as an overall factor, unlike cloth springs! - * this is crap, but needed due to cloth/hair mixing ... - * max_bend factor is not even used for hair, so ... + /* XXX WARNING: angular bending springs for hair apply stiffness factor as an overall factor, + * unlike cloth springs! this is crap, but needed due to cloth/hair mixing ... max_bend factor + * is not even used for hair, so ... */ scaling = s->lin_stiffness * parms->bending; kb = scaling / (20.0f * (parms->avg_spring_len + FLT_EPSILON)); @@ -469,7 +470,8 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s) // Fix for [#45084] for cloth stiffness must have cb proportional to kb cb = kb * parms->bending_damping; - /* XXX assuming same restlen for ij and jk segments here, this can be done correctly for hair later */ + /* XXX assuming same restlen for ij and jk segments here, + * this can be done correctly for hair later. */ BPH_mass_spring_force_spring_bending_hair(data, s->ij, s->kl, s->mn, s->target, kb, cb); # if 0 @@ -487,8 +489,8 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s) BKE_sim_debug_data_add_vector( clmd->debug_data, x_kl, d, 0.8, 0.8, 0.2, "target", 7982, s->kl); - // copy_v3_v3(d, s->target_ij); - // BKE_sim_debug_data_add_vector(clmd->debug_data, x, d, 1, 0.4, 0.4, "target", 7983, s->kl); + // copy_v3_v3(d, s->target_ij); + // BKE_sim_debug_data_add_vector(clmd->debug_data, x, d, 1, 0.4, 0.4, "target", 7983, s->kl); } # endif #endif @@ -861,12 +863,18 @@ static void cloth_continuum_step(ClothModifierData *clmd, float dt) BPH_hair_volume_grid_interpolate(grid, x, &gdensity, gvel, gvel_smooth, NULL, NULL); - // BKE_sim_debug_data_add_circle(clmd->debug_data, x, gdensity, 0.7, 0.3, 1, "grid density", i, j, 3111); + // BKE_sim_debug_data_add_circle( + // clmd->debug_data, x, gdensity, 0.7, 0.3, 1, + // "grid density", i, j, 3111); if (!is_zero_v3(gvel) || !is_zero_v3(gvel_smooth)) { float dvel[3]; sub_v3_v3v3(dvel, gvel_smooth, gvel); - // BKE_sim_debug_data_add_vector(clmd->debug_data, x, gvel, 0.4, 0, 1, "grid velocity", i, j, 3112); - // BKE_sim_debug_data_add_vector(clmd->debug_data, x, gvel_smooth, 0.6, 1, 1, "grid velocity", i, j, 3113); + // BKE_sim_debug_data_add_vector( + // clmd->debug_data, x, gvel, 0.4, 0, 1, + // "grid velocity", i, j, 3112); + // BKE_sim_debug_data_add_vector( + // clmd->debug_data, x, gvel_smooth, 0.6, 1, 1, + // "grid velocity", i, j, 3113); BKE_sim_debug_data_add_vector( clmd->debug_data, x, dvel, 0.4, 1, 0.7, "grid velocity", i, j, 3114); # if 0 @@ -875,10 +883,16 @@ static void cloth_continuum_step(ClothModifierData *clmd, float dt) float col1[3] = {0.0, 1.0, 0.0}; float col[3]; - interp_v3_v3v3(col, col0, col1, CLAMPIS(gdensity * clmd->sim_parms->density_strength, 0.0, 1.0)); -// BKE_sim_debug_data_add_circle(clmd->debug_data, x, gdensity * clmd->sim_parms->density_strength, 0, 1, 0.4, "grid velocity", i, j, 3115); -// BKE_sim_debug_data_add_dot(clmd->debug_data, x, col[0], col[1], col[2], "grid velocity", i, j, 3115); - BKE_sim_debug_data_add_circle(clmd->debug_data, x, 0.01f, col[0], col[1], col[2], "grid velocity", i, j, 3115); + interp_v3_v3v3(col, col0, col1, + CLAMPIS(gdensity * clmd->sim_parms->density_strength, 0.0, 1.0)); + // BKE_sim_debug_data_add_circle( + // clmd->debug_data, x, gdensity * clmd->sim_parms->density_strength, 0, 1, 0.4, + // "grid velocity", i, j, 3115); + // BKE_sim_debug_data_add_dot( + // clmd->debug_data, x, col[0], col[1], col[2], + // "grid velocity", i, j, 3115); + BKE_sim_debug_data_add_circle( + clmd->debug_data, x, 0.01f, col[0], col[1], col[2], "grid velocity", i, j, 3115); } # endif } @@ -1118,7 +1132,8 @@ int BPH_cloth_solve( if (clmd->sim_parms->vgroup_mass > 0) { if (verts[i].flags & CLOTH_VERT_FLAG_PINNED) { float x[3]; - /* divide by time_scale to prevent pinned vertices' delta locations from being multiplied */ + /* divide by time_scale to prevent pinned vertices' + * delta locations from being multiplied */ interp_v3_v3v3( x, verts[i].xold, verts[i].xconst, (step + dt) / clmd->sim_parms->time_scale); BPH_mass_spring_set_position(id, i, x); diff --git a/source/blender/physics/intern/ConstrainedConjugateGradient.h b/source/blender/physics/intern/ConstrainedConjugateGradient.h index 8d375d00056..4a0a6ab298c 100644 --- a/source/blender/physics/intern/ConstrainedConjugateGradient.h +++ b/source/blender/physics/intern/ConstrainedConjugateGradient.h @@ -31,9 +31,11 @@ namespace internal { * \param rhs: The right hand side vector b * \param x: On input and initial solution, on output the computed solution. * \param precond: A preconditioner being able to efficiently solve for an - * approximation of Ax=b (regardless of b) - * \param iters: On input the max number of iteration, on output the number of performed iterations. - * \param tol_error: On input the tolerance error, on output an estimation of the relative error. + * approximation of Ax=b (regardless of b) + * \param iters: On input the max number of iteration, + * on output the number of performed iterations. + * \param tol_error: On input the tolerance error, + * on output an estimation of the relative error. */ template::epsilon() for the tolerance. + * The maximal number of iterations and tolerance value can be controlled via the + * setMaxIterations() and setTolerance() methods. The defaults are the size of the problem for the + * maximal number of iterations and NumTraits::epsilon() for the tolerance. * * This class can be used as the direct solver classes. Here is a typical usage example: * \code diff --git a/source/blender/physics/intern/eigen_utils.h b/source/blender/physics/intern/eigen_utils.h index 7d56fe1a608..361ebadf5d2 100644 --- a/source/blender/physics/intern/eigen_utils.h +++ b/source/blender/physics/intern/eigen_utils.h @@ -140,8 +140,9 @@ typedef Eigen::SparseMatrix lMatrix; /* Constructor type that provides more convenient handling of Eigen triplets * for efficient construction of sparse 3x3 block matrices. - * This should be used for building lMatrix instead of writing to such lMatrix directly (which is very inefficient). - * After all elements have been defined using the set() method, the actual matrix can be filled using construct(). + * This should be used for building lMatrix instead of writing to such lMatrix directly (which is + * very inefficient). After all elements have been defined using the set() method, the actual + * matrix can be filled using construct(). */ struct lMatrix3fCtor { lMatrix3fCtor() diff --git a/source/blender/physics/intern/hair_volume.cpp b/source/blender/physics/intern/hair_volume.cpp index 44d2aaceac5..a07d1fe8f75 100644 --- a/source/blender/physics/intern/hair_volume.cpp +++ b/source/blender/physics/intern/hair_volume.cpp @@ -487,7 +487,9 @@ BLI_INLINE void hair_volume_add_segment_2D(HairGrid *grid, BKE_sim_debug_data_add_dot(x2w, 0.1, 0.1, 0.7, "grid", 649, debug_i, j, k); BKE_sim_debug_data_add_line(wloc, x2w, 0.3, 0.8, 0.3, "grid", 253, debug_i, j, k); BKE_sim_debug_data_add_line(wloc, x3w, 0.8, 0.3, 0.3, "grid", 254, debug_i, j, k); -// BKE_sim_debug_data_add_circle(x2w, len_v3v3(wloc, x2w), 0.2, 0.7, 0.2, "grid", 255, i, j, k); + // BKE_sim_debug_data_add_circle( + // x2w, len_v3v3(wloc, x2w), 0.2, 0.7, 0.2, + // "grid", 255, i, j, k); } } # endif @@ -980,7 +982,9 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid, if (!is_margin) { float dvel[3]; sub_v3_v3v3(dvel, vert->velocity_smooth, vert->velocity); - // BKE_sim_debug_data_add_vector(grid->debug_data, wloc, dvel, 1, 1, 1, "grid", 5566, i, j, k); + // BKE_sim_debug_data_add_vector( + // grid->debug_data, wloc, dvel, 1, 1, 1, + // "grid", 5566, i, j, k); } if (!is_margin) { @@ -990,8 +994,11 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid, float col[3]; interp_v3_v3v3(col, col0, colp, d); - // if (d > 0.05f) - // BKE_sim_debug_data_add_dot(grid->debug_data, wloc, col[0], col[1], col[2], "grid", 5544, i, j, k); + // if (d > 0.05f) { + // BKE_sim_debug_data_add_dot( + // grid->debug_data, wloc, col[0], col[1], col[2], + // "grid", 5544, i, j, k); + // } } } } diff --git a/source/blender/physics/intern/implicit_blender.c b/source/blender/physics/intern/implicit_blender.c index 654825e814b..cdd4d66d485 100644 --- a/source/blender/physics/intern/implicit_blender.c +++ b/source/blender/physics/intern/implicit_blender.c @@ -766,7 +766,9 @@ DO_INLINE void filter(lfVector *V, fmatrix3x3 *S) } } -# if 0 /* this version of the CG algorithm does not work very well with partial constraints (where S has non-zero elements) */ +/* this version of the CG algorithm does not work very well with partial constraints + * (where S has non-zero elements). */ +# if 0 static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z, fmatrix3x3 *S) { // Solves for unknown X in equation AX=B @@ -1455,7 +1457,8 @@ static float calc_nor_area_tri(float nor[3], return normalize_v3(nor); } -/* XXX does not support force jacobians yet, since the effector system does not provide them either */ +/* XXX does not support force jacobians yet, since the effector system does not provide them either + */ void BPH_mass_spring_force_face_wind( Implicit_Data *data, int v1, int v2, int v3, const float (*winvec)[3]) { @@ -1538,7 +1541,7 @@ void BPH_mass_spring_force_vertex_wind(Implicit_Data *data, BLI_INLINE void dfdx_spring(float to[3][3], const float dir[3], float length, float L, float k) { // dir is unit length direction, rest is spring's restlength, k is spring constant. - //return ( (I-outerprod(dir, dir))*Min(1.0f, rest/length) - I) * -k; + // return ( (I-outerprod(dir, dir))*Min(1.0f, rest/length) - I) * -k; outerproduct(to, dir, dir); sub_m3_m3m3(to, I, to); @@ -1699,7 +1702,8 @@ bool BPH_mass_spring_force_spring_linear(Implicit_Data *data, dfdx_spring(dfdx, dir, length, restlen, stiffness_tension); } else if (new_compress) { - /* This is based on the Choi and Ko bending model, which works surprisingly well for compression. */ + /* This is based on the Choi and Ko bending model, + * which works surprisingly well for compression. */ float kb = stiffness_compression; float cb = kb; /* cb equal to kb seems to work, but a factor can be added if necessary */ @@ -1828,7 +1832,8 @@ BLI_INLINE void spring_angle(Implicit_Data *data, sub_v3_v3(r_vel_b, vel_e); } -/* Angular springs roughly based on the bending model proposed by Baraff and Witkin in "Large Steps in Cloth Simulation". */ +/* Angular springs roughly based on the bending model proposed by Baraff and Witkin in "Large Steps + * in Cloth Simulation". */ bool BPH_mass_spring_force_spring_angular(Implicit_Data *data, int i, int j, diff --git a/source/blender/physics/intern/implicit_eigen.cpp b/source/blender/physics/intern/implicit_eigen.cpp index cfa3d653961..04ca24e0382 100644 --- a/source/blender/physics/intern/implicit_eigen.cpp +++ b/source/blender/physics/intern/implicit_eigen.cpp @@ -182,8 +182,9 @@ typedef Eigen::SparseMatrix lMatrix; /* Constructor type that provides more convenient handling of Eigen triplets * for efficient construction of sparse 3x3 block matrices. - * This should be used for building lMatrix instead of writing to such lMatrix directly (which is very inefficient). - * After all elements have been defined using the set() method, the actual matrix can be filled using construct(). + * This should be used for building lMatrix instead of writing to such lMatrix directly (which is + * very inefficient). After all elements have been defined using the set() method, the actual + * matrix can be filled using construct(). */ struct lMatrixCtor { lMatrixCtor() @@ -814,7 +815,8 @@ static float calc_nor_area_tri(float nor[3], return normalize_v3(nor); } -/* XXX does not support force jacobians yet, since the effector system does not provide them either */ +/* XXX does not support force jacobians yet, + * since the effector system does not provide them either. */ void BPH_mass_spring_force_face_wind( Implicit_Data *data, int v1, int v2, int v3, const float (*winvec)[3]) { @@ -855,8 +857,8 @@ void BPH_mass_spring_force_edge_wind(Implicit_Data *data, int v1, int v2, const BLI_INLINE void dfdx_spring(float to[3][3], const float dir[3], float length, float L, float k) { - // dir is unit length direction, rest is spring's restlength, k is spring constant. - //return ( (I-outerprod(dir, dir))*Min(1.0f, rest/length) - I) * -k; + /* dir is unit length direction, rest is spring's restlength, k is spring constant. */ + // return ((I - outerprod(dir, dir)) * Min(1.0f, rest / length) - I) * -k; outerproduct(to, dir, dir); sub_m3_m3m3(to, I, to); -- cgit v1.2.3