Refactor: Convert mask module to C++

Pull Request: https://projects.blender.org/blender/blender/pulls/107615
This commit is contained in:
Sergey Sharybin 2023-05-04 17:36:01 +02:00 committed by Sergey Sharybin
parent 5aa51cf607
commit eca8e6bf5e
14 changed files with 471 additions and 547 deletions

View File

@ -186,9 +186,9 @@ set(SRC
intern/main.c
intern/main_idmap.c
intern/main_namemap.cc
intern/mask.c
intern/mask_evaluate.c
intern/mask_rasterize.c
intern/mask.cc
intern/mask_evaluate.cc
intern/mask_rasterize.cc
intern/material.cc
intern/mball.cc
intern/mball_tessellate.cc

View File

@ -46,10 +46,7 @@
static CLG_LogRef LOG = {"bke.mask"};
static void mask_copy_data(Main *UNUSED(bmain),
ID *id_dst,
const ID *id_src,
const int UNUSED(flag))
static void mask_copy_data(Main * /*bmain*/, ID *id_dst, const ID *id_src, const int /*flag*/)
{
Mask *mask_dst = (Mask *)id_dst;
const Mask *mask_src = (const Mask *)id_src;
@ -93,8 +90,6 @@ static void mask_blend_write(BlendWriter *writer, ID *id, const void *id_address
{
Mask *mask = (Mask *)id;
MaskLayer *masklay;
BLO_write_id_struct(writer, Mask, id_address, &mask->id);
BKE_id_blend_write(writer, &mask->id);
@ -102,17 +97,14 @@ static void mask_blend_write(BlendWriter *writer, ID *id, const void *id_address
BKE_animdata_blend_write(writer, mask->adt);
}
for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
MaskSpline *spline;
MaskLayerShape *masklay_shape;
LISTBASE_FOREACH (MaskLayer *, masklay, &mask->masklayers) {
BLO_write_struct(writer, MaskLayer, masklay);
for (spline = masklay->splines.first; spline; spline = spline->next) {
LISTBASE_FOREACH (MaskSpline *, spline, &masklay->splines) {
int i;
void *points_deform = spline->points_deform;
spline->points_deform = NULL;
MaskSplinePoint *points_deform = spline->points_deform;
spline->points_deform = nullptr;
BLO_write_struct(writer, MaskSpline, spline);
BLO_write_struct_array(writer, MaskSplinePoint, spline->tot_point, spline->points);
@ -128,9 +120,7 @@ static void mask_blend_write(BlendWriter *writer, ID *id, const void *id_address
}
}
for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
masklay_shape = masklay_shape->next)
{
LISTBASE_FOREACH (MaskLayerShape *, masklay_shape, &masklay->splines_shapes) {
BLO_write_struct(writer, MaskLayerShape, masklay_shape);
BLO_write_float_array(
writer, masklay_shape->tot_vert * MASK_OBJECT_SHAPE_ELEM_SIZE, masklay_shape->data);
@ -147,7 +137,7 @@ static void mask_blend_read_data(BlendDataReader *reader, ID *id)
LISTBASE_FOREACH (MaskLayer *, masklay, &mask->masklayers) {
/* Can't use #newdataadr since it's a pointer within an array. */
MaskSplinePoint *act_point_search = NULL;
MaskSplinePoint *act_point_search = nullptr;
BLO_read_list(reader, &masklay->splines);
@ -165,7 +155,7 @@ static void mask_blend_read_data(BlendDataReader *reader, ID *id)
}
/* detect active point */
if ((act_point_search == NULL) && (masklay->act_point >= points_old) &&
if ((act_point_search == nullptr) && (masklay->act_point >= points_old) &&
(masklay->act_point < points_old + spline->tot_point))
{
act_point_search = &spline->points[masklay->act_point - points_old];
@ -200,9 +190,7 @@ static void mask_blend_read_lib(BlendLibReader *reader, ID *id)
{
Mask *mask = (Mask *)id;
LISTBASE_FOREACH (MaskLayer *, masklay, &mask->masklayers) {
MaskSpline *spline;
spline = masklay->splines.first;
MaskSpline *spline = static_cast<MaskSpline *>(masklay->splines.first);
while (spline) {
for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
@ -240,39 +228,39 @@ static void mask_blend_read_expand(BlendExpander *expander, ID *id)
}
IDTypeInfo IDType_ID_MSK = {
.id_code = ID_MSK,
.id_filter = FILTER_ID_MSK,
.main_listbase_index = INDEX_ID_MSK,
.struct_size = sizeof(Mask),
.name = "Mask",
.name_plural = "masks",
.translation_context = BLT_I18NCONTEXT_ID_MASK,
.flags = IDTYPE_FLAGS_APPEND_IS_REUSABLE,
.asset_type_info = NULL,
/*id_code*/ ID_MSK,
/*id_filter*/ FILTER_ID_MSK,
/*main_listbase_index*/ INDEX_ID_MSK,
/*struct_size*/ sizeof(Mask),
/*name*/ "Mask",
/*name_plural*/ "masks",
/*translation_context*/ BLT_I18NCONTEXT_ID_MASK,
/*flags*/ IDTYPE_FLAGS_APPEND_IS_REUSABLE,
/*asset_type_info*/ nullptr,
.init_data = NULL,
.copy_data = mask_copy_data,
.free_data = mask_free_data,
.make_local = NULL,
.foreach_id = mask_foreach_id,
.foreach_cache = NULL,
.foreach_path = NULL,
.owner_pointer_get = NULL,
/*init_data*/ nullptr,
/*copy_data*/ mask_copy_data,
/*free_data*/ mask_free_data,
/*make_local*/ nullptr,
/*foreach_id*/ mask_foreach_id,
/*foreach_cache*/ nullptr,
/*foreach_path*/ nullptr,
/*owner_pointer_get*/ nullptr,
.blend_write = mask_blend_write,
.blend_read_data = mask_blend_read_data,
.blend_read_lib = mask_blend_read_lib,
.blend_read_expand = mask_blend_read_expand,
/*blend_write*/ mask_blend_write,
/*blend_read_data*/ mask_blend_read_data,
/*blend_read_lib*/ mask_blend_read_lib,
/*blend_read_expand*/ mask_blend_read_expand,
.blend_read_undo_preserve = NULL,
/*blend_read_undo_preserve*/ nullptr,
.lib_override_apply_post = NULL,
/*lib_override_apply_post*/ nullptr,
};
static struct {
ListBase splines;
struct GHash *id_hash;
} mask_clipboard = {{NULL}};
} mask_clipboard = {{nullptr}};
static MaskSplinePoint *mask_spline_point_next(MaskSpline *spline,
MaskSplinePoint *points_array,
@ -283,7 +271,7 @@ static MaskSplinePoint *mask_spline_point_next(MaskSpline *spline,
return &points_array[0];
}
return NULL;
return nullptr;
}
return point + 1;
@ -298,7 +286,7 @@ static MaskSplinePoint *mask_spline_point_prev(MaskSpline *spline,
return &points_array[spline->tot_point - 1];
}
return NULL;
return nullptr;
}
return point - 1;
@ -313,7 +301,7 @@ BezTriple *BKE_mask_spline_point_next_bezt(MaskSpline *spline,
return &(points_array[0].bezt);
}
return NULL;
return nullptr;
}
return &(point + 1)->bezt;
@ -338,14 +326,14 @@ MaskSplinePoint *BKE_mask_spline_point_array_from_point(MaskSpline *spline,
}
BLI_assert_msg(0, "wrong array");
return NULL;
return nullptr;
}
/* mask layers */
MaskLayer *BKE_mask_layer_new(Mask *mask, const char *name)
{
MaskLayer *masklay = MEM_callocN(sizeof(MaskLayer), __func__);
MaskLayer *masklay = MEM_cnew<MaskLayer>(__func__);
if (name && name[0]) {
BLI_strncpy(masklay->name, name, sizeof(masklay->name));
@ -369,7 +357,7 @@ MaskLayer *BKE_mask_layer_new(Mask *mask, const char *name)
MaskLayer *BKE_mask_layer_active(Mask *mask)
{
return BLI_findlink(&mask->masklayers, mask->masklay_act);
return static_cast<MaskLayer *>(BLI_findlink(&mask->masklayers, mask->masklay_act));
}
void BKE_mask_layer_active_set(Mask *mask, MaskLayer *masklay)
@ -411,10 +399,7 @@ void BKE_mask_layer_rename(Mask *mask, MaskLayer *masklay, char *oldname, char *
MaskLayer *BKE_mask_layer_copy(const MaskLayer *masklay)
{
MaskLayer *masklay_new;
MaskSpline *spline;
masklay_new = MEM_callocN(sizeof(MaskLayer), "new mask layer");
MaskLayer *masklay_new = MEM_cnew<MaskLayer>("new mask layer");
BLI_strncpy(masklay_new->name, masklay->name, sizeof(masklay_new->name));
@ -425,7 +410,7 @@ MaskLayer *BKE_mask_layer_copy(const MaskLayer *masklay)
masklay_new->falloff = masklay->falloff;
masklay_new->visibility_flag = masklay->visibility_flag;
for (spline = masklay->splines.first; spline; spline = spline->next) {
LISTBASE_FOREACH (MaskSpline *, spline, &masklay->splines) {
MaskSpline *spline_new = BKE_mask_spline_copy(spline);
BLI_addtail(&masklay_new->splines, spline_new);
@ -444,15 +429,10 @@ MaskLayer *BKE_mask_layer_copy(const MaskLayer *masklay)
/* correct animation */
if (masklay->splines_shapes.first) {
MaskLayerShape *masklay_shape;
MaskLayerShape *masklay_shape_new;
LISTBASE_FOREACH (MaskLayerShape *, masklay_shape, &masklay->splines_shapes) {
MaskLayerShape *masklay_shape_new = MEM_cnew<MaskLayerShape>("new mask layer shape");
for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
masklay_shape = masklay_shape->next)
{
masklay_shape_new = MEM_callocN(sizeof(MaskLayerShape), "new mask layer shape");
masklay_shape_new->data = MEM_dupallocN(masklay_shape->data);
masklay_shape_new->data = static_cast<float *>(MEM_dupallocN(masklay_shape->data));
masklay_shape_new->tot_vert = masklay_shape->tot_vert;
masklay_shape_new->flag = masklay_shape->flag;
masklay_shape_new->frame = masklay_shape->frame;
@ -466,9 +446,7 @@ MaskLayer *BKE_mask_layer_copy(const MaskLayer *masklay)
void BKE_mask_layer_copy_list(ListBase *masklayers_new, const ListBase *masklayers)
{
MaskLayer *layer;
for (layer = masklayers->first; layer; layer = layer->next) {
LISTBASE_FOREACH (MaskLayer *, layer, masklayers) {
MaskLayer *layer_new = BKE_mask_layer_copy(layer);
BLI_addtail(masklayers_new, layer_new);
@ -479,13 +457,12 @@ void BKE_mask_layer_copy_list(ListBase *masklayers_new, const ListBase *masklaye
MaskSpline *BKE_mask_spline_add(MaskLayer *masklay)
{
MaskSpline *spline;
MaskSpline *spline = MEM_cnew<MaskSpline>("new mask spline");
spline = MEM_callocN(sizeof(MaskSpline), "new mask spline");
BLI_addtail(&masklay->splines, spline);
/* spline shall have one point at least */
spline->points = MEM_callocN(sizeof(MaskSplinePoint), "new mask spline point");
spline->points = MEM_cnew<MaskSplinePoint>("new mask spline point");
spline->tot_point = 1;
/* cyclic shapes are more usually used */
@ -574,13 +551,9 @@ void BKE_mask_spline_direction_switch(MaskLayer *masklay, MaskSpline *spline)
/* correct animation */
if (masklay->splines_shapes.first) {
MaskLayerShape *masklay_shape;
const int spline_index = BKE_mask_layer_shape_spline_to_index(masklay, spline);
for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
masklay_shape = masklay_shape->next)
{
LISTBASE_FOREACH (MaskLayerShape *, masklay_shape, &masklay->splines_shapes) {
MaskLayerShapeElem *fp_arr = (MaskLayerShapeElem *)masklay_shape->data;
for (i = 0; i < tot_point_half; i++) {
@ -800,13 +773,13 @@ void BKE_mask_point_normal(MaskSpline *spline, MaskSplinePoint *point, float u,
BKE_mask_get_handle_point_adjacent(spline, point, &point_prev, &point_next);
if (u - du < 0.0f && point_prev == NULL) {
if (u - du < 0.0f && point_prev == nullptr) {
float co[2], dir[2];
BKE_mask_point_segment_co(spline, point, u + du, co);
sub_v2_v2v2(dir, co, point->bezt.vec[1]);
orthogonal_direction_get(dir, n);
}
else if (u + du > 1.0f && point_next == NULL) {
else if (u + du > 1.0f && point_next == nullptr) {
float co[2], dir[2];
BKE_mask_point_segment_co(spline, point, u - du, co);
sub_v2_v2v2(dir, point->bezt.vec[1], co);
@ -951,10 +924,11 @@ MaskSplinePointUW *BKE_mask_point_sort_uw(MaskSplinePoint *point, MaskSplinePoin
void BKE_mask_point_add_uw(MaskSplinePoint *point, float u, float w)
{
if (!point->uw) {
point->uw = MEM_mallocN(sizeof(*point->uw), "mask point uw");
point->uw = MEM_cnew<MaskSplinePointUW>("mask point uw");
}
else {
point->uw = MEM_reallocN(point->uw, (point->tot_uw + 1) * sizeof(*point->uw));
point->uw = static_cast<MaskSplinePointUW *>(
MEM_reallocN(point->uw, (point->tot_uw + 1) * sizeof(*point->uw)));
}
point->uw[point->tot_uw].u = u;
@ -1024,9 +998,7 @@ void BKE_mask_point_select_set_handle(MaskSplinePoint *point,
/* only mask block itself */
static Mask *mask_alloc(Main *bmain, const char *name)
{
Mask *mask;
mask = BKE_libblock_alloc(bmain, ID_MSK, name, 0);
Mask *mask = static_cast<Mask *>(BKE_libblock_alloc(bmain, ID_MSK, name, 0));
id_fake_user_set(&mask->id);
@ -1089,7 +1061,7 @@ void BKE_mask_spline_free(MaskSpline *spline)
void BKE_mask_spline_free_list(ListBase *splines)
{
MaskSpline *spline = splines->first;
MaskSpline *spline = static_cast<MaskSpline *>(splines->first);
while (spline) {
MaskSpline *next_spline = spline->next;
@ -1102,13 +1074,13 @@ void BKE_mask_spline_free_list(ListBase *splines)
static MaskSplinePoint *mask_spline_points_copy(const MaskSplinePoint *points, int tot_point)
{
MaskSplinePoint *npoints = MEM_dupallocN(points);
MaskSplinePoint *npoints = static_cast<MaskSplinePoint *>(MEM_dupallocN(points));
for (int i = 0; i < tot_point; i++) {
MaskSplinePoint *point = &npoints[i];
if (point->uw) {
point->uw = MEM_dupallocN(point->uw);
point->uw = static_cast<MaskSplinePointUW *>(MEM_dupallocN(point->uw));
}
}
@ -1117,11 +1089,11 @@ static MaskSplinePoint *mask_spline_points_copy(const MaskSplinePoint *points, i
MaskSpline *BKE_mask_spline_copy(const MaskSpline *spline)
{
MaskSpline *nspline = MEM_callocN(sizeof(MaskSpline), "new spline");
MaskSpline *nspline = MEM_cnew<MaskSpline>("new spline");
*nspline = *spline;
nspline->points_deform = NULL;
nspline->points_deform = nullptr;
nspline->points = mask_spline_points_copy(spline->points, spline->tot_point);
if (spline->points_deform) {
@ -1136,11 +1108,10 @@ MaskLayerShape *BKE_mask_layer_shape_alloc(MaskLayer *masklay, const int frame)
MaskLayerShape *masklay_shape;
int tot_vert = BKE_mask_layer_shape_totvert(masklay);
masklay_shape = MEM_mallocN(sizeof(MaskLayerShape), __func__);
masklay_shape = MEM_cnew<MaskLayerShape>(__func__);
masklay_shape->frame = frame;
masklay_shape->tot_vert = tot_vert;
masklay_shape->data = MEM_mallocN(tot_vert * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE,
__func__);
masklay_shape->data = MEM_cnew_array<float>(tot_vert * MASK_OBJECT_SHAPE_ELEM_SIZE, __func__);
return masklay_shape;
}
@ -1159,7 +1130,7 @@ void BKE_mask_layer_free_shapes(MaskLayer *masklay)
MaskLayerShape *masklay_shape;
/* free animation data */
masklay_shape = masklay->splines_shapes.first;
masklay_shape = static_cast<MaskLayerShape *>(masklay->splines_shapes.first);
while (masklay_shape) {
MaskLayerShape *next_masklay_shape = masklay_shape->next;
@ -1183,7 +1154,7 @@ void BKE_mask_layer_free(MaskLayer *masklay)
void BKE_mask_layer_free_list(ListBase *masklayers)
{
MaskLayer *masklay = masklayers->first;
MaskLayer *masklay = static_cast<MaskLayer *>(masklayers->first);
while (masklay) {
MaskLayer *masklay_next = masklay->next;
@ -1366,7 +1337,7 @@ static void mask_calc_point_handle(MaskSplinePoint *point,
MaskSplinePoint *point_next)
{
BezTriple *bezt = &point->bezt;
BezTriple *bezt_prev = NULL, *bezt_next = NULL;
BezTriple *bezt_prev = nullptr, *bezt_next = nullptr;
// int handle_type = bezt->h1;
if (point_prev) {
@ -1536,8 +1507,7 @@ void BKE_mask_calc_handle_point_auto(MaskSpline *spline,
void BKE_mask_layer_calc_handles(MaskLayer *masklay)
{
MaskSpline *spline;
for (spline = masklay->splines.first; spline; spline = spline->next) {
LISTBASE_FOREACH (MaskSpline *, spline, &masklay->splines) {
for (int i = 0; i < spline->tot_point; i++) {
BKE_mask_calc_handle_point(spline, &spline->points[i]);
}
@ -1549,7 +1519,7 @@ void BKE_mask_spline_ensure_deform(MaskSpline *spline)
int allocated_points = (MEM_allocN_len(spline->points_deform) / sizeof(*spline->points_deform));
// printf("SPLINE ALLOC %p %d\n", spline->points_deform, allocated_points);
if (spline->points_deform == NULL || allocated_points != spline->tot_point) {
if (spline->points_deform == nullptr || allocated_points != spline->tot_point) {
// printf("alloc new deform spline\n");
if (spline->points_deform) {
@ -1561,8 +1531,7 @@ void BKE_mask_spline_ensure_deform(MaskSpline *spline)
MEM_freeN(spline->points_deform);
}
spline->points_deform = MEM_callocN(sizeof(*spline->points_deform) * spline->tot_point,
__func__);
spline->points_deform = MEM_cnew_array<MaskSplinePoint>(spline->tot_point, __func__);
}
else {
// printf("alloc spline done\n");
@ -1581,9 +1550,7 @@ void BKE_mask_layer_evaluate(MaskLayer *masklay, const float ctime, const bool d
void BKE_mask_evaluate(Mask *mask, const float ctime, const bool do_newframe)
{
MaskLayer *masklay;
for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
LISTBASE_FOREACH (MaskLayer *, masklay, &mask->masklayers) {
BKE_mask_layer_evaluate(masklay, ctime, do_newframe);
}
}
@ -1599,9 +1566,8 @@ void BKE_mask_parent_init(MaskParent *parent)
int BKE_mask_layer_shape_totvert(MaskLayer *masklay)
{
int tot = 0;
MaskSpline *spline;
for (spline = masklay->splines.first; spline; spline = spline->next) {
LISTBASE_FOREACH (MaskSpline *, spline, &masklay->splines) {
tot += spline->tot_point;
}
@ -1635,8 +1601,7 @@ void BKE_mask_layer_shape_from_mask(MaskLayer *masklay, MaskLayerShape *masklay_
if (masklay_shape->tot_vert == tot) {
float *fp = masklay_shape->data;
MaskSpline *spline;
for (spline = masklay->splines.first; spline; spline = spline->next) {
LISTBASE_FOREACH (MaskSpline *, spline, &masklay->splines) {
for (int i = 0; i < spline->tot_point; i++) {
mask_layer_shape_from_mask_point(&spline->points[i].bezt, fp);
fp += MASK_OBJECT_SHAPE_ELEM_SIZE;
@ -1659,8 +1624,7 @@ void BKE_mask_layer_shape_to_mask(MaskLayer *masklay, MaskLayerShape *masklay_sh
if (masklay_shape->tot_vert == tot) {
float *fp = masklay_shape->data;
MaskSpline *spline;
for (spline = masklay->splines.first; spline; spline = spline->next) {
LISTBASE_FOREACH (MaskSpline *, spline, &masklay->splines) {
for (int i = 0; i < spline->tot_point; i++) {
mask_layer_shape_to_mask_point(&spline->points[i].bezt, fp);
fp += MASK_OBJECT_SHAPE_ELEM_SIZE;
@ -1694,8 +1658,7 @@ void BKE_mask_layer_shape_to_mask_interp(MaskLayer *masklay,
const float *fp_b = masklay_shape_b->data;
const float ifac = 1.0f - fac;
MaskSpline *spline;
for (spline = masklay->splines.first; spline; spline = spline->next) {
LISTBASE_FOREACH (MaskSpline *, spline, &masklay->splines) {
for (int i = 0; i < spline->tot_point; i++) {
BezTriple *bezt = &spline->points[i].bezt;
/* *** BKE_mask_layer_shape_from_mask - swapped *** */
@ -1728,11 +1691,7 @@ void BKE_mask_layer_shape_to_mask_interp(MaskLayer *masklay,
MaskLayerShape *BKE_mask_layer_shape_find_frame(MaskLayer *masklay, const int frame)
{
MaskLayerShape *masklay_shape;
for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
masklay_shape = masklay_shape->next)
{
LISTBASE_FOREACH (MaskLayerShape *, masklay_shape, &masklay->splines_shapes) {
if (frame == masklay_shape->frame) {
return masklay_shape;
}
@ -1741,7 +1700,7 @@ MaskLayerShape *BKE_mask_layer_shape_find_frame(MaskLayer *masklay, const int fr
}
}
return NULL;
return nullptr;
}
int BKE_mask_layer_shape_find_frame_range(MaskLayer *masklay,
@ -1751,12 +1710,12 @@ int BKE_mask_layer_shape_find_frame_range(MaskLayer *masklay,
{
MaskLayerShape *masklay_shape;
for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
for (masklay_shape = static_cast<MaskLayerShape *>(masklay->splines_shapes.first); masklay_shape;
masklay_shape = masklay_shape->next)
{
if (frame == masklay_shape->frame) {
*r_masklay_shape_a = masklay_shape;
*r_masklay_shape_b = NULL;
*r_masklay_shape_b = nullptr;
return 1;
}
if (frame < masklay_shape->frame) {
@ -1767,19 +1726,19 @@ int BKE_mask_layer_shape_find_frame_range(MaskLayer *masklay,
}
*r_masklay_shape_a = masklay_shape;
*r_masklay_shape_b = NULL;
*r_masklay_shape_b = nullptr;
return 1;
}
}
if ((masklay_shape = masklay->splines_shapes.last)) {
if ((masklay_shape = static_cast<MaskLayerShape *>(masklay->splines_shapes.last))) {
*r_masklay_shape_a = masklay_shape;
*r_masklay_shape_b = NULL;
*r_masklay_shape_b = nullptr;
return 1;
}
*r_masklay_shape_a = NULL;
*r_masklay_shape_b = NULL;
*r_masklay_shape_a = nullptr;
*r_masklay_shape_b = nullptr;
return 0;
}
@ -1790,7 +1749,7 @@ MaskLayerShape *BKE_mask_layer_shape_verify_frame(MaskLayer *masklay, const int
masklay_shape = BKE_mask_layer_shape_find_frame(masklay, frame);
if (masklay_shape == NULL) {
if (masklay_shape == nullptr) {
masklay_shape = BKE_mask_layer_shape_alloc(masklay, frame);
BLI_addtail(&masklay->splines_shapes, masklay_shape);
BKE_mask_layer_shape_sort(masklay);
@ -1801,12 +1760,10 @@ MaskLayerShape *BKE_mask_layer_shape_verify_frame(MaskLayer *masklay, const int
MaskLayerShape *BKE_mask_layer_shape_duplicate(MaskLayerShape *masklay_shape)
{
MaskLayerShape *masklay_shape_copy;
masklay_shape_copy = MEM_dupallocN(masklay_shape);
MaskLayerShape *masklay_shape_copy = static_cast<MaskLayerShape *>(MEM_dupallocN(masklay_shape));
if (LIKELY(masklay_shape_copy->data)) {
masklay_shape_copy->data = MEM_dupallocN(masklay_shape_copy->data);
masklay_shape_copy->data = static_cast<float *>(MEM_dupallocN(masklay_shape_copy->data));
}
return masklay_shape_copy;
@ -1822,8 +1779,8 @@ void BKE_mask_layer_shape_unlink(MaskLayer *masklay, MaskLayerShape *masklay_sha
static int mask_layer_shape_sort_cb(const void *masklay_shape_a_ptr,
const void *masklay_shape_b_ptr)
{
const MaskLayerShape *masklay_shape_a = masklay_shape_a_ptr;
const MaskLayerShape *masklay_shape_b = masklay_shape_b_ptr;
const MaskLayerShape *masklay_shape_a = static_cast<const MaskLayerShape *>(masklay_shape_a_ptr);
const MaskLayerShape *masklay_shape_b = static_cast<const MaskLayerShape *>(masklay_shape_b_ptr);
if (masklay_shape_a->frame < masklay_shape_b->frame) {
return -1;
@ -1845,9 +1802,7 @@ bool BKE_mask_layer_shape_spline_from_index(MaskLayer *masklay,
MaskSpline **r_masklay_shape,
int *r_index)
{
MaskSpline *spline;
for (spline = masklay->splines.first; spline; spline = spline->next) {
LISTBASE_FOREACH (MaskSpline *, spline, &masklay->splines) {
if (index < spline->tot_point) {
*r_masklay_shape = spline;
*r_index = index;
@ -1863,7 +1818,8 @@ int BKE_mask_layer_shape_spline_to_index(MaskLayer *masklay, MaskSpline *spline)
{
MaskSpline *spline_iter;
int i_abs = 0;
for (spline_iter = masklay->splines.first; spline_iter && spline_iter != spline;
for (spline_iter = static_cast<MaskSpline *>(masklay->splines.first);
spline_iter && spline_iter != spline;
i_abs += spline_iter->tot_point, spline_iter = spline_iter->next)
{
/* pass */
@ -1913,8 +1869,6 @@ void BKE_mask_layer_shape_changed_add(MaskLayer *masklay,
bool do_init,
bool do_init_interpolate)
{
MaskLayerShape *masklay_shape;
/* spline index from masklay */
MaskSpline *spline;
int spline_point_index;
@ -1946,15 +1900,13 @@ void BKE_mask_layer_shape_changed_add(MaskLayer *masklay,
}
}
for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
masklay_shape = masklay_shape->next)
{
LISTBASE_FOREACH (MaskLayerShape *, masklay_shape, &masklay->splines_shapes) {
if (tot == masklay_shape->tot_vert) {
float *data_resized;
masklay_shape->tot_vert++;
data_resized = MEM_mallocN(
masklay_shape->tot_vert * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE, __func__);
data_resized = MEM_cnew_array<float>(masklay_shape->tot_vert * MASK_OBJECT_SHAPE_ELEM_SIZE,
__func__);
if (index > 0) {
memcpy(data_resized,
masklay_shape->data,
@ -2005,20 +1957,16 @@ void BKE_mask_layer_shape_changed_add(MaskLayer *masklay,
void BKE_mask_layer_shape_changed_remove(MaskLayer *masklay, int index, int count)
{
MaskLayerShape *masklay_shape;
/* the point has already been removed in this array so add one when comparing with the shapes */
int tot = BKE_mask_layer_shape_totvert(masklay);
for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
masklay_shape = masklay_shape->next)
{
LISTBASE_FOREACH (MaskLayerShape *, masklay_shape, &masklay->splines_shapes) {
if (tot == masklay_shape->tot_vert - count) {
float *data_resized;
masklay_shape->tot_vert -= count;
data_resized = MEM_mallocN(
masklay_shape->tot_vert * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE, __func__);
data_resized = MEM_cnew_array<float>(masklay_shape->tot_vert * MASK_OBJECT_SHAPE_ELEM_SIZE,
__func__);
if (index > 0) {
memcpy(data_resized,
masklay_shape->data,
@ -2057,10 +2005,10 @@ static void mask_clipboard_free_ex(bool final_free)
BLI_listbase_clear(&mask_clipboard.splines);
if (mask_clipboard.id_hash) {
if (final_free) {
BLI_ghash_free(mask_clipboard.id_hash, NULL, MEM_freeN);
BLI_ghash_free(mask_clipboard.id_hash, nullptr, MEM_freeN);
}
else {
BLI_ghash_clear(mask_clipboard.id_hash, NULL, MEM_freeN);
BLI_ghash_clear(mask_clipboard.id_hash, nullptr, MEM_freeN);
}
}
}
@ -2072,19 +2020,17 @@ void BKE_mask_clipboard_free(void)
void BKE_mask_clipboard_copy_from_layer(MaskLayer *mask_layer)
{
MaskSpline *spline;
/* Nothing to do if selection if disabled for the given layer. */
if (mask_layer->visibility_flag & MASK_HIDE_SELECT) {
return;
}
mask_clipboard_free_ex(false);
if (mask_clipboard.id_hash == NULL) {
if (mask_clipboard.id_hash == nullptr) {
mask_clipboard.id_hash = BLI_ghash_ptr_new("mask clipboard ID hash");
}
for (spline = mask_layer->splines.first; spline; spline = spline->next) {
LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
if (spline->flag & SELECT) {
MaskSpline *spline_new = BKE_mask_spline_copy(spline);
for (int i = 0; i < spline_new->tot_point; i++) {
@ -2092,7 +2038,7 @@ void BKE_mask_clipboard_copy_from_layer(MaskLayer *mask_layer)
if (point->parent.id) {
if (!BLI_ghash_lookup(mask_clipboard.id_hash, point->parent.id)) {
int len = strlen(point->parent.id->name);
char *name_copy = MEM_mallocN(len + 1, "mask clipboard ID name");
char *name_copy = static_cast<char *>(MEM_mallocN(len + 1, "mask clipboard ID name"));
strcpy(name_copy, point->parent.id->name);
BLI_ghash_insert(mask_clipboard.id_hash, point->parent.id, name_copy);
}
@ -2111,21 +2057,21 @@ bool BKE_mask_clipboard_is_empty(void)
void BKE_mask_clipboard_paste_to_layer(Main *bmain, MaskLayer *mask_layer)
{
MaskSpline *spline;
for (spline = mask_clipboard.splines.first; spline; spline = spline->next) {
LISTBASE_FOREACH (MaskSpline *, spline, &mask_clipboard.splines) {
MaskSpline *spline_new = BKE_mask_spline_copy(spline);
for (int i = 0; i < spline_new->tot_point; i++) {
MaskSplinePoint *point = &spline_new->points[i];
if (point->parent.id) {
const char *id_name = BLI_ghash_lookup(mask_clipboard.id_hash, point->parent.id);
const char *id_name = static_cast<const char *>(
BLI_ghash_lookup(mask_clipboard.id_hash, point->parent.id));
ListBase *listbase;
BLI_assert(id_name != NULL);
BLI_assert(id_name != nullptr);
listbase = which_libbase(bmain, GS(id_name));
point->parent.id = BLI_findstring(listbase, id_name + 2, offsetof(ID, name) + 2);
point->parent.id = static_cast<ID *>(
BLI_findstring(listbase, id_name + 2, offsetof(ID, name) + 2));
}
}

View File

@ -12,6 +12,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
@ -42,7 +43,7 @@ uint BKE_mask_spline_resolution(MaskSpline *spline, int width, int height)
bezt_curr = &point->bezt;
bezt_next = BKE_mask_spline_point_next_bezt(spline, spline->points, point);
if (bezt_next == NULL) {
if (bezt_next == nullptr) {
break;
}
@ -125,12 +126,12 @@ float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline,
if (spline->tot_point <= 1) {
/* nothing to differentiate */
*r_tot_diff_point = 0;
return NULL;
return nullptr;
}
/* len+1 because of 'forward_diff_bezier' function */
*r_tot_diff_point = tot;
diff_points = fp = MEM_mallocN((tot + 1) * sizeof(*diff_points), "mask spline vets");
diff_points = fp = MEM_cnew_array<float[2]>(tot + 1, "mask spline vets");
a = spline->tot_point - 1;
if (spline->flag & MASK_SPLINE_CYCLIC) {
@ -197,12 +198,11 @@ static void feather_bucket_add_edge(FeatherEdgesBucket *bucket, int start, int e
if (bucket->tot_segment >= bucket->alloc_segment) {
if (!bucket->segments) {
bucket->segments = MEM_callocN(alloc_delta * sizeof(*bucket->segments),
"feather bucket segments");
bucket->segments = MEM_cnew_array<int[2]>(alloc_delta, "feather bucket segments");
}
else {
bucket->segments = MEM_reallocN(
bucket->segments, (alloc_delta + bucket->tot_segment) * sizeof(*bucket->segments));
bucket->segments = static_cast<int(*)[2]>(MEM_reallocN(
bucket->segments, (alloc_delta + bucket->tot_segment) * sizeof(*bucket->segments)));
}
bucket->alloc_segment += alloc_delta;
@ -402,7 +402,7 @@ void BKE_mask_spline_feather_collapse_inner_loops(MaskSpline *spline,
bucket_scale[1] = 1.0f / ((max[1] - min[1]) * bucket_size);
/* fill in buckets' edges */
buckets = MEM_callocN(sizeof(FeatherEdgesBucket) * tot_bucket, "feather buckets");
buckets = MEM_cnew_array<FeatherEdgesBucket>(tot_bucket, "feather buckets");
for (int i = 0; i < tot_feather_point; i++) {
int start = i, end = i + 1;
@ -503,7 +503,7 @@ static float (
int a;
/* tot+1 because of 'forward_diff_bezier' function */
feather = fp = MEM_mallocN((tot + 1) * sizeof(*feather), "mask spline feather diff points");
feather = fp = MEM_cnew_array<float[2]>(tot + 1, "mask spline feather diff points");
a = spline->tot_point - 1;
if (spline->flag & MASK_SPLINE_CYCLIC) {
@ -579,12 +579,12 @@ static float (*mask_spline_feather_differentiated_points_with_resolution__double
if (spline->tot_point <= 1) {
/* nothing to differentiate */
*r_tot_feather_point = 0;
return NULL;
return nullptr;
}
/* len+1 because of 'forward_diff_bezier' function */
*r_tot_feather_point = tot;
feather = fp = MEM_mallocN((tot + 1) * sizeof(*feather), "mask spline vets");
feather = fp = MEM_cnew_array<float[2]>(tot + 1, "mask spline vets");
a = spline->tot_point - 1;
if (spline->flag & MASK_SPLINE_CYCLIC) {
@ -736,7 +736,7 @@ float (*BKE_mask_spline_feather_points(MaskSpline *spline, int *r_tot_feather_po
}
/* create data */
feather = fp = MEM_mallocN(tot * sizeof(*feather), "mask spline feather points");
feather = fp = MEM_cnew_array<float[2]>(tot, "mask spline feather points");
for (i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &points_array[i];
@ -774,7 +774,7 @@ float *BKE_mask_point_segment_feather_diff(
float *feather, *fp;
uint resol = BKE_mask_spline_feather_resolution(spline, width, height);
feather = fp = MEM_callocN(2 * resol * sizeof(float), "mask point spline feather diff points");
feather = fp = MEM_cnew_array<float>(2 * resol, "mask point spline feather diff points");
for (uint i = 0; i < resol; i++, fp += 2) {
float u = (float)(i % resol) / resol, weight;
@ -806,12 +806,12 @@ float *BKE_mask_point_segment_diff(
bezt_next = BKE_mask_spline_point_next_bezt(spline, points_array, point);
if (!bezt_next) {
return NULL;
return nullptr;
}
/* resol+1 because of 'forward_diff_bezier' function */
*r_tot_diff_point = resol + 1;
diff_points = fp = MEM_callocN(sizeof(float[2]) * (resol + 1), "mask segment vets");
diff_points = fp = MEM_cnew_array<float>(2 * (resol + 1), "mask segment vets");
for (j = 0; j < 2; j++) {
BKE_curve_forward_diff_bezier(bezt->vec[1][j],
@ -879,7 +879,7 @@ void BKE_mask_layer_evaluate_animation(MaskLayer *masklay, const float ctime)
void BKE_mask_layer_evaluate_deform(MaskLayer *masklay, const float ctime)
{
BKE_mask_layer_calc_handles(masklay);
for (MaskSpline *spline = masklay->splines.first; spline != NULL; spline = spline->next) {
LISTBASE_FOREACH (MaskSpline *, spline, &masklay->splines) {
bool need_handle_recalc = false;
BKE_mask_spline_ensure_deform(spline);
for (int i = 0; i < spline->tot_point; i++) {
@ -887,7 +887,8 @@ void BKE_mask_layer_evaluate_deform(MaskLayer *masklay, const float ctime)
MaskSplinePoint *point_deform = &spline->points_deform[i];
BKE_mask_point_free(point_deform);
*point_deform = *point;
point_deform->uw = point->uw ? MEM_dupallocN(point->uw) : NULL;
point_deform->uw = point->uw ? static_cast<MaskSplinePointUW *>(MEM_dupallocN(point->uw)) :
nullptr;
mask_evaluate_apply_point_parent(point_deform, ctime);
if (ELEM(point->bezt.h1, HD_AUTO, HD_VECT)) {
need_handle_recalc = true;
@ -912,9 +913,7 @@ void BKE_mask_eval_animation(struct Depsgraph *depsgraph, Mask *mask)
{
float ctime = DEG_get_ctime(depsgraph);
DEG_debug_print_eval(depsgraph, __func__, mask->id.name, mask);
for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer != NULL;
mask_layer = mask_layer->next)
{
LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
BKE_mask_layer_evaluate_animation(mask_layer, ctime);
}
}
@ -924,22 +923,20 @@ void BKE_mask_eval_update(struct Depsgraph *depsgraph, Mask *mask)
const bool is_depsgraph_active = DEG_is_active(depsgraph);
float ctime = DEG_get_ctime(depsgraph);
DEG_debug_print_eval(depsgraph, __func__, mask->id.name, mask);
for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer != NULL;
mask_layer = mask_layer->next)
{
LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
BKE_mask_layer_evaluate_deform(mask_layer, ctime);
}
if (is_depsgraph_active) {
Mask *mask_orig = (Mask *)DEG_get_original_id(&mask->id);
for (MaskLayer *masklay_orig = mask_orig->masklayers.first,
*masklay_eval = mask->masklayers.first;
masklay_orig != NULL;
for (MaskLayer *masklay_orig = static_cast<MaskLayer *>(mask_orig->masklayers.first),
*masklay_eval = static_cast<MaskLayer *>(mask->masklayers.first);
masklay_orig != nullptr;
masklay_orig = masklay_orig->next, masklay_eval = masklay_eval->next)
{
for (MaskSpline *spline_orig = masklay_orig->splines.first,
*spline_eval = masklay_eval->splines.first;
spline_orig != NULL;
for (MaskSpline *spline_orig = static_cast<MaskSpline *>(masklay_orig->splines.first),
*spline_eval = static_cast<MaskSpline *>(masklay_eval->splines.first);
spline_orig != nullptr;
spline_orig = spline_orig->next, spline_eval = spline_eval->next)
{
for (int i = 0; i < spline_eval->tot_point; i++) {

View File

@ -208,7 +208,7 @@ MaskRasterHandle *BKE_maskrasterize_handle_new(void)
{
MaskRasterHandle *mr_handle;
mr_handle = MEM_callocN(sizeof(MaskRasterHandle), "MaskRasterHandle");
mr_handle = MEM_cnew<MaskRasterHandle>("MaskRasterHandle");
return mr_handle;
}
@ -426,8 +426,8 @@ static void layer_bucket_init(MaskRasterLayer *layer, const float pixel_size)
float(*cos)[3] = layer->face_coords;
const uint bucket_tot = layer->buckets_x * layer->buckets_y;
LinkNode **bucketstore = MEM_callocN(bucket_tot * sizeof(LinkNode *), __func__);
uint *bucketstore_tot = MEM_callocN(bucket_tot * sizeof(uint), __func__);
LinkNode **bucketstore = MEM_cnew_array<LinkNode *>(bucket_tot, __func__);
uint *bucketstore_tot = MEM_cnew_array<uint>(bucket_tot, __func__);
uint face_index;
@ -525,12 +525,12 @@ static void layer_bucket_init(MaskRasterLayer *layer, const float pixel_size)
if (1) {
/* Now convert link-nodes into arrays for faster per pixel access. */
uint **buckets_face = MEM_mallocN(bucket_tot * sizeof(*buckets_face), __func__);
uint **buckets_face = MEM_cnew_array<uint *>(bucket_tot, __func__);
uint bucket_index;
for (bucket_index = 0; bucket_index < bucket_tot; bucket_index++) {
if (bucketstore_tot[bucket_index]) {
uint *bucket = MEM_mallocN((bucketstore_tot[bucket_index] + 1) * sizeof(uint), __func__);
uint *bucket = MEM_cnew_array<uint>((bucketstore_tot[bucket_index] + 1), __func__);
LinkNode *bucket_node;
buckets_face[bucket_index] = bucket;
@ -577,23 +577,19 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle,
MemArena *sf_arena;
mr_handle->layers_tot = (uint)BLI_listbase_count(&mask->masklayers);
mr_handle->layers = MEM_mallocN(sizeof(MaskRasterLayer) * mr_handle->layers_tot,
"MaskRasterLayer");
mr_handle->layers = MEM_cnew_array<MaskRasterLayer>(mr_handle->layers_tot, "MaskRasterLayer");
BLI_rctf_init_minmax(&mr_handle->bounds);
sf_arena = BLI_memarena_new(BLI_SCANFILL_ARENA_SIZE, __func__);
for (masklay = mask->masklayers.first, masklay_index = 0; masklay;
for (masklay = static_cast<MaskLayer *>(mask->masklayers.first), masklay_index = 0; masklay;
masklay = masklay->next, masklay_index++)
{
/* we need to store vertex ranges for open splines for filling */
uint tot_splines;
MaskRasterSplineInfo *open_spline_ranges;
uint open_spline_index = 0;
MaskSpline *spline;
/* scanfill */
ScanFillContext sf_ctx;
ScanFillVert *sf_vert = NULL;
@ -616,11 +612,11 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle,
}
tot_splines = (uint)BLI_listbase_count(&masklay->splines);
open_spline_ranges = MEM_callocN(sizeof(*open_spline_ranges) * tot_splines, __func__);
open_spline_ranges = MEM_cnew_array<MaskRasterSplineInfo>(tot_splines, __func__);
BLI_scanfill_begin_arena(&sf_ctx, sf_arena);
for (spline = masklay->splines.first; spline; spline = spline->next) {
LISTBASE_FOREACH (MaskSpline *, spline, &masklay->splines) {
const bool is_cyclic = (spline->flag & MASK_SPLINE_CYCLIC) != 0;
const bool is_fill = (spline->flag & MASK_SPLINE_NOFILL) == 0;
@ -686,8 +682,8 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle,
if (do_mask_aa == true) {
if (do_feather == false) {
tot_diff_feather_points = tot_diff_point;
diff_feather_points = MEM_mallocN(
sizeof(*diff_feather_points) * (size_t)tot_diff_feather_points, __func__);
diff_feather_points = MEM_cnew_array<float[2]>((size_t)tot_diff_feather_points,
__func__);
/* add single pixel feather */
maskrasterize_spline_differentiate_point_outset(
diff_feather_points, diff_points, tot_diff_point, pixel_size, false);
@ -722,7 +718,7 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle,
}
sf_vert = sf_vert_prev;
sf_vert_prev = sf_ctx.fillvertbase.last;
sf_vert_prev = static_cast<ScanFillVert *>(sf_ctx.fillvertbase.last);
for (j = 0; j < tot_diff_point; j++) {
ScanFillEdge *sf_edge = BLI_scanfill_edge_add(&sf_ctx, sf_vert_prev, sf_vert);
@ -758,8 +754,8 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle,
if (diff_feather_points) {
if (spline->flag & MASK_SPLINE_NOINTERSECT) {
diff_feather_points_flip = MEM_mallocN(sizeof(float[2]) * tot_diff_feather_points,
"diff_feather_points_flip");
diff_feather_points_flip = MEM_cnew_array<float[2]>(tot_diff_feather_points,
"diff_feather_points_flip");
float co_diff[2];
for (j = 0; j < tot_diff_point; j++) {
@ -913,14 +909,16 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle,
ListBase isect_remedgebase = {NULL, NULL};
/* now we have all the splines */
face_coords = MEM_mallocN(sizeof(float[3]) * sf_vert_tot, "maskrast_face_coords");
face_coords = MEM_cnew_array<float[3]>(sf_vert_tot, "maskrast_face_coords");
/* init bounds */
BLI_rctf_init_minmax(&bounds);
/* coords */
cos = (float *)face_coords;
for (sf_vert = sf_ctx.fillvertbase.first; sf_vert; sf_vert = sf_vert_next) {
for (sf_vert = static_cast<ScanFillVert *>(sf_ctx.fillvertbase.first); sf_vert;
sf_vert = sf_vert_next)
{
sf_vert_next = sf_vert->next;
copy_v3_v3(cos, sf_vert->co);
@ -946,12 +944,14 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle,
uint sf_vert_tot_isect = (uint)BLI_listbase_count(&sf_ctx.fillvertbase);
uint i = sf_vert_tot;
face_coords = MEM_reallocN(face_coords,
sizeof(float[3]) * (sf_vert_tot + sf_vert_tot_isect));
face_coords = static_cast<float(*)[3]>(
MEM_reallocN(face_coords, sizeof(float[3]) * (sf_vert_tot + sf_vert_tot_isect)));
cos = (float *)&face_coords[sf_vert_tot][0];
for (sf_vert = sf_ctx.fillvertbase.first; sf_vert; sf_vert = sf_vert->next) {
for (sf_vert = static_cast<ScanFillVert *>(sf_ctx.fillvertbase.first); sf_vert;
sf_vert = sf_vert->next)
{
copy_v3_v3(cos, sf_vert->co);
sf_vert->tmp.u = i++;
cos += 3;
@ -978,14 +978,16 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle,
BLI_movelisttolist(&sf_ctx.filledgebase, &isect_remedgebase);
}
face_array = MEM_mallocN(sizeof(*face_array) *
((size_t)sf_tri_tot + (size_t)tot_feather_quads),
"maskrast_face_index");
face_array = static_cast<uint(*)[4]>(
MEM_mallocN(sizeof(*face_array) * ((size_t)sf_tri_tot + (size_t)tot_feather_quads),
"maskrast_face_index"));
face_index = 0;
/* faces */
face = (uint *)face_array;
for (sf_tri = sf_ctx.fillfacebase.first; sf_tri; sf_tri = sf_tri->next) {
for (sf_tri = static_cast<ScanFillFace *>(sf_ctx.fillfacebase.first); sf_tri;
sf_tri = sf_tri->next)
{
*(face++) = sf_tri->v3->tmp.u;
*(face++) = sf_tri->v2->tmp.u;
*(face++) = sf_tri->v1->tmp.u;
@ -1003,7 +1005,9 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle,
if (tot_feather_quads) {
ScanFillEdge *sf_edge;
for (sf_edge = sf_ctx.filledgebase.first; sf_edge; sf_edge = sf_edge->next) {
for (sf_edge = static_cast<ScanFillEdge *>(sf_ctx.filledgebase.first); sf_edge;
sf_edge = sf_edge->next)
{
if (sf_edge->tmp.c == SF_EDGE_IS_BOUNDARY) {
*(face++) = sf_edge->v1->tmp.u;
*(face++) = sf_edge->v2->tmp.u;
@ -1430,9 +1434,9 @@ typedef struct MaskRasterizeBufferData {
static void maskrasterize_buffer_cb(void *__restrict userdata,
const int y,
const TaskParallelTLS *__restrict UNUSED(tls))
const TaskParallelTLS *__restrict /*tls*/)
{
MaskRasterizeBufferData *data = userdata;
MaskRasterizeBufferData *data = static_cast<MaskRasterizeBufferData *>(userdata);
MaskRasterHandle *mr_handle = data->mr_handle;
float *buffer = data->buffer;
@ -1461,15 +1465,14 @@ void BKE_maskrasterize_buffer(MaskRasterHandle *mr_handle,
const float x_inv = 1.0f / (float)width;
const float y_inv = 1.0f / (float)height;
MaskRasterizeBufferData data = {
.mr_handle = mr_handle,
.x_inv = x_inv,
.y_inv = y_inv,
.x_px_ofs = x_inv * 0.5f,
.y_px_ofs = y_inv * 0.5f,
.width = width,
.buffer = buffer,
};
MaskRasterizeBufferData data{};
data.mr_handle = mr_handle;
data.x_inv = x_inv;
data.y_inv = y_inv;
data.x_px_ofs = x_inv * 0.5f;
data.y_px_ofs = y_inv * 0.5f;
data.width = width;
data.buffer = buffer;
TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = ((size_t)height * width > 10000);

View File

@ -17,15 +17,15 @@ set(INC_SYS
)
set(SRC
mask_add.c
mask_draw.c
mask_edit.c
mask_editaction.c
mask_ops.c
mask_query.c
mask_relationships.c
mask_select.c
mask_shapekey.c
mask_add.cc
mask_draw.cc
mask_edit.cc
mask_editaction.cc
mask_ops.cc
mask_query.cc
mask_relationships.cc
mask_select.cc
mask_shapekey.cc
mask_intern.h
)

View File

@ -44,7 +44,7 @@ static void setup_vertex_point(Mask *mask,
const MaskSplinePoint *reference_point,
const bool reference_adjacent)
{
const MaskSplinePoint *reference_parent_point = NULL;
const MaskSplinePoint *reference_parent_point = nullptr;
BezTriple *bezt;
float co[3];
@ -104,8 +104,8 @@ static void setup_vertex_point(Mask *mask,
next_point = &spline->points[mod_i(index + 1, spline->tot_point)];
}
else {
prev_point = (index != 0) ? &spline->points[index - 1] : NULL;
next_point = (index != spline->tot_point - 1) ? &spline->points[index + 1] : NULL;
prev_point = (index != 0) ? &spline->points[index - 1] : nullptr;
next_point = (index != spline->tot_point - 1) ? &spline->points[index + 1] : nullptr;
}
if (prev_point && next_point) {
@ -173,10 +173,10 @@ static void finSelectedSplinePoint(MaskLayer *mask_layer,
MaskSplinePoint **point,
bool check_active)
{
MaskSpline *cur_spline = mask_layer->splines.first;
MaskSpline *cur_spline = static_cast<MaskSpline *>(mask_layer->splines.first);
*spline = NULL;
*point = NULL;
*spline = nullptr;
*point = nullptr;
if (check_active) {
/* TODO: having an active point but no active spline is possible, why? */
@ -193,13 +193,13 @@ static void finSelectedSplinePoint(MaskLayer *mask_layer,
MaskSplinePoint *cur_point = &cur_spline->points[i];
if (MASKPOINT_ISSEL_ANY(cur_point)) {
if (!ELEM(*spline, NULL, cur_spline)) {
*spline = NULL;
*point = NULL;
if (!ELEM(*spline, nullptr, cur_spline)) {
*spline = nullptr;
*point = nullptr;
return;
}
if (*point) {
*point = NULL;
*point = nullptr;
}
else {
*spline = cur_spline;
@ -222,8 +222,7 @@ static void mask_spline_add_point_at_index(MaskSpline *spline, int point_index)
{
MaskSplinePoint *new_point_array;
new_point_array = MEM_callocN(sizeof(MaskSplinePoint) * (spline->tot_point + 1),
"add mask vert points");
new_point_array = MEM_cnew_array<MaskSplinePoint>(spline->tot_point + 1, "add mask vert points");
memcpy(new_point_array, spline->points, sizeof(MaskSplinePoint) * (point_index + 1));
memcpy(new_point_array + point_index + 2,
@ -239,7 +238,7 @@ static bool add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2
{
MaskLayer *mask_layer;
MaskSpline *spline;
MaskSplinePoint *point = NULL;
MaskSplinePoint *point = nullptr;
const float threshold = 12;
float tangent[2];
float u;
@ -256,7 +255,7 @@ static bool add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2
&spline,
&point,
&u,
NULL))
nullptr))
{
Scene *scene = CTX_data_scene(C);
const float ctime = scene->r.cfra;
@ -270,7 +269,7 @@ static bool add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2
new_point = &spline->points[point_index + 1];
setup_vertex_point(mask, spline, new_point, co, u, ctime, NULL, true);
setup_vertex_point(mask, spline, new_point, co, u, ctime, nullptr, true);
/* TODO: we could pass the spline! */
BKE_mask_layer_shape_changed_add(mask_layer,
@ -300,7 +299,7 @@ static bool add_vertex_extrude(const bContext *C,
MaskSpline *spline;
MaskSplinePoint *point;
MaskSplinePoint *new_point = NULL, *ref_point = NULL;
MaskSplinePoint *new_point = nullptr, *ref_point = nullptr;
/* check on which side we want to add the point */
int point_index;
@ -399,7 +398,7 @@ static bool add_vertex_new(const bContext *C, Mask *mask, MaskLayer *mask_layer,
const float ctime = scene->r.cfra;
MaskSpline *spline;
MaskSplinePoint *new_point = NULL, *ref_point = NULL;
MaskSplinePoint *new_point = nullptr, *ref_point = nullptr;
if (!mask_layer) {
/* If there's no mask layer currently operating on, create new one. */
@ -516,15 +515,15 @@ static int add_vertex_exec(bContext *C, wmOperator *op)
ED_mask_view_lock_state_store(C, &lock_state);
Mask *mask = CTX_data_edit_mask(C);
if (mask == NULL) {
if (mask == nullptr) {
/* if there's no active mask, create one */
mask = ED_mask_new(C, NULL);
mask = ED_mask_new(C, nullptr);
}
MaskLayer *mask_layer = BKE_mask_layer_active(mask);
if (mask_layer && mask_layer->visibility_flag & (MASK_HIDE_VIEW | MASK_HIDE_SELECT)) {
mask_layer = NULL;
mask_layer = nullptr;
}
float co[2];
@ -595,7 +594,7 @@ void MASK_OT_add_vertex(wmOperatorType *ot)
RNA_def_float_vector(ot->srna,
"location",
2,
NULL,
nullptr,
-FLT_MAX,
FLT_MAX,
"Location",
@ -615,19 +614,30 @@ static int add_feather_vertex_exec(bContext *C, wmOperator *op)
Mask *mask = CTX_data_edit_mask(C);
MaskLayer *mask_layer;
MaskSpline *spline;
MaskSplinePoint *point = NULL;
MaskSplinePoint *point = nullptr;
const float threshold = 12;
float co[2], u;
RNA_float_get_array(op->ptr, "location", co);
point = ED_mask_point_find_nearest(C, mask, co, threshold, NULL, NULL, NULL, NULL);
point = ED_mask_point_find_nearest(C, mask, co, threshold, nullptr, nullptr, nullptr, nullptr);
if (point) {
return OPERATOR_FINISHED;
}
if (ED_mask_find_nearest_diff_point(
C, mask, co, threshold, true, NULL, true, true, &mask_layer, &spline, &point, &u, NULL))
if (ED_mask_find_nearest_diff_point(C,
mask,
co,
threshold,
true,
nullptr,
true,
true,
&mask_layer,
&spline,
&point,
&u,
nullptr))
{
float w = BKE_mask_point_weight(spline, point, u);
float weight_scalar = BKE_mask_point_weight_scalar(spline, point, u);
@ -681,7 +691,7 @@ void MASK_OT_add_feather_vertex(wmOperatorType *ot)
RNA_def_float_vector(ot->srna,
"location",
2,
NULL,
nullptr,
-FLT_MAX,
FLT_MAX,
"Location",
@ -702,7 +712,7 @@ static BezTriple *points_to_bezier(const float (*points)[2],
const float scale,
const float location[2])
{
BezTriple *bezier_points = MEM_calloc_arrayN(num_points, sizeof(BezTriple), __func__);
BezTriple *bezier_points = MEM_cnew_array<BezTriple>(num_points, __func__);
for (int i = 0; i < num_points; i++) {
copy_v2_v2(bezier_points[i].vec[1], points[i]);
mul_v2_fl(bezier_points[i].vec[1], scale);
@ -758,10 +768,11 @@ static int create_primitive_from_points(
MaskSpline *new_spline = BKE_mask_spline_add(mask_layer);
new_spline->flag = MASK_SPLINE_CYCLIC | SELECT;
new_spline->points = MEM_recallocN(new_spline->points, sizeof(MaskSplinePoint) * num_points);
new_spline->points = static_cast<MaskSplinePoint *>(
MEM_recallocN(new_spline->points, sizeof(MaskSplinePoint) * num_points));
mask_layer->act_spline = new_spline;
mask_layer->act_point = NULL;
mask_layer->act_point = nullptr;
const int spline_index = BKE_mask_layer_shape_spline_to_index(mask_layer, new_spline);
@ -785,7 +796,7 @@ static int create_primitive_from_points(
MEM_freeN(bezier_points);
if (added_mask) {
WM_event_add_notifier(C, NC_MASK | NA_ADDED, NULL);
WM_event_add_notifier(C, NC_MASK | NA_ADDED, nullptr);
}
WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
@ -796,7 +807,7 @@ static int create_primitive_from_points(
return OPERATOR_FINISHED;
}
static int primitive_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int primitive_add_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
ScrArea *area = CTX_wm_area(C);
float cursor[2];
@ -820,7 +831,7 @@ static void define_primitive_add_properties(wmOperatorType *ot)
RNA_def_float_vector(ot->srna,
"location",
2,
NULL,
nullptr,
-FLT_MAX,
FLT_MAX,
"Location",

View File

@ -60,8 +60,8 @@ static void mask_spline_color_get(MaskLayer *mask_layer,
r_rgb[3] = 255;
}
static void mask_spline_feather_color_get(MaskLayer *UNUSED(mask_layer),
MaskSpline *UNUSED(spline),
static void mask_spline_feather_color_get(MaskLayer * /*mask_layer*/,
MaskSpline * /*spline*/,
const bool is_sel,
uchar r_rgb[4])
{
@ -391,7 +391,7 @@ static void mask_draw_curve_type(const bContext *C,
const bool undistort = sc->clip && (sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT);
if (undistort) {
points = MEM_callocN(2 * tot_point * sizeof(float), "undistorthed mask curve");
points = MEM_cnew_array<float[2]>(tot_point, "undistorthed mask curve");
for (int i = 0; i < tot_point; i++) {
mask_point_undistort_pos(sc, points[i], orig_points[i]);
@ -579,9 +579,9 @@ static void draw_layer_splines(const bContext *C,
/* show undeform for testing */
if (0) {
void *back = spline->points_deform;
MaskSplinePoint *back = spline->points_deform;
spline->points_deform = NULL;
spline->points_deform = nullptr;
draw_spline_curve(C, layer, spline, draw_type, is_active, width, height);
draw_spline_points(C, layer, spline, draw_type);
spline->points_deform = back;
@ -595,13 +595,9 @@ static void draw_mask_layers(
GPU_blend(GPU_BLEND_ALPHA);
GPU_program_point_size(true);
MaskLayer *mask_layer;
MaskLayer *active = nullptr;
int i;
MaskLayer *active = NULL;
for (mask_layer = mask->masklayers.first, i = 0; mask_layer != NULL;
mask_layer = mask_layer->next, i++)
{
LISTBASE_FOREACH_INDEX (MaskLayer *, mask_layer, &mask->masklayers, i) {
const bool is_active = (i == mask->masklay_act);
if (mask_layer->visibility_flag & MASK_HIDE_VIEW) {
@ -616,7 +612,7 @@ static void draw_mask_layers(
draw_layer_splines(C, mask_layer, draw_type, width, height, is_active);
}
if (active != NULL) {
if (active != nullptr) {
draw_layer_splines(C, active, draw_type, width, height, true);
}
@ -627,7 +623,7 @@ static void draw_mask_layers(
static float *mask_rasterize(Mask *mask, const int width, const int height)
{
MaskRasterHandle *handle;
float *buffer = MEM_mallocN(sizeof(float) * height * width, "rasterized mask buffer");
float *buffer = MEM_cnew_array<float>(height * width, "rasterized mask buffer");
/* Initialize rasterization handle. */
handle = BKE_maskrasterize_handle_new();
@ -735,7 +731,7 @@ void ED_mask_draw_region(
}
else {
immDrawPixelsTexTiled(
&state, 0.0f, 0.0f, width, height, GPU_R16F, false, buffer, 1.0f, 1.0f, NULL);
&state, 0.0f, 0.0f, width, height, GPU_R16F, false, buffer, 1.0f, 1.0f, nullptr);
}
GPU_matrix_pop();
@ -778,7 +774,7 @@ void ED_mask_draw_frames(
const float framelen = region->winx / (float)(efra - sfra + 1);
MaskLayer *mask_layer = BKE_mask_layer_active(mask);
if (mask_layer == NULL) {
if (mask_layer == nullptr) {
return;
}
@ -799,10 +795,7 @@ void ED_mask_draw_frames(
immBegin(GPU_PRIM_LINES, 2 * num_lines);
for (MaskLayerShape *mask_layer_shape = mask_layer->splines_shapes.first;
mask_layer_shape != NULL;
mask_layer_shape = mask_layer_shape->next)
{
LISTBASE_FOREACH (MaskLayerShape *, mask_layer_shape, &mask_layer->splines_shapes) {
int frame = mask_layer_shape->frame;
// draw_keyframe(i, scene->r.cfra, sfra, framelen, 1);

View File

@ -40,17 +40,13 @@ bool ED_masklayer_frames_looper(MaskLayer *mask_layer,
Scene *scene,
bool (*mask_layer_shape_cb)(MaskLayerShape *, Scene *))
{
MaskLayerShape *mask_layer_shape;
/* error checker */
if (mask_layer == NULL) {
if (mask_layer == nullptr) {
return false;
}
/* do loop */
for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape;
mask_layer_shape = mask_layer_shape->next)
{
LISTBASE_FOREACH (MaskLayerShape *, mask_layer_shape, &mask_layer->splines_shapes) {
/* execute callback */
if (mask_layer_shape_cb(mask_layer_shape, scene)) {
return true;
@ -66,20 +62,16 @@ bool ED_masklayer_frames_looper(MaskLayer *mask_layer,
void ED_masklayer_make_cfra_list(MaskLayer *mask_layer, ListBase *elems, bool onlysel)
{
MaskLayerShape *mask_layer_shape;
CfraElem *ce;
/* error checking */
if (ELEM(NULL, mask_layer, elems)) {
if (ELEM(nullptr, mask_layer, elems)) {
return;
}
/* loop through mask-frames, adding */
for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape;
mask_layer_shape = mask_layer_shape->next)
{
LISTBASE_FOREACH (MaskLayerShape *, mask_layer_shape, &mask_layer->splines_shapes) {
if ((onlysel == false) || (mask_layer_shape->flag & MASK_SHAPE_SELECT)) {
ce = MEM_callocN(sizeof(CfraElem), "CfraElem");
CfraElem *ce = MEM_cnew<CfraElem>("CfraElem");
ce->cfra = (float)mask_layer_shape->frame;
ce->sel = (mask_layer_shape->flag & MASK_SHAPE_SELECT) ? 1 : 0;
@ -94,17 +86,13 @@ void ED_masklayer_make_cfra_list(MaskLayer *mask_layer, ListBase *elems, bool on
bool ED_masklayer_frame_select_check(const MaskLayer *mask_layer)
{
MaskLayerShape *mask_layer_shape;
/* error checking */
if (mask_layer == NULL) {
if (mask_layer == nullptr) {
return 0;
}
/* stop at the first one found */
for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape;
mask_layer_shape = mask_layer_shape->next)
{
LISTBASE_FOREACH (MaskLayerShape *, mask_layer_shape, &mask_layer->splines_shapes) {
if (mask_layer_shape->flag & MASK_SHAPE_SELECT) {
return true;
}
@ -117,7 +105,7 @@ bool ED_masklayer_frame_select_check(const MaskLayer *mask_layer)
/* helper function - select mask-frame based on SELECT_* mode */
static void mask_layer_shape_select(MaskLayerShape *mask_layer_shape, short select_mode)
{
if (mask_layer_shape == NULL) {
if (mask_layer_shape == nullptr) {
return;
}
@ -136,17 +124,13 @@ static void mask_layer_shape_select(MaskLayerShape *mask_layer_shape, short sele
void ED_mask_select_frames(MaskLayer *mask_layer, short select_mode)
{
MaskLayerShape *mask_layer_shape;
/* error checking */
if (mask_layer == NULL) {
if (mask_layer == nullptr) {
return;
}
/* handle according to mode */
for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape;
mask_layer_shape = mask_layer_shape->next)
{
LISTBASE_FOREACH (MaskLayerShape *, mask_layer_shape, &mask_layer->splines_shapes) {
mask_layer_shape_select(mask_layer_shape, select_mode);
}
}
@ -154,7 +138,7 @@ void ED_mask_select_frames(MaskLayer *mask_layer, short select_mode)
void ED_masklayer_frame_select_set(MaskLayer *mask_layer, short mode)
{
/* error checking */
if (mask_layer == NULL) {
if (mask_layer == nullptr) {
return;
}
@ -166,7 +150,7 @@ void ED_mask_select_frame(MaskLayer *mask_layer, int selx, short select_mode)
{
MaskLayerShape *mask_layer_shape;
if (mask_layer == NULL) {
if (mask_layer == nullptr) {
return;
}
@ -179,16 +163,12 @@ void ED_mask_select_frame(MaskLayer *mask_layer, int selx, short select_mode)
void ED_masklayer_frames_select_box(MaskLayer *mask_layer, float min, float max, short select_mode)
{
MaskLayerShape *mask_layer_shape;
if (mask_layer == NULL) {
if (mask_layer == nullptr) {
return;
}
/* only select those frames which are in bounds */
for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape;
mask_layer_shape = mask_layer_shape->next)
{
LISTBASE_FOREACH (MaskLayerShape *, mask_layer_shape, &mask_layer->splines_shapes) {
if (IN_RANGE(mask_layer_shape->frame, min, max)) {
mask_layer_shape_select(mask_layer_shape, select_mode);
}
@ -200,16 +180,12 @@ void ED_masklayer_frames_select_region(KeyframeEditData *ked,
short tool,
short select_mode)
{
MaskLayerShape *mask_layer_shape;
if (mask_layer == NULL) {
if (mask_layer == nullptr) {
return;
}
/* only select frames which are within the region */
for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape;
mask_layer_shape = mask_layer_shape->next)
{
LISTBASE_FOREACH (MaskLayerShape *, mask_layer_shape, &mask_layer->splines_shapes) {
/* construct a dummy point coordinate to do this testing with */
float pt[2] = {0};
@ -219,13 +195,13 @@ void ED_masklayer_frames_select_region(KeyframeEditData *ked,
/* check the necessary regions */
if (tool == BEZT_OK_CHANNEL_LASSO) {
/* Lasso */
if (keyframe_region_lasso_test(ked->data, pt)) {
if (keyframe_region_lasso_test(static_cast<KeyframeEdit_LassoData *>(ked->data), pt)) {
mask_layer_shape_select(mask_layer_shape, select_mode);
}
}
else if (tool == BEZT_OK_CHANNEL_CIRCLE) {
/* Circle */
if (keyframe_region_circle_test(ked->data, pt)) {
if (keyframe_region_circle_test(static_cast<KeyframeEdit_CircleData *>(ked->data), pt)) {
mask_layer_shape_select(mask_layer_shape, select_mode);
}
}
@ -237,20 +213,15 @@ void ED_masklayer_frames_select_region(KeyframeEditData *ked,
bool ED_masklayer_frames_delete(MaskLayer *mask_layer)
{
MaskLayerShape *mask_layer_shape, *mask_layer_shape_next;
bool changed = false;
/* error checking */
if (mask_layer == NULL) {
if (mask_layer == nullptr) {
return false;
}
/* check for frames to delete */
for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape;
mask_layer_shape = mask_layer_shape_next)
{
mask_layer_shape_next = mask_layer_shape->next;
LISTBASE_FOREACH_MUTABLE (MaskLayerShape *, mask_layer_shape, &mask_layer->splines_shapes) {
if (mask_layer_shape->flag & MASK_SHAPE_SELECT) {
BKE_mask_layer_shape_unlink(mask_layer, mask_layer_shape);
changed = true;
@ -262,18 +233,13 @@ bool ED_masklayer_frames_delete(MaskLayer *mask_layer)
void ED_masklayer_frames_duplicate(MaskLayer *mask_layer)
{
MaskLayerShape *mask_layer_shape, *gpfn;
/* Error checking. */
if (mask_layer == NULL) {
if (mask_layer == nullptr) {
return;
}
/* Duplicate selected frames. */
for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape;
mask_layer_shape = gpfn)
{
gpfn = mask_layer_shape->next;
LISTBASE_FOREACH_MUTABLE (MaskLayerShape *, mask_layer_shape, &mask_layer->splines_shapes) {
/* Duplicate this frame. */
if (mask_layer_shape->flag & MASK_SHAPE_SELECT) {
@ -292,7 +258,7 @@ void ED_masklayer_frames_duplicate(MaskLayer *mask_layer)
/* -------------------------------------- */
/* Snap Tools */
static bool snap_mask_layer_nearest(MaskLayerShape *mask_layer_shape, Scene *UNUSED(scene))
static bool snap_mask_layer_nearest(MaskLayerShape *mask_layer_shape, Scene * /*scene*/)
{
if (mask_layer_shape->flag & MASK_SHAPE_SELECT) {
mask_layer_shape->frame = (int)floor(mask_layer_shape->frame + 0.5);

View File

@ -49,7 +49,7 @@ Mask *ED_mask_new(bContext *C, const char *name)
if (area && area->spacedata.first) {
switch (area->spacetype) {
case SPACE_CLIP: {
SpaceClip *sc = area->spacedata.first;
SpaceClip *sc = static_cast<SpaceClip *>(area->spacedata.first);
ED_space_clip_set_mask(C, sc, mask);
break;
}
@ -58,7 +58,7 @@ Mask *ED_mask_new(bContext *C, const char *name)
break;
}
case SPACE_IMAGE: {
SpaceImage *sima = area->spacedata.first;
SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
ED_space_image_set_mask(C, sima, mask);
break;
}
@ -73,14 +73,14 @@ MaskLayer *ED_mask_layer_ensure(bContext *C, bool *r_added_mask)
Mask *mask = CTX_data_edit_mask(C);
MaskLayer *mask_layer;
if (mask == NULL) {
if (mask == nullptr) {
/* If there's no active mask, create one. */
mask = ED_mask_new(C, NULL);
mask = ED_mask_new(C, nullptr);
*r_added_mask = true;
}
mask_layer = BKE_mask_layer_active(mask);
if (mask_layer == NULL) {
if (mask_layer == nullptr) {
/* If there's no active mask layer, create one. */
mask_layer = BKE_mask_layer_new(mask, "");
}
@ -96,7 +96,7 @@ static int mask_new_exec(bContext *C, wmOperator *op)
ED_mask_new(C, name);
WM_event_add_notifier(C, NC_MASK | NA_ADDED, NULL);
WM_event_add_notifier(C, NC_MASK | NA_ADDED, nullptr);
return OPERATOR_FINISHED;
}
@ -116,7 +116,7 @@ void MASK_OT_new(wmOperatorType *ot)
ot->poll = ED_maskedit_poll;
/* properties */
RNA_def_string(ot->srna, "name", NULL, MAX_ID_NAME - 2, "Name", "Name of new mask");
RNA_def_string(ot->srna, "name", nullptr, MAX_ID_NAME - 2, "Name", "Name of new mask");
}
/******************** create new mask layer *********************/
@ -152,12 +152,12 @@ void MASK_OT_layer_new(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
RNA_def_string(ot->srna, "name", NULL, MAX_ID_NAME - 2, "Name", "Name of new mask layer");
RNA_def_string(ot->srna, "name", nullptr, MAX_ID_NAME - 2, "Name", "Name of new mask layer");
}
/******************** remove mask layer *********************/
static int mask_layer_remove_exec(bContext *C, wmOperator *UNUSED(op))
static int mask_layer_remove_exec(bContext *C, wmOperator * /*op*/)
{
Mask *mask = CTX_data_edit_mask(C);
MaskLayer *mask_layer = BKE_mask_layer_active(mask);
@ -253,11 +253,11 @@ static bool spline_under_mouse_get(const bContext *C,
ScrArea *area = CTX_wm_area(C);
SpaceClip *sc = CTX_wm_space_clip(C);
float closest_dist_squared = 0.0f;
MaskLayer *closest_layer = NULL;
MaskSpline *closest_spline = NULL;
MaskLayer *closest_layer = nullptr;
MaskSpline *closest_spline = nullptr;
bool undistort = false;
*r_mask_layer = NULL;
*r_mask_spline = NULL;
*r_mask_layer = nullptr;
*r_mask_spline = nullptr;
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Mask *mask_eval = (Mask *)DEG_get_evaluated_id(depsgraph, &mask_orig->id);
@ -267,21 +267,22 @@ static bool spline_under_mouse_get(const bContext *C,
float pixel_co[2];
pixel_co[0] = co[0] * width;
pixel_co[1] = co[1] * height;
if (sc != NULL) {
undistort = (sc->clip != NULL) && (sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT) != 0;
if (sc != nullptr) {
undistort = (sc->clip != nullptr) &&
(sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT) != 0;
}
for (MaskLayer *mask_layer_orig = mask_orig->masklayers.first,
*mask_layer_eval = mask_eval->masklayers.first;
mask_layer_orig != NULL;
for (MaskLayer *mask_layer_orig = static_cast<MaskLayer *>(mask_orig->masklayers.first),
*mask_layer_eval = static_cast<MaskLayer *>(mask_eval->masklayers.first);
mask_layer_orig != nullptr;
mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next)
{
if (mask_layer_orig->visibility_flag & (MASK_HIDE_VIEW | MASK_HIDE_SELECT)) {
continue;
}
for (MaskSpline *spline_orig = mask_layer_orig->splines.first,
*spline_eval = mask_layer_eval->splines.first;
spline_orig != NULL;
for (MaskSpline *spline_orig = static_cast<MaskSpline *>(mask_layer_orig->splines.first),
*spline_eval = static_cast<MaskSpline *>(mask_layer_eval->splines.first);
spline_orig != nullptr;
spline_orig = spline_orig->next, spline_eval = spline_eval->next)
{
if ((spline_orig->flag & SELECT) == 0) {
@ -310,7 +311,7 @@ static bool spline_under_mouse_get(const bContext *C,
float dist_squared = len_squared_v2v2(pixel_co, center);
float max_bb_side = min_ff((max[0] - min[0]) * width, (max[1] - min[1]) * height);
if (dist_squared <= max_bb_side * max_bb_side * 0.5f &&
(closest_spline == NULL || dist_squared < closest_dist_squared))
(closest_spline == nullptr || dist_squared < closest_dist_squared))
{
closest_layer = mask_layer_orig;
closest_spline = spline_orig;
@ -318,20 +319,20 @@ static bool spline_under_mouse_get(const bContext *C,
}
}
}
if (closest_dist_squared < square_f(threshold) && closest_spline != NULL) {
if (closest_dist_squared < square_f(threshold) && closest_spline != nullptr) {
float diff_score;
if (ED_mask_find_nearest_diff_point(C,
mask_orig,
co,
threshold,
false,
NULL,
nullptr,
true,
false,
NULL,
NULL,
NULL,
NULL,
nullptr,
nullptr,
nullptr,
nullptr,
&diff_score))
{
if (square_f(diff_score) < closest_dist_squared) {
@ -414,17 +415,17 @@ static void check_sliding_handle_type(MaskSplinePoint *point, eMaskWhichHandle w
}
}
static void *slide_point_customdata(bContext *C, wmOperator *op, const wmEvent *event)
static SlidePointData *slide_point_customdata(bContext *C, wmOperator *op, const wmEvent *event)
{
ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
Mask *mask = CTX_data_edit_mask(C);
SlidePointData *customdata = NULL;
SlidePointData *customdata = nullptr;
MaskLayer *mask_layer, *cv_mask_layer, *feather_mask_layer;
MaskSpline *spline, *cv_spline, *feather_spline;
MaskSplinePoint *point, *cv_point, *feather_point;
MaskSplinePointUW *uw = NULL;
MaskSplinePointUW *uw = nullptr;
int width, height, action = SLIDE_ACTION_NONE;
const bool slide_feather = RNA_boolean_get(op->ptr, "slide_feather");
float co[2], cv_score, feather_score;
@ -475,12 +476,12 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, const wmEvent *
if (action == SLIDE_ACTION_NONE) {
if (spline_under_mouse_get(C, mask, co, &mask_layer, &spline)) {
action = SLIDE_ACTION_SPLINE;
point = NULL;
point = nullptr;
}
}
if (action != SLIDE_ACTION_NONE) {
customdata = MEM_callocN(sizeof(SlidePointData), "mask slide point data");
customdata = MEM_cnew<SlidePointData>("mask slide point data");
customdata->event_invoke_type = event->type;
customdata->mask = mask;
customdata->mask_layer = mask_layer;
@ -542,7 +543,9 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, const wmEvent *
}
ED_mask_mouse_pos(area, region, event->mval, customdata->prev_mouse_coord);
ED_mask_mouse_pos(area, region, (int[2]){0, 0}, customdata->prev_zero_coord);
const int zero_mouse[2] = {0, 0};
ED_mask_mouse_pos(area, region, zero_mouse, customdata->prev_zero_coord);
}
return customdata;
@ -553,7 +556,7 @@ static int slide_point_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Mask *mask = CTX_data_edit_mask(C);
SlidePointData *slidedata;
if (mask == NULL) {
if (mask == nullptr) {
return OPERATOR_PASS_THROUGH;
}
@ -672,8 +675,9 @@ static int slide_point_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* Compensate for possibly moved view offset since the last event.
* The idea is to see how mapping of a fixed and known position did change. */
{
const int zero_mouse[2] = {0, 0};
float zero_coord[2];
ED_mask_mouse_pos(area, region, (int[2]){0, 0}, zero_coord);
ED_mask_mouse_pos(area, region, zero_mouse, zero_coord);
float zero_delta[2];
sub_v2_v2v2(zero_delta, zero_coord, data->prev_zero_coord);
@ -732,7 +736,7 @@ static int slide_point_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
else if (data->action == SLIDE_ACTION_FEATHER) {
float vec[2], no[2], p[2], c[2], w, offco[2];
float *weight = NULL;
float *weight = nullptr;
float weight_scalar = 1.0f;
bool is_overall_feather = data->is_overall_feather || data->is_initial_feather;
@ -799,7 +803,7 @@ static int slide_point_modal(bContext *C, wmOperator *op, const wmEvent *event)
w_delta = w - data->weight * data->weight_scalar;
if (data->orig_spline == NULL) {
if (data->orig_spline == nullptr) {
/* restore weight for currently sliding point, so orig_spline would be created
* with original weights used
*/
@ -824,7 +828,7 @@ static int slide_point_modal(bContext *C, wmOperator *op, const wmEvent *event)
slide_point_restore_spline(data);
BKE_mask_spline_free(data->orig_spline);
data->orig_spline = NULL;
data->orig_spline = nullptr;
}
if (weight_scalar != 0.0f) {
@ -836,7 +840,7 @@ static int slide_point_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
else if (data->action == SLIDE_ACTION_SPLINE) {
if (data->orig_spline == NULL) {
if (data->orig_spline == nullptr) {
data->orig_spline = BKE_mask_spline_copy(data->spline);
}
@ -878,23 +882,24 @@ static int slide_point_modal(bContext *C, wmOperator *op, const wmEvent *event)
WM_event_add_notifier(C, NC_MASK | NA_EDITED, data->mask);
DEG_id_tag_update(&data->mask->id, 0);
free_slide_point_data(op->customdata); /* keep this last! */
free_slide_point_data(data); /* keep this last! */
return OPERATOR_FINISHED;
}
else if (event->type != data->event_invoke_type && event->val == KM_PRESS) {
/* pass to ESCKEY */
ATTR_FALLTHROUGH;
}
else {
break;
}
case EVT_ESCKEY:
cancel_slide_point(op->customdata);
cancel_slide_point(data);
WM_event_add_notifier(C, NC_MASK | NA_EDITED, data->mask);
DEG_id_tag_update(&data->mask->id, 0);
free_slide_point_data(op->customdata); /* keep this last! */
free_slide_point_data(data); /* keep this last! */
return OPERATOR_CANCELLED;
}
@ -969,11 +974,13 @@ static bool slide_spline_curvature_check(bContext *C, const wmEvent *event)
ED_mask_mouse_pos(CTX_wm_area(C), CTX_wm_region(C), event->mval, co);
if (ED_mask_point_find_nearest(C, mask, co, threshold, NULL, NULL, NULL, NULL)) {
if (ED_mask_point_find_nearest(C, mask, co, threshold, nullptr, nullptr, nullptr, nullptr)) {
return false;
}
if (ED_mask_feather_find_nearest(C, mask, co, threshold, NULL, NULL, NULL, NULL, NULL)) {
if (ED_mask_feather_find_nearest(
C, mask, co, threshold, nullptr, nullptr, nullptr, nullptr, nullptr))
{
return false;
}
@ -1003,24 +1010,24 @@ static SlideSplineCurvatureData *slide_spline_curvature_customdata(bContext *C,
co,
threshold,
false,
NULL,
nullptr,
true,
false,
&mask_layer,
&spline,
&point,
&u,
NULL))
nullptr))
{
return NULL;
return nullptr;
}
next_bezt = BKE_mask_spline_point_next_bezt(spline, spline->points, point);
if (next_bezt == NULL) {
return NULL;
if (next_bezt == nullptr) {
return nullptr;
}
slide_data = MEM_callocN(sizeof(SlideSplineCurvatureData), "slide curvature slide");
slide_data = MEM_cnew<SlideSplineCurvatureData>("slide curvature slide");
slide_data->event_invoke_type = event->type;
slide_data->mask = mask;
slide_data->mask_layer = mask_layer;
@ -1089,7 +1096,7 @@ static int slide_spline_curvature_invoke(bContext *C, wmOperator *op, const wmEv
Mask *mask = CTX_data_edit_mask(C);
SlideSplineCurvatureData *slide_data;
if (mask == NULL) {
if (mask == nullptr) {
return OPERATOR_PASS_THROUGH;
}
@ -1099,7 +1106,7 @@ static int slide_spline_curvature_invoke(bContext *C, wmOperator *op, const wmEv
}
slide_data = slide_spline_curvature_customdata(C, event);
if (slide_data != NULL) {
if (slide_data != nullptr) {
op->customdata = slide_data;
WM_event_add_modal_handler(C, op);
WM_event_add_notifier(C, NC_MASK | ND_SELECT, mask);
@ -1287,7 +1294,7 @@ static int slide_spline_curvature_modal(bContext *C, wmOperator *op, const wmEve
WM_event_add_notifier(C, NC_MASK | NA_EDITED, slide_data->mask);
DEG_id_tag_update(&slide_data->mask->id, 0);
free_slide_spline_curvature_data(op->customdata); /* keep this last! */
free_slide_spline_curvature_data(slide_data); /* keep this last! */
return OPERATOR_CANCELLED;
}
@ -1312,7 +1319,7 @@ void MASK_OT_slide_spline_curvature(wmOperatorType *ot)
/******************** toggle cyclic *********************/
static int cyclic_toggle_exec(bContext *C, wmOperator *UNUSED(op))
static int cyclic_toggle_exec(bContext *C, wmOperator * /*op*/)
{
Mask *mask = CTX_data_edit_mask(C);
@ -1367,14 +1374,14 @@ static void delete_feather_points(MaskSplinePoint *point)
if (count == 0) {
MEM_freeN(point->uw);
point->uw = NULL;
point->uw = nullptr;
point->tot_uw = 0;
}
else {
MaskSplinePointUW *new_uw;
int j = 0;
new_uw = MEM_callocN(count * sizeof(MaskSplinePointUW), "new mask uw points");
new_uw = MEM_cnew_array<MaskSplinePointUW>(count, "new mask uw points");
for (int i = 0; i < point->tot_uw; i++) {
if ((point->uw[i].flag & SELECT) == 0) {
@ -1389,7 +1396,7 @@ static void delete_feather_points(MaskSplinePoint *point)
}
}
static int delete_exec(bContext *C, wmOperator *UNUSED(op))
static int delete_exec(bContext *C, wmOperator * /*op*/)
{
Mask *mask = CTX_data_edit_mask(C);
bool changed = false;
@ -1402,7 +1409,7 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op))
continue;
}
spline = mask_layer->splines.first;
spline = static_cast<MaskSpline *>(mask_layer->splines.first);
while (spline) {
const int tot_point_orig = spline->tot_point;
@ -1424,8 +1431,8 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op))
BKE_mask_spline_free(spline);
if (spline == mask_layer->act_spline) {
mask_layer->act_spline = NULL;
mask_layer->act_point = NULL;
mask_layer->act_spline = nullptr;
mask_layer->act_point = nullptr;
}
BKE_mask_layer_shape_changed_remove(mask_layer, mask_layer_shape_ofs, tot_point_orig);
@ -1433,7 +1440,7 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op))
else {
MaskSplinePoint *new_points;
new_points = MEM_callocN(count * sizeof(MaskSplinePoint), "deleteMaskPoints");
new_points = MEM_cnew_array<MaskSplinePoint>(count, "deleteMaskPoints");
for (int i = 0, j = 0; i < tot_point_orig; i++) {
MaskSplinePoint *point = &spline->points[i];
@ -1450,7 +1457,7 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op))
}
else {
if (point == mask_layer->act_point) {
mask_layer->act_point = NULL;
mask_layer->act_point = nullptr;
}
BKE_mask_point_free(point);
@ -1507,7 +1514,7 @@ void MASK_OT_delete(wmOperatorType *ot)
}
/* *** switch direction *** */
static int mask_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
static int mask_switch_direction_exec(bContext *C, wmOperator * /*op*/)
{
Scene *scene = CTX_data_scene(C);
Mask *mask = CTX_data_edit_mask(C);
@ -1565,7 +1572,7 @@ void MASK_OT_switch_direction(wmOperatorType *ot)
}
/* *** recalc normals *** */
static int mask_normals_make_consistent_exec(bContext *C, wmOperator *UNUSED(op))
static int mask_normals_make_consistent_exec(bContext *C, wmOperator * /*op*/)
{
Scene *scene = CTX_data_scene(C);
Mask *mask = CTX_data_edit_mask(C);
@ -1689,7 +1696,7 @@ void MASK_OT_handle_type_set(wmOperatorType *ot)
{HD_ALIGN, "ALIGNED", 0, "Aligned Single", ""},
{HD_ALIGN_DOUBLESIDE, "ALIGNED_DOUBLESIDE", 0, "Aligned", ""},
{HD_FREE, "FREE", 0, "Free", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* identifiers */
@ -1771,7 +1778,7 @@ static int mask_hide_view_set_exec(bContext *C, wmOperator *op)
mask_layer->visibility_flag |= OB_HIDE_VIEWPORT;
changed = true;
if (mask_layer == BKE_mask_layer_active(mask)) {
BKE_mask_layer_active_set(mask, NULL);
BKE_mask_layer_active_set(mask, nullptr);
}
}
}
@ -1780,7 +1787,7 @@ static int mask_hide_view_set_exec(bContext *C, wmOperator *op)
mask_layer->visibility_flag |= OB_HIDE_VIEWPORT;
changed = true;
if (mask_layer == BKE_mask_layer_active(mask)) {
BKE_mask_layer_active_set(mask, NULL);
BKE_mask_layer_active_set(mask, nullptr);
}
}
}
@ -1813,7 +1820,7 @@ void MASK_OT_hide_view_set(wmOperatorType *ot)
ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected layers");
}
static int mask_feather_weight_clear_exec(bContext *C, wmOperator *UNUSED(op))
static int mask_feather_weight_clear_exec(bContext *C, wmOperator * /*op*/)
{
Mask *mask = CTX_data_edit_mask(C);
bool changed = false;
@ -1878,7 +1885,8 @@ static bool mask_layer_move_poll(bContext *C)
static int mask_layer_move_exec(bContext *C, wmOperator *op)
{
Mask *mask = CTX_data_edit_mask(C);
MaskLayer *mask_layer = BLI_findlink(&mask->masklayers, mask->masklay_act);
MaskLayer *mask_layer = static_cast<MaskLayer *>(
BLI_findlink(&mask->masklayers, mask->masklay_act));
MaskLayer *mask_layer_other;
int direction = RNA_enum_get(op->ptr, "direction");
@ -1920,7 +1928,7 @@ void MASK_OT_layer_move(wmOperatorType *ot)
static const EnumPropertyItem direction_items[] = {
{-1, "UP", 0, "Up", ""},
{1, "DOWN", 0, "Down", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* identifiers */
@ -1946,12 +1954,12 @@ void MASK_OT_layer_move(wmOperatorType *ot)
/******************** duplicate *********************/
static int mask_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
static int mask_duplicate_exec(bContext *C, wmOperator * /*op*/)
{
Mask *mask = CTX_data_edit_mask(C);
LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
for (MaskSpline *spline = mask_layer->splines.last; spline; spline = spline->prev) {
LISTBASE_FOREACH_BACKWARD (MaskSpline *, spline, &mask_layer->splines) {
MaskSplinePoint *point = spline->points;
int i = 0;
while (i < spline->tot_point) {
@ -1987,8 +1995,8 @@ static int mask_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
/* Allocate new points and copy them from old spline. */
new_spline->tot_point = end - start + 1;
new_spline->points = MEM_mallocN(sizeof(MaskSplinePoint) * new_spline->tot_point,
"duplicated mask points");
new_spline->points = MEM_cnew_array<MaskSplinePoint>(new_spline->tot_point,
"duplicated mask points");
memcpy(new_spline->points,
spline->points + start,
@ -2005,7 +2013,7 @@ static int mask_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
/* Select points and duplicate their UWs (if needed). */
for (b = 0, new_point = new_spline->points; b < tot_point; b++, new_point++) {
if (new_point->uw) {
new_point->uw = MEM_dupallocN(new_point->uw);
new_point->uw = static_cast<MaskSplinePointUW *>(MEM_dupallocN(new_point->uw));
}
BKE_mask_point_select_set(new_point, true);
@ -2058,12 +2066,12 @@ void MASK_OT_duplicate(wmOperatorType *ot)
/********************** copy splines to clipboard operator *********************/
static int copy_splines_exec(bContext *C, wmOperator *UNUSED(op))
static int copy_splines_exec(bContext *C, wmOperator * /*op*/)
{
Mask *mask = CTX_data_edit_mask(C);
MaskLayer *mask_layer = BKE_mask_layer_active(mask);
if (mask_layer == NULL) {
if (mask_layer == nullptr) {
return OPERATOR_CANCELLED;
}
@ -2098,12 +2106,12 @@ static bool paste_splines_poll(bContext *C)
return 0;
}
static int paste_splines_exec(bContext *C, wmOperator *UNUSED(op))
static int paste_splines_exec(bContext *C, wmOperator * /*op*/)
{
Mask *mask = CTX_data_edit_mask(C);
MaskLayer *mask_layer = BKE_mask_layer_active(mask);
if (mask_layer == NULL) {
if (mask_layer == nullptr) {
mask_layer = BKE_mask_layer_new(mask, "");
}

View File

@ -52,7 +52,7 @@ bool ED_mask_find_nearest_diff_point(const bContext *C,
MaskLayer *point_mask_layer;
MaskSpline *point_spline;
MaskSplinePoint *point = NULL;
MaskSplinePoint *point = nullptr;
float dist_best_sq = FLT_MAX, co[2];
int width, height;
float u = 0.0f;
@ -67,18 +67,18 @@ bool ED_mask_find_nearest_diff_point(const bContext *C,
co[0] = normal_co[0] * scalex;
co[1] = normal_co[1] * scaley;
for (MaskLayer *mask_layer_orig = mask_orig->masklayers.first,
*mask_layer_eval = mask_eval->masklayers.first;
mask_layer_orig != NULL;
for (MaskLayer *mask_layer_orig = static_cast<MaskLayer *>(mask_orig->masklayers.first),
*mask_layer_eval = static_cast<MaskLayer *>(mask_eval->masklayers.first);
mask_layer_orig != nullptr;
mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next)
{
if (mask_layer_orig->visibility_flag & (MASK_HIDE_VIEW | MASK_HIDE_SELECT)) {
continue;
}
for (MaskSpline *spline_orig = mask_layer_orig->splines.first,
*spline_eval = mask_layer_eval->splines.first;
spline_orig != NULL;
for (MaskSpline *spline_orig = static_cast<MaskSpline *>(mask_layer_orig->splines.first),
*spline_eval = static_cast<MaskSpline *>(mask_layer_eval->splines.first);
spline_orig != nullptr;
spline_orig = spline_orig->next, spline_eval = spline_eval->next)
{
int i;
@ -95,7 +95,7 @@ bool ED_mask_find_nearest_diff_point(const bContext *C,
if (diff_points) {
int j, tot_point;
uint tot_feather_point;
float *feather_points = NULL, *points;
float *feather_points = nullptr, *points;
if (feather) {
feather_points = BKE_mask_point_segment_feather_diff(
@ -135,7 +135,7 @@ bool ED_mask_find_nearest_diff_point(const bContext *C,
}
}
if (feather_points != NULL) {
if (feather_points != nullptr) {
MEM_freeN(feather_points);
}
MEM_freeN(diff_points);
@ -174,15 +174,15 @@ bool ED_mask_find_nearest_diff_point(const bContext *C,
}
if (r_mask_layer) {
*r_mask_layer = NULL;
*r_mask_layer = nullptr;
}
if (r_spline) {
*r_spline = NULL;
*r_spline = nullptr;
}
if (r_point) {
*r_point = NULL;
*r_point = nullptr;
}
return false;
@ -211,9 +211,9 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C,
ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
MaskLayer *point_mask_layer = NULL;
MaskSpline *point_spline = NULL;
MaskSplinePoint *point = NULL;
MaskLayer *point_mask_layer = nullptr;
MaskSpline *point_spline = nullptr;
MaskSplinePoint *point = nullptr;
float co[2];
const float threshold_sq = threshold * threshold;
float len_sq = FLT_MAX, scalex, scaley;
@ -229,9 +229,9 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C,
co[0] = normal_co[0] * scalex;
co[1] = normal_co[1] * scaley;
for (MaskLayer *mask_layer_orig = mask_orig->masklayers.first,
*mask_layer_eval = mask_eval->masklayers.first;
mask_layer_orig != NULL;
for (MaskLayer *mask_layer_orig = static_cast<MaskLayer *>(mask_orig->masklayers.first),
*mask_layer_eval = static_cast<MaskLayer *>(mask_eval->masklayers.first);
mask_layer_orig != nullptr;
mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next)
{
@ -239,9 +239,9 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C,
continue;
}
for (MaskSpline *spline_orig = mask_layer_orig->splines.first,
*spline_eval = mask_layer_eval->splines.first;
spline_orig != NULL;
for (MaskSpline *spline_orig = static_cast<MaskSpline *>(mask_layer_orig->splines.first),
*spline_eval = static_cast<MaskSpline *>(mask_layer_eval->splines.first);
spline_orig != nullptr;
spline_orig = spline_orig->next, spline_eval = spline_eval->next)
{
MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline_eval);
@ -341,18 +341,18 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C,
}
if (r_mask_layer) {
*r_mask_layer = NULL;
*r_mask_layer = nullptr;
}
if (r_spline) {
*r_spline = NULL;
*r_spline = nullptr;
}
if (r_which_handle) {
*r_which_handle = MASK_WHICH_HANDLE_NONE;
}
return NULL;
return nullptr;
}
bool ED_mask_feather_find_nearest(const bContext *C,
@ -368,10 +368,10 @@ bool ED_mask_feather_find_nearest(const bContext *C,
ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
MaskLayer *point_mask_layer = NULL;
MaskSpline *point_spline = NULL;
MaskSplinePoint *point = NULL;
MaskSplinePointUW *uw = NULL;
MaskLayer *point_mask_layer = nullptr;
MaskSpline *point_spline = nullptr;
MaskSplinePoint *point = nullptr;
MaskSplinePointUW *uw = nullptr;
const float threshold_sq = threshold * threshold;
float len = FLT_MAX, co[2];
float scalex, scaley;
@ -386,15 +386,15 @@ bool ED_mask_feather_find_nearest(const bContext *C,
co[0] = normal_co[0] * scalex;
co[1] = normal_co[1] * scaley;
for (MaskLayer *mask_layer_orig = mask_orig->masklayers.first,
*mask_layer_eval = mask_eval->masklayers.first;
mask_layer_orig != NULL;
for (MaskLayer *mask_layer_orig = static_cast<MaskLayer *>(mask_orig->masklayers.first),
*mask_layer_eval = static_cast<MaskLayer *>(mask_eval->masklayers.first);
mask_layer_orig != nullptr;
mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next)
{
for (MaskSpline *spline_orig = mask_layer_orig->splines.first,
*spline_eval = mask_layer_eval->splines.first;
spline_orig != NULL;
for (MaskSpline *spline_orig = static_cast<MaskSpline *>(mask_layer_orig->splines.first),
*spline_eval = static_cast<MaskSpline *>(mask_layer_eval->splines.first);
spline_orig != nullptr;
spline_orig = spline_orig->next, spline_eval = spline_eval->next)
{
// MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
@ -421,9 +421,9 @@ bool ED_mask_feather_find_nearest(const bContext *C,
cur_len_sq = len_squared_v2v2(vec, co);
if (point == NULL || cur_len_sq < len) {
if (point == nullptr || cur_len_sq < len) {
if (j == 0) {
uw = NULL;
uw = nullptr;
}
else {
uw = &cur_point_orig->uw[j - 1];
@ -468,15 +468,15 @@ bool ED_mask_feather_find_nearest(const bContext *C,
}
if (r_mask_layer) {
*r_mask_layer = NULL;
*r_mask_layer = nullptr;
}
if (r_spline) {
*r_spline = NULL;
*r_spline = nullptr;
}
if (r_point) {
*r_point = NULL;
*r_point = nullptr;
}
return false;
@ -487,7 +487,7 @@ void ED_mask_mouse_pos(ScrArea *area, ARegion *region, const int mval[2], float
if (area) {
switch (area->spacetype) {
case SPACE_CLIP: {
SpaceClip *sc = area->spacedata.first;
SpaceClip *sc = static_cast<SpaceClip *>(area->spacedata.first);
ED_clip_mouse_pos(sc, region, mval, co);
BKE_mask_coord_from_movieclip(sc->clip, &sc->user, co, co);
break;
@ -497,7 +497,7 @@ void ED_mask_mouse_pos(ScrArea *area, ARegion *region, const int mval[2], float
break;
}
case SPACE_IMAGE: {
SpaceImage *sima = area->spacedata.first;
SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
ED_image_mouse_pos(sima, region, mval, co);
BKE_mask_coord_from_image(sima->image, &sima->iuser, co, co);
break;
@ -522,7 +522,7 @@ void ED_mask_point_pos(ScrArea *area, ARegion *region, float x, float y, float *
if (area) {
switch (area->spacetype) {
case SPACE_CLIP: {
SpaceClip *sc = area->spacedata.first;
SpaceClip *sc = static_cast<SpaceClip *>(area->spacedata.first);
ED_clip_point_stable_pos(sc, region, x, y, &co[0], &co[1]);
BKE_mask_coord_from_movieclip(sc->clip, &sc->user, co, co);
break;
@ -531,7 +531,7 @@ void ED_mask_point_pos(ScrArea *area, ARegion *region, float x, float y, float *
zero_v2(co); /* MASKTODO */
break;
case SPACE_IMAGE: {
SpaceImage *sima = area->spacedata.first;
SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
ED_image_point_pos(sima, region, x, y, &co[0], &co[1]);
BKE_mask_coord_from_image(sima->image, &sima->iuser, co, co);
break;
@ -560,7 +560,7 @@ void ED_mask_point_pos__reverse(
if (area) {
switch (area->spacetype) {
case SPACE_CLIP: {
SpaceClip *sc = area->spacedata.first;
SpaceClip *sc = static_cast<SpaceClip *>(area->spacedata.first);
co[0] = x;
co[1] = y;
BKE_mask_coord_to_movieclip(sc->clip, &sc->user, co, co);
@ -571,7 +571,7 @@ void ED_mask_point_pos__reverse(
zero_v2(co); /* MASKTODO */
break;
case SPACE_IMAGE: {
SpaceImage *sima = area->spacedata.first;
SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
co[0] = x;
co[1] = y;
BKE_mask_coord_to_image(sima->image, &sima->iuser, co, co);
@ -616,7 +616,7 @@ bool ED_mask_selected_minmax(const bContext *C,
bool ok = false;
if (mask == NULL) {
if (mask == nullptr) {
return ok;
}
@ -626,13 +626,11 @@ bool ED_mask_selected_minmax(const bContext *C,
Mask *mask_eval = (Mask *)DEG_get_evaluated_id(depsgraph, &mask->id);
INIT_MINMAX2(min, max);
for (MaskLayer *mask_layer = mask_eval->masklayers.first; mask_layer != NULL;
mask_layer = mask_layer->next)
{
LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask_eval->masklayers) {
if (mask_layer->visibility_flag & (MASK_HIDE_VIEW | MASK_HIDE_SELECT)) {
continue;
}
for (MaskSpline *spline = mask_layer->splines.first; spline != NULL; spline = spline->next) {
LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
for (int i = 0; i < spline->tot_point; i++) {
const MaskSplinePoint *point = &spline->points[i];
@ -684,17 +682,17 @@ void ED_mask_get_size(ScrArea *area, int *width, int *height)
if (area && area->spacedata.first) {
switch (area->spacetype) {
case SPACE_CLIP: {
SpaceClip *sc = area->spacedata.first;
SpaceClip *sc = static_cast<SpaceClip *>(area->spacedata.first);
ED_space_clip_get_size(sc, width, height);
break;
}
case SPACE_SEQ: {
// Scene *scene = CTX_data_scene(C);
// BKE_render_resolution(&scene->r, false, width, height);
// Scene *scene = CTX_data_scene(C);
// BKE_render_resolution(&scene->r, false, width, height);
break;
}
case SPACE_IMAGE: {
SpaceImage *sima = area->spacedata.first;
SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
ED_space_image_get_size(sima, width, height);
break;
}
@ -718,7 +716,7 @@ void ED_mask_zoom(ScrArea *area, ARegion *region, float *zoomx, float *zoomy)
if (area && area->spacedata.first) {
switch (area->spacetype) {
case SPACE_CLIP: {
SpaceClip *sc = area->spacedata.first;
SpaceClip *sc = static_cast<SpaceClip *>(area->spacedata.first);
ED_space_clip_get_zoom(sc, region, zoomx, zoomy);
break;
}
@ -727,7 +725,7 @@ void ED_mask_zoom(ScrArea *area, ARegion *region, float *zoomx, float *zoomy)
break;
}
case SPACE_IMAGE: {
SpaceImage *sima = area->spacedata.first;
SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
ED_space_image_get_zoom(sima, region, zoomx, zoomy);
break;
}
@ -744,12 +742,12 @@ void ED_mask_zoom(ScrArea *area, ARegion *region, float *zoomx, float *zoomy)
}
}
void ED_mask_get_aspect(ScrArea *area, ARegion *UNUSED(region), float *aspx, float *aspy)
void ED_mask_get_aspect(ScrArea *area, ARegion * /*region*/, float *aspx, float *aspy)
{
if (area && area->spacedata.first) {
switch (area->spacetype) {
case SPACE_CLIP: {
SpaceClip *sc = area->spacedata.first;
SpaceClip *sc = static_cast<SpaceClip *>(area->spacedata.first);
ED_space_clip_get_aspect(sc, aspx, aspy);
break;
}
@ -758,7 +756,7 @@ void ED_mask_get_aspect(ScrArea *area, ARegion *UNUSED(region), float *aspx, flo
break;
}
case SPACE_IMAGE: {
SpaceImage *sima = area->spacedata.first;
SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
ED_space_image_get_aspect(sima, aspx, aspy);
break;
}
@ -780,7 +778,7 @@ void ED_mask_pixelspace_factor(ScrArea *area, ARegion *region, float *scalex, fl
if (area && area->spacedata.first) {
switch (area->spacetype) {
case SPACE_CLIP: {
SpaceClip *sc = area->spacedata.first;
SpaceClip *sc = static_cast<SpaceClip *>(area->spacedata.first);
float aspx, aspy;
UI_view2d_scale_get(&region->v2d, scalex, scaley);
@ -795,7 +793,7 @@ void ED_mask_pixelspace_factor(ScrArea *area, ARegion *region, float *scalex, fl
break;
}
case SPACE_IMAGE: {
SpaceImage *sima = area->spacedata.first;
SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
float aspx, aspy;
UI_view2d_scale_get(&region->v2d, scalex, scaley);
@ -823,7 +821,7 @@ void ED_mask_cursor_location_get(ScrArea *area, float cursor[2])
if (area) {
switch (area->spacetype) {
case SPACE_CLIP: {
SpaceClip *space_clip = area->spacedata.first;
SpaceClip *space_clip = static_cast<SpaceClip *>(area->spacedata.first);
copy_v2_v2(cursor, space_clip->cursor);
break;
}
@ -832,7 +830,7 @@ void ED_mask_cursor_location_get(ScrArea *area, float cursor[2])
break;
}
case SPACE_IMAGE: {
SpaceImage *space_image = area->spacedata.first;
SpaceImage *space_image = static_cast<SpaceImage *>(area->spacedata.first);
copy_v2_v2(cursor, space_image->cursor);
break;
}

View File

@ -26,7 +26,7 @@
#include "mask_intern.h" /* own include */
static int mask_parent_clear_exec(bContext *C, wmOperator *UNUSED(op))
static int mask_parent_clear_exec(bContext *C, wmOperator * /*op*/)
{
Mask *mask = CTX_data_edit_mask(C);
@ -40,7 +40,7 @@ static int mask_parent_clear_exec(bContext *C, wmOperator *UNUSED(op))
MaskSplinePoint *point = &spline->points[i];
if (MASKPOINT_ISSEL_ANY(point)) {
point->parent.id = NULL;
point->parent.id = nullptr;
}
}
}
@ -68,7 +68,7 @@ void MASK_OT_parent_clear(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int mask_parent_set_exec(bContext *C, wmOperator *UNUSED(op))
static int mask_parent_set_exec(bContext *C, wmOperator * /*op*/)
{
Mask *mask = CTX_data_edit_mask(C);
@ -84,7 +84,7 @@ static int mask_parent_set_exec(bContext *C, wmOperator *UNUSED(op))
float parmask_pos[2], orig_corners[4][2];
const char *sub_parent_name;
if (ELEM(NULL, sc, clip)) {
if (ELEM(nullptr, sc, clip)) {
return OPERATOR_CANCELLED;
}
@ -92,11 +92,11 @@ static int mask_parent_set_exec(bContext *C, wmOperator *UNUSED(op))
tracking_object = BKE_tracking_object_get_active(&clip->tracking);
if (tracking_object == NULL) {
if (tracking_object == nullptr) {
return OPERATOR_CANCELLED;
}
if ((track = tracking_object->active_track) != NULL) {
if ((track = tracking_object->active_track) != nullptr) {
MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
float marker_pos_ofs[2];
@ -108,7 +108,7 @@ static int mask_parent_set_exec(bContext *C, wmOperator *UNUSED(op))
parent_type = MASK_PARENT_POINT_TRACK;
memset(orig_corners, 0, sizeof(orig_corners));
}
else if ((plane_track = tracking_object->active_plane_track) != NULL) {
else if ((plane_track = tracking_object->active_plane_track) != nullptr) {
MovieTrackingPlaneMarker *plane_marker = BKE_tracking_plane_marker_get(plane_track, framenr);
zero_v2(parmask_pos);

View File

@ -240,7 +240,7 @@ static int select_exec(bContext *C, wmOperator *op)
Mask *mask = CTX_data_edit_mask(C);
MaskLayer *mask_layer;
MaskSpline *spline;
MaskSplinePoint *point = NULL;
MaskSplinePoint *point = nullptr;
float co[2];
bool extend = RNA_boolean_get(op->ptr, "extend");
bool deselect = RNA_boolean_get(op->ptr, "deselect");
@ -255,7 +255,7 @@ static int select_exec(bContext *C, wmOperator *op)
RNA_float_get_array(op->ptr, "location", co);
point = ED_mask_point_find_nearest(
C, mask, co, threshold, &mask_layer, &spline, &which_handle, NULL);
C, mask, co, threshold, &mask_layer, &spline, &which_handle, nullptr);
if (extend == false && deselect == false && toggle == false) {
ED_mask_select_toggle_all(mask, SEL_DESELECT);
@ -323,7 +323,8 @@ static int select_exec(bContext *C, wmOperator *op)
MaskSplinePointUW *uw;
if (ED_mask_feather_find_nearest(
C, mask, co, threshold, &mask_layer, &spline, &point, &uw, NULL)) {
C, mask, co, threshold, &mask_layer, &spline, &point, &uw, nullptr))
{
if (extend) {
mask_layer->act_spline = spline;
@ -408,7 +409,7 @@ void MASK_OT_select(wmOperatorType *ot)
RNA_def_float_vector(ot->srna,
"location",
2,
NULL,
nullptr,
-FLT_MAX,
FLT_MAX,
"Location",
@ -436,7 +437,7 @@ static int box_select_exec(bContext *C, wmOperator *op)
rctf rectf;
bool changed = false;
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
const eSelectOp sel_op = eSelectOp(RNA_enum_get(op->ptr, "mode"));
const bool select = (sel_op != SEL_OP_SUB);
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
ED_mask_select_toggle_all(mask_orig, SEL_DESELECT);
@ -450,17 +451,17 @@ static int box_select_exec(bContext *C, wmOperator *op)
ED_mask_point_pos(area, region, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax);
/* do actual selection */
for (MaskLayer *mask_layer_orig = mask_orig->masklayers.first,
*mask_layer_eval = mask_eval->masklayers.first;
mask_layer_orig != NULL;
for (MaskLayer *mask_layer_orig = static_cast<MaskLayer *>(mask_orig->masklayers.first),
*mask_layer_eval = static_cast<MaskLayer *>(mask_eval->masklayers.first);
mask_layer_orig != nullptr;
mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next)
{
if (mask_layer_orig->visibility_flag & (MASK_HIDE_VIEW | MASK_HIDE_SELECT)) {
continue;
}
for (MaskSpline *spline_orig = mask_layer_orig->splines.first,
*spline_eval = mask_layer_eval->splines.first;
spline_orig != NULL;
for (MaskSpline *spline_orig = static_cast<MaskSpline *>(mask_layer_orig->splines.first),
*spline_eval = static_cast<MaskSpline *>(mask_layer_eval->splines.first);
spline_orig != nullptr;
spline_orig = spline_orig->next, spline_eval = spline_eval->next)
{
@ -545,17 +546,17 @@ static bool do_lasso_select_mask(bContext *C,
BLI_lasso_boundbox(&rect, mcoords, mcoords_len);
/* do actual selection */
for (MaskLayer *mask_layer_orig = mask_orig->masklayers.first,
*mask_layer_eval = mask_eval->masklayers.first;
mask_layer_orig != NULL;
for (MaskLayer *mask_layer_orig = static_cast<MaskLayer *>(mask_orig->masklayers.first),
*mask_layer_eval = static_cast<MaskLayer *>(mask_eval->masklayers.first);
mask_layer_orig != nullptr;
mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next)
{
if (mask_layer_orig->visibility_flag & (MASK_HIDE_VIEW | MASK_HIDE_SELECT)) {
continue;
}
for (MaskSpline *spline_orig = mask_layer_orig->splines.first,
*spline_eval = mask_layer_eval->splines.first;
spline_orig != NULL;
for (MaskSpline *spline_orig = static_cast<MaskSpline *>(mask_layer_orig->splines.first),
*spline_eval = static_cast<MaskSpline *>(mask_layer_eval->splines.first);
spline_orig != nullptr;
spline_orig = spline_orig->next, spline_eval = spline_eval->next)
{
@ -609,7 +610,7 @@ static int clip_lasso_select_exec(bContext *C, wmOperator *op)
const int(*mcoords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcoords_len);
if (mcoords) {
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
const eSelectOp sel_op = eSelectOp(RNA_enum_get(op->ptr, "mode"));
do_lasso_select_mask(C, mcoords, mcoords_len, sel_op);
MEM_freeN((void *)mcoords);
@ -688,8 +689,9 @@ static int circle_select_exec(bContext *C, wmOperator *op)
ED_mask_point_pos(area, region, x, y, &offset[0], &offset[1]);
const eSelectOp sel_op = ED_select_op_modal(RNA_enum_get(op->ptr, "mode"),
WM_gesture_is_modal_first(op->customdata));
const eSelectOp sel_op = ED_select_op_modal(
eSelectOp(RNA_enum_get(op->ptr, "mode")),
WM_gesture_is_modal_first(static_cast<wmGesture *>(op->customdata)));
const bool select = (sel_op != SEL_OP_SUB);
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
ED_mask_select_toggle_all(mask_orig, SEL_DESELECT);
@ -697,17 +699,17 @@ static int circle_select_exec(bContext *C, wmOperator *op)
}
/* do actual selection */
for (MaskLayer *mask_layer_orig = mask_orig->masklayers.first,
*mask_layer_eval = mask_eval->masklayers.first;
mask_layer_orig != NULL;
for (MaskLayer *mask_layer_orig = static_cast<MaskLayer *>(mask_orig->masklayers.first),
*mask_layer_eval = static_cast<MaskLayer *>(mask_eval->masklayers.first);
mask_layer_orig != nullptr;
mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next)
{
if (mask_layer_orig->visibility_flag & (MASK_HIDE_VIEW | MASK_HIDE_SELECT)) {
continue;
}
for (MaskSpline *spline_orig = mask_layer_orig->splines.first,
*spline_eval = mask_layer_eval->splines.first;
spline_orig != NULL;
for (MaskSpline *spline_orig = static_cast<MaskSpline *>(mask_layer_orig->splines.first),
*spline_eval = static_cast<MaskSpline *>(mask_layer_eval->splines.first);
spline_orig != nullptr;
spline_orig = spline_orig->next, spline_eval = spline_eval->next)
{
@ -775,7 +777,7 @@ static int mask_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmE
Mask *mask = CTX_data_edit_mask(C);
MaskLayer *mask_layer;
MaskSpline *spline;
MaskSplinePoint *point = NULL;
MaskSplinePoint *point = nullptr;
float co[2];
bool do_select = !RNA_boolean_get(op->ptr, "deselect");
const float threshold = 19;
@ -783,7 +785,8 @@ static int mask_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmE
ED_mask_mouse_pos(area, region, event->mval, co);
point = ED_mask_point_find_nearest(C, mask, co, threshold, &mask_layer, &spline, NULL, NULL);
point = ED_mask_point_find_nearest(
C, mask, co, threshold, &mask_layer, &spline, nullptr, nullptr);
if (point) {
ED_mask_spline_select_set(spline, do_select);
@ -828,7 +831,7 @@ void MASK_OT_select_linked_pick(wmOperatorType *ot)
/** \name Select Linked Operator
* \{ */
static int mask_select_linked_exec(bContext *C, wmOperator *UNUSED(op))
static int mask_select_linked_exec(bContext *C, wmOperator * /*op*/)
{
Mask *mask = CTX_data_edit_mask(C);
@ -954,7 +957,7 @@ static int mask_select_more_less(bContext *C, bool more)
return OPERATOR_FINISHED;
}
static int mask_select_more_exec(bContext *C, wmOperator *UNUSED(op))
static int mask_select_more_exec(bContext *C, wmOperator * /*op*/)
{
return mask_select_more_less(C, true);
}
@ -974,7 +977,7 @@ void MASK_OT_select_more(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int mask_select_less_exec(bContext *C, wmOperator *UNUSED(op))
static int mask_select_less_exec(bContext *C, wmOperator * /*op*/)
{
return mask_select_more_less(C, false);
}

View File

@ -30,7 +30,7 @@
#include "mask_intern.h" /* own include */
static int mask_shape_key_insert_exec(bContext *C, wmOperator *UNUSED(op))
static int mask_shape_key_insert_exec(bContext *C, wmOperator * /*op*/)
{
Scene *scene = CTX_data_scene(C);
const int frame = scene->r.cfra;
@ -73,7 +73,7 @@ void MASK_OT_shape_key_insert(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int mask_shape_key_clear_exec(bContext *C, wmOperator *UNUSED(op))
static int mask_shape_key_clear_exec(bContext *C, wmOperator * /*op*/)
{
Scene *scene = CTX_data_scene(C);
const int frame = scene->r.cfra;
@ -119,7 +119,7 @@ void MASK_OT_shape_key_clear(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int mask_shape_key_feather_reset_exec(bContext *C, wmOperator *UNUSED(op))
static int mask_shape_key_feather_reset_exec(bContext *C, wmOperator * /*op*/)
{
Scene *scene = CTX_data_scene(C);
const int frame = scene->r.cfra;
@ -134,17 +134,13 @@ static int mask_shape_key_feather_reset_exec(bContext *C, wmOperator *UNUSED(op)
if (mask_layer->splines_shapes.first) {
MaskLayerShape *mask_layer_shape_reset;
MaskLayerShape *mask_layer_shape;
/* Get the shape-key of the current state. */
mask_layer_shape_reset = BKE_mask_layer_shape_alloc(mask_layer, frame);
/* Initialize from mask - as if inserting a keyframe. */
BKE_mask_layer_shape_from_mask(mask_layer, mask_layer_shape_reset);
for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape;
mask_layer_shape = mask_layer_shape->next)
{
LISTBASE_FOREACH (MaskLayerShape *, mask_layer_shape, &mask_layer->splines_shapes) {
if (mask_layer_shape_reset->tot_vert == mask_layer_shape->tot_vert) {
int i_abs = 0;
MaskLayerShapeElem *shape_ele_src;
@ -235,27 +231,28 @@ static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op)
if (mask_layer->splines_shapes.first) {
MaskLayerShape *mask_layer_shape, *mask_layer_shape_next;
MaskLayerShape *mask_layer_shape_lastsel = NULL;
MaskLayerShape *mask_layer_shape_lastsel = nullptr;
for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape;
for (mask_layer_shape = static_cast<MaskLayerShape *>(mask_layer->splines_shapes.first);
mask_layer_shape;
mask_layer_shape = mask_layer_shape_next)
{
MaskLayerShape *mask_layer_shape_a = NULL;
MaskLayerShape *mask_layer_shape_b = NULL;
MaskLayerShape *mask_layer_shape_a = nullptr;
MaskLayerShape *mask_layer_shape_b = nullptr;
mask_layer_shape_next = mask_layer_shape->next;
/* find contiguous selections */
if (mask_layer_shape->flag & MASK_SHAPE_SELECT) {
if (mask_layer_shape_lastsel == NULL) {
if (mask_layer_shape_lastsel == nullptr) {
mask_layer_shape_lastsel = mask_layer_shape;
}
if ((mask_layer_shape->next == NULL) ||
if ((mask_layer_shape->next == nullptr) ||
(((MaskLayerShape *)mask_layer_shape->next)->flag & MASK_SHAPE_SELECT) == 0)
{
mask_layer_shape_a = mask_layer_shape_lastsel;
mask_layer_shape_b = mask_layer_shape;
mask_layer_shape_lastsel = NULL;
mask_layer_shape_lastsel = nullptr;
/* this will be freed below, step over selection */
mask_layer_shape_next = mask_layer_shape->next;
@ -264,7 +261,7 @@ static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op)
/* we have a from<>to? - re-interpolate! */
if (mask_layer_shape_a && mask_layer_shape_b) {
ListBase shapes_tmp = {NULL, NULL};
ListBase shapes_tmp = {nullptr, nullptr};
MaskLayerShape *mask_layer_shape_tmp;
MaskLayerShape *mask_layer_shape_tmp_next;
MaskLayerShape *mask_layer_shape_tmp_last = mask_layer_shape_b->next;
@ -281,7 +278,8 @@ static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op)
}
/* re-key, NOTE: can't modify the keys here since it messes up. */
for (mask_layer_shape_tmp = shapes_tmp.first; mask_layer_shape_tmp;
for (mask_layer_shape_tmp = static_cast<MaskLayerShape *>(shapes_tmp.first);
mask_layer_shape_tmp;
mask_layer_shape_tmp = mask_layer_shape_tmp->next)
{
BKE_mask_layer_evaluate(mask_layer, mask_layer_shape_tmp->frame, true);
@ -292,7 +290,8 @@ static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op)
}
/* restore unselected points and free copies */
for (mask_layer_shape_tmp = shapes_tmp.first; mask_layer_shape_tmp;
for (mask_layer_shape_tmp = static_cast<MaskLayerShape *>(shapes_tmp.first);
mask_layer_shape_tmp;
mask_layer_shape_tmp = mask_layer_shape_tmp_next)
{
/* restore */