[Bf-blender-cvs] [60ea01aa30d] master: Cleanup: Move four sculpt/paint files to C++
Hans Goudey
noreply at git.blender.org
Fri Jan 20 18:56:32 CET 2023
Commit: 60ea01aa30d36a5bb81649142d38786d00fa3481
Author: Hans Goudey
Date: Fri Jan 20 11:55:43 2023 -0600
Branches: master
https://developer.blender.org/rB60ea01aa30d36a5bb81649142d38786d00fa3481
Cleanup: Move four sculpt/paint files to C++
For continued refactoring of the Mesh data structure. See T103343.
===================================================================
M source/blender/editors/sculpt_paint/CMakeLists.txt
R088 source/blender/editors/sculpt_paint/paint_mask.c source/blender/editors/sculpt_paint/paint_mask.cc
R087 source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c source/blender/editors/sculpt_paint/paint_vertex_weight_ops.cc
R094 source/blender/editors/sculpt_paint/sculpt_expand.c source/blender/editors/sculpt_paint/sculpt_expand.cc
R096 source/blender/editors/sculpt_paint/sculpt_geodesic.c source/blender/editors/sculpt_paint/sculpt_geodesic.cc
===================================================================
diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt
index 62a07310106..35fc4ba705e 100644
--- a/source/blender/editors/sculpt_paint/CMakeLists.txt
+++ b/source/blender/editors/sculpt_paint/CMakeLists.txt
@@ -51,14 +51,14 @@ set(SRC
paint_image_2d_curve_mask.cc
paint_image_ops_paint.cc
paint_image_proj.cc
- paint_mask.c
+ paint_mask.cc
paint_ops.c
paint_stroke.c
paint_utils.c
paint_vertex.cc
paint_vertex_color_ops.cc
paint_vertex_proj.c
- paint_vertex_weight_ops.c
+ paint_vertex_weight_ops.cc
paint_vertex_weight_utils.c
sculpt.cc
sculpt_automasking.cc
@@ -67,12 +67,12 @@ set(SRC
sculpt_cloth.c
sculpt_detail.c
sculpt_dyntopo.cc
- sculpt_expand.c
+ sculpt_expand.cc
sculpt_face_set.cc
sculpt_filter_color.c
sculpt_filter_mask.c
sculpt_filter_mesh.c
- sculpt_geodesic.c
+ sculpt_geodesic.cc
sculpt_mask_expand.c
sculpt_mask_init.c
sculpt_multiplane_scrape.c
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.cc
similarity index 88%
rename from source/blender/editors/sculpt_paint/paint_mask.c
rename to source/blender/editors/sculpt_paint/paint_mask.cc
index 26d3b4fead9..c0f4ddf4218 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.cc
@@ -5,6 +5,8 @@
* \ingroup edsculpt
*/
+#include <cstdlib>
+
#include "MEM_guardedalloc.h"
#include "DNA_mesh_types.h"
@@ -13,7 +15,6 @@
#include "DNA_object_types.h"
#include "DNA_vec_types.h"
-#include "BLI_alloca.h"
#include "BLI_bitmap_draw_2d.h"
#include "BLI_lasso_2d.h"
#include "BLI_math_geom.h"
@@ -53,8 +54,6 @@
/* For undo push. */
#include "sculpt_intern.h"
-#include <stdlib.h>
-
static const EnumPropertyItem mode_items[] = {
{PAINT_MASK_FLOOD_VALUE,
"VALUE",
@@ -84,7 +83,7 @@ static void mask_flood_fill_set_elem(float *elem, PaintMaskFloodMode mode, float
}
}
-typedef struct MaskTaskData {
+struct MaskTaskData {
Object *ob;
PBVH *pbvh;
PBVHNode **nodes;
@@ -96,13 +95,13 @@ typedef struct MaskTaskData {
bool front_faces_only;
float view_normal[3];
-} MaskTaskData;
+};
static void mask_flood_fill_task_cb(void *__restrict userdata,
const int i,
- const TaskParallelTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict /*tls*/)
{
- MaskTaskData *data = userdata;
+ MaskTaskData *data = static_cast<MaskTaskData *>(userdata);
PBVHNode *node = data->nodes[i];
@@ -136,15 +135,13 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op)
const Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
- PaintMaskFloodMode mode;
- float value;
PBVH *pbvh;
PBVHNode **nodes;
int totnode;
bool multires;
- mode = RNA_enum_get(op->ptr, "mode");
- value = RNA_float_get(op->ptr, "value");
+ PaintMaskFloodMode mode = PaintMaskFloodMode(RNA_enum_get(op->ptr, "mode"));
+ float value = RNA_float_get(op->ptr, "value");
MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, ob);
BKE_sculpt_mask_layers_ensure(depsgraph, CTX_data_main(C), ob, mmd);
@@ -153,18 +150,17 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op)
pbvh = ob->sculpt->pbvh;
multires = (BKE_pbvh_type(pbvh) == PBVH_GRIDS);
- BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode);
+ BKE_pbvh_search_gather(pbvh, nullptr, nullptr, &nodes, &totnode);
SCULPT_undo_push_begin(ob, op);
- MaskTaskData data = {
- .ob = ob,
- .pbvh = pbvh,
- .nodes = nodes,
- .multires = multires,
- .mode = mode,
- .value = value,
- };
+ MaskTaskData data{};
+ data.ob = ob;
+ data.pbvh = pbvh;
+ data.nodes = nodes;
+ data.multires = multires;
+ data.mode = mode;
+ data.value = value;
TaskParallelSettings settings;
BKE_pbvh_parallel_range_settings(&settings, true, totnode);
@@ -187,7 +183,7 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-void PAINT_OT_mask_flood_fill(struct wmOperatorType *ot)
+void PAINT_OT_mask_flood_fill(wmOperatorType *ot)
{
/* Identifiers. */
ot->name = "Mask Flood Fill";
@@ -201,7 +197,7 @@ void PAINT_OT_mask_flood_fill(struct wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER;
/* RNA. */
- RNA_def_enum(ot->srna, "mode", mode_items, PAINT_MASK_FLOOD_VALUE, "Mode", NULL);
+ RNA_def_enum(ot->srna, "mode", mode_items, PAINT_MASK_FLOOD_VALUE, "Mode", nullptr);
RNA_def_float(
ot->srna,
"value",
@@ -216,13 +212,13 @@ void PAINT_OT_mask_flood_fill(struct wmOperatorType *ot)
/* Sculpt Gesture Operators. */
-typedef enum eSculptGestureShapeType {
+enum eSculptGestureShapeType {
SCULPT_GESTURE_SHAPE_BOX,
SCULPT_GESTURE_SHAPE_LASSO,
SCULPT_GESTURE_SHAPE_LINE,
-} eMaskGesturesShapeType;
+};
-typedef struct LassoGestureData {
+struct LassoGestureData {
float projviewobjmat[4][4];
rcti boundbox;
@@ -230,9 +226,9 @@ typedef struct LassoGestureData {
/* 2D bitmap to test if a vertex is affected by the lasso shape. */
BLI_bitmap *mask_px;
-} LassoGestureData;
+};
-typedef struct LineGestureData {
+struct LineGestureData {
/* Plane aligned to the gesture line. */
float true_plane[4];
float plane[4];
@@ -244,11 +240,11 @@ typedef struct LineGestureData {
bool use_side_planes;
bool flip;
-} LineGestureData;
+};
struct SculptGestureOperation;
-typedef struct SculptGestureContext {
+struct SculptGestureContext {
SculptSession *ss;
ViewContext vc;
@@ -257,10 +253,10 @@ typedef struct SculptGestureContext {
ePaintSymmetryFlags symmpass;
/* Operation parameters. */
- eMaskGesturesShapeType shape_type;
+ eSculptGestureShapeType shape_type;
bool front_faces_only;
- struct SculptGestureOperation *operation;
+ SculptGestureOperation *operation;
/* Gesture data. */
/* Screen space points that represent the gesture shape. */
@@ -294,19 +290,19 @@ typedef struct SculptGestureContext {
/* Task Callback Data. */
PBVHNode **nodes;
int totnode;
-} SculptGestureContext;
+};
-typedef struct SculptGestureOperation {
+struct SculptGestureOperation {
/* Initial setup (data updates, special undo push...). */
- void (*sculpt_gesture_begin)(struct bContext *, SculptGestureContext *);
+ void (*sculpt_gesture_begin)(bContext *, SculptGestureContext *);
/* Apply the gesture action for each symmetry pass. */
- void (*sculpt_gesture_apply_for_symmetry_pass)(struct bContext *, SculptGestureContext *);
+ void (*sculpt_gesture_apply_for_symmetry_pass)(bContext *, SculptGestureContext *);
/* Remaining actions after finishing the symmetry passes iterations
* (updating data-layers, tagging PBVH updates...). */
- void (*sculpt_gesture_end)(struct bContext *, SculptGestureContext *);
-} SculptGestureOperation;
+ void (*sculpt_gesture_end)(bContext *, SculptGestureContext *);
+};
static void sculpt_gesture_operator_properties(wmOperatorType *ot)
{
@@ -340,7 +336,7 @@ static void sculpt_gesture_context_init_common(bContext *C,
sgcontext->ss = ob->sculpt;
/* Symmetry. */
- sgcontext->symm = SCULPT_mesh_symmetry_xyz_get(ob);
+ sgcontext->symm = ePaintSymmetryFlags(SCULPT_mesh_symmetry_xyz_get(ob));
/* View Normal. */
float mat[3][3];
@@ -359,7 +355,7 @@ static void sculpt_gesture_context_init_common(bContext *C,
static void sculpt_gesture_lasso_px_cb(int x, int x_end, int y, void *user_data)
{
- SculptGestureContext *mcontext = user_data;
+ SculptGestureContext *mcontext = static_cast<SculptGestureContext *>(user_data);
LassoGestureData *lasso = &mcontext->lasso;
int index = (y * lasso->width) + x;
int index_end = (y * lasso->width) + x_end;
@@ -370,8 +366,7 @@ static void sculpt_gesture_lasso_px_cb(int x, int x_end, int y, void *user_data)
static SculptGestureContext *sculpt_gesture_init_from_lasso(bContext *C, wmOperator *op)
{
- SculptGestureContext *sgcontext = MEM_callocN(sizeof(SculptGestureContext),
- "sculpt gesture context lasso");
+ SculptGestureContext *sgcontext = MEM_cnew<SculptGestureContext>(__func__);
sgcontext->shape_type = SCULPT_GESTURE_SHAPE_LASSO;
sculpt_gesture_context_init_common(C, op, sgcontext);
@@ -380,7 +375,7 @@ static SculptGestureContext *sculpt_gesture_init_from_lasso(bContext *C, wmOpera
const int(*mcoords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcoords_len);
if (!mcoords) {
- return NULL;
+ return nullptr;
}
ED_view3d_ob_project_mat_get(
@@ -407,7 +402,8 @@ static SculptGestureContext *sculpt_gesture_init_from_lasso(bContext *C, wmOpera
sgcontext->vc.obact,
&sgcontext->lasso.boundbox);
- sgcontext->gesture_points = MEM_malloc_arrayN(mcoords_len, sizeof(float[2]), "trim points");
+ sgcontext->gesture_points = static_cast<float(*)[2]>(
+ MEM_malloc_arrayN(mcoords_len, sizeof(float[2]), "trim points"));
sgcontext->tot_gesture_points = mcoords_len;
for (int i = 0; i < mcoords_len; i++) {
sgcontext->gesture_points[i][0] = mcoords[i][0];
@@ -421,8 +417,7 @@ static SculptGestureContext *sculpt_gesture_init_from_lasso(bContext *C, wmOpera
static SculptGestureContext *sculpt_gesture_init_from_box(bContext *C, wmOperator *op)
{
- SculptGestureContext *sgcontext = MEM_callocN(sizeof(SculptGestureContext),
- "sculpt gesture context box");
+ SculptGestureContext *sgcontext = MEM_cnew<SculptGestureContext>(__func__);
sgcontext->shape_type = SCULPT_GESTURE_SHAPE_BOX;
sculpt_gesture_context_init_common(C, op, sgcontext);
@@ -434,7 +429,8 @@ static SculptGestureContext *sculpt_gesture_init_from_box(bContext *C, wmOperato
ED_view3d_clipping_calc(
&bb, sgcontext->true_clip_planes, sgcontext->vc.region, sgcontext->vc.obact, &rect);
- sgcontext->gesture_points = MEM_calloc_arrayN(4, sizeof(float[2]), "trim points"
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list