Cleanup: Move four sculpt/paint files to C++
For continued refactoring of the Mesh data structure. See T103343.
This commit is contained in:
parent
f31f7e3ef0
commit
60ea01aa30
|
@ -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
|
||||
|
|
|
@ -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");
|
||||
sgcontext->gesture_points = static_cast<float(*)[2]>(
|
||||
MEM_calloc_arrayN(4, sizeof(float[2]), "trim points"));
|
||||
sgcontext->tot_gesture_points = 4;
|
||||
|
||||
sgcontext->gesture_points[0][0] = rect.xmax;
|
||||
|
@ -497,8 +493,7 @@ static void sculpt_gesture_line_calculate_plane_points(SculptGestureContext *sgc
|
|||
|
||||
static SculptGestureContext *sculpt_gesture_init_from_line(bContext *C, wmOperator *op)
|
||||
{
|
||||
SculptGestureContext *sgcontext = MEM_callocN(sizeof(SculptGestureContext),
|
||||
"sculpt gesture context line");
|
||||
SculptGestureContext *sgcontext = MEM_cnew<SculptGestureContext>(__func__);
|
||||
sgcontext->shape_type = SCULPT_GESTURE_SHAPE_LINE;
|
||||
|
||||
sculpt_gesture_context_init_common(C, op, sgcontext);
|
||||
|
@ -600,8 +595,10 @@ static void sculpt_gesture_update_effected_nodes_by_line_plane(SculptGestureCont
|
|||
copy_v4_v4(clip_planes[1], sgcontext->line.side_plane[0]);
|
||||
copy_v4_v4(clip_planes[2], sgcontext->line.side_plane[1]);
|
||||
|
||||
const int num_planes = sgcontext->line.use_side_planes ? 3 : 1;
|
||||
PBVHFrustumPlanes frustum = {.planes = clip_planes, .num_planes = num_planes};
|
||||
PBVHFrustumPlanes frustum{};
|
||||
frustum.planes = clip_planes;
|
||||
frustum.num_planes = sgcontext->line.use_side_planes ? 3 : 1;
|
||||
|
||||
BKE_pbvh_search_gather(ss->pbvh,
|
||||
BKE_pbvh_node_frustum_contain_AABB,
|
||||
&frustum,
|
||||
|
@ -615,7 +612,11 @@ static void sculpt_gesture_update_effected_nodes_by_clip_planes(SculptGestureCon
|
|||
float clip_planes[4][4];
|
||||
copy_m4_m4(clip_planes, sgcontext->clip_planes);
|
||||
negate_m4(clip_planes);
|
||||
PBVHFrustumPlanes frustum = {.planes = clip_planes, .num_planes = 4};
|
||||
|
||||
PBVHFrustumPlanes frustum{};
|
||||
frustum.planes = clip_planes;
|
||||
frustum.num_planes = 4;
|
||||
|
||||
BKE_pbvh_search_gather(ss->pbvh,
|
||||
BKE_pbvh_node_frustum_contain_AABB,
|
||||
&frustum,
|
||||
|
@ -709,9 +710,9 @@ static void sculpt_gesture_apply(bContext *C, SculptGestureContext *sgcontext, w
|
|||
|
||||
operation->sculpt_gesture_begin(C, sgcontext);
|
||||
|
||||
for (ePaintSymmetryFlags symmpass = 0; symmpass <= sgcontext->symm; symmpass++) {
|
||||
for (int symmpass = 0; symmpass <= sgcontext->symm; symmpass++) {
|
||||
if (SCULPT_is_symmetry_iteration_valid(symmpass, sgcontext->symm)) {
|
||||
sculpt_gesture_flip_for_symmetry_pass(sgcontext, symmpass);
|
||||
sculpt_gesture_flip_for_symmetry_pass(sgcontext, ePaintSymmetryFlags(symmpass));
|
||||
sculpt_gesture_update_effected_nodes(sgcontext);
|
||||
|
||||
operation->sculpt_gesture_apply_for_symmetry_pass(C, sgcontext);
|
||||
|
@ -730,11 +731,11 @@ static void sculpt_gesture_apply(bContext *C, SculptGestureContext *sgcontext, w
|
|||
|
||||
/* Face Set Gesture Operation. */
|
||||
|
||||
typedef struct SculptGestureFaceSetOperation {
|
||||
struct SculptGestureFaceSetOperation {
|
||||
SculptGestureOperation op;
|
||||
|
||||
int new_face_set_id;
|
||||
} SculptGestureFaceSetOperation;
|
||||
};
|
||||
|
||||
static void sculpt_gesture_face_set_begin(bContext *C, SculptGestureContext *sgcontext)
|
||||
{
|
||||
|
@ -744,9 +745,9 @@ static void sculpt_gesture_face_set_begin(bContext *C, SculptGestureContext *sgc
|
|||
|
||||
static void face_set_gesture_apply_task_cb(void *__restrict userdata,
|
||||
const int i,
|
||||
const TaskParallelTLS *__restrict UNUSED(tls))
|
||||
const TaskParallelTLS *__restrict /*tls*/)
|
||||
{
|
||||
SculptGestureContext *sgcontext = userdata;
|
||||
SculptGestureContext *sgcontext = static_cast<SculptGestureContext *>(userdata);
|
||||
SculptGestureFaceSetOperation *face_set_operation = (SculptGestureFaceSetOperation *)
|
||||
sgcontext->operation;
|
||||
PBVHNode *node = sgcontext->nodes[i];
|
||||
|
@ -768,7 +769,7 @@ static void face_set_gesture_apply_task_cb(void *__restrict userdata,
|
|||
}
|
||||
}
|
||||
|
||||
static void sculpt_gesture_face_set_apply_for_symmetry_pass(bContext *UNUSED(C),
|
||||
static void sculpt_gesture_face_set_apply_for_symmetry_pass(bContext * /*C*/,
|
||||
SculptGestureContext *sgcontext)
|
||||
{
|
||||
TaskParallelSettings settings;
|
||||
|
@ -777,16 +778,17 @@ static void sculpt_gesture_face_set_apply_for_symmetry_pass(bContext *UNUSED(C),
|
|||
0, sgcontext->totnode, sgcontext, face_set_gesture_apply_task_cb, &settings);
|
||||
}
|
||||
|
||||
static void sculpt_gesture_face_set_end(bContext *UNUSED(C), SculptGestureContext *sgcontext)
|
||||
static void sculpt_gesture_face_set_end(bContext * /*C*/, SculptGestureContext *sgcontext)
|
||||
{
|
||||
BKE_pbvh_update_vertex_data(sgcontext->ss->pbvh, PBVH_UpdateVisibility);
|
||||
}
|
||||
|
||||
static void sculpt_gesture_init_face_set_properties(SculptGestureContext *sgcontext,
|
||||
wmOperator *UNUSED(op))
|
||||
wmOperator * /*op*/)
|
||||
{
|
||||
struct Mesh *mesh = BKE_mesh_from_object(sgcontext->vc.obact);
|
||||
sgcontext->operation = MEM_callocN(sizeof(SculptGestureFaceSetOperation), "Face Set Operation");
|
||||
Mesh *mesh = BKE_mesh_from_object(sgcontext->vc.obact);
|
||||
sgcontext->operation = reinterpret_cast<SculptGestureOperation *>(
|
||||
MEM_cnew<SculptGestureFaceSetOperation>(__func__));
|
||||
|
||||
sgcontext->ss->face_sets = BKE_sculpt_face_sets_ensure(mesh);
|
||||
|
||||
|
@ -803,12 +805,12 @@ static void sculpt_gesture_init_face_set_properties(SculptGestureContext *sgcont
|
|||
|
||||
/* Mask Gesture Operation. */
|
||||
|
||||
typedef struct SculptGestureMaskOperation {
|
||||
struct SculptGestureMaskOperation {
|
||||
SculptGestureOperation op;
|
||||
|
||||
PaintMaskFloodMode mode;
|
||||
float value;
|
||||
} SculptGestureMaskOperation;
|
||||
};
|
||||
|
||||
static void sculpt_gesture_mask_begin(bContext *C, SculptGestureContext *sgcontext)
|
||||
{
|
||||
|
@ -818,9 +820,9 @@ static void sculpt_gesture_mask_begin(bContext *C, SculptGestureContext *sgconte
|
|||
|
||||
static void mask_gesture_apply_task_cb(void *__restrict userdata,
|
||||
const int i,
|
||||
const TaskParallelTLS *__restrict UNUSED(tls))
|
||||
const TaskParallelTLS *__restrict /*tls*/)
|
||||
{
|
||||
SculptGestureContext *sgcontext = userdata;
|
||||
SculptGestureContext *sgcontext = static_cast<SculptGestureContext *>(userdata);
|
||||
SculptGestureMaskOperation *mask_operation = (SculptGestureMaskOperation *)sgcontext->operation;
|
||||
Object *ob = sgcontext->vc.obact;
|
||||
PBVHNode *node = sgcontext->nodes[i];
|
||||
|
@ -856,7 +858,7 @@ static void mask_gesture_apply_task_cb(void *__restrict userdata,
|
|||
}
|
||||
}
|
||||
|
||||
static void sculpt_gesture_mask_apply_for_symmetry_pass(bContext *UNUSED(C),
|
||||
static void sculpt_gesture_mask_apply_for_symmetry_pass(bContext * /*C*/,
|
||||
SculptGestureContext *sgcontext)
|
||||
{
|
||||
TaskParallelSettings settings;
|
||||
|
@ -877,7 +879,8 @@ static void sculpt_gesture_init_mask_properties(bContext *C,
|
|||
SculptGestureContext *sgcontext,
|
||||
wmOperator *op)
|
||||
{
|
||||
sgcontext->operation = MEM_callocN(sizeof(SculptGestureMaskOperation), "Mask Operation");
|
||||
sgcontext->operation = reinterpret_cast<SculptGestureOperation *>(
|
||||
MEM_cnew<SculptGestureMaskOperation>(__func__));
|
||||
|
||||
SculptGestureMaskOperation *mask_operation = (SculptGestureMaskOperation *)sgcontext->operation;
|
||||
|
||||
|
@ -891,13 +894,13 @@ static void sculpt_gesture_init_mask_properties(bContext *C,
|
|||
sculpt_gesture_mask_apply_for_symmetry_pass;
|
||||
mask_operation->op.sculpt_gesture_end = sculpt_gesture_mask_end;
|
||||
|
||||
mask_operation->mode = RNA_enum_get(op->ptr, "mode");
|
||||
mask_operation->mode = PaintMaskFloodMode(RNA_enum_get(op->ptr, "mode"));
|
||||
mask_operation->value = RNA_float_get(op->ptr, "value");
|
||||
}
|
||||
|
||||
static void paint_mask_gesture_operator_properties(wmOperatorType *ot)
|
||||
{
|
||||
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",
|
||||
|
@ -912,12 +915,12 @@ static void paint_mask_gesture_operator_properties(wmOperatorType *ot)
|
|||
|
||||
/* Trim Gesture Operation. */
|
||||
|
||||
typedef enum eSculptTrimOperationType {
|
||||
enum eSculptTrimOperationType {
|
||||
SCULPT_GESTURE_TRIM_INTERSECT,
|
||||
SCULPT_GESTURE_TRIM_DIFFERENCE,
|
||||
SCULPT_GESTURE_TRIM_UNION,
|
||||
SCULPT_GESTURE_TRIM_JOIN,
|
||||
} eSculptTrimOperationType;
|
||||
};
|
||||
|
||||
/* Intersect is not exposed in the UI because it does not work correctly with symmetry (it deletes
|
||||
* the symmetrical part of the mesh in the first symmetry pass). */
|
||||
|
@ -933,13 +936,13 @@ static EnumPropertyItem prop_trim_operation_types[] = {
|
|||
0,
|
||||
"Join",
|
||||
"Join the new mesh as separate geometry, without performing any boolean operation"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
typedef enum eSculptTrimOrientationType {
|
||||
enum eSculptTrimOrientationType {
|
||||
SCULPT_GESTURE_TRIM_ORIENTATION_VIEW,
|
||||
SCULPT_GESTURE_TRIM_ORIENTATION_SURFACE,
|
||||
} eSculptTrimOrientationType;
|
||||
};
|
||||
static EnumPropertyItem prop_trim_orientation_types[] = {
|
||||
{SCULPT_GESTURE_TRIM_ORIENTATION_VIEW,
|
||||
"VIEW",
|
||||
|
@ -951,13 +954,13 @@ static EnumPropertyItem prop_trim_orientation_types[] = {
|
|||
0,
|
||||
"Surface",
|
||||
"Use the surface normal to orientate the trimming shape"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
typedef enum eSculptTrimExtrudeMode {
|
||||
enum eSculptTrimExtrudeMode {
|
||||
SCULPT_GESTURE_TRIM_EXTRUDE_PROJECT,
|
||||
SCULPT_GESTURE_TRIM_EXTRUDE_FIXED
|
||||
} eSculptTrimExtrudeMode;
|
||||
};
|
||||
|
||||
static EnumPropertyItem prop_trim_extrude_modes[] = {
|
||||
{SCULPT_GESTURE_TRIM_EXTRUDE_PROJECT,
|
||||
|
@ -966,10 +969,10 @@ static EnumPropertyItem prop_trim_extrude_modes[] = {
|
|||
"Project",
|
||||
"Project back faces when extruding"},
|
||||
{SCULPT_GESTURE_TRIM_EXTRUDE_FIXED, "FIXED", 0, "Fixed", "Extrude back faces by fixed amount"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
typedef struct SculptGestureTrimOperation {
|
||||
struct SculptGestureTrimOperation {
|
||||
SculptGestureOperation op;
|
||||
|
||||
Mesh *mesh;
|
||||
|
@ -983,7 +986,7 @@ typedef struct SculptGestureTrimOperation {
|
|||
eSculptTrimOperationType mode;
|
||||
eSculptTrimOrientationType orientation;
|
||||
eSculptTrimExtrudeMode extrude_mode;
|
||||
} SculptGestureTrimOperation;
|
||||
};
|
||||
|
||||
static void sculpt_gesture_trim_normals_update(SculptGestureContext *sgcontext)
|
||||
{
|
||||
|
@ -991,31 +994,29 @@ static void sculpt_gesture_trim_normals_update(SculptGestureContext *sgcontext)
|
|||
Mesh *trim_mesh = trim_operation->mesh;
|
||||
|
||||
const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(trim_mesh);
|
||||
BMesh *bm;
|
||||
bm = BM_mesh_create(&allocsize,
|
||||
&((struct BMeshCreateParams){
|
||||
.use_toolflags = true,
|
||||
}));
|
||||
|
||||
BM_mesh_bm_from_me(bm,
|
||||
trim_mesh,
|
||||
(&(struct BMeshFromMeshParams){
|
||||
.calc_face_normal = true,
|
||||
.calc_vert_normal = true,
|
||||
}));
|
||||
BMeshCreateParams bm_create_params{};
|
||||
bm_create_params.use_toolflags = true;
|
||||
BMesh *bm = BM_mesh_create(&allocsize, &bm_create_params);
|
||||
|
||||
BMeshFromMeshParams bm_from_me_params{};
|
||||
bm_from_me_params.calc_face_normal = true;
|
||||
bm_from_me_params.calc_vert_normal = true;
|
||||
BM_mesh_bm_from_me(bm, trim_mesh, &bm_from_me_params);
|
||||
|
||||
BM_mesh_elem_hflag_enable_all(bm, BM_FACE, BM_ELEM_TAG, false);
|
||||
BMO_op_callf(bm,
|
||||
(BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE),
|
||||
"recalc_face_normals faces=%hf",
|
||||
BM_ELEM_TAG);
|
||||
BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_TAG, false);
|
||||
Mesh *result = BKE_mesh_from_bmesh_nomain(bm,
|
||||
(&(struct BMeshToMeshParams){
|
||||
.calc_object_remap = false,
|
||||
}),
|
||||
trim_mesh);
|
||||
|
||||
BMeshToMeshParams convert_params{};
|
||||
convert_params.calc_object_remap = false;
|
||||
Mesh *result = BKE_mesh_from_bmesh_nomain(bm, &convert_params, trim_mesh);
|
||||
|
||||
BM_mesh_free(bm);
|
||||
BKE_id_free(NULL, trim_mesh);
|
||||
BKE_id_free(nullptr, trim_mesh);
|
||||
trim_operation->mesh = result;
|
||||
}
|
||||
|
||||
|
@ -1142,7 +1143,8 @@ static void sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex
|
|||
const int trim_totpolys = (2 * (tot_screen_points - 2)) + (2 * tot_screen_points);
|
||||
trim_operation->mesh = BKE_mesh_new_nomain(
|
||||
trim_totverts, 0, 0, trim_totpolys * 3, trim_totpolys);
|
||||
trim_operation->true_mesh_co = MEM_malloc_arrayN(trim_totverts, sizeof(float[3]), "mesh orco");
|
||||
trim_operation->true_mesh_co = static_cast<float(*)[3]>(
|
||||
MEM_malloc_arrayN(trim_totverts, sizeof(float[3]), "mesh orco"));
|
||||
|
||||
float depth_front = trim_operation->depth_front;
|
||||
float depth_back = trim_operation->depth_back;
|
||||
|
@ -1213,7 +1215,8 @@ static void sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex
|
|||
|
||||
/* Get the triangulation for the front/back poly. */
|
||||
const int tot_tris_face = tot_screen_points - 2;
|
||||
uint(*r_tris)[3] = MEM_malloc_arrayN(tot_tris_face, sizeof(uint[3]), "tris");
|
||||
uint(*r_tris)[3] = static_cast<uint(*)[3]>(
|
||||
MEM_malloc_arrayN(tot_tris_face, sizeof(uint[3]), "tris"));
|
||||
BLI_polyfill_calc(screen_points, tot_screen_points, 0, r_tris);
|
||||
|
||||
/* Write the front face triangle indices. */
|
||||
|
@ -1222,7 +1225,7 @@ static void sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex
|
|||
MPoly *mp = polys;
|
||||
MLoop *ml = loops;
|
||||
for (int i = 0; i < tot_tris_face; i++, mp++, ml += 3) {
|
||||
mp->loopstart = (int)(ml - loops);
|
||||
mp->loopstart = int(ml - loops);
|
||||
mp->totloop = 3;
|
||||
ml[0].v = r_tris[i][0];
|
||||
ml[1].v = r_tris[i][1];
|
||||
|
@ -1231,7 +1234,7 @@ static void sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex
|
|||
|
||||
/* Write the back face triangle indices. */
|
||||
for (int i = 0; i < tot_tris_face; i++, mp++, ml += 3) {
|
||||
mp->loopstart = (int)(ml - loops);
|
||||
mp->loopstart = int(ml - loops);
|
||||
mp->totloop = 3;
|
||||
ml[0].v = r_tris[i][0] + tot_screen_points;
|
||||
ml[1].v = r_tris[i][1] + tot_screen_points;
|
||||
|
@ -1242,7 +1245,7 @@ static void sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex
|
|||
|
||||
/* Write the indices for the lateral triangles. */
|
||||
for (int i = 0; i < tot_screen_points; i++, mp++, ml += 3) {
|
||||
mp->loopstart = (int)(ml - loops);
|
||||
mp->loopstart = int(ml - loops);
|
||||
mp->totloop = 3;
|
||||
int current_index = i;
|
||||
int next_index = current_index + 1;
|
||||
|
@ -1255,7 +1258,7 @@ static void sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex
|
|||
}
|
||||
|
||||
for (int i = 0; i < tot_screen_points; i++, mp++, ml += 3) {
|
||||
mp->loopstart = (int)(ml - loops);
|
||||
mp->loopstart = int(ml - loops);
|
||||
mp->totloop = 3;
|
||||
int current_index = i;
|
||||
int next_index = current_index + 1;
|
||||
|
@ -1274,11 +1277,11 @@ static void sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex
|
|||
static void sculpt_gesture_trim_geometry_free(SculptGestureContext *sgcontext)
|
||||
{
|
||||
SculptGestureTrimOperation *trim_operation = (SculptGestureTrimOperation *)sgcontext->operation;
|
||||
BKE_id_free(NULL, trim_operation->mesh);
|
||||
BKE_id_free(nullptr, trim_operation->mesh);
|
||||
MEM_freeN(trim_operation->true_mesh_co);
|
||||
}
|
||||
|
||||
static int bm_face_isect_pair(BMFace *f, void *UNUSED(user_data))
|
||||
static int bm_face_isect_pair(BMFace *f, void * /*user_data*/)
|
||||
{
|
||||
return BM_elem_flag_test(f, BM_ELEM_DRAW) ? 1 : 0;
|
||||
}
|
||||
|
@ -1289,30 +1292,21 @@ static void sculpt_gesture_apply_trim(SculptGestureContext *sgcontext)
|
|||
Mesh *sculpt_mesh = BKE_mesh_from_object(sgcontext->vc.obact);
|
||||
Mesh *trim_mesh = trim_operation->mesh;
|
||||
|
||||
BMesh *bm;
|
||||
const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(sculpt_mesh, trim_mesh);
|
||||
bm = BM_mesh_create(&allocsize,
|
||||
&((struct BMeshCreateParams){
|
||||
.use_toolflags = false,
|
||||
}));
|
||||
|
||||
BM_mesh_bm_from_me(bm,
|
||||
trim_mesh,
|
||||
&((struct BMeshFromMeshParams){
|
||||
.calc_face_normal = true,
|
||||
.calc_vert_normal = true,
|
||||
}));
|
||||
BMeshCreateParams bm_create_params{};
|
||||
bm_create_params.use_toolflags = false;
|
||||
BMesh *bm = BM_mesh_create(&allocsize, &bm_create_params);
|
||||
|
||||
BM_mesh_bm_from_me(bm,
|
||||
sculpt_mesh,
|
||||
&((struct BMeshFromMeshParams){
|
||||
.calc_face_normal = true,
|
||||
.calc_vert_normal = true,
|
||||
}));
|
||||
BMeshFromMeshParams bm_from_me_params{};
|
||||
bm_from_me_params.calc_face_normal = true;
|
||||
bm_from_me_params.calc_vert_normal = true;
|
||||
BM_mesh_bm_from_me(bm, trim_mesh, &bm_from_me_params);
|
||||
BM_mesh_bm_from_me(bm, sculpt_mesh, &bm_from_me_params);
|
||||
|
||||
const int looptris_tot = poly_to_tri_count(bm->totface, bm->totloop);
|
||||
BMLoop *(*looptris)[3];
|
||||
looptris = MEM_malloc_arrayN(looptris_tot, sizeof(*looptris), __func__);
|
||||
BMLoop *(*looptris)[3] = static_cast<BMLoop *(*)[3]>(
|
||||
MEM_malloc_arrayN(looptris_tot, sizeof(*looptris), __func__));
|
||||
BM_mesh_calc_tessellation_beauty(bm, looptris);
|
||||
|
||||
BMIter iter;
|
||||
|
@ -1323,7 +1317,7 @@ static void sculpt_gesture_apply_trim(SculptGestureContext *sgcontext)
|
|||
* we could calculate on the fly too (before calling split). */
|
||||
|
||||
const short ob_src_totcol = trim_mesh->totcol;
|
||||
short *material_remap = BLI_array_alloca(material_remap, ob_src_totcol ? ob_src_totcol : 1);
|
||||
blender::Array<short> material_remap(ob_src_totcol ? ob_src_totcol : 1);
|
||||
|
||||
BMFace *efa;
|
||||
i = 0;
|
||||
|
@ -1360,19 +1354,27 @@ static void sculpt_gesture_apply_trim(SculptGestureContext *sgcontext)
|
|||
BLI_assert(false);
|
||||
break;
|
||||
}
|
||||
BM_mesh_boolean(
|
||||
bm, looptris, looptris_tot, bm_face_isect_pair, NULL, 2, true, true, false, boolean_mode);
|
||||
BM_mesh_boolean(bm,
|
||||
looptris,
|
||||
looptris_tot,
|
||||
bm_face_isect_pair,
|
||||
nullptr,
|
||||
2,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
boolean_mode);
|
||||
}
|
||||
|
||||
MEM_freeN(looptris);
|
||||
|
||||
Mesh *result = BKE_mesh_from_bmesh_nomain(bm,
|
||||
(&(struct BMeshToMeshParams){
|
||||
.calc_object_remap = false,
|
||||
}),
|
||||
sculpt_mesh);
|
||||
BMeshToMeshParams convert_params{};
|
||||
convert_params.calc_object_remap = false;
|
||||
Mesh *result = BKE_mesh_from_bmesh_nomain(bm, &convert_params, sculpt_mesh);
|
||||
|
||||
BM_mesh_free(bm);
|
||||
BKE_mesh_nomain_to_mesh(result, sgcontext->vc.obact->data, sgcontext->vc.obact);
|
||||
BKE_mesh_nomain_to_mesh(
|
||||
result, static_cast<Mesh *>(sgcontext->vc.obact->data), sgcontext->vc.obact);
|
||||
}
|
||||
|
||||
static void sculpt_gesture_trim_begin(bContext *C, SculptGestureContext *sgcontext)
|
||||
|
@ -1387,10 +1389,10 @@ static void sculpt_gesture_trim_begin(bContext *C, SculptGestureContext *sgconte
|
|||
sculpt_gesture_trim_geometry_generate(sgcontext);
|
||||
SCULPT_topology_islands_invalidate(ss);
|
||||
BKE_sculpt_update_object_for_edit(depsgraph, sgcontext->vc.obact, true, false, false);
|
||||
SCULPT_undo_push_node(sgcontext->vc.obact, NULL, SCULPT_UNDO_GEOMETRY);
|
||||
SCULPT_undo_push_node(sgcontext->vc.obact, nullptr, SCULPT_UNDO_GEOMETRY);
|
||||
}
|
||||
|
||||
static void sculpt_gesture_trim_apply_for_symmetry_pass(bContext *UNUSED(C),
|
||||
static void sculpt_gesture_trim_apply_for_symmetry_pass(bContext * /*C*/,
|
||||
SculptGestureContext *sgcontext)
|
||||
{
|
||||
SculptGestureTrimOperation *trim_operation = (SculptGestureTrimOperation *)sgcontext->operation;
|
||||
|
@ -1403,30 +1405,31 @@ static void sculpt_gesture_trim_apply_for_symmetry_pass(bContext *UNUSED(C),
|
|||
sculpt_gesture_apply_trim(sgcontext);
|
||||
}
|
||||
|
||||
static void sculpt_gesture_trim_end(bContext *UNUSED(C), SculptGestureContext *sgcontext)
|
||||
static void sculpt_gesture_trim_end(bContext * /*C*/, SculptGestureContext *sgcontext)
|
||||
{
|
||||
Object *object = sgcontext->vc.obact;
|
||||
SculptSession *ss = object->sculpt;
|
||||
Mesh *mesh = (Mesh *)object->data;
|
||||
|
||||
ss->face_sets = CustomData_get_layer_named_for_write(
|
||||
&mesh->pdata, CD_PROP_INT32, ".sculpt_face_set", mesh->totpoly);
|
||||
ss->face_sets = static_cast<int *>(CustomData_get_layer_named_for_write(
|
||||
&mesh->pdata, CD_PROP_INT32, ".sculpt_face_set", mesh->totpoly));
|
||||
if (ss->face_sets) {
|
||||
/* Assign a new Face Set ID to the new faces created by the trim operation. */
|
||||
const int next_face_set_id = ED_sculpt_face_sets_find_next_available_id(object->data);
|
||||
ED_sculpt_face_sets_initialize_none_to_id(object->data, next_face_set_id);
|
||||
const int next_face_set_id = ED_sculpt_face_sets_find_next_available_id(mesh);
|
||||
ED_sculpt_face_sets_initialize_none_to_id(mesh, next_face_set_id);
|
||||
}
|
||||
|
||||
sculpt_gesture_trim_geometry_free(sgcontext);
|
||||
|
||||
SCULPT_undo_push_node(sgcontext->vc.obact, NULL, SCULPT_UNDO_GEOMETRY);
|
||||
BKE_mesh_batch_cache_dirty_tag(sgcontext->vc.obact->data, BKE_MESH_BATCH_DIRTY_ALL);
|
||||
SCULPT_undo_push_node(sgcontext->vc.obact, nullptr, SCULPT_UNDO_GEOMETRY);
|
||||
BKE_mesh_batch_cache_dirty_tag(mesh, BKE_MESH_BATCH_DIRTY_ALL);
|
||||
DEG_id_tag_update(&sgcontext->vc.obact->id, ID_RECALC_GEOMETRY);
|
||||
}
|
||||
|
||||
static void sculpt_gesture_init_trim_properties(SculptGestureContext *sgcontext, wmOperator *op)
|
||||
{
|
||||
sgcontext->operation = MEM_callocN(sizeof(SculptGestureTrimOperation), "Trim Operation");
|
||||
sgcontext->operation = reinterpret_cast<SculptGestureOperation *>(
|
||||
MEM_cnew<SculptGestureTrimOperation>(__func__));
|
||||
|
||||
SculptGestureTrimOperation *trim_operation = (SculptGestureTrimOperation *)sgcontext->operation;
|
||||
|
||||
|
@ -1435,10 +1438,12 @@ static void sculpt_gesture_init_trim_properties(SculptGestureContext *sgcontext,
|
|||
sculpt_gesture_trim_apply_for_symmetry_pass;
|
||||
trim_operation->op.sculpt_gesture_end = sculpt_gesture_trim_end;
|
||||
|
||||
trim_operation->mode = RNA_enum_get(op->ptr, "trim_mode");
|
||||
trim_operation->mode = eSculptTrimOperationType(RNA_enum_get(op->ptr, "trim_mode"));
|
||||
trim_operation->use_cursor_depth = RNA_boolean_get(op->ptr, "use_cursor_depth");
|
||||
trim_operation->orientation = RNA_enum_get(op->ptr, "trim_orientation");
|
||||
trim_operation->extrude_mode = RNA_enum_get(op->ptr, "trim_extrude_mode");
|
||||
trim_operation->orientation = eSculptTrimOrientationType(
|
||||
RNA_enum_get(op->ptr, "trim_orientation"));
|
||||
trim_operation->extrude_mode = eSculptTrimExtrudeMode(
|
||||
RNA_enum_get(op->ptr, "trim_extrude_mode"));
|
||||
|
||||
/* If the cursor was not over the mesh, force the orientation to view. */
|
||||
if (!sgcontext->ss->gesture_initial_hit) {
|
||||
|
@ -1453,7 +1458,7 @@ static void sculpt_trim_gesture_operator_properties(wmOperatorType *ot)
|
|||
prop_trim_operation_types,
|
||||
SCULPT_GESTURE_TRIM_DIFFERENCE,
|
||||
"Trim Mode",
|
||||
NULL);
|
||||
nullptr);
|
||||
RNA_def_boolean(
|
||||
ot->srna,
|
||||
"use_cursor_depth",
|
||||
|
@ -1465,20 +1470,20 @@ static void sculpt_trim_gesture_operator_properties(wmOperatorType *ot)
|
|||
prop_trim_orientation_types,
|
||||
SCULPT_GESTURE_TRIM_ORIENTATION_VIEW,
|
||||
"Shape Orientation",
|
||||
NULL);
|
||||
nullptr);
|
||||
RNA_def_enum(ot->srna,
|
||||
"trim_extrude_mode",
|
||||
prop_trim_extrude_modes,
|
||||
SCULPT_GESTURE_TRIM_EXTRUDE_FIXED,
|
||||
"Extrude Mode",
|
||||
NULL);
|
||||
nullptr);
|
||||
}
|
||||
|
||||
/* Project Gesture Operation. */
|
||||
|
||||
typedef struct SculptGestureProjectOperation {
|
||||
struct SculptGestureProjectOperation {
|
||||
SculptGestureOperation operation;
|
||||
} SculptGestureProjectOperation;
|
||||
};
|
||||
|
||||
static void sculpt_gesture_project_begin(bContext *C, SculptGestureContext *sgcontext)
|
||||
{
|
||||
|
@ -1488,9 +1493,9 @@ static void sculpt_gesture_project_begin(bContext *C, SculptGestureContext *sgco
|
|||
|
||||
static void project_line_gesture_apply_task_cb(void *__restrict userdata,
|
||||
const int i,
|
||||
const TaskParallelTLS *__restrict UNUSED(tls))
|
||||
const TaskParallelTLS *__restrict /*tls*/)
|
||||
{
|
||||
SculptGestureContext *sgcontext = userdata;
|
||||
SculptGestureContext *sgcontext = static_cast<SculptGestureContext *>(userdata);
|
||||
|
||||
PBVHNode *node = sgcontext->nodes[i];
|
||||
PBVHVertexIter vd;
|
||||
|
@ -1526,7 +1531,7 @@ static void project_line_gesture_apply_task_cb(void *__restrict userdata,
|
|||
}
|
||||
}
|
||||
|
||||
static void sculpt_gesture_project_apply_for_symmetry_pass(bContext *UNUSED(C),
|
||||
static void sculpt_gesture_project_apply_for_symmetry_pass(bContext * /*C*/,
|
||||
SculptGestureContext *sgcontext)
|
||||
{
|
||||
TaskParallelSettings settings;
|
||||
|
@ -1558,9 +1563,10 @@ static void sculpt_gesture_project_end(bContext *C, SculptGestureContext *sgcont
|
|||
}
|
||||
|
||||
static void sculpt_gesture_init_project_properties(SculptGestureContext *sgcontext,
|
||||
wmOperator *UNUSED(op))
|
||||
wmOperator * /*op*/)
|
||||
{
|
||||
sgcontext->operation = MEM_callocN(sizeof(SculptGestureFaceSetOperation), "Project Operation");
|
||||
sgcontext->operation = reinterpret_cast<SculptGestureOperation *>(
|
||||
MEM_cnew<SculptGestureFaceSetOperation>(__func__));
|
||||
|
||||
SculptGestureProjectOperation *project_operation = (SculptGestureProjectOperation *)
|
||||
sgcontext->operation;
|
||||
|
@ -1662,7 +1668,7 @@ static int sculpt_trim_gesture_box_invoke(bContext *C, wmOperator *op, const wmE
|
|||
SculptSession *ss = ob->sculpt;
|
||||
|
||||
SculptCursorGeometryInfo sgi;
|
||||
const float mval_fl[2] = {UNPACK2(event->mval)};
|
||||
const float mval_fl[2] = {float(event->mval[0]), float(event->mval[1])};
|
||||
SCULPT_vertex_random_access_ensure(ss);
|
||||
ss->gesture_initial_hit = SCULPT_cursor_geometry_info_update(C, &sgi, mval_fl, false);
|
||||
if (ss->gesture_initial_hit) {
|
||||
|
@ -1703,7 +1709,7 @@ static int sculpt_trim_gesture_lasso_invoke(bContext *C, wmOperator *op, const w
|
|||
SculptSession *ss = ob->sculpt;
|
||||
|
||||
SculptCursorGeometryInfo sgi;
|
||||
const float mval_fl[2] = {UNPACK2(event->mval)};
|
||||
const float mval_fl[2] = {float(event->mval[0]), float(event->mval[1])};
|
||||
SCULPT_vertex_random_access_ensure(ss);
|
||||
ss->gesture_initial_hit = SCULPT_cursor_geometry_info_update(C, &sgi, mval_fl, false);
|
||||
if (ss->gesture_initial_hit) {
|
|
@ -52,34 +52,35 @@
|
|||
|
||||
struct WPaintPrev {
|
||||
/* previous vertex weights */
|
||||
struct MDeformVert *wpaint_prev;
|
||||
MDeformVert *wpaint_prev;
|
||||
/* allocation size of prev buffers */
|
||||
int tot;
|
||||
};
|
||||
|
||||
static void wpaint_prev_init(struct WPaintPrev *wpp)
|
||||
static void wpaint_prev_init(WPaintPrev *wpp)
|
||||
{
|
||||
wpp->wpaint_prev = NULL;
|
||||
wpp->wpaint_prev = nullptr;
|
||||
wpp->tot = 0;
|
||||
}
|
||||
|
||||
static void wpaint_prev_create(struct WPaintPrev *wpp, MDeformVert *dverts, int dcount)
|
||||
static void wpaint_prev_create(WPaintPrev *wpp, MDeformVert *dverts, int dcount)
|
||||
{
|
||||
wpaint_prev_init(wpp);
|
||||
|
||||
if (dverts && dcount) {
|
||||
wpp->wpaint_prev = MEM_mallocN(sizeof(MDeformVert) * dcount, "wpaint prev");
|
||||
wpp->wpaint_prev = static_cast<MDeformVert *>(
|
||||
MEM_malloc_arrayN(dcount, sizeof(MDeformVert), __func__));
|
||||
wpp->tot = dcount;
|
||||
BKE_defvert_array_copy(wpp->wpaint_prev, dverts, dcount);
|
||||
}
|
||||
}
|
||||
|
||||
static void wpaint_prev_destroy(struct WPaintPrev *wpp)
|
||||
static void wpaint_prev_destroy(WPaintPrev *wpp)
|
||||
{
|
||||
if (wpp->wpaint_prev) {
|
||||
BKE_defvert_array_free(wpp->wpaint_prev, wpp->tot);
|
||||
}
|
||||
wpp->wpaint_prev = NULL;
|
||||
wpp->wpaint_prev = nullptr;
|
||||
wpp->tot = 0;
|
||||
}
|
||||
|
||||
|
@ -102,7 +103,7 @@ static int weight_from_bones_exec(bContext *C, wmOperator *op)
|
|||
Scene *scene = CTX_data_scene(C);
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
Object *armob = BKE_modifiers_is_deformed_by_armature(ob);
|
||||
Mesh *me = ob->data;
|
||||
Mesh *me = static_cast<Mesh *>(ob->data);
|
||||
int type = RNA_enum_get(op->ptr, "type");
|
||||
|
||||
ED_object_vgroup_calc_from_armature(
|
||||
|
@ -124,7 +125,7 @@ void PAINT_OT_weight_from_bones(wmOperatorType *ot)
|
|||
0,
|
||||
"From Envelopes",
|
||||
"Weights from envelopes with user defined radius"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
/* identifiers */
|
||||
|
@ -203,7 +204,7 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, const wmEvent *even
|
|||
float vgroup_weight = BKE_defvert_find_weight(&dvert[v_idx_best], vgroup_active);
|
||||
const int defbase_tot = BLI_listbase_count(&me->vertex_group_names);
|
||||
bool use_lock_relative = ts->wpaint_lock_relative;
|
||||
bool *defbase_locked = NULL, *defbase_unlocked = NULL;
|
||||
bool *defbase_locked = nullptr, *defbase_unlocked = nullptr;
|
||||
|
||||
if (use_lock_relative) {
|
||||
defbase_locked = BKE_object_defgroup_lock_flags_get(vc.obact, defbase_tot);
|
||||
|
@ -257,7 +258,7 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, const wmEvent *even
|
|||
|
||||
if (changed) {
|
||||
/* not really correct since the brush didn't change, but redraws the toolbar */
|
||||
WM_main_add_notifier(NC_BRUSH | NA_EDITED, NULL); /* ts->wpaint->paint.brush */
|
||||
WM_main_add_notifier(NC_BRUSH | NA_EDITED, nullptr); /* ts->wpaint->paint.brush */
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -303,8 +304,8 @@ static bool weight_paint_sample_enum_itemf__helper(const MDeformVert *dvert,
|
|||
return found;
|
||||
}
|
||||
static const EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C,
|
||||
PointerRNA *UNUSED(ptr),
|
||||
PropertyRNA *UNUSED(prop),
|
||||
PointerRNA * /*ptr*/,
|
||||
PropertyRNA * /*prop*/,
|
||||
bool *r_free)
|
||||
{
|
||||
if (C) {
|
||||
|
@ -323,7 +324,7 @@ static const EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C,
|
|||
if (me && dverts && vc.v3d && vc.rv3d && me->vertex_group_names.first) {
|
||||
const int defbase_tot = BLI_listbase_count(&me->vertex_group_names);
|
||||
const bool use_vert_sel = (me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
|
||||
int *groups = MEM_callocN(defbase_tot * sizeof(int), "groups");
|
||||
int *groups = static_cast<int *>(MEM_callocN(defbase_tot * sizeof(int), "groups"));
|
||||
bool found = false;
|
||||
uint index;
|
||||
|
||||
|
@ -357,11 +358,13 @@ static const EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C,
|
|||
MEM_freeN(groups);
|
||||
}
|
||||
else {
|
||||
EnumPropertyItem *item = NULL, item_tmp = {0};
|
||||
EnumPropertyItem *item = nullptr, item_tmp = {0};
|
||||
int totitem = 0;
|
||||
int i = 0;
|
||||
bDeformGroup *dg;
|
||||
for (dg = me->vertex_group_names.first; dg && i < defbase_tot; i++, dg = dg->next) {
|
||||
for (dg = static_cast<bDeformGroup *>(me->vertex_group_names.first);
|
||||
dg && i < defbase_tot;
|
||||
i++, dg = dg->next) {
|
||||
if (groups[i]) {
|
||||
item_tmp.identifier = item_tmp.name = dg->name;
|
||||
item_tmp.value = i;
|
||||
|
@ -402,7 +405,7 @@ void PAINT_OT_weight_sample_group(wmOperatorType *ot)
|
|||
/* TODO: we could make this a menu into #OBJECT_OT_vertex_group_set_active
|
||||
* rather than its own operator */
|
||||
|
||||
PropertyRNA *prop = NULL;
|
||||
PropertyRNA *prop = nullptr;
|
||||
|
||||
/* identifiers */
|
||||
ot->name = "Weight Paint Sample Group";
|
||||
|
@ -434,7 +437,7 @@ void PAINT_OT_weight_sample_group(wmOperatorType *ot)
|
|||
/* fills in the selected faces with the current weight and vertex group */
|
||||
static bool weight_paint_set(Object *ob, float paintweight)
|
||||
{
|
||||
Mesh *me = ob->data;
|
||||
Mesh *me = static_cast<Mesh *>(ob->data);
|
||||
const MPoly *mp;
|
||||
MDeformWeight *dw, *dw_prev;
|
||||
int vgroup_active, vgroup_mirror = -1;
|
||||
|
@ -448,7 +451,7 @@ static bool weight_paint_set(Object *ob, float paintweight)
|
|||
const MLoop *loops = BKE_mesh_loops(me);
|
||||
MDeformVert *dvert = BKE_mesh_deform_verts_for_write(me);
|
||||
|
||||
if (me->totpoly == 0 || dvert == NULL) {
|
||||
if (me->totpoly == 0 || dvert == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -459,7 +462,7 @@ static bool weight_paint_set(Object *ob, float paintweight)
|
|||
vgroup_mirror = ED_wpaint_mirror_vgroup_ensure(ob, vgroup_active);
|
||||
}
|
||||
|
||||
struct WPaintPrev wpp;
|
||||
WPaintPrev wpp;
|
||||
wpaint_prev_create(&wpp, dvert, me->totvert);
|
||||
|
||||
const bool *select_vert = (const bool *)CustomData_get_layer_named(
|
||||
|
@ -490,7 +493,7 @@ static bool weight_paint_set(Object *ob, float paintweight)
|
|||
|
||||
if (me->symmetry & ME_SYMMETRY_X) {
|
||||
/* x mirror painting */
|
||||
int j = mesh_get_x_mirror_vert(ob, NULL, vidx, topology);
|
||||
int j = mesh_get_x_mirror_vert(ob, nullptr, vidx, topology);
|
||||
if (j >= 0) {
|
||||
/* copy, not paint again */
|
||||
if (vgroup_mirror != -1) {
|
||||
|
@ -528,13 +531,13 @@ static bool weight_paint_set(Object *ob, float paintweight)
|
|||
|
||||
static int weight_paint_set_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
struct Scene *scene = CTX_data_scene(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Object *obact = CTX_data_active_object(C);
|
||||
ToolSettings *ts = CTX_data_tool_settings(C);
|
||||
Brush *brush = BKE_paint_brush(&ts->wpaint->paint);
|
||||
float vgroup_weight = BKE_brush_weight_get(scene, brush);
|
||||
|
||||
if (ED_wpaint_ensure_data(C, op->reports, WPAINT_ENSURE_MIRROR, NULL) == false) {
|
||||
if (ED_wpaint_ensure_data(C, op->reports, WPAINT_ENSURE_MIRROR, nullptr) == false) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
|
@ -567,23 +570,25 @@ void PAINT_OT_weight_set(wmOperatorType *ot)
|
|||
* \{ */
|
||||
|
||||
/* *** VGroups Gradient *** */
|
||||
typedef struct WPGradient_vertStore {
|
||||
float sco[2];
|
||||
float weight_orig;
|
||||
enum {
|
||||
struct WPGradient_vertStore {
|
||||
enum Flag {
|
||||
VGRAD_STORE_NOP = 0,
|
||||
VGRAD_STORE_DW_EXIST = (1 << 0),
|
||||
VGRAD_STORE_IS_MODIFIED = (1 << 1)
|
||||
} flag;
|
||||
} WPGradient_vertStore;
|
||||
};
|
||||
float sco[2];
|
||||
float weight_orig;
|
||||
Flag flag;
|
||||
};
|
||||
ENUM_OPERATORS(WPGradient_vertStore::Flag, WPGradient_vertStore::VGRAD_STORE_IS_MODIFIED);
|
||||
|
||||
typedef struct WPGradient_vertStoreBase {
|
||||
struct WPaintPrev wpp;
|
||||
struct WPGradient_vertStoreBase {
|
||||
WPaintPrev wpp;
|
||||
WPGradient_vertStore elem[0];
|
||||
} WPGradient_vertStoreBase;
|
||||
};
|
||||
|
||||
typedef struct WPGradient_userData {
|
||||
struct ARegion *region;
|
||||
struct WPGradient_userData {
|
||||
ARegion *region;
|
||||
Scene *scene;
|
||||
Mesh *me;
|
||||
MDeformVert *dvert;
|
||||
|
@ -603,16 +608,17 @@ typedef struct WPGradient_userData {
|
|||
bool use_vgroup_restrict;
|
||||
short type;
|
||||
float weightpaint;
|
||||
} WPGradient_userData;
|
||||
};
|
||||
|
||||
static void gradientVert_update(WPGradient_userData *grad_data, int index)
|
||||
{
|
||||
WPGradient_vertStore *vs = &grad_data->vert_cache->elem[index];
|
||||
|
||||
/* Optionally restrict to assigned vertices only. */
|
||||
if (grad_data->use_vgroup_restrict && ((vs->flag & VGRAD_STORE_DW_EXIST) == 0)) {
|
||||
if (grad_data->use_vgroup_restrict &&
|
||||
((vs->flag & WPGradient_vertStore::VGRAD_STORE_DW_EXIST) == 0)) {
|
||||
/* In this case the vertex will never have been touched. */
|
||||
BLI_assert((vs->flag & VGRAD_STORE_IS_MODIFIED) == 0);
|
||||
BLI_assert((vs->flag & WPGradient_vertStore::VGRAD_STORE_IS_MODIFIED) == 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -641,12 +647,12 @@ static void gradientVert_update(WPGradient_userData *grad_data, int index)
|
|||
tool, vs->weight_orig, grad_data->weightpaint, alpha * grad_data->brush->alpha);
|
||||
CLAMP(testw, 0.0f, 1.0f);
|
||||
dw->weight = testw;
|
||||
vs->flag |= VGRAD_STORE_IS_MODIFIED;
|
||||
vs->flag |= WPGradient_vertStore::VGRAD_STORE_IS_MODIFIED;
|
||||
}
|
||||
else {
|
||||
MDeformVert *dv = &grad_data->dvert[index];
|
||||
if (vs->flag & VGRAD_STORE_DW_EXIST) {
|
||||
/* normally we NULL check, but in this case we know it exists */
|
||||
if (vs->flag & WPGradient_vertStore::VGRAD_STORE_DW_EXIST) {
|
||||
/* normally we nullptr check, but in this case we know it exists */
|
||||
MDeformWeight *dw = BKE_defvert_find_index(dv, grad_data->def_nr);
|
||||
dw->weight = vs->weight_orig;
|
||||
}
|
||||
|
@ -657,16 +663,16 @@ static void gradientVert_update(WPGradient_userData *grad_data, int index)
|
|||
BKE_defvert_remove_group(dv, dw);
|
||||
}
|
||||
}
|
||||
vs->flag &= ~VGRAD_STORE_IS_MODIFIED;
|
||||
vs->flag &= ~WPGradient_vertStore::VGRAD_STORE_IS_MODIFIED;
|
||||
}
|
||||
}
|
||||
|
||||
static void gradientVertUpdate__mapFunc(void *userData,
|
||||
int index,
|
||||
const float UNUSED(co[3]),
|
||||
const float UNUSED(no[3]))
|
||||
const float /*co*/[3],
|
||||
const float /*no*/[3])
|
||||
{
|
||||
WPGradient_userData *grad_data = userData;
|
||||
WPGradient_userData *grad_data = static_cast<WPGradient_userData *>(userData);
|
||||
WPGradient_vertStore *vs = &grad_data->vert_cache->elem[index];
|
||||
|
||||
if (vs->sco[0] == FLT_MAX) {
|
||||
|
@ -679,9 +685,9 @@ static void gradientVertUpdate__mapFunc(void *userData,
|
|||
static void gradientVertInit__mapFunc(void *userData,
|
||||
int index,
|
||||
const float co[3],
|
||||
const float UNUSED(no[3]))
|
||||
const float /*no*/[3])
|
||||
{
|
||||
WPGradient_userData *grad_data = userData;
|
||||
WPGradient_userData *grad_data = static_cast<WPGradient_userData *>(userData);
|
||||
WPGradient_vertStore *vs = &grad_data->vert_cache->elem[index];
|
||||
|
||||
if (grad_data->use_select && (grad_data->select_vert && !grad_data->select_vert[index])) {
|
||||
|
@ -709,11 +715,11 @@ static void gradientVertInit__mapFunc(void *userData,
|
|||
const MDeformWeight *dw = BKE_defvert_find_index(dv, grad_data->def_nr);
|
||||
if (dw) {
|
||||
vs->weight_orig = dw->weight;
|
||||
vs->flag = VGRAD_STORE_DW_EXIST;
|
||||
vs->flag = WPGradient_vertStore::VGRAD_STORE_DW_EXIST;
|
||||
}
|
||||
else {
|
||||
vs->weight_orig = 0.0f;
|
||||
vs->flag = VGRAD_STORE_NOP;
|
||||
vs->flag = WPGradient_vertStore::VGRAD_STORE_NOP;
|
||||
}
|
||||
BLI_BITMAP_ENABLE(grad_data->vert_visit, index);
|
||||
gradientVert_update(grad_data, index);
|
||||
|
@ -721,8 +727,9 @@ static void gradientVertInit__mapFunc(void *userData,
|
|||
|
||||
static int paint_weight_gradient_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
wmGesture *gesture = op->customdata;
|
||||
WPGradient_vertStoreBase *vert_cache = gesture->user_data.data;
|
||||
wmGesture *gesture = static_cast<wmGesture *>(op->customdata);
|
||||
WPGradient_vertStoreBase *vert_cache = static_cast<WPGradient_vertStoreBase *>(
|
||||
gesture->user_data.data);
|
||||
int ret = WM_gesture_straightline_modal(C, op, event);
|
||||
|
||||
if (ret & OPERATOR_RUNNING_MODAL) {
|
||||
|
@ -736,8 +743,8 @@ static int paint_weight_gradient_modal(bContext *C, wmOperator *op, const wmEven
|
|||
|
||||
if (ret & OPERATOR_CANCELLED) {
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
if (vert_cache != NULL) {
|
||||
Mesh *me = ob->data;
|
||||
if (vert_cache != nullptr) {
|
||||
Mesh *me = static_cast<Mesh *>(ob->data);
|
||||
if (vert_cache->wpp.wpaint_prev) {
|
||||
MDeformVert *dvert = BKE_mesh_deform_verts_for_write(me);
|
||||
BKE_defvert_array_free_elems(dvert, me->totvert);
|
||||
|
@ -760,27 +767,27 @@ static int paint_weight_gradient_modal(bContext *C, wmOperator *op, const wmEven
|
|||
|
||||
static int paint_weight_gradient_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
wmGesture *gesture = op->customdata;
|
||||
wmGesture *gesture = static_cast<wmGesture *>(op->customdata);
|
||||
WPGradient_vertStoreBase *vert_cache;
|
||||
struct ARegion *region = CTX_wm_region(C);
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
Mesh *me = ob->data;
|
||||
Mesh *me = static_cast<Mesh *>(ob->data);
|
||||
MDeformVert *dverts = BKE_mesh_deform_verts_for_write(me);
|
||||
int x_start = RNA_int_get(op->ptr, "xstart");
|
||||
int y_start = RNA_int_get(op->ptr, "ystart");
|
||||
int x_end = RNA_int_get(op->ptr, "xend");
|
||||
int y_end = RNA_int_get(op->ptr, "yend");
|
||||
const float sco_start[2] = {x_start, y_start};
|
||||
const float sco_end[2] = {x_end, y_end};
|
||||
const bool is_interactive = (gesture != NULL);
|
||||
const float sco_start[2] = {float(x_start), float(y_start)};
|
||||
const float sco_end[2] = {float(x_end), float(y_end)};
|
||||
const bool is_interactive = (gesture != nullptr);
|
||||
|
||||
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
||||
|
||||
WPGradient_userData data = {NULL};
|
||||
WPGradient_userData data = {nullptr};
|
||||
|
||||
if (is_interactive) {
|
||||
if (gesture->user_data.data == NULL) {
|
||||
if (gesture->user_data.data == nullptr) {
|
||||
gesture->user_data.data = MEM_mallocN(sizeof(WPGradient_vertStoreBase) +
|
||||
(sizeof(WPGradient_vertStore) * me->totvert),
|
||||
__func__);
|
||||
|
@ -796,21 +803,22 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op)
|
|||
}
|
||||
}
|
||||
|
||||
vert_cache = gesture->user_data.data;
|
||||
vert_cache = static_cast<WPGradient_vertStoreBase *>(gesture->user_data.data);
|
||||
}
|
||||
else {
|
||||
if (ED_wpaint_ensure_data(C, op->reports, 0, NULL) == false) {
|
||||
if (ED_wpaint_ensure_data(C, op->reports, eWPaintFlag(0), nullptr) == false) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
data.is_init = true;
|
||||
vert_cache = MEM_mallocN(
|
||||
sizeof(WPGradient_vertStoreBase) + (sizeof(WPGradient_vertStore) * me->totvert), __func__);
|
||||
vert_cache = static_cast<WPGradient_vertStoreBase *>(MEM_mallocN(
|
||||
sizeof(WPGradient_vertStoreBase) + (sizeof(WPGradient_vertStore) * me->totvert),
|
||||
__func__));
|
||||
}
|
||||
|
||||
data.region = region;
|
||||
data.scene = scene;
|
||||
data.me = ob->data;
|
||||
data.me = me;
|
||||
data.dvert = dverts;
|
||||
data.select_vert = (const bool *)CustomData_get_layer_named(
|
||||
&me->vdata, CD_PROP_BOOL, ".select_vert");
|
||||
|
@ -820,13 +828,13 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op)
|
|||
data.def_nr = BKE_object_defgroup_active_index_get(ob) - 1;
|
||||
data.use_select = (me->editflag & (ME_EDIT_PAINT_FACE_SEL | ME_EDIT_PAINT_VERT_SEL)) != 0;
|
||||
data.vert_cache = vert_cache;
|
||||
data.vert_visit = NULL;
|
||||
data.vert_visit = nullptr;
|
||||
data.type = RNA_enum_get(op->ptr, "type");
|
||||
|
||||
{
|
||||
ToolSettings *ts = CTX_data_tool_settings(C);
|
||||
VPaint *wp = ts->wpaint;
|
||||
struct Brush *brush = BKE_paint_brush(&wp->paint);
|
||||
Brush *brush = BKE_paint_brush(&wp->paint);
|
||||
|
||||
BKE_curvemapping_init(brush->curve);
|
||||
|
||||
|
@ -835,7 +843,7 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op)
|
|||
data.use_vgroup_restrict = (ts->wpaint->flag & VP_FLAG_VGROUP_RESTRICT) != 0;
|
||||
}
|
||||
|
||||
ED_view3d_init_mats_rv3d(ob, region->regiondata);
|
||||
ED_view3d_init_mats_rv3d(ob, static_cast<RegionView3D *>(region->regiondata));
|
||||
|
||||
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
|
||||
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
|
||||
|
@ -851,7 +859,7 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op)
|
|||
BKE_mesh_foreach_mapped_vert(me_eval, gradientVertInit__mapFunc, &data, MESH_FOREACH_NOP);
|
||||
|
||||
MEM_freeN(data.vert_visit);
|
||||
data.vert_visit = NULL;
|
||||
data.vert_visit = nullptr;
|
||||
}
|
||||
else {
|
||||
BKE_mesh_foreach_mapped_vert(me_eval, gradientVertUpdate__mapFunc, &data, MESH_FOREACH_NOP);
|
||||
|
@ -867,10 +875,10 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op)
|
|||
if (scene->toolsettings->auto_normalize) {
|
||||
const int vgroup_num = BLI_listbase_count(&me->vertex_group_names);
|
||||
bool *vgroup_validmap = BKE_object_defgroup_validmap_get(ob, vgroup_num);
|
||||
if (vgroup_validmap != NULL) {
|
||||
if (vgroup_validmap != nullptr) {
|
||||
MDeformVert *dvert = dverts;
|
||||
for (int i = 0; i < me->totvert; i++) {
|
||||
if ((data.vert_cache->elem[i].flag & VGRAD_STORE_IS_MODIFIED) != 0) {
|
||||
if ((data.vert_cache->elem[i].flag & WPGradient_vertStore::VGRAD_STORE_IS_MODIFIED) != 0) {
|
||||
BKE_defvert_normalize_lock_single(&dvert[i], vgroup_validmap, vgroup_num, data.def_nr);
|
||||
}
|
||||
}
|
||||
|
@ -885,17 +893,17 @@ static int paint_weight_gradient_invoke(bContext *C, wmOperator *op, const wmEve
|
|||
{
|
||||
int ret;
|
||||
|
||||
if (ED_wpaint_ensure_data(C, op->reports, 0, NULL) == false) {
|
||||
if (ED_wpaint_ensure_data(C, op->reports, eWPaintFlag(0), nullptr) == false) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
ret = WM_gesture_straightline_invoke(C, op, event);
|
||||
if (ret & OPERATOR_RUNNING_MODAL) {
|
||||
struct ARegion *region = CTX_wm_region(C);
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
if (region->regiontype == RGN_TYPE_WINDOW) {
|
||||
/* TODO: hard-coded, extend `WM_gesture_straightline_*`. */
|
||||
if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
|
||||
wmGesture *gesture = op->customdata;
|
||||
wmGesture *gesture = static_cast<wmGesture *>(op->customdata);
|
||||
gesture->is_active = true;
|
||||
}
|
||||
}
|
||||
|
@ -909,7 +917,7 @@ void PAINT_OT_weight_gradient(wmOperatorType *ot)
|
|||
static const EnumPropertyItem gradient_types[] = {
|
||||
{WPAINT_GRADIENT_TYPE_LINEAR, "LINEAR", 0, "Linear", ""},
|
||||
{WPAINT_GRADIENT_TYPE_RADIAL, "RADIAL", 0, "Radial", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
PropertyRNA *prop;
|
|
@ -5,6 +5,9 @@
|
|||
* \ingroup edsculpt
|
||||
*/
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_linklist_stack.h"
|
||||
|
@ -48,9 +51,6 @@
|
|||
|
||||
#include "bmesh.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Sculpt Expand. */
|
||||
/* Operator for creating selections and patterns in Sculpt Mode. Expand can create masks, face sets
|
||||
* and fill vertex colors. */
|
||||
|
@ -421,8 +421,8 @@ static PBVHVertRef sculpt_expand_get_vertex_index_for_symmetry_pass(
|
|||
}
|
||||
else {
|
||||
float location[3];
|
||||
flip_v3_v3(location, SCULPT_vertex_co_get(ss, original_vertex), symm_it);
|
||||
symm_vertex = SCULPT_nearest_vertex_get(NULL, ob, location, FLT_MAX, false);
|
||||
flip_v3_v3(location, SCULPT_vertex_co_get(ss, original_vertex), ePaintSymmetryFlags(symm_it));
|
||||
symm_vertex = SCULPT_nearest_vertex_get(nullptr, ob, location, FLT_MAX, false);
|
||||
}
|
||||
return symm_vertex;
|
||||
}
|
||||
|
@ -440,12 +440,12 @@ static float *sculpt_expand_geodesic_falloff_create(Sculpt *sd, Object *ob, cons
|
|||
* Topology: Initializes the falloff using a flood-fill operation,
|
||||
* increasing the falloff value by 1 when visiting a new vertex.
|
||||
*/
|
||||
typedef struct ExpandFloodFillData {
|
||||
struct ExpandFloodFillData {
|
||||
float original_normal[3];
|
||||
float edge_sensitivity;
|
||||
float *dists;
|
||||
float *edge_factor;
|
||||
} ExpandFloodFillData;
|
||||
};
|
||||
|
||||
static bool expand_topology_floodfill_cb(
|
||||
SculptSession *ss, PBVHVertRef from_v, PBVHVertRef to_v, bool is_duplicate, void *userdata)
|
||||
|
@ -453,7 +453,7 @@ static bool expand_topology_floodfill_cb(
|
|||
int from_v_i = BKE_pbvh_vertex_to_index(ss->pbvh, from_v);
|
||||
int to_v_i = BKE_pbvh_vertex_to_index(ss->pbvh, to_v);
|
||||
|
||||
ExpandFloodFillData *data = userdata;
|
||||
ExpandFloodFillData *data = static_cast<ExpandFloodFillData *>(userdata);
|
||||
if (!is_duplicate) {
|
||||
const float to_it = data->dists[from_v_i] + 1.0f;
|
||||
data->dists[to_v_i] = to_it;
|
||||
|
@ -468,7 +468,7 @@ static float *sculpt_expand_topology_falloff_create(Sculpt *sd, Object *ob, cons
|
|||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
float *dists = MEM_calloc_arrayN(totvert, sizeof(float), "topology dist");
|
||||
float *dists = static_cast<float *>(MEM_calloc_arrayN(totvert, sizeof(float), __func__));
|
||||
|
||||
SculptFloodFill flood;
|
||||
SCULPT_floodfill_init(ss, &flood);
|
||||
|
@ -494,7 +494,7 @@ static bool mask_expand_normal_floodfill_cb(
|
|||
int from_v_i = BKE_pbvh_vertex_to_index(ss->pbvh, from_v);
|
||||
int to_v_i = BKE_pbvh_vertex_to_index(ss->pbvh, to_v);
|
||||
|
||||
ExpandFloodFillData *data = userdata;
|
||||
ExpandFloodFillData *data = static_cast<ExpandFloodFillData *>(userdata);
|
||||
if (!is_duplicate) {
|
||||
float current_normal[3], prev_normal[3];
|
||||
SCULPT_vertex_normal_get(ss, to_v, current_normal);
|
||||
|
@ -521,8 +521,8 @@ static float *sculpt_expand_normal_falloff_create(Sculpt *sd,
|
|||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
float *dists = MEM_malloc_arrayN(totvert, sizeof(float), "normal dist");
|
||||
float *edge_factor = MEM_callocN(sizeof(float) * totvert, "mask edge factor");
|
||||
float *dists = static_cast<float *>(MEM_malloc_arrayN(totvert, sizeof(float), __func__));
|
||||
float *edge_factor = static_cast<float *>(MEM_callocN(sizeof(float) * totvert, __func__));
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
edge_factor[i] = 1.0f;
|
||||
}
|
||||
|
@ -568,7 +568,7 @@ static float *sculpt_expand_spherical_falloff_create(Object *ob, const PBVHVertR
|
|||
SculptSession *ss = ob->sculpt;
|
||||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
|
||||
float *dists = MEM_malloc_arrayN(totvert, sizeof(float), "spherical dist");
|
||||
float *dists = static_cast<float *>(MEM_malloc_arrayN(totvert, sizeof(float), __func__));
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
dists[i] = FLT_MAX;
|
||||
}
|
||||
|
@ -602,7 +602,7 @@ static float *sculpt_expand_boundary_topology_falloff_create(Object *ob, const P
|
|||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
float *dists = MEM_calloc_arrayN(totvert, sizeof(float), "spherical dist");
|
||||
float *dists = static_cast<float *>(MEM_calloc_arrayN(totvert, sizeof(float), __func__));
|
||||
BLI_bitmap *visited_verts = BLI_BITMAP_NEW(totvert, "visited verts");
|
||||
GSQueue *queue = BLI_gsqueue_new(sizeof(PBVHVertRef));
|
||||
|
||||
|
@ -616,7 +616,7 @@ static float *sculpt_expand_boundary_topology_falloff_create(Object *ob, const P
|
|||
const PBVHVertRef symm_vertex = sculpt_expand_get_vertex_index_for_symmetry_pass(
|
||||
ob, symm_it, v);
|
||||
|
||||
SculptBoundary *boundary = SCULPT_boundary_data_init(ob, NULL, symm_vertex, FLT_MAX);
|
||||
SculptBoundary *boundary = SCULPT_boundary_data_init(ob, nullptr, symm_vertex, FLT_MAX);
|
||||
if (!boundary) {
|
||||
continue;
|
||||
}
|
||||
|
@ -666,7 +666,7 @@ static float *sculpt_expand_diagonals_falloff_create(Object *ob, const PBVHVertR
|
|||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
float *dists = MEM_calloc_arrayN(totvert, sizeof(float), "spherical dist");
|
||||
float *dists = static_cast<float *>(MEM_calloc_arrayN(totvert, sizeof(float), __func__));
|
||||
|
||||
/* This algorithm uses mesh data (polys and loops), so this falloff type can't be initialized for
|
||||
* Multires. It also does not make sense to implement it for dyntopo as the result will be the
|
||||
|
@ -822,11 +822,11 @@ static void sculpt_expand_mesh_face_falloff_from_vertex_falloff(SculptSession *s
|
|||
Mesh *mesh,
|
||||
ExpandCache *expand_cache)
|
||||
{
|
||||
BLI_assert(expand_cache->vert_falloff != NULL);
|
||||
BLI_assert(expand_cache->vert_falloff != nullptr);
|
||||
|
||||
if (!expand_cache->face_falloff) {
|
||||
expand_cache->face_falloff = MEM_malloc_arrayN(
|
||||
mesh->totpoly, sizeof(float), "face falloff factors");
|
||||
expand_cache->face_falloff = static_cast<float *>(
|
||||
MEM_malloc_arrayN(mesh->totpoly, sizeof(float), __func__));
|
||||
}
|
||||
|
||||
if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) {
|
||||
|
@ -869,7 +869,7 @@ static void sculpt_expand_geodesics_from_state_boundary(Object *ob,
|
|||
MEM_SAFE_FREE(expand_cache->face_falloff);
|
||||
|
||||
expand_cache->vert_falloff = SCULPT_geodesic_distances_create(ob, initial_verts, FLT_MAX);
|
||||
BLI_gset_free(initial_verts, NULL);
|
||||
BLI_gset_free(initial_verts, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -886,7 +886,7 @@ static void sculpt_expand_topology_from_state_boundary(Object *ob,
|
|||
SculptSession *ss = ob->sculpt;
|
||||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
|
||||
float *dists = MEM_calloc_arrayN(totvert, sizeof(float), "topology dist");
|
||||
float *dists = static_cast<float *>(MEM_calloc_arrayN(totvert, sizeof(float), __func__));
|
||||
BLI_bitmap *boundary_verts = sculpt_expand_boundary_from_enabled(ss, enabled_verts, false);
|
||||
|
||||
SculptFloodFill flood;
|
||||
|
@ -939,7 +939,8 @@ static void sculpt_expand_resursion_step_add(Object *ob,
|
|||
|
||||
sculpt_expand_update_max_vert_falloff_value(ss, expand_cache);
|
||||
if (expand_cache->target == SCULPT_EXPAND_TARGET_FACE_SETS) {
|
||||
sculpt_expand_mesh_face_falloff_from_vertex_falloff(ss, ob->data, expand_cache);
|
||||
sculpt_expand_mesh_face_falloff_from_vertex_falloff(
|
||||
ss, static_cast<Mesh *>(ob->data), expand_cache);
|
||||
sculpt_expand_update_max_face_falloff_factor(ss, expand_cache);
|
||||
}
|
||||
|
||||
|
@ -1069,7 +1070,8 @@ static void sculpt_expand_falloff_factors_from_vertex_and_symm_create(
|
|||
/* Update max falloff values and propagate to base mesh faces if needed. */
|
||||
sculpt_expand_update_max_vert_falloff_value(ss, expand_cache);
|
||||
if (expand_cache->target == SCULPT_EXPAND_TARGET_FACE_SETS) {
|
||||
sculpt_expand_mesh_face_falloff_from_vertex_falloff(ss, ob->data, expand_cache);
|
||||
sculpt_expand_mesh_face_falloff_from_vertex_falloff(
|
||||
ss, static_cast<Mesh *>(ob->data), expand_cache);
|
||||
sculpt_expand_update_max_face_falloff_factor(ss, expand_cache);
|
||||
}
|
||||
}
|
||||
|
@ -1113,7 +1115,7 @@ static void sculpt_expand_snap_initialize_from_enabled(SculptSession *ss,
|
|||
}
|
||||
if (any_disabled) {
|
||||
const int face_set = expand_cache->original_face_sets[p];
|
||||
BLI_gset_remove(expand_cache->snap_enabled_face_sets, POINTER_FROM_INT(face_set), NULL);
|
||||
BLI_gset_remove(expand_cache->snap_enabled_face_sets, POINTER_FROM_INT(face_set), nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1128,7 +1130,7 @@ static void sculpt_expand_snap_initialize_from_enabled(SculptSession *ss,
|
|||
static void sculpt_expand_cache_data_free(ExpandCache *expand_cache)
|
||||
{
|
||||
if (expand_cache->snap_enabled_face_sets) {
|
||||
BLI_gset_free(expand_cache->snap_enabled_face_sets, NULL);
|
||||
BLI_gset_free(expand_cache->snap_enabled_face_sets, nullptr);
|
||||
}
|
||||
MEM_SAFE_FREE(expand_cache->nodes);
|
||||
MEM_SAFE_FREE(expand_cache->vert_falloff);
|
||||
|
@ -1143,9 +1145,9 @@ static void sculpt_expand_cache_data_free(ExpandCache *expand_cache)
|
|||
static void sculpt_expand_cache_free(SculptSession *ss)
|
||||
{
|
||||
sculpt_expand_cache_data_free(ss->expand_cache);
|
||||
/* Needs to be set to NULL as the paint cursor relies on checking this pointer detecting if an
|
||||
/* Needs to be set to nullptr as the paint cursor relies on checking this pointer detecting if an
|
||||
* expand operation is running. */
|
||||
ss->expand_cache = NULL;
|
||||
ss->expand_cache = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1155,7 +1157,7 @@ static void sculpt_expand_restore_face_set_data(SculptSession *ss, ExpandCache *
|
|||
{
|
||||
PBVHNode **nodes;
|
||||
int totnode;
|
||||
BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode);
|
||||
BKE_pbvh_search_gather(ss->pbvh, nullptr, nullptr, &nodes, &totnode);
|
||||
for (int n = 0; n < totnode; n++) {
|
||||
PBVHNode *node = nodes[n];
|
||||
BKE_pbvh_node_mark_redraw(node);
|
||||
|
@ -1170,7 +1172,7 @@ static void sculpt_expand_restore_color_data(SculptSession *ss, ExpandCache *exp
|
|||
{
|
||||
PBVHNode **nodes;
|
||||
int totnode;
|
||||
BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode);
|
||||
BKE_pbvh_search_gather(ss->pbvh, nullptr, nullptr, &nodes, &totnode);
|
||||
for (int n = 0; n < totnode; n++) {
|
||||
PBVHNode *node = nodes[n];
|
||||
PBVHVertexIter vd;
|
||||
|
@ -1187,7 +1189,7 @@ static void sculpt_expand_restore_mask_data(SculptSession *ss, ExpandCache *expa
|
|||
{
|
||||
PBVHNode **nodes;
|
||||
int totnode;
|
||||
BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode);
|
||||
BKE_pbvh_search_gather(ss->pbvh, nullptr, nullptr, &nodes, &totnode);
|
||||
for (int n = 0; n < totnode; n++) {
|
||||
PBVHNode *node = nodes[n];
|
||||
PBVHVertexIter vd;
|
||||
|
@ -1232,7 +1234,7 @@ static void sculpt_expand_restore_original_state(bContext *C,
|
|||
/**
|
||||
* Cancel operator callback.
|
||||
*/
|
||||
static void sculpt_expand_cancel(bContext *C, wmOperator *UNUSED(op))
|
||||
static void sculpt_expand_cancel(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
SculptSession *ss = ob->sculpt;
|
||||
|
@ -1250,9 +1252,9 @@ static void sculpt_expand_cancel(bContext *C, wmOperator *UNUSED(op))
|
|||
*/
|
||||
static void sculpt_expand_mask_update_task_cb(void *__restrict userdata,
|
||||
const int i,
|
||||
const TaskParallelTLS *__restrict UNUSED(tls))
|
||||
const TaskParallelTLS *__restrict /*tls*/)
|
||||
{
|
||||
SculptThreadedTaskData *data = userdata;
|
||||
SculptThreadedTaskData *data = static_cast<SculptThreadedTaskData *>(userdata);
|
||||
SculptSession *ss = data->ob->sculpt;
|
||||
PBVHNode *node = data->nodes[i];
|
||||
ExpandCache *expand_cache = ss->expand_cache;
|
||||
|
@ -1329,9 +1331,9 @@ static void sculpt_expand_face_sets_update(SculptSession *ss, ExpandCache *expan
|
|||
*/
|
||||
static void sculpt_expand_colors_update_task_cb(void *__restrict userdata,
|
||||
const int i,
|
||||
const TaskParallelTLS *__restrict UNUSED(tls))
|
||||
const TaskParallelTLS *__restrict /*tls*/)
|
||||
{
|
||||
SculptThreadedTaskData *data = userdata;
|
||||
SculptThreadedTaskData *data = static_cast<SculptThreadedTaskData *>(userdata);
|
||||
SculptSession *ss = data->ob->sculpt;
|
||||
PBVHNode *node = data->nodes[i];
|
||||
ExpandCache *expand_cache = ss->expand_cache;
|
||||
|
@ -1362,7 +1364,7 @@ static void sculpt_expand_colors_update_task_cb(void *__restrict userdata,
|
|||
IMB_blend_color_float(final_color,
|
||||
expand_cache->original_colors[vd.index],
|
||||
final_fill_color,
|
||||
expand_cache->blend_mode);
|
||||
IMB_BlendMode(expand_cache->blend_mode));
|
||||
|
||||
if (equals_v4v4(initial_color, final_color)) {
|
||||
continue;
|
||||
|
@ -1405,8 +1407,10 @@ static void sculpt_expand_original_state_store(Object *ob, ExpandCache *expand_c
|
|||
const int totface = ss->totfaces;
|
||||
|
||||
/* Face Sets are always stored as they are needed for snapping. */
|
||||
expand_cache->initial_face_sets = MEM_malloc_arrayN(totface, sizeof(int), "initial face set");
|
||||
expand_cache->original_face_sets = MEM_malloc_arrayN(totface, sizeof(int), "original face set");
|
||||
expand_cache->initial_face_sets = static_cast<int *>(
|
||||
MEM_malloc_arrayN(totface, sizeof(int), "initial face set"));
|
||||
expand_cache->original_face_sets = static_cast<int *>(
|
||||
MEM_malloc_arrayN(totface, sizeof(int), "original face set"));
|
||||
if (ss->face_sets) {
|
||||
for (int i = 0; i < totface; i++) {
|
||||
expand_cache->initial_face_sets[i] = ss->face_sets[i];
|
||||
|
@ -1419,7 +1423,8 @@ static void sculpt_expand_original_state_store(Object *ob, ExpandCache *expand_c
|
|||
}
|
||||
|
||||
if (expand_cache->target == SCULPT_EXPAND_TARGET_MASK) {
|
||||
expand_cache->original_mask = MEM_malloc_arrayN(totvert, sizeof(float), "initial mask");
|
||||
expand_cache->original_mask = static_cast<float *>(
|
||||
MEM_malloc_arrayN(totvert, sizeof(float), "initial mask"));
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
|
@ -1428,7 +1433,8 @@ static void sculpt_expand_original_state_store(Object *ob, ExpandCache *expand_c
|
|||
}
|
||||
|
||||
if (expand_cache->target == SCULPT_EXPAND_TARGET_COLORS) {
|
||||
expand_cache->original_colors = MEM_malloc_arrayN(totvert, sizeof(float[4]), "initial colors");
|
||||
expand_cache->original_colors = static_cast<float(*)[4]>(
|
||||
MEM_malloc_arrayN(totvert, sizeof(float[4]), "initial colors"));
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
|
@ -1483,11 +1489,10 @@ static void sculpt_expand_update_for_vertex(bContext *C, Object *ob, const PBVHV
|
|||
}
|
||||
|
||||
/* Update the mesh sculpt data. */
|
||||
SculptThreadedTaskData data = {
|
||||
.sd = sd,
|
||||
.ob = ob,
|
||||
.nodes = expand_cache->nodes,
|
||||
};
|
||||
SculptThreadedTaskData data{};
|
||||
data.sd = sd;
|
||||
data.ob = ob;
|
||||
data.nodes = expand_cache->nodes;
|
||||
|
||||
TaskParallelSettings settings;
|
||||
BKE_pbvh_parallel_range_settings(&settings, true, expand_cache->totnode);
|
||||
|
@ -1597,7 +1602,7 @@ static void sculpt_expand_finish(bContext *C)
|
|||
/* Tag all nodes to redraw to avoid artifacts after the fast partial updates. */
|
||||
PBVHNode **nodes;
|
||||
int totnode;
|
||||
BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode);
|
||||
BKE_pbvh_search_gather(ss->pbvh, nullptr, nullptr, &nodes, &totnode);
|
||||
for (int n = 0; n < totnode; n++) {
|
||||
BKE_pbvh_node_mark_update_mask(nodes[n]);
|
||||
}
|
||||
|
@ -1616,7 +1621,7 @@ static void sculpt_expand_finish(bContext *C)
|
|||
}
|
||||
|
||||
sculpt_expand_cache_free(ss);
|
||||
ED_workspace_status_text(C, NULL);
|
||||
ED_workspace_status_text(C, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1640,8 +1645,8 @@ static void sculpt_expand_find_active_connected_components_from_vert(
|
|||
const PBVHVertRef symm_vertex = sculpt_expand_get_vertex_index_for_symmetry_pass(
|
||||
ob, symm_it, initial_vertex);
|
||||
|
||||
expand_cache->active_connected_islands[(int)symm_it] = SCULPT_vertex_island_get(
|
||||
ss, symm_vertex);
|
||||
expand_cache->active_connected_islands[int(symm_it)] = SCULPT_vertex_island_get(ss,
|
||||
symm_vertex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1679,7 +1684,8 @@ static void sculpt_expand_set_initial_components_for_mouse(bContext *C,
|
|||
expand_cache->next_face_set = SCULPT_active_face_set_get(ss);
|
||||
}
|
||||
else {
|
||||
expand_cache->next_face_set = ED_sculpt_face_sets_find_next_available_id(ob->data);
|
||||
expand_cache->next_face_set = ED_sculpt_face_sets_find_next_available_id(
|
||||
static_cast<Mesh *>(ob->data));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1699,7 +1705,7 @@ static void sculpt_expand_move_propagation_origin(bContext *C,
|
|||
{
|
||||
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
|
||||
|
||||
const float mval_fl[2] = {UNPACK2(event->mval)};
|
||||
const float mval_fl[2] = {float(event->mval[0]), float(event->mval[1])};
|
||||
float move_disp[2];
|
||||
sub_v2_v2v2(move_disp, mval_fl, expand_cache->initial_mouse_move);
|
||||
|
||||
|
@ -1767,7 +1773,7 @@ static int sculpt_expand_modal(bContext *C, wmOperator *op, const wmEvent *event
|
|||
sculpt_expand_ensure_sculptsession_data(ob);
|
||||
|
||||
/* Update and get the active vertex (and face) from the cursor. */
|
||||
const float mval_fl[2] = {UNPACK2(event->mval)};
|
||||
const float mval_fl[2] = {float(event->mval[0]), float(event->mval[1])};
|
||||
const PBVHVertRef target_expand_vertex = sculpt_expand_target_vertex_update_and_get(
|
||||
C, ob, mval_fl);
|
||||
|
||||
|
@ -1802,8 +1808,8 @@ static int sculpt_expand_modal(bContext *C, wmOperator *op, const wmEvent *event
|
|||
if (expand_cache->snap) {
|
||||
expand_cache->snap = false;
|
||||
if (expand_cache->snap_enabled_face_sets) {
|
||||
BLI_gset_free(expand_cache->snap_enabled_face_sets, NULL);
|
||||
expand_cache->snap_enabled_face_sets = NULL;
|
||||
BLI_gset_free(expand_cache->snap_enabled_face_sets, nullptr);
|
||||
expand_cache->snap_enabled_face_sets = nullptr;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -1916,7 +1922,7 @@ static int sculpt_expand_modal(bContext *C, wmOperator *op, const wmEvent *event
|
|||
case SCULPT_EXPAND_MODAL_TEXTURE_DISTORTION_INCREASE: {
|
||||
if (expand_cache->texture_distortion_strength == 0.0f) {
|
||||
const MTex *mask_tex = BKE_brush_mask_texture_get(expand_cache->brush, OB_MODE_SCULPT);
|
||||
if (mask_tex->tex == NULL) {
|
||||
if (mask_tex->tex == nullptr) {
|
||||
BKE_report(op->reports,
|
||||
RPT_WARNING,
|
||||
"Active brush does not contain any texture to distort the expand boundary");
|
||||
|
@ -2067,7 +2073,7 @@ static void sculpt_expand_cache_initial_config_set(bContext *C,
|
|||
expand_cache->preserve = RNA_boolean_get(op->ptr, "use_mask_preserve");
|
||||
expand_cache->auto_mask = RNA_boolean_get(op->ptr, "use_auto_mask");
|
||||
expand_cache->falloff_gradient = RNA_boolean_get(op->ptr, "use_falloff_gradient");
|
||||
expand_cache->target = RNA_enum_get(op->ptr, "target");
|
||||
expand_cache->target = eSculptExpandTargetType(RNA_enum_get(op->ptr, "target"));
|
||||
expand_cache->modify_active_face_set = RNA_boolean_get(op->ptr, "use_modify_active");
|
||||
expand_cache->reposition_pivot = RNA_boolean_get(op->ptr, "use_reposition_pivot");
|
||||
expand_cache->max_geodesic_move_preview = RNA_int_get(op->ptr, "max_geodesic_move_preview");
|
||||
|
@ -2099,7 +2105,7 @@ static void sculpt_expand_undo_push(Object *ob, ExpandCache *expand_cache)
|
|||
SculptSession *ss = ob->sculpt;
|
||||
PBVHNode **nodes;
|
||||
int totnode;
|
||||
BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode);
|
||||
BKE_pbvh_search_gather(ss->pbvh, nullptr, nullptr, &nodes, &totnode);
|
||||
|
||||
switch (expand_cache->target) {
|
||||
case SCULPT_EXPAND_TARGET_MASK:
|
||||
|
@ -2132,7 +2138,7 @@ static int sculpt_expand_invoke(bContext *C, wmOperator *op, const wmEvent *even
|
|||
SCULPT_stroke_id_next(ob);
|
||||
|
||||
/* Create and configure the Expand Cache. */
|
||||
ss->expand_cache = MEM_callocN(sizeof(ExpandCache), "expand cache");
|
||||
ss->expand_cache = MEM_cnew<ExpandCache>(__func__);
|
||||
sculpt_expand_cache_initial_config_set(C, op, ss->expand_cache);
|
||||
|
||||
/* Update object. */
|
||||
|
@ -2168,7 +2174,7 @@ static int sculpt_expand_invoke(bContext *C, wmOperator *op, const wmEvent *even
|
|||
|
||||
/* TODO: implement SCULPT_vertex_mask_set and use it here. */
|
||||
|
||||
BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &nodes_num);
|
||||
BKE_pbvh_search_gather(ss->pbvh, nullptr, nullptr, &nodes, &nodes_num);
|
||||
for (int i = 0; i < nodes_num; i++) {
|
||||
PBVHVertexIter vd;
|
||||
|
||||
|
@ -2192,8 +2198,8 @@ static int sculpt_expand_invoke(bContext *C, wmOperator *op, const wmEvent *even
|
|||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
Mesh *mesh = static_cast<Mesh *>(ob->data);
|
||||
if (ss->expand_cache->target == SCULPT_EXPAND_TARGET_FACE_SETS) {
|
||||
Mesh *mesh = ob->data;
|
||||
ss->face_sets = BKE_sculpt_face_sets_ensure(mesh);
|
||||
}
|
||||
|
||||
|
@ -2211,12 +2217,12 @@ static int sculpt_expand_invoke(bContext *C, wmOperator *op, const wmEvent *even
|
|||
sculpt_expand_undo_push(ob, ss->expand_cache);
|
||||
|
||||
/* Set the initial element for expand from the event position. */
|
||||
const float mouse[2] = {event->mval[0], event->mval[1]};
|
||||
const float mouse[2] = {float(event->mval[0]), float(event->mval[1])};
|
||||
sculpt_expand_set_initial_components_for_mouse(C, ob, ss->expand_cache, mouse);
|
||||
|
||||
/* Cache PBVH nodes. */
|
||||
BKE_pbvh_search_gather(
|
||||
ss->pbvh, NULL, NULL, &ss->expand_cache->nodes, &ss->expand_cache->totnode);
|
||||
ss->pbvh, nullptr, nullptr, &ss->expand_cache->nodes, &ss->expand_cache->totnode);
|
||||
|
||||
/* Store initial state. */
|
||||
sculpt_expand_original_state_store(ob, ss->expand_cache);
|
||||
|
@ -2225,12 +2231,13 @@ static int sculpt_expand_invoke(bContext *C, wmOperator *op, const wmEvent *even
|
|||
sculpt_expand_delete_face_set_id(ss->expand_cache->initial_face_sets,
|
||||
ss,
|
||||
ss->expand_cache,
|
||||
ob->data,
|
||||
mesh,
|
||||
ss->expand_cache->next_face_set);
|
||||
}
|
||||
|
||||
/* Initialize the falloff. */
|
||||
eSculptExpandFalloffType falloff_type = RNA_enum_get(op->ptr, "falloff_type");
|
||||
eSculptExpandFalloffType falloff_type = eSculptExpandFalloffType(
|
||||
RNA_enum_get(op->ptr, "falloff_type"));
|
||||
|
||||
/* When starting from a boundary vertex, set the initial falloff to boundary. */
|
||||
if (SCULPT_vertex_is_boundary(ss, ss->expand_cache->initial_active_vertex)) {
|
||||
|
@ -2302,7 +2309,7 @@ void sculpt_expand_modal_keymap(wmKeyConfig *keyconf)
|
|||
0,
|
||||
"Texture Distortion Decrease",
|
||||
""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
static const char *name = "Sculpt Expand Modal";
|
||||
|
@ -2345,14 +2352,14 @@ void SCULPT_OT_expand(wmOperatorType *ot)
|
|||
{SCULPT_EXPAND_FALLOFF_BOUNDARY_TOPOLOGY, "BOUNDARY_TOPOLOGY", 0, "Boundary Topology", ""},
|
||||
{SCULPT_EXPAND_FALLOFF_BOUNDARY_FACE_SET, "BOUNDARY_FACE_SET", 0, "Boundary Face Set", ""},
|
||||
{SCULPT_EXPAND_FALLOFF_ACTIVE_FACE_SET, "ACTIVE_FACE_SET", 0, "Active Face Set", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
static EnumPropertyItem prop_sculpt_expand_target_type_items[] = {
|
||||
{SCULPT_EXPAND_TARGET_MASK, "MASK", 0, "Mask", ""},
|
||||
{SCULPT_EXPAND_TARGET_FACE_SETS, "FACE_SETS", 0, "Face Sets", ""},
|
||||
{SCULPT_EXPAND_TARGET_COLORS, "COLOR", 0, "Color", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
RNA_def_enum(ot->srna,
|
|
@ -5,6 +5,9 @@
|
|||
* \ingroup edsculpt
|
||||
*/
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_linklist_stack.h"
|
||||
|
@ -29,8 +32,6 @@
|
|||
|
||||
#include "bmesh.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#define SCULPT_GEODESIC_VERTEX_NONE -1
|
||||
|
||||
/* Propagate distance from v1 and v2 to v0. */
|
||||
|
@ -90,7 +91,7 @@ static float *SCULPT_geodesic_mesh_create(Object *ob,
|
|||
const MPoly *polys = BKE_mesh_polys(mesh);
|
||||
const MLoop *loops = BKE_mesh_loops(mesh);
|
||||
|
||||
float *dists = MEM_malloc_arrayN(totvert, sizeof(float), "distances");
|
||||
float *dists = static_cast<float *>(MEM_malloc_arrayN(totvert, sizeof(float), __func__));
|
||||
BLI_bitmap *edge_tag = BLI_BITMAP_NEW(totedge, "edge tag");
|
||||
|
||||
if (!ss->epmap) {
|
||||
|
@ -242,7 +243,7 @@ static float *SCULPT_geodesic_fallback_create(Object *ob, GSet *initial_verts)
|
|||
SculptSession *ss = ob->sculpt;
|
||||
Mesh *mesh = BKE_object_get_original_mesh(ob);
|
||||
const int totvert = mesh->totvert;
|
||||
float *dists = MEM_malloc_arrayN(totvert, sizeof(float), "distances");
|
||||
float *dists = static_cast<float *>(MEM_malloc_arrayN(totvert, sizeof(float), __func__));
|
||||
int first_affected = SCULPT_GEODESIC_VERTEX_NONE;
|
||||
GSetIterator gs_iter;
|
||||
GSET_ITER (gs_iter, initial_verts) {
|
||||
|
@ -279,7 +280,7 @@ float *SCULPT_geodesic_distances_create(Object *ob, GSet *initial_verts, const f
|
|||
return SCULPT_geodesic_fallback_create(ob, initial_verts);
|
||||
}
|
||||
BLI_assert(false);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
float *SCULPT_geodesic_from_vertex_and_symm(Sculpt *sd,
|
||||
|
@ -300,7 +301,7 @@ float *SCULPT_geodesic_from_vertex_and_symm(Sculpt *sd,
|
|||
}
|
||||
else {
|
||||
float location[3];
|
||||
flip_v3_v3(location, SCULPT_vertex_co_get(ss, vertex), i);
|
||||
flip_v3_v3(location, SCULPT_vertex_co_get(ss, vertex), ePaintSymmetryFlags(i));
|
||||
v = SCULPT_nearest_vertex_get(sd, ob, location, FLT_MAX, false);
|
||||
}
|
||||
if (v.i != PBVH_REF_NONE) {
|
||||
|
@ -310,7 +311,7 @@ float *SCULPT_geodesic_from_vertex_and_symm(Sculpt *sd,
|
|||
}
|
||||
|
||||
float *dists = SCULPT_geodesic_distances_create(ob, initial_verts, limit_radius);
|
||||
BLI_gset_free(initial_verts, NULL);
|
||||
BLI_gset_free(initial_verts, nullptr);
|
||||
return dists;
|
||||
}
|
||||
|
||||
|
@ -320,6 +321,6 @@ float *SCULPT_geodesic_from_vertex(Object *ob, const PBVHVertRef vertex, const f
|
|||
BLI_gset_add(initial_verts,
|
||||
POINTER_FROM_INT(BKE_pbvh_vertex_to_index(ob->sculpt->pbvh, vertex)));
|
||||
float *dists = SCULPT_geodesic_distances_create(ob, initial_verts, limit_radius);
|
||||
BLI_gset_free(initial_verts, NULL);
|
||||
BLI_gset_free(initial_verts, nullptr);
|
||||
return dists;
|
||||
}
|
Loading…
Reference in New Issue