[Bf-blender-cvs] [fb5696de256] soc-2020-soft-body: ran make format

mattoverby noreply at git.blender.org
Wed Aug 19 15:39:27 CEST 2020


Commit: fb5696de256a5f57286aa2db4318e89b03c69047
Author: mattoverby
Date:   Wed Aug 19 08:37:17 2020 -0500
Branches: soc-2020-soft-body
https://developer.blender.org/rBfb5696de256a5f57286aa2db4318e89b03c69047

ran make format

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

M	extern/softbody/src/admmpd_collision.cpp
M	source/blender/blenkernel/BKE_mesh_remesh_voxel.h
M	source/blender/blenkernel/intern/mesh_remesh_voxel.c
M	source/blender/blenkernel/intern/softbody.c
M	source/blender/editors/object/object_remesh.c
M	source/blender/gpu/intern/gpu_backend.hh
M	source/blender/makesdna/DNA_object_force_types.h
M	source/blender/makesrna/intern/rna_object_force.c
M	source/blender/modifiers/intern/MOD_softbody.c

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

diff --git a/extern/softbody/src/admmpd_collision.cpp b/extern/softbody/src/admmpd_collision.cpp
index 3e2400ed9dd..78889b810b8 100644
--- a/extern/softbody/src/admmpd_collision.cpp
+++ b/extern/softbody/src/admmpd_collision.cpp
@@ -191,6 +191,9 @@ int EmbeddedMeshCollision::detect(
 
 	//
 	// Detection function for a single embedded vertex
+	// This function is very poorly optimized in terms of
+	// cache friendlyness.
+	// Some refactoring would greatly improve run time.
 	//
 //	auto per_embedded_vertex_detect = [](
 //		void *__restrict userdata,
@@ -299,8 +302,7 @@ int EmbeddedMeshCollision::detect(
 	// vertices next to eachother are on different threads to provide
 	// better concurrency. Otherwise a standard slice may end up doing
 	// all of the BVH traversals and the other threads do none.
-	// I haven't actually profiled this, so maybe I'm wrong. Either way it
-	// won't hurt. I think.
+	// I haven't actually profiled this, so maybe I'm wrong.
 	int max_threads = std::max(1, std::min(nev, admmpd::get_max_threads(options)));
 	const auto & per_thread_function = [&per_embedded_vertex_detect,&max_threads,&nev]
 		(DetectThreadData *td, int thread_idx)
diff --git a/source/blender/blenkernel/BKE_mesh_remesh_voxel.h b/source/blender/blenkernel/BKE_mesh_remesh_voxel.h
index 51b9369bd4e..277747e3e27 100644
--- a/source/blender/blenkernel/BKE_mesh_remesh_voxel.h
+++ b/source/blender/blenkernel/BKE_mesh_remesh_voxel.h
@@ -57,8 +57,8 @@ struct Mesh *BKE_mesh_remesh_quadriflow_to_mesh_nomain(struct Mesh *mesh,
                                                        void *update_cb,
                                                        void *update_cb_data);
 struct Mesh *BKE_mesh_remesh_tetgen_to_mesh_nomain(struct Mesh *mesh,
-													unsigned int **tets,
-													int *numtets);
+                                                   unsigned int **tets,
+                                                   int *numtets);
 
 /* Data reprojection functions */
 void BKE_mesh_remesh_reproject_paint_mask(struct Mesh *target, struct Mesh *source);
diff --git a/source/blender/blenkernel/intern/mesh_remesh_voxel.c b/source/blender/blenkernel/intern/mesh_remesh_voxel.c
index a488d292aa4..05cc9769bf7 100644
--- a/source/blender/blenkernel/intern/mesh_remesh_voxel.c
+++ b/source/blender/blenkernel/intern/mesh_remesh_voxel.c
@@ -265,9 +265,7 @@ static Mesh *BKE_mesh_remesh_quadriflow(Mesh *input_mesh,
 #endif
 
 #ifdef WITH_TETGEN
-static Mesh *BKE_mesh_remesh_tetgen(Mesh *input_mesh,
-                                  unsigned int **tets,
-                                  int *numtets)
+static Mesh *BKE_mesh_remesh_tetgen(Mesh *input_mesh, unsigned int **tets, int *numtets)
 {
   // Ensure that the triangulated mesh data is up to data
   BKE_mesh_runtime_looptri_recalc(input_mesh);
@@ -318,11 +316,9 @@ static Mesh *BKE_mesh_remesh_tetgen(Mesh *input_mesh,
   verttri = NULL;
 
   Mesh *mesh = NULL;
-  if (success)
-  {
+  if (success) {
     // Construct the new output mesh
-    mesh = BKE_mesh_new_nomain(
-        tg.out_totverts, 0, 0, (tg.out_totfacets * 3), tg.out_totfacets);
+    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++) {
       copy_v3_v3(mesh->mvert[i].co, &tg.out_verts[i * 3]);
@@ -341,26 +337,24 @@ static Mesh *BKE_mesh_remesh_tetgen(Mesh *input_mesh,
     BKE_mesh_calc_normals(mesh);
 
     *numtets = tg.out_tottets;
-    *tets = (unsigned int *)MEM_malloc_arrayN(tg.out_tottets*4, sizeof(unsigned int), "remesh_output_tets");
+    *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));
+    memcpy(*tets, tg.out_tets, tg.out_tottets * 4 * sizeof(unsigned int));
 
-  } // end success
+  }  // end success
 
-  if (tg.out_verts != NULL)
-  {
+  if (tg.out_verts != NULL) {
     MEM_freeN(tg.out_verts);
     tg.out_verts = NULL;
   }
 
-  if (tg.out_facets != NULL)
-  {
+  if (tg.out_facets != NULL) {
     MEM_freeN(tg.out_facets);
     tg.out_facets = NULL;
   }
 
-  if (tg.out_tets != NULL)
-  {
+  if (tg.out_tets != NULL) {
     MEM_freeN(tg.out_tets);
     tg.out_tets = NULL;
   }
@@ -370,16 +364,14 @@ static Mesh *BKE_mesh_remesh_tetgen(Mesh *input_mesh,
 #endif
 
 struct Mesh *BKE_mesh_remesh_tetgen_to_mesh_nomain(struct Mesh *mesh,
-                                                unsigned int **tets,
-                                                int *numtets)
+                                                   unsigned int **tets,
+                                                   int *numtets)
 {
-  #ifdef WITH_TETGEN
-  return BKE_mesh_remesh_tetgen(mesh,tets,numtets);  
-  #else
-  UNUSED_VARS(mesh,
-              tets,
-              numtets);
-  #endif
+#ifdef WITH_TETGEN
+  return BKE_mesh_remesh_tetgen(mesh, tets, numtets);
+#else
+  UNUSED_VARS(mesh, tets, numtets);
+#endif
   return NULL;
 }
 
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index 2ef42be1f83..bca2af1fb18 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -926,7 +926,7 @@ static void free_scratch(SoftBody *sb)
 /* only frees internal data */
 static void free_softbody_intern(SoftBody *sb)
 {
-  if (sb) {   
+  if (sb) {
     int a;
     BodyPoint *bp;
 
@@ -3085,7 +3085,7 @@ static void softbody_to_object(Object *ob, float (*vertexCos)[3], int numVerts,
 {
   SoftBody *sb = ob->soft;
   if (sb) {
-    //int sb_totpt = sb->totpoint;
+    // int sb_totpt = sb->totpoint;
 
     BodyPoint *bp = sb->bpoint;
     int a;
@@ -3128,12 +3128,12 @@ SoftBody *sbNew(Scene *scene)
   SoftBody *sb;
   sb = MEM_callocN(sizeof(SoftBody), "softbody");
 
-  sb->solver_mode = SOLVER_MODE_LEGACY;//SOLVER_MODE_ADMMPD;
-  sb->admmpd_mesh_mode = 0; // embedded
+  sb->solver_mode = SOLVER_MODE_LEGACY;  // SOLVER_MODE_ADMMPD;
+  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_material = 0;  // ARAP
   sb->admmpd_embed_res = 3;
   sb->admmpd_converge_eps = 1e-4;
   sb->admmpd_youngs_exp = 6;
@@ -3143,11 +3143,11 @@ SoftBody *sbNew(Scene *scene)
   sb->admmpd_pk_exp = 4;
   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_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_loglevel = 1;   // low
+  sb->admmpd_linsolver = 1;  // PCG
   sb->admmpd = MEM_callocN(sizeof(ADMMPDInterfaceData), "SoftBody_admmpd");
 
   sb->mediafrict = 0.5f;
@@ -3564,22 +3564,21 @@ static void sbStoreLastFrame(struct Depsgraph *depsgraph, Object *object, float
   object_orig->soft->last_frame = framenr;
 }
 
-static void update_collider_admmpd(
-  Depsgraph *depsgraph,
-  Collection *collection,
-  Object *vertexowner)
+static void update_collider_admmpd(Depsgraph *depsgraph,
+                                   Collection *collection,
+                                   Object *vertexowner)
 {
   SoftBody *sb = vertexowner->soft;
-  if (!sb) { return; }
-  if (!sb->admmpd) { return; }
+  if (!sb) {
+    return;
+  }
+  if (!sb->admmpd) {
+    return;
+  }
 
   unsigned int numobjects;
   Object **objects = BKE_collision_objects_create(
-      depsgraph,
-      vertexowner,
-      collection,
-      &numobjects,
-      eModifierType_Collision);
+      depsgraph, vertexowner, collection, &numobjects, eModifierType_Collision);
 
   // How many faces and vertices do we need to allocate?
   int tot_verts = 0;
@@ -3587,9 +3586,9 @@ static void update_collider_admmpd(
   for (int i = 0; i < numobjects; ++i) {
     Object *ob = objects[i];
     if (ob->type == OB_MESH) {
-      if (ob->pd && ob->pd->deflect){
-        CollisionModifierData *cmd = (CollisionModifierData *)
-          BKE_modifiers_findby_type(ob, eModifierType_Collision);
+      if (ob->pd && ob->pd->deflect) {
+        CollisionModifierData *cmd = (CollisionModifierData *)BKE_modifiers_findby_type(
+            ob, eModifierType_Collision);
         if (!cmd)
           continue;
         tot_verts += cmd->mvert_num;
@@ -3598,9 +3597,9 @@ static void update_collider_admmpd(
     }
   }
 
-  float *obs_v0 = MEM_callocN(sizeof(float)*3*tot_verts, __func__);
-  float *obs_v1 = MEM_callocN(sizeof(float)*3*tot_verts, __func__);
-  unsigned int *obs_faces = MEM_callocN(sizeof(unsigned int)*3*tot_faces, __func__);
+  float *obs_v0 = MEM_callocN(sizeof(float) * 3 * tot_verts, __func__);
+  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
   int curr_verts = 0;
@@ -3608,24 +3607,24 @@ static void update_collider_admmpd(
   for (int i = 0; i < numobjects; ++i) {
     Object *ob = objects[i];
     if (ob->type == OB_MESH) {
-      if (ob->pd && ob->pd->deflect){
-        CollisionModifierData *cmd = (CollisionModifierData *)
-          BKE_modifiers_findby_type(ob, eModifierType_Collision);
+      if (ob->pd && ob->pd->deflect) {
+        CollisionModifierData *cmd = (CollisionModifierData *)BKE_modifiers_findby_type(
+            ob, eModifierType_Collision);
         if (!cmd)
           continue;
 
-        for (int j=0; j<cmd->mvert_num; ++j) {
-          int v_idx = j*3 + curr_verts*3;
-          for (int k=0; k<3; ++k) { 
-            obs_v0[v_idx+k] = cmd->x[j].co[k];
-            obs_v1[v_idx+k] = cmd->xnew[j].co[k];
+        for (int j = 0; j < cmd->mvert_num; ++j) {
+          int v_idx = j * 3 + curr_verts * 3;
+          for (int k = 0; k < 3; ++k) {
+            obs_v0[v_idx + k] = cmd->x[j].co[k];
+            obs_v1[v_idx + k] = cmd->xnew[j].co[k];
        

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list