[Bf-blender-cvs] [ca29376e002] master: Cleanup: Move sculpt_automasking.c to c++

Joseph Eagar noreply at git.blender.org
Wed Jun 8 12:33:22 CEST 2022


Commit: ca29376e002c5427513ee2ed6633dd82811ac1bd
Author: Joseph Eagar
Date:   Wed Jun 8 03:32:57 2022 -0700
Branches: master
https://developer.blender.org/rBca29376e002c5427513ee2ed6633dd82811ac1bd

Cleanup: Move sculpt_automasking.c to c++

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

M	release/datafiles/locale
M	release/scripts/addons
M	release/scripts/addons_contrib
M	source/blender/editors/sculpt_paint/CMakeLists.txt
R090	source/blender/editors/sculpt_paint/sculpt_automasking.c	source/blender/editors/sculpt_paint/sculpt_automasking.cc
M	source/tools

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

diff --git a/release/datafiles/locale b/release/datafiles/locale
index 71e0f87dd1b..915744ad8e2 160000
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit 71e0f87dd1ba4e0ed5f619b031045a428e534230
+Subproject commit 915744ad8e255d1723d77671a6c6b074773c2199
diff --git a/release/scripts/addons b/release/scripts/addons
index bcb71eea69a..d990559d7b1 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit bcb71eea69a7b83c44112a5872ccd67cae96ec6f
+Subproject commit d990559d7b19593cbaff17ba59b8dd9d0d60e615
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
index 61efd17f87b..95107484d07 160000
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@ -1 +1 @@
-Subproject commit 61efd17f87b45c3049091127a5619219f9d2a821
+Subproject commit 95107484d076bc965239942e857c83433bfa86d7
diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt
index 9a9efc9e6cf..b1b52d16c6d 100644
--- a/source/blender/editors/sculpt_paint/CMakeLists.txt
+++ b/source/blender/editors/sculpt_paint/CMakeLists.txt
@@ -58,7 +58,7 @@ set(SRC
   paint_vertex_weight_ops.c
   paint_vertex_weight_utils.c
   sculpt.c
-  sculpt_automasking.c
+  sculpt_automasking.cc
   sculpt_boundary.c
   sculpt_brush_types.c
   sculpt_cloth.c
diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.c b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
similarity index 90%
rename from source/blender/editors/sculpt_paint/sculpt_automasking.c
rename to source/blender/editors/sculpt_paint/sculpt_automasking.cc
index d7a2a18504c..94417defe48 100644
--- a/source/blender/editors/sculpt_paint/sculpt_automasking.c
+++ b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
@@ -9,6 +9,7 @@
 
 #include "BLI_blenlib.h"
 #include "BLI_hash.h"
+#include "BLI_index_range.hh"
 #include "BLI_math.h"
 #include "BLI_task.h"
 
@@ -46,6 +47,8 @@
 #include <math.h>
 #include <stdlib.h>
 
+using blender::IndexRange;
+
 AutomaskingCache *SCULPT_automasking_active_cache_get(SculptSession *ss)
 {
   if (ss->cache) {
@@ -178,7 +181,7 @@ typedef struct AutomaskFloodFillData {
 static bool automask_floodfill_cb(
     SculptSession *ss, int from_v, int to_v, bool UNUSED(is_duplicate), void *userdata)
 {
-  AutomaskFloodFillData *data = userdata;
+  AutomaskFloodFillData *data = (AutomaskFloodFillData *)userdata;
 
   data->automask_factor[to_v] = 1.0f;
   data->automask_factor[from_v] = 1.0f;
@@ -198,7 +201,7 @@ static float *SCULPT_topology_automasking_init(Sculpt *sd, Object *ob, float *au
   }
 
   const int totvert = SCULPT_vertex_count_get(ss);
-  for (int i = 0; i < totvert; i++) {
+  for (int i : IndexRange(totvert)) {
     automask_factor[i] = 0.0f;
   }
 
@@ -209,12 +212,13 @@ static float *SCULPT_topology_automasking_init(Sculpt *sd, Object *ob, float *au
   const float radius = ss->cache ? ss->cache->radius : FLT_MAX;
   SCULPT_floodfill_add_active(sd, ob, ss, &flood, radius);
 
-  AutomaskFloodFillData fdata = {
-      .automask_factor = automask_factor,
-      .radius = radius,
-      .use_radius = ss->cache && sculpt_automasking_is_constrained_by_radius(brush),
-      .symm = SCULPT_mesh_symmetry_xyz_get(ob),
-  };
+  AutomaskFloodFillData fdata = {0};
+
+  fdata.automask_factor = automask_factor;
+  fdata.radius = radius;
+  fdata.use_radius = ss->cache && sculpt_automasking_is_constrained_by_radius(brush);
+  fdata.symm = SCULPT_mesh_symmetry_xyz_get(ob);
+
   copy_v3_v3(fdata.location, SCULPT_active_vertex_co_get(ss));
   SCULPT_floodfill_execute(ss, &flood, automask_floodfill_cb, &fdata);
   SCULPT_floodfill_free(&flood);
@@ -238,7 +242,7 @@ static float *sculpt_face_sets_automasking_init(Sculpt *sd, Object *ob, float *a
 
   int tot_vert = SCULPT_vertex_count_get(ss);
   int active_face_set = SCULPT_active_face_set_get(ss);
-  for (int i = 0; i < tot_vert; i++) {
+  for (int i : IndexRange(tot_vert)) {
     if (!SCULPT_vertex_has_face_set(ss, i, active_face_set)) {
       automask_factor[i] *= 0.0f;
     }
@@ -262,9 +266,9 @@ float *SCULPT_boundary_automasking_init(Object *ob,
   }
 
   const int totvert = SCULPT_vertex_count_get(ss);
-  int *edge_distance = MEM_callocN(sizeof(int) * totvert, "automask_factor");
+  int *edge_distance = (int *)MEM_callocN(sizeof(int) * totvert, "automask_factor");
 
-  for (int i = 0; i < totvert; i++) {
+  for (int i : IndexRange(totvert)) {
     edge_distance[i] = EDGE_DISTANCE_INF;
     switch (mode) {
       case AUTOMASK_INIT_BOUNDARY_EDGES:
@@ -280,8 +284,8 @@ float *SCULPT_boundary_automasking_init(Object *ob,
     }
   }
 
-  for (int propagation_it = 0; propagation_it < propagation_steps; propagation_it++) {
-    for (int i = 0; i < totvert; i++) {
+  for (int propagation_it : IndexRange(propagation_steps)) {
+    for (int i : IndexRange(totvert)) {
       if (edge_distance[i] != EDGE_DISTANCE_INF) {
         continue;
       }
@@ -295,7 +299,7 @@ float *SCULPT_boundary_automasking_init(Object *ob,
     }
   }
 
-  for (int i = 0; i < totvert; i++) {
+  for (int i : IndexRange(totvert)) {
     if (edge_distance[i] == EDGE_DISTANCE_INF) {
       continue;
     }
@@ -326,7 +330,8 @@ AutomaskingCache *SCULPT_automasking_cache_init(Sculpt *sd, Brush *brush, Object
     return NULL;
   }
 
-  AutomaskingCache *automasking = MEM_callocN(sizeof(AutomaskingCache), "automasking cache");
+  AutomaskingCache *automasking = (AutomaskingCache *)MEM_callocN(sizeof(AutomaskingCache),
+                                                                  "automasking cache");
   SCULPT_automasking_cache_settings_update(automasking, ss, sd, brush);
   SCULPT_boundary_info_ensure(ob);
 
@@ -334,8 +339,8 @@ AutomaskingCache *SCULPT_automasking_cache_init(Sculpt *sd, Brush *brush, Object
     return automasking;
   }
 
-  automasking->factor = MEM_malloc_arrayN(totvert, sizeof(float), "automask_factor");
-  for (int i = 0; i < totvert; i++) {
+  automasking->factor = (float *)MEM_malloc_arrayN(totvert, sizeof(float), "automask_factor");
+  for (int i : IndexRange(totvert)) {
     automasking->factor[i] = 1.0f;
   }
 
diff --git a/source/tools b/source/tools
index ccc8fceb6bd..01b4c0e4a17 160000
--- a/source/tools
+++ b/source/tools
@@ -1 +1 @@
-Subproject commit ccc8fceb6bd83ffbf6e5207247fb8f76fc47a5b6
+Subproject commit 01b4c0e4a172819414229445c314be34527bf412



More information about the Bf-blender-cvs mailing list