[Bf-blender-cvs] [674209e35f7] soc-2020-soft-body: sebastian comments

mattoverby noreply at git.blender.org
Thu Aug 20 01:55:46 CEST 2020


Commit: 674209e35f7d99df2ed8d2229fc03649bb1ef238
Author: mattoverby
Date:   Wed Aug 19 18:55:42 2020 -0500
Branches: soc-2020-soft-body
https://developer.blender.org/rB674209e35f7d99df2ed8d2229fc03649bb1ef238

sebastian comments

===================================================================

M	release/scripts/startup/bl_ui/properties_physics_softbody.py
M	source/blender/blenkernel/intern/mesh_remesh_voxel.c
M	source/blender/blenkernel/intern/softbody.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/makesdna/DNA_object_force_types.h

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_physics_softbody.py b/release/scripts/startup/bl_ui/properties_physics_softbody.py
index 65475b97666..4d6e93b5bf6 100644
--- a/release/scripts/startup/bl_ui/properties_physics_softbody.py
+++ b/release/scripts/startup/bl_ui/properties_physics_softbody.py
@@ -57,6 +57,7 @@ class PHYSICS_PT_softbody(PhysicButtonsPanel, Panel):
         layout.prop(softbody, "solver_mode")
     
         if softbody.solver_mode=='LEGACY':
+            # Moved to collision dropdown in ADMMPD
             layout.prop(softbody, "collision_collection")
         elif softbody.solver_mode=='ADMMPD':
             layout.prop(softbody, "admmpd_mesh_mode")
@@ -350,6 +351,8 @@ class PHYSICS_PT_softbody_admmpdcollision(PhysicButtonsPanel, Panel):
         layout.enabled = softbody_panel_enabled(md)
         ob = context.object
 
+        layout.prop(softbody, "collision_collection")
+
         layout.prop(softbody, "admmpd_ck_exp")
         layout.prop(softbody, "admmpd_floor_z")
         layout.prop(softbody, "admmpd_self_collision")
diff --git a/source/blender/blenkernel/intern/mesh_remesh_voxel.c b/source/blender/blenkernel/intern/mesh_remesh_voxel.c
index 485a4733f55..ab07e08c928 100644
--- a/source/blender/blenkernel/intern/mesh_remesh_voxel.c
+++ b/source/blender/blenkernel/intern/mesh_remesh_voxel.c
@@ -169,11 +169,11 @@ static Mesh *BKE_mesh_remesh_quadriflow(Mesh *input_mesh,
                                         void *update_cb,
                                         void *update_cb_data)
 {
-  /* Ensure that the triangulated mesh data is up to data */
+  /* Ensure that the triangulated mesh data is up to data. */
   BKE_mesh_runtime_looptri_recalc(input_mesh);
   const MLoopTri *looptri = BKE_mesh_runtime_looptri_ensure(input_mesh);
 
-  /* Gather the required data for export to the internal quadiflow mesh format */
+  /* Gather the required data for export to the internal quadiflow mesh format. */
   MVertTri *verttri = MEM_callocN(sizeof(*verttri) * BKE_mesh_runtime_looptri_len(input_mesh),
                                   "remesh_looptri");
   BKE_mesh_runtime_verttri_from_looptri(
@@ -199,7 +199,7 @@ static Mesh *BKE_mesh_remesh_quadriflow(Mesh *input_mesh,
     faces[i * 3 + 2] = vt->tri[2];
   }
 
-  /* Fill out the required input data */
+  /* Fill out the required input data. */
   QuadriflowRemeshData qrd;
 
   qrd.totfaces = totfaces;
@@ -217,7 +217,7 @@ static Mesh *BKE_mesh_remesh_quadriflow(Mesh *input_mesh,
 
   qrd.out_faces = NULL;
 
-  /* Run the remesher */
+  /* Run the remesher. */
   QFLOW_quadriflow_remesh(&qrd, update_cb, update_cb_data);
 
   MEM_freeN(verts);
@@ -225,7 +225,7 @@ static Mesh *BKE_mesh_remesh_quadriflow(Mesh *input_mesh,
   MEM_freeN(verttri);
 
   if (qrd.out_faces == NULL) {
-    /* The remeshing was canceled */
+    /* The remeshing was canceled. */
     return NULL;
   }
 
@@ -269,11 +269,11 @@ static Mesh *BKE_mesh_remesh_quadriflow(Mesh *input_mesh,
 #ifdef WITH_TETGEN
 static Mesh *BKE_mesh_remesh_tetgen(Mesh *input_mesh, unsigned int **tets, int *numtets)
 {
-  // Ensure that the triangulated mesh data is up to data
+  /* Ensure that the triangulated mesh data is up to data. */
   BKE_mesh_runtime_looptri_recalc(input_mesh);
   const MLoopTri *looptri = BKE_mesh_runtime_looptri_ensure(input_mesh);
 
-  // Gather the required data
+  /* Gather the required data. */
   MVertTri *verttri = MEM_callocN(sizeof(*verttri) * BKE_mesh_runtime_looptri_len(input_mesh),
                                   "remesh_looptri");
   BKE_mesh_runtime_verttri_from_looptri(
@@ -299,7 +299,7 @@ static Mesh *BKE_mesh_remesh_tetgen(Mesh *input_mesh, unsigned int **tets, int *
     faces[i * 3 + 2] = vt->tri[2];
   }
 
-  // Call the tetgen remesher
+  /* Call the tetgen remesher. */
   TetGenRemeshData tg;
   init_tetgenremeshdata(&tg);
   tg.in_totfaces = totfaces;
@@ -319,7 +319,7 @@ static Mesh *BKE_mesh_remesh_tetgen(Mesh *input_mesh, unsigned int **tets, int *
 
   Mesh *mesh = NULL;
   if (success) {
-    // Construct the new output mesh
+    /* Construct the new output mesh. */
     mesh = BKE_mesh_new_nomain(tg.out_totverts, 0, 0, (tg.out_totfacets * 3), tg.out_totfacets);
 
     for (int i = 0; i < tg.out_totverts; i++) {
@@ -341,10 +341,9 @@ static Mesh *BKE_mesh_remesh_tetgen(Mesh *input_mesh, unsigned int **tets, int *
     *numtets = tg.out_tottets;
     *tets = (unsigned int *)MEM_malloc_arrayN(
         tg.out_tottets * 4, sizeof(unsigned int), "remesh_output_tets");
-    //*tets = (unsigned int *)malloc(tg.out_tottets*4*sizeof(unsigned int));
     memcpy(*tets, tg.out_tets, tg.out_tottets * 4 * sizeof(unsigned int));
 
-  }  // end success
+  }
 
   if (tg.out_verts != NULL) {
     MEM_freeN(tg.out_verts);
@@ -383,11 +382,11 @@ static Mesh *BKE_mesh_remesh_tetlattice(struct Mesh *input_mesh,
                                         int *numtets)
 {
 
-  // Ensure that the triangulated mesh data is up to data
+  /* Ensure that the triangulated mesh data is up to data. */
   BKE_mesh_runtime_looptri_recalc(input_mesh);
   const MLoopTri *looptri = BKE_mesh_runtime_looptri_ensure(input_mesh);
 
-  // Gather the required data
+  /* Gather the required data. */
   MVertTri *verttri = MEM_callocN(sizeof(*verttri) * BKE_mesh_runtime_looptri_len(input_mesh),
                                   "remesh_looptri");
   BKE_mesh_runtime_verttri_from_looptri(
@@ -436,7 +435,7 @@ static Mesh *BKE_mesh_remesh_tetlattice(struct Mesh *input_mesh,
     int nt = *numtets;
     int nf = *numtets * 4;
 
-    // Construct the new output mesh
+    /* Construct the new output mesh. */
     mesh = BKE_mesh_new_nomain(out_totverts, 0, 0, (nf*3), nf);
 
     for (int i = 0; i < out_totverts; i++) {
@@ -469,7 +468,7 @@ static Mesh *BKE_mesh_remesh_tetlattice(struct Mesh *input_mesh,
       }
     }
 
-  }  // end success
+  }
   BKE_mesh_calc_edges(mesh, false, false);
   BKE_mesh_calc_normals(mesh);
 
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index 97a7dd8eafd..c59b8701dbc 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -3085,8 +3085,6 @@ static void softbody_to_object(Object *ob, float (*vertexCos)[3], int numVerts,
 {
   SoftBody *sb = ob->soft;
   if (sb) {
-    // int sb_totpt = sb->totpoint;
-
     BodyPoint *bp = sb->bpoint;
     int a;
     if (sb->solverflags & SBSO_ESTIMATEIPO) {
@@ -3129,26 +3127,25 @@ SoftBody *sbNew(Scene *scene)
   sb = MEM_callocN(sizeof(SoftBody), "softbody");
 
   sb->solver_mode = SOLVER_MODE_LEGACY;
-  sb->admmpd_mesh_mode = 0;              // embedded
+  sb->admmpd_mesh_mode = 0; /* Embedded. */
   sb->admmpd_substeps = 1;
   sb->admmpd_max_admm_iters = 20;
   sb->admmpd_self_collision = 0;
-  sb->admmpd_material = 0;  // ARAP
-  sb->admmpd_embed_res = 3;
-  sb->admmpd_converge_eps = 1e-4;
-  sb->admmpd_youngs_exp = 6;
-  sb->admmpd_poisson = 0.399;
-  sb->admmpd_density_kgm3 = 1522;
-  sb->admmpd_ck_exp = 7;
-  sb->admmpd_pk_exp = 4;
+  sb->admmpd_material = 0;  /* ARAP. */
+  sb->admmpd_embed_res = 3; /* Max subdivisions for embedded lattice. */
+  sb->admmpd_converge_eps = 1e-4; /* Solver residual stop condition. */
+  sb->admmpd_youngs_exp = 6; /* Exponent of Young's mod. */
+  sb->admmpd_poisson = 0.399; 
+  sb->admmpd_density_kgm3 = 1522; /* Density of rubber. */
+  sb->admmpd_ck_exp = 7; /* Exponent of collision stiffness. */
+  sb->admmpd_pk_exp = 4; /* Exponent of pin stiffness. */
   sb->admmpd_floor_z = -999;
   sb->admmpd_gravity = -9.8;
-  sb->admmpd_strainlimit_min = 0;    // no compression
-  sb->admmpd_strainlimit_max = 100;  // 100x stretch
-  sb->admmpd_maxthreads = -1;
-  sb->admmpd_loglevel = 1;   // low
-  sb->admmpd_linsolver = 1;  // PCG
-  //sb->admmpd = MEM_callocN(sizeof(ADMMPDInterfaceData), "SoftBody_ADMMPD");
+  sb->admmpd_strainlimit_min = 0;    /* 0 = compression allowed. */
+  sb->admmpd_strainlimit_max = 100;  /* 100 = 100x strech allowed. */
+  sb->admmpd_maxthreads = -1; /* Auto detect. */
+  sb->admmpd_loglevel = 1;   /* Low terminal output. */
+  sb->admmpd_linsolver = 1;  /* PCG solver. */
 
   sb->mediafrict = 0.5f;
   sb->nodemass = 1.0f;
@@ -3226,10 +3223,14 @@ void sbFree(Object *ob)
           MEM_freeN(admmpd);
         }
       }
+      /* If we deleted data from the linked list
+      * we can delete the head ptr */
       if (cleared_admmpd_list) {
         MEM_freeN(sb->shared->admmpd_list);
-        sb->shared->admmpd_list = NULL;
       }
+      /* Otherwise we've allready freed, just
+      * set the ptr to NULL */
+      sb->shared->admmpd_list = NULL;
     }
 
     BKE_ptcache_free_list(&sb->shared->ptcaches);
@@ -3618,7 +3619,7 @@ static void update_collider_admmpd(Depsgraph *depsgraph,
   Object **objects = BKE_collision_objects_create(
       depsgraph, vertexowner, collection, &numobjects, eModifierType_Collision);
 
-  // How many faces and vertices do we need to allocate?
+  /* How many faces and vertices do we need to allocate? */
   int tot_verts = 0;
   int tot_faces = 0;
   for (int i = 0; i < numobjects; ++i) {
@@ -3639,7 +3640,7 @@ static void update_collider_admmpd(Depsgraph *depsgraph,
   float *obs_v1 = MEM_callocN(sizeof(float) * 3 * tot_verts, __func__);
   unsigned int *obs_faces = MEM_callocN(sizeof(unsigned int) * 3 * tot_faces, __func__);
 
-  // Copy over vertices and faces
+  /* Copy over vertices and faces */
   int curr_verts = 0;
   int curr_faces = 0;
   for (int i = 0; i < numobjects; ++i) {
@@ -3672,10 +3673,9 @@ static void update_collider_admmpd(Depsgraph *depsgraph,
     }
   }
 
-  // Update via API
+  /* Pass obstacle data to ADMMPD */
   admmpd_update_obstacles(admmpd, obs_v0, obs_v1, tot_verts, obs_faces, tot_faces);
 
-  // Cleanup
   MEM_freeN(obs_v0);
   MEM_freeN(obs_v1);
   MEM_freeN(obs_faces);
@@ -3768,8 +3768,7 @@ void sbObjectStep(struct Depsgraph *depsgraph,
 
     /* Do we need to initialize the ADMM-PD mesh?
      * a) Has never been initialized.
-     * b) The mesh topology has changed.
-     * TODO: ob->obmat or vertexCos change. */
+     * b) The mesh topology has changed. */
     int init_mesh = 0;
     if (is_first_frame || admmpd_mes

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list