0
0
Fork 0

me-main #1

Merged
Nate Rupsis merged 123 commits from me-main into main 2023-02-13 18:39:11 +01:00
39 changed files with 497 additions and 620 deletions
Showing only changes of commit 5c8edbd99b - Show all commits

View File

@ -478,7 +478,7 @@ void ED_object_constraint_copy_for_pose(struct Main *bmain,
struct bPoseChannel *pchan, struct bPoseChannel *pchan,
struct bConstraint *con); struct bConstraint *con);
/* object_modes.c */ /* object_modes.cc */
/** /**
* Checks the mode to be set is compatible with the object * Checks the mode to be set is compatible with the object

View File

@ -24,7 +24,7 @@ struct wmKeyConfig;
struct wmOperator; struct wmOperator;
typedef struct PaintTileMap PaintTileMap; typedef struct PaintTileMap PaintTileMap;
/* paint_ops.c */ /* paint_ops.cc */
void ED_operatortypes_paint(void); void ED_operatortypes_paint(void);
void ED_operatormacros_paint(void); void ED_operatormacros_paint(void);

View File

@ -18,7 +18,7 @@ struct IDRemapper;
struct Main; struct Main;
struct bContext; struct bContext;
/* ed_util.c */ /* ed_util.cc */
void ED_editors_init_for_undo(struct Main *bmain); void ED_editors_init_for_undo(struct Main *bmain);
void ED_editors_init(struct bContext *C); void ED_editors_init(struct bContext *C);

View File

@ -44,7 +44,7 @@ set(SRC
object_facemap_ops.c object_facemap_ops.c
object_gpencil_modifier.c object_gpencil_modifier.c
object_hook.c object_hook.c
object_modes.c object_modes.cc
object_modifier.cc object_modifier.cc
object_ops.c object_ops.c
object_random.c object_random.c

View File

@ -97,7 +97,7 @@ static const char *object_mode_op_string(eObjectMode mode)
if (mode == OB_MODE_SCULPT_CURVES) { if (mode == OB_MODE_SCULPT_CURVES) {
return "CURVES_OT_sculptmode_toggle"; return "CURVES_OT_sculptmode_toggle";
} }
return NULL; return nullptr;
} }
bool ED_object_mode_compat_test(const Object *ob, eObjectMode mode) bool ED_object_mode_compat_test(const Object *ob, eObjectMode mode)
@ -160,9 +160,9 @@ bool ED_object_mode_compat_set(bContext *C, Object *ob, eObjectMode mode, Report
{ {
bool ok; bool ok;
if (!ELEM(ob->mode, mode, OB_MODE_OBJECT)) { if (!ELEM(ob->mode, mode, OB_MODE_OBJECT)) {
const char *opstring = object_mode_op_string(ob->mode); const char *opstring = object_mode_op_string(eObjectMode(ob->mode));
WM_operator_name_call(C, opstring, WM_OP_EXEC_REGION_WIN, NULL, NULL); WM_operator_name_call(C, opstring, WM_OP_EXEC_REGION_WIN, nullptr, nullptr);
ok = ELEM(ob->mode, mode, OB_MODE_OBJECT); ok = ELEM(ob->mode, mode, OB_MODE_OBJECT);
if (!ok) { if (!ok) {
wmOperatorType *ot = WM_operatortype_find(opstring, false); wmOperatorType *ot = WM_operatortype_find(opstring, false);
@ -194,7 +194,7 @@ bool ED_object_mode_set_ex(bContext *C, eObjectMode mode, bool use_undo, ReportL
BKE_view_layer_synced_ensure(scene, view_layer); BKE_view_layer_synced_ensure(scene, view_layer);
Object *ob = BKE_view_layer_active_object_get(view_layer); Object *ob = BKE_view_layer_active_object_get(view_layer);
if (ob == NULL) { if (ob == nullptr) {
return (mode == OB_MODE_OBJECT); return (mode == OB_MODE_OBJECT);
} }
@ -210,13 +210,14 @@ bool ED_object_mode_set_ex(bContext *C, eObjectMode mode, bool use_undo, ReportL
return false; return false;
} }
const char *opstring = object_mode_op_string((mode == OB_MODE_OBJECT) ? ob->mode : mode); const char *opstring = object_mode_op_string((mode == OB_MODE_OBJECT) ? eObjectMode(ob->mode) :
mode);
wmOperatorType *ot = WM_operatortype_find(opstring, false); wmOperatorType *ot = WM_operatortype_find(opstring, false);
if (!use_undo) { if (!use_undo) {
wm->op_undo_depth++; wm->op_undo_depth++;
} }
WM_operator_name_call_ptr(C, ot, WM_OP_EXEC_REGION_WIN, NULL, NULL); WM_operator_name_call_ptr(C, ot, WM_OP_EXEC_REGION_WIN, nullptr, nullptr);
if (!use_undo) { if (!use_undo) {
wm->op_undo_depth--; wm->op_undo_depth--;
} }
@ -232,20 +233,17 @@ bool ED_object_mode_set_ex(bContext *C, eObjectMode mode, bool use_undo, ReportL
bool ED_object_mode_set(bContext *C, eObjectMode mode) bool ED_object_mode_set(bContext *C, eObjectMode mode)
{ {
/* Don't do undo push by default, since this may be called by lower level code. */ /* Don't do undo push by default, since this may be called by lower level code. */
return ED_object_mode_set_ex(C, mode, true, NULL); return ED_object_mode_set_ex(C, mode, true, nullptr);
} }
/** /**
* Use for changing works-paces or changing active object. * Use for changing works-paces or changing active object.
* Caller can check #OB_MODE_ALL_MODE_DATA to test if this needs to be run. * Caller can check #OB_MODE_ALL_MODE_DATA to test if this needs to be run.
*/ */
static bool ed_object_mode_generic_exit_ex(struct Main *bmain, static bool ed_object_mode_generic_exit_ex(
struct Depsgraph *depsgraph, Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob, bool only_test)
struct Scene *scene,
struct Object *ob,
bool only_test)
{ {
BLI_assert((bmain == NULL) == only_test); BLI_assert((bmain == nullptr) == only_test);
if (ob->mode & OB_MODE_EDIT) { if (ob->mode & OB_MODE_EDIT) {
if (BKE_object_is_in_editmode(ob)) { if (BKE_object_is_in_editmode(ob)) {
if (only_test) { if (only_test) {
@ -279,7 +277,7 @@ static bool ed_object_mode_generic_exit_ex(struct Main *bmain,
} }
} }
else if (ob->mode & OB_MODE_POSE) { else if (ob->mode & OB_MODE_POSE) {
if (ob->pose != NULL) { if (ob->pose != nullptr) {
if (only_test) { if (only_test) {
return true; return true;
} }
@ -332,7 +330,7 @@ static void ed_object_posemode_set_for_weight_paint_ex(bContext *C,
const Scene *scene = CTX_data_scene(C); const Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C); ViewLayer *view_layer = CTX_data_view_layer(C);
if (ob_arm != NULL) { if (ob_arm != nullptr) {
BKE_view_layer_synced_ensure(scene, view_layer); BKE_view_layer_synced_ensure(scene, view_layer);
const Base *base_arm = BKE_view_layer_base_find(view_layer, ob_arm); const Base *base_arm = BKE_view_layer_base_find(view_layer, ob_arm);
if (base_arm && BASE_VISIBLE(v3d, base_arm)) { if (base_arm && BASE_VISIBLE(v3d, base_arm)) {
@ -387,17 +385,14 @@ void ED_object_posemode_set_for_weight_paint(bContext *C,
} }
} }
void ED_object_mode_generic_exit(struct Main *bmain, void ED_object_mode_generic_exit(Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob)
struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *ob)
{ {
ed_object_mode_generic_exit_ex(bmain, depsgraph, scene, ob, false); ed_object_mode_generic_exit_ex(bmain, depsgraph, scene, ob, false);
} }
bool ED_object_mode_generic_has_data(struct Depsgraph *depsgraph, const struct Object *ob) bool ED_object_mode_generic_has_data(Depsgraph *depsgraph, const Object *ob)
{ {
return ed_object_mode_generic_exit_ex(NULL, depsgraph, NULL, (Object *)ob, true); return ed_object_mode_generic_exit_ex(nullptr, depsgraph, nullptr, (Object *)ob, true);
} }
/** \} */ /** \} */
@ -425,7 +420,7 @@ static void object_transfer_mode_reposition_view_pivot(bContext *C, const int mv
Scene *scene = CTX_data_scene(C); Scene *scene = CTX_data_scene(C);
float global_loc[3]; float global_loc[3];
if (!ED_view3d_autodist_simple(region, mval, global_loc, 0, NULL)) { if (!ED_view3d_autodist_simple(region, mval, global_loc, 0, nullptr)) {
return; return;
} }
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
@ -446,7 +441,7 @@ static bool object_transfer_mode_to_base(bContext *C, wmOperator *op, Base *base
Scene *scene = CTX_data_scene(C); Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C); ViewLayer *view_layer = CTX_data_view_layer(C);
if (base_dst == NULL) { if (base_dst == nullptr) {
return false; return false;
} }

View File

@ -45,15 +45,15 @@ set(SRC
paint_cursor.cc paint_cursor.cc
paint_curve.c paint_curve.c
paint_curve_undo.c paint_curve_undo.c
paint_hide.c paint_hide.cc
paint_image.cc paint_image.cc
paint_image_2d.c paint_image_2d.c
paint_image_2d_curve_mask.cc paint_image_2d_curve_mask.cc
paint_image_ops_paint.cc paint_image_ops_paint.cc
paint_image_proj.cc paint_image_proj.cc
paint_mask.cc paint_mask.cc
paint_ops.c paint_ops.cc
paint_stroke.c paint_stroke.cc
paint_utils.c paint_utils.c
paint_vertex.cc paint_vertex.cc
paint_vertex_color_ops.cc paint_vertex_color_ops.cc
@ -88,7 +88,7 @@ set(SRC
curves_sculpt_intern.h curves_sculpt_intern.h
curves_sculpt_intern.hh curves_sculpt_intern.hh
paint_intern.h paint_intern.h
sculpt_intern.h sculpt_intern.hh
) )
set(LIB set(LIB

View File

@ -55,7 +55,7 @@
#include "paint_intern.h" #include "paint_intern.h"
/* still needed for sculpt_stroke_get_location, should be /* still needed for sculpt_stroke_get_location, should be
* removed eventually (TODO) */ * removed eventually (TODO) */
#include "sculpt_intern.h" #include "sculpt_intern.hh"
/* TODOs: /* TODOs:
* *

View File

@ -41,7 +41,7 @@
#include "paint_intern.h" #include "paint_intern.h"
/* For undo push. */ /* For undo push. */
#include "sculpt_intern.h" #include "sculpt_intern.hh"
/* Return true if the element should be hidden/shown. */ /* Return true if the element should be hidden/shown. */
static bool is_effected(PartialVisArea area, static bool is_effected(PartialVisArea area,
@ -67,21 +67,21 @@ static void partialvis_update_mesh(Object *ob,
PartialVisArea area, PartialVisArea area,
float planes[4][4]) float planes[4][4])
{ {
Mesh *me = ob->data; Mesh *me = static_cast<Mesh *>(ob->data);
const float(*positions)[3] = BKE_pbvh_get_vert_positions(pbvh); const float(*positions)[3] = BKE_pbvh_get_vert_positions(pbvh);
const float *paint_mask; const float *paint_mask;
int totvert, i; int totvert, i;
bool any_changed = false, any_visible = false; bool any_changed = false, any_visible = false;
BKE_pbvh_node_num_verts(pbvh, node, NULL, &totvert); BKE_pbvh_node_num_verts(pbvh, node, nullptr, &totvert);
const int *vert_indices = BKE_pbvh_node_get_vert_indices(node); const int *vert_indices = BKE_pbvh_node_get_vert_indices(node);
paint_mask = CustomData_get_layer(&me->vdata, CD_PAINT_MASK); paint_mask = static_cast<const float *>(CustomData_get_layer(&me->vdata, CD_PAINT_MASK));
bool *hide_vert = CustomData_get_layer_named_for_write( bool *hide_vert = static_cast<bool *>(
&me->vdata, CD_PROP_BOOL, ".hide_vert", me->totvert); CustomData_get_layer_named_for_write(&me->vdata, CD_PROP_BOOL, ".hide_vert", me->totvert));
if (hide_vert == NULL) { if (hide_vert == nullptr) {
hide_vert = CustomData_add_layer_named( hide_vert = static_cast<bool *>(CustomData_add_layer_named(
&me->vdata, CD_PROP_BOOL, CD_SET_DEFAULT, NULL, me->totvert, ".hide_vert"); &me->vdata, CD_PROP_BOOL, CD_SET_DEFAULT, nullptr, me->totvert, ".hide_vert"));
} }
SCULPT_undo_push_node(ob, node, SCULPT_UNDO_HIDDEN); SCULPT_undo_push_node(ob, node, SCULPT_UNDO_HIDDEN);
@ -122,7 +122,7 @@ static void partialvis_update_grids(Depsgraph *depsgraph,
bool any_changed = false, any_visible = false; bool any_changed = false, any_visible = false;
/* Get PBVH data. */ /* Get PBVH data. */
BKE_pbvh_node_get_grids(pbvh, node, &grid_indices, &totgrid, NULL, NULL, &grids); BKE_pbvh_node_get_grids(pbvh, node, &grid_indices, &totgrid, nullptr, nullptr, &grids);
grid_hidden = BKE_pbvh_grid_hidden(pbvh); grid_hidden = BKE_pbvh_grid_hidden(pbvh);
CCGKey key = *BKE_pbvh_get_grid_key(pbvh); CCGKey key = *BKE_pbvh_get_grid_key(pbvh);
@ -147,7 +147,7 @@ static void partialvis_update_grids(Depsgraph *depsgraph,
else if (action == PARTIALVIS_SHOW && area == PARTIALVIS_ALL) { else if (action == PARTIALVIS_SHOW && area == PARTIALVIS_ALL) {
/* Special case if we're showing all, just free the grid. */ /* Special case if we're showing all, just free the grid. */
MEM_freeN(gh); MEM_freeN(gh);
grid_hidden[g] = NULL; grid_hidden[g] = nullptr;
any_changed = true; any_changed = true;
any_visible = true; any_visible = true;
continue; continue;
@ -180,7 +180,7 @@ static void partialvis_update_grids(Depsgraph *depsgraph,
/* If everything in the grid is now visible, free the grid flags. */ /* If everything in the grid is now visible, free the grid flags. */
if (!any_hidden) { if (!any_hidden) {
MEM_freeN(gh); MEM_freeN(gh);
grid_hidden[g] = NULL; grid_hidden[g] = nullptr;
} }
} }
@ -203,8 +203,9 @@ static void partialvis_update_bmesh_verts(BMesh *bm,
GSetIterator gs_iter; GSetIterator gs_iter;
GSET_ITER (gs_iter, verts) { GSET_ITER (gs_iter, verts) {
BMVert *v = BLI_gsetIterator_getKey(&gs_iter); BMVert *v = static_cast<BMVert *>(BLI_gsetIterator_getKey(&gs_iter));
float *vmask = CustomData_bmesh_get(&bm->vdata, v->head.data, CD_PAINT_MASK); float *vmask = static_cast<float *>(
CustomData_bmesh_get(&bm->vdata, v->head.data, CD_PAINT_MASK));
/* Hide vertex if in the hide volume. */ /* Hide vertex if in the hide volume. */
if (is_effected(area, planes, v->co, *vmask)) { if (is_effected(area, planes, v->co, *vmask)) {
@ -228,7 +229,7 @@ static void partialvis_update_bmesh_faces(GSet *faces)
GSetIterator gs_iter; GSetIterator gs_iter;
GSET_ITER (gs_iter, faces) { GSET_ITER (gs_iter, faces) {
BMFace *f = BLI_gsetIterator_getKey(&gs_iter); BMFace *f = static_cast<BMFace *>(BLI_gsetIterator_getKey(&gs_iter));
if (paint_is_bmesh_face_hidden(f)) { if (paint_is_bmesh_face_hidden(f)) {
BM_elem_flag_enable(f, BM_ELEM_HIDDEN); BM_elem_flag_enable(f, BM_ELEM_HIDDEN);
@ -298,7 +299,7 @@ static void clip_planes_from_rect(bContext *C,
static void get_pbvh_nodes( static void get_pbvh_nodes(
PBVH *pbvh, PBVHNode ***nodes, int *totnode, float clip_planes[4][4], PartialVisArea mode) PBVH *pbvh, PBVHNode ***nodes, int *totnode, float clip_planes[4][4], PartialVisArea mode)
{ {
BKE_pbvh_SearchCallback cb = NULL; BKE_pbvh_SearchCallback cb = nullptr;
/* Select search callback. */ /* Select search callback. */
switch (mode) { switch (mode) {
@ -313,7 +314,9 @@ static void get_pbvh_nodes(
break; break;
} }
PBVHFrustumPlanes frustum = {.planes = clip_planes, .num_planes = 4}; PBVHFrustumPlanes frustum{};
frustum.planes = clip_planes;
frustum.num_planes = 4;
BKE_pbvh_search_gather(pbvh, cb, &frustum, nodes, totnode); BKE_pbvh_search_gather(pbvh, cb, &frustum, nodes, totnode);
} }
@ -322,7 +325,7 @@ static int hide_show_exec(bContext *C, wmOperator *op)
ARegion *region = CTX_wm_region(C); ARegion *region = CTX_wm_region(C);
Object *ob = CTX_data_active_object(C); Object *ob = CTX_data_active_object(C);
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Mesh *me = ob->data; Mesh *me = static_cast<Mesh *>(ob->data);
PartialVisAction action; PartialVisAction action;
PartialVisArea area; PartialVisArea area;
PBVH *pbvh; PBVH *pbvh;
@ -333,8 +336,8 @@ static int hide_show_exec(bContext *C, wmOperator *op)
int totnode; int totnode;
/* Read operator properties. */ /* Read operator properties. */
action = RNA_enum_get(op->ptr, "action"); action = PartialVisAction(RNA_enum_get(op->ptr, "action"));
area = RNA_enum_get(op->ptr, "area"); area = PartialVisArea(RNA_enum_get(op->ptr, "area"));
rect_from_props(&rect, op->ptr); rect_from_props(&rect, op->ptr);
clip_planes_from_rect(C, depsgraph, clip_planes, &rect); clip_planes_from_rect(C, depsgraph, clip_planes, &rect);
@ -395,7 +398,7 @@ static int hide_show_exec(bContext *C, wmOperator *op)
static int hide_show_invoke(bContext *C, wmOperator *op, const wmEvent *event) static int hide_show_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{ {
PartialVisArea area = RNA_enum_get(op->ptr, "area"); PartialVisArea area = PartialVisArea(RNA_enum_get(op->ptr, "area"));
if (!ELEM(area, PARTIALVIS_ALL, PARTIALVIS_MASKED)) { if (!ELEM(area, PARTIALVIS_ALL, PARTIALVIS_MASKED)) {
return WM_gesture_box_invoke(C, op, event); return WM_gesture_box_invoke(C, op, event);
@ -403,12 +406,12 @@ static int hide_show_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return op->type->exec(C, op); return op->type->exec(C, op);
} }
void PAINT_OT_hide_show(struct wmOperatorType *ot) void PAINT_OT_hide_show(wmOperatorType *ot)
{ {
static const EnumPropertyItem action_items[] = { static const EnumPropertyItem action_items[] = {
{PARTIALVIS_HIDE, "HIDE", 0, "Hide", "Hide vertices"}, {PARTIALVIS_HIDE, "HIDE", 0, "Hide", "Hide vertices"},
{PARTIALVIS_SHOW, "SHOW", 0, "Show", "Show vertices"}, {PARTIALVIS_SHOW, "SHOW", 0, "Show", "Show vertices"},
{0, NULL, 0, NULL, NULL}, {0, nullptr, 0, nullptr, nullptr},
}; };
static const EnumPropertyItem area_items[] = { static const EnumPropertyItem area_items[] = {
@ -420,7 +423,7 @@ void PAINT_OT_hide_show(struct wmOperatorType *ot)
0, 0,
"Masked", "Masked",
"Hide or show vertices that are masked (minimum mask value of 0.5)"}, "Hide or show vertices that are masked (minimum mask value of 0.5)"},
{0, NULL, 0, NULL, NULL}, {0, nullptr, 0, nullptr, nullptr},
}; };
/* Identifiers. */ /* Identifiers. */

View File

@ -46,7 +46,7 @@ typedef struct CoNo {
float no[3]; float no[3];
} CoNo; } CoNo;
/* paint_stroke.c */ /* paint_stroke.cc */
typedef bool (*StrokeGetLocation)(struct bContext *C, typedef bool (*StrokeGetLocation)(struct bContext *C,
float location[3], float location[3],
@ -87,7 +87,7 @@ bool paint_supports_texture(enum ePaintMode mode);
bool paint_supports_jitter(enum ePaintMode mode); bool paint_supports_jitter(enum ePaintMode mode);
/** /**
* Called in paint_ops.c, on each regeneration of key-maps. * Called in paint_ops.cc, on each regeneration of key-maps.
*/ */
struct wmKeyMap *paint_stroke_modal_keymap(struct wmKeyConfig *keyconf); struct wmKeyMap *paint_stroke_modal_keymap(struct wmKeyConfig *keyconf);
int paint_stroke_modal(struct bContext *C, int paint_stroke_modal(struct bContext *C,
@ -457,7 +457,7 @@ typedef enum BrushStrokeMode {
BRUSH_STROKE_SMOOTH, BRUSH_STROKE_SMOOTH,
} BrushStrokeMode; } BrushStrokeMode;
/* paint_hide.c */ /* paint_hide.cc */
typedef enum { typedef enum {
PARTIALVIS_HIDE, PARTIALVIS_HIDE,

View File

@ -52,7 +52,7 @@
#include "paint_intern.h" #include "paint_intern.h"
/* For undo push. */ /* For undo push. */
#include "sculpt_intern.h" #include "sculpt_intern.hh"
static const EnumPropertyItem mode_items[] = { static const EnumPropertyItem mode_items[] = {
{PAINT_MASK_FLOOD_VALUE, {PAINT_MASK_FLOOD_VALUE,

View File

@ -4,13 +4,16 @@
* \ingroup edsculpt * \ingroup edsculpt
*/ */
#include <cstddef>
#include <cstdlib>
#include <cstring>
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
#include "BLI_listbase.h" #include "BLI_listbase.h"
#include "BLI_math_vector.h" #include "BLI_math_vector.h"
#include "BLI_string.h" #include "BLI_string.h"
#include "BLI_utildefines.h" #include "BLI_utildefines.h"
#include <stdlib.h>
#include "IMB_imbuf.h" #include "IMB_imbuf.h"
#include "IMB_imbuf_types.h" #include "IMB_imbuf_types.h"
@ -41,13 +44,10 @@
#include "curves_sculpt_intern.h" #include "curves_sculpt_intern.h"
#include "paint_intern.h" #include "paint_intern.h"
#include "sculpt_intern.h" #include "sculpt_intern.hh"
#include <stddef.h>
#include <string.h>
/* Brush operators */ /* Brush operators */
static int brush_add_exec(bContext *C, wmOperator *UNUSED(op)) static int brush_add_exec(bContext *C, wmOperator * /*op*/)
{ {
// int type = RNA_enum_get(op->ptr, "type"); // int type = RNA_enum_get(op->ptr, "type");
Paint *paint = BKE_paint_get_active_from_context(C); Paint *paint = BKE_paint_get_active_from_context(C);
@ -158,7 +158,7 @@ static eGPBrush_Presets gpencil_get_brush_preset_from_tool(bToolRef *tool,
return GP_BRUSH_PRESET_UNKNOWN; return GP_BRUSH_PRESET_UNKNOWN;
} }
static int brush_add_gpencil_exec(bContext *C, wmOperator *UNUSED(op)) static int brush_add_gpencil_exec(bContext *C, wmOperator * /*op*/)
{ {
Paint *paint = BKE_paint_get_active_from_context(C); Paint *paint = BKE_paint_get_active_from_context(C);
Brush *br = BKE_paint_brush(paint); Brush *br = BKE_paint_brush(paint);
@ -170,11 +170,11 @@ static int brush_add_gpencil_exec(bContext *C, wmOperator *UNUSED(op))
else { else {
/* Get the active tool to determine what type of brush is active. */ /* Get the active tool to determine what type of brush is active. */
bScreen *screen = CTX_wm_screen(C); bScreen *screen = CTX_wm_screen(C);
if (screen == NULL) { if (screen == nullptr) {
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
} }
bToolRef *tool = NULL; bToolRef *tool = nullptr;
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
if (area->spacetype == SPACE_VIEW3D) { if (area->spacetype == SPACE_VIEW3D) {
/* Check the current tool is a brush. */ /* Check the current tool is a brush. */
@ -186,7 +186,7 @@ static int brush_add_gpencil_exec(bContext *C, wmOperator *UNUSED(op))
} }
} }
if (tool == NULL) { if (tool == nullptr) {
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
} }
@ -255,7 +255,7 @@ static int brush_scale_size_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C); Scene *scene = CTX_data_scene(C);
Paint *paint = BKE_paint_get_active_from_context(C); Paint *paint = BKE_paint_get_active_from_context(C);
Brush *brush = BKE_paint_brush(paint); Brush *brush = BKE_paint_brush(paint);
const bool is_gpencil = (brush && brush->gpencil_settings != NULL); const bool is_gpencil = (brush && brush->gpencil_settings != nullptr);
// Object *ob = CTX_data_active_object(C); // Object *ob = CTX_data_active_object(C);
float scalar = RNA_float_get(op->ptr, "scalar"); float scalar = RNA_float_get(op->ptr, "scalar");
@ -318,7 +318,7 @@ static void BRUSH_OT_scale_size(wmOperatorType *ot)
/* Palette operators */ /* Palette operators */
static int palette_new_exec(bContext *C, wmOperator *UNUSED(op)) static int palette_new_exec(bContext *C, wmOperator * /*op*/)
{ {
Paint *paint = BKE_paint_get_active_from_context(C); Paint *paint = BKE_paint_get_active_from_context(C);
Main *bmain = CTX_data_main(C); Main *bmain = CTX_data_main(C);
@ -349,7 +349,7 @@ static bool palette_poll(bContext *C)
{ {
Paint *paint = BKE_paint_get_active_from_context(C); Paint *paint = BKE_paint_get_active_from_context(C);
if (paint && paint->palette != NULL && !ID_IS_LINKED(paint->palette) && if (paint && paint->palette != nullptr && !ID_IS_LINKED(paint->palette) &&
!ID_IS_OVERRIDE_LIBRARY(paint->palette)) { !ID_IS_OVERRIDE_LIBRARY(paint->palette)) {
return true; return true;
} }
@ -357,7 +357,7 @@ static bool palette_poll(bContext *C)
return false; return false;
} }
static int palette_color_add_exec(bContext *C, wmOperator *UNUSED(op)) static int palette_color_add_exec(bContext *C, wmOperator * /*op*/)
{ {
Scene *scene = CTX_data_scene(C); Scene *scene = CTX_data_scene(C);
Paint *paint = BKE_paint_get_active_from_context(C); Paint *paint = BKE_paint_get_active_from_context(C);
@ -401,11 +401,12 @@ static void PALETTE_OT_color_add(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
} }
static int palette_color_delete_exec(bContext *C, wmOperator *UNUSED(op)) static int palette_color_delete_exec(bContext *C, wmOperator * /*op*/)
{ {
Paint *paint = BKE_paint_get_active_from_context(C); Paint *paint = BKE_paint_get_active_from_context(C);
Palette *palette = paint->palette; Palette *palette = paint->palette;
PaletteColor *color = BLI_findlink(&palette->colors, palette->active_color); PaletteColor *color = static_cast<PaletteColor *>(
BLI_findlink(&palette->colors, palette->active_color));
if (color) { if (color) {
BKE_palette_color_remove(palette, color); BKE_palette_color_remove(palette, color);
@ -432,7 +433,7 @@ static void PALETTE_OT_color_delete(wmOperatorType *ot)
static bool palette_extract_img_poll(bContext *C) static bool palette_extract_img_poll(bContext *C)
{ {
SpaceLink *sl = CTX_wm_space_data(C); SpaceLink *sl = CTX_wm_space_data(C);
if ((sl != NULL) && (sl->spacetype == SPACE_IMAGE)) { if ((sl != nullptr) && (sl->spacetype == SPACE_IMAGE)) {
SpaceImage *sima = CTX_wm_space_image(C); SpaceImage *sima = CTX_wm_space_image(C);
Image *image = sima->image; Image *image = sima->image;
ImageUser iuser = sima->iuser; ImageUser iuser = sima->iuser;
@ -480,7 +481,7 @@ static int palette_extract_img_exec(bContext *C, wmOperator *op)
} }
/* Free memory. */ /* Free memory. */
BLI_ghash_free(color_table, NULL, NULL); BLI_ghash_free(color_table, nullptr, nullptr);
BKE_image_release_ibuf(image, ibuf, lock); BKE_image_release_ibuf(image, ibuf, lock);
if (done) { if (done) {
@ -508,7 +509,7 @@ static void PALETTE_OT_extract_from_image(wmOperatorType *ot)
/* properties */ /* properties */
prop = RNA_def_int(ot->srna, "threshold", 1, 1, 1, "Threshold", "", 1, 1); prop = RNA_def_int(ot->srna, "threshold", 1, 1, 1, "Threshold", "", 1, 1);
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); RNA_def_property_flag(prop, PropertyFlag(PROP_HIDDEN | PROP_SKIP_SAVE));
} }
/* Sort Palette color by Hue and Saturation. */ /* Sort Palette color by Hue and Saturation. */
@ -519,17 +520,17 @@ static int palette_sort_exec(bContext *C, wmOperator *op)
Paint *paint = BKE_paint_get_active_from_context(C); Paint *paint = BKE_paint_get_active_from_context(C);
Palette *palette = paint->palette; Palette *palette = paint->palette;
if (palette == NULL) { if (palette == nullptr) {
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
} }
tPaletteColorHSV *color_array = NULL; tPaletteColorHSV *color_array = nullptr;
tPaletteColorHSV *col_elm = NULL; tPaletteColorHSV *col_elm = nullptr;
const int totcol = BLI_listbase_count(&palette->colors); const int totcol = BLI_listbase_count(&palette->colors);
if (totcol > 0) { if (totcol > 0) {
color_array = MEM_calloc_arrayN(totcol, sizeof(tPaletteColorHSV), __func__); color_array = MEM_cnew_array<tPaletteColorHSV>(totcol, __func__);
/* Put all colors in an array. */ /* Put all colors in an array. */
int t = 0; int t = 0;
LISTBASE_FOREACH (PaletteColor *, color, &palette->colors) { LISTBASE_FOREACH (PaletteColor *, color, &palette->colors) {
@ -558,9 +559,7 @@ static int palette_sort_exec(bContext *C, wmOperator *op)
} }
/* Clear old color swatches. */ /* Clear old color swatches. */
PaletteColor *color_next = NULL; LISTBASE_FOREACH_MUTABLE (PaletteColor *, color, &palette->colors) {
for (PaletteColor *color = palette->colors.first; color; color = color_next) {
color_next = color->next;
BKE_palette_color_remove(palette, color); BKE_palette_color_remove(palette, color);
} }
@ -579,7 +578,7 @@ static int palette_sort_exec(bContext *C, wmOperator *op)
MEM_SAFE_FREE(color_array); MEM_SAFE_FREE(color_array);
} }
WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, NULL); WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, nullptr);
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
} }
@ -591,7 +590,7 @@ static void PALETTE_OT_sort(wmOperatorType *ot)
{2, "SVH", 0, "Saturation, Value, Hue", ""}, {2, "SVH", 0, "Saturation, Value, Hue", ""},
{3, "VHS", 0, "Value, Hue, Saturation", ""}, {3, "VHS", 0, "Value, Hue, Saturation", ""},
{4, "LUMINANCE", 0, "Luminance", ""}, {4, "LUMINANCE", 0, "Luminance", ""},
{0, NULL, 0, NULL, NULL}, {0, nullptr, 0, nullptr, nullptr},
}; };
/* identifiers */ /* identifiers */
@ -614,9 +613,10 @@ static int palette_color_move_exec(bContext *C, wmOperator *op)
{ {
Paint *paint = BKE_paint_get_active_from_context(C); Paint *paint = BKE_paint_get_active_from_context(C);
Palette *palette = paint->palette; Palette *palette = paint->palette;
PaletteColor *palcolor = BLI_findlink(&palette->colors, palette->active_color); PaletteColor *palcolor = static_cast<PaletteColor *>(
BLI_findlink(&palette->colors, palette->active_color));
if (palcolor == NULL) { if (palcolor == nullptr) {
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
} }
@ -625,7 +625,7 @@ static int palette_color_move_exec(bContext *C, wmOperator *op)
BLI_assert(ELEM(direction, -1, 0, 1)); /* we use value below */ BLI_assert(ELEM(direction, -1, 0, 1)); /* we use value below */
if (BLI_listbase_link_move(&palette->colors, palcolor, direction)) { if (BLI_listbase_link_move(&palette->colors, palcolor, direction)) {
palette->active_color += direction; palette->active_color += direction;
WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, NULL); WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, nullptr);
} }
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
@ -636,7 +636,7 @@ static void PALETTE_OT_color_move(wmOperatorType *ot)
static const EnumPropertyItem slot_move[] = { static const EnumPropertyItem slot_move[] = {
{-1, "UP", 0, "Up", ""}, {-1, "UP", 0, "Up", ""},
{1, "DOWN", 0, "Down", ""}, {1, "DOWN", 0, "Down", ""},
{0, NULL, 0, NULL, NULL}, {0, nullptr, 0, nullptr, nullptr},
}; };
/* identifiers */ /* identifiers */
@ -660,18 +660,18 @@ static int palette_join_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C); Main *bmain = CTX_data_main(C);
Paint *paint = BKE_paint_get_active_from_context(C); Paint *paint = BKE_paint_get_active_from_context(C);
Palette *palette = paint->palette; Palette *palette = paint->palette;
Palette *palette_join = NULL; Palette *palette_join = nullptr;
bool done = false; bool done = false;
char name[MAX_ID_NAME - 2]; char name[MAX_ID_NAME - 2];
RNA_string_get(op->ptr, "palette", name); RNA_string_get(op->ptr, "palette", name);
if ((palette == NULL) || (name[0] == '\0')) { if ((palette == nullptr) || (name[0] == '\0')) {
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
} }
palette_join = (Palette *)BKE_libblock_find_name(bmain, ID_PAL, name); palette_join = (Palette *)BKE_libblock_find_name(bmain, ID_PAL, name);
if (palette_join == NULL) { if (palette_join == nullptr) {
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
} }
@ -690,14 +690,12 @@ static int palette_join_exec(bContext *C, wmOperator *op)
if (done) { if (done) {
/* Clear old color swatches. */ /* Clear old color swatches. */
PaletteColor *color_next = NULL; LISTBASE_FOREACH_MUTABLE (PaletteColor *, color, &palette_join->colors) {
for (PaletteColor *color = palette_join->colors.first; color; color = color_next) {
color_next = color->next;
BKE_palette_color_remove(palette_join, color); BKE_palette_color_remove(palette_join, color);
} }
/* Notifier. */ /* Notifier. */
WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, NULL); WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, nullptr);
} }
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
@ -718,10 +716,10 @@ static void PALETTE_OT_join(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */ /* properties */
RNA_def_string(ot->srna, "palette", NULL, MAX_ID_NAME - 2, "Palette", "Name of the Palette"); RNA_def_string(ot->srna, "palette", nullptr, MAX_ID_NAME - 2, "Palette", "Name of the Palette");
} }
static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op)) static int brush_reset_exec(bContext *C, wmOperator * /*op*/)
{ {
Paint *paint = BKE_paint_get_active_from_context(C); Paint *paint = BKE_paint_get_active_from_context(C);
Brush *brush = BKE_paint_brush(paint); Brush *brush = BKE_paint_brush(paint);
@ -771,8 +769,8 @@ static Brush *brush_tool_cycle(Main *bmain, Paint *paint, Brush *brush_orig, con
{ {
Brush *brush, *first_brush; Brush *brush, *first_brush;
if (!brush_orig && !(brush_orig = bmain->brushes.first)) { if (!brush_orig && !(brush_orig = static_cast<Brush *>(bmain->brushes.first))) {
return NULL; return nullptr;
} }
if (brush_tool(brush_orig, paint->runtime.tool_offset) != tool) { if (brush_tool(brush_orig, paint->runtime.tool_offset) != tool) {
@ -784,8 +782,8 @@ static Brush *brush_tool_cycle(Main *bmain, Paint *paint, Brush *brush_orig, con
/* Try to tool-slot first. */ /* Try to tool-slot first. */
first_brush = BKE_paint_toolslots_brush_get(paint, tool); first_brush = BKE_paint_toolslots_brush_get(paint, tool);
if (first_brush == NULL) { if (first_brush == nullptr) {
first_brush = bmain->brushes.first; first_brush = static_cast<Brush *>(bmain->brushes.first);
} }
} }
else { else {
@ -793,7 +791,8 @@ static Brush *brush_tool_cycle(Main *bmain, Paint *paint, Brush *brush_orig, con
* currently active brush do a cycling via all possible * currently active brush do a cycling via all possible
* brushes with requested tool. * brushes with requested tool.
*/ */
first_brush = brush_orig->id.next ? brush_orig->id.next : bmain->brushes.first; first_brush = brush_orig->id.next ? static_cast<Brush *>(brush_orig->id.next) :
static_cast<Brush *>(bmain->brushes.first);
} }
/* get the next brush with the active tool */ /* get the next brush with the active tool */
@ -804,10 +803,11 @@ static Brush *brush_tool_cycle(Main *bmain, Paint *paint, Brush *brush_orig, con
return brush; return brush;
} }
brush = brush->id.next ? brush->id.next : bmain->brushes.first; brush = brush->id.next ? static_cast<Brush *>(brush->id.next) :
static_cast<Brush *>(bmain->brushes.first);
} while (brush != first_brush); } while (brush != first_brush);
return NULL; return nullptr;
} }
static Brush *brush_tool_toggle(Main *bmain, Paint *paint, Brush *brush_orig, const int tool) static Brush *brush_tool_toggle(Main *bmain, Paint *paint, Brush *brush_orig, const int tool)
@ -829,7 +829,7 @@ static Brush *brush_tool_toggle(Main *bmain, Paint *paint, Brush *brush_orig, co
* back to the previously selected brush. */ * back to the previously selected brush. */
return brush_orig->toggle_brush; return brush_orig->toggle_brush;
} }
return NULL; return nullptr;
} }
static bool brush_generic_tool_set(bContext *C, static bool brush_generic_tool_set(bContext *C,
@ -849,9 +849,9 @@ static bool brush_generic_tool_set(bContext *C,
brush = brush_tool_cycle(bmain, paint, brush_orig, tool); brush = brush_tool_cycle(bmain, paint, brush_orig, tool);
} }
if (((brush == NULL) && create_missing) && if (((brush == nullptr) && create_missing) &&
((brush_orig == NULL) || brush_tool(brush_orig, paint->runtime.tool_offset) != tool)) { ((brush_orig == nullptr) || brush_tool(brush_orig, paint->runtime.tool_offset) != tool)) {
brush = BKE_brush_add(bmain, tool_name, paint->runtime.ob_mode); brush = BKE_brush_add(bmain, tool_name, eObjectMode(paint->runtime.ob_mode));
id_us_min(&brush->id); /* fake user only */ id_us_min(&brush->id); /* fake user only */
brush_tool_set(brush, paint->runtime.tool_offset, tool); brush_tool_set(brush, paint->runtime.tool_offset, tool);
brush->toggle_brush = brush_orig; brush->toggle_brush = brush_orig;
@ -918,7 +918,7 @@ static int brush_select_exec(bContext *C, wmOperator *op)
} }
Paint *paint = BKE_paint_get_active_from_paintmode(scene, paint_mode); Paint *paint = BKE_paint_get_active_from_paintmode(scene, paint_mode);
if (paint == NULL) { if (paint == nullptr) {
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
} }
const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode); const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
@ -957,34 +957,34 @@ static void PAINT_OT_brush_select(wmOperatorType *ot)
prop = RNA_def_boolean( prop = RNA_def_boolean(
ot->srna, "toggle", 0, "Toggle", "Toggle between two brushes rather than cycling"); ot->srna, "toggle", 0, "Toggle", "Toggle between two brushes rather than cycling");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); RNA_def_property_flag(prop, PropertyFlag(PROP_HIDDEN | PROP_SKIP_SAVE));
prop = RNA_def_boolean(ot->srna, prop = RNA_def_boolean(ot->srna,
"create_missing", "create_missing",
0, 0,
"Create Missing", "Create Missing",
"If the requested brush type does not exist, create a new brush"); "If the requested brush type does not exist, create a new brush");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); RNA_def_property_flag(prop, PropertyFlag(PROP_HIDDEN | PROP_SKIP_SAVE));
} }
/***** Stencil Control *****/ /***** Stencil Control *****/
typedef enum { enum StencilControlMode {
STENCIL_TRANSLATE, STENCIL_TRANSLATE,
STENCIL_SCALE, STENCIL_SCALE,
STENCIL_ROTATE, STENCIL_ROTATE,
} StencilControlMode; };
typedef enum { enum StencilTextureMode {
STENCIL_PRIMARY = 0, STENCIL_PRIMARY = 0,
STENCIL_SECONDARY = 1, STENCIL_SECONDARY = 1,
} StencilTextureMode; };
typedef enum { enum StencilConstraint {
STENCIL_CONSTRAINT_X = 1, STENCIL_CONSTRAINT_X = 1,
STENCIL_CONSTRAINT_Y = 2, STENCIL_CONSTRAINT_Y = 2,
} StencilConstraint; };
typedef struct { struct StencilControlData {
float init_mouse[2]; float init_mouse[2];
float init_spos[2]; float init_spos[2];
float init_sdim[2]; float init_sdim[2];
@ -1001,7 +1001,7 @@ typedef struct {
float *rot_target; float *rot_target;
float *pos_target; float *pos_target;
short launch_event; short launch_event;
} StencilControlData; };
static void stencil_set_target(StencilControlData *scd) static void stencil_set_target(StencilControlData *scd)
{ {
@ -1039,7 +1039,7 @@ static int stencil_control_invoke(bContext *C, wmOperator *op, const wmEvent *ev
{ {
Paint *paint = BKE_paint_get_active_from_context(C); Paint *paint = BKE_paint_get_active_from_context(C);
Brush *br = BKE_paint_brush(paint); Brush *br = BKE_paint_brush(paint);
const float mvalf[2] = {event->mval[0], event->mval[1]}; const float mvalf[2] = {float(event->mval[0]), float(event->mval[1])};
ARegion *region = CTX_wm_region(C); ARegion *region = CTX_wm_region(C);
StencilControlData *scd; StencilControlData *scd;
int mask = RNA_enum_get(op->ptr, "texmode"); int mask = RNA_enum_get(op->ptr, "texmode");
@ -1055,7 +1055,7 @@ static int stencil_control_invoke(bContext *C, wmOperator *op, const wmEvent *ev
} }
} }
scd = MEM_mallocN(sizeof(StencilControlData), "stencil_control"); scd = static_cast<StencilControlData *>(MEM_mallocN(sizeof(StencilControlData), __func__));
scd->mask = mask; scd->mask = mask;
scd->br = br; scd->br = br;
@ -1063,7 +1063,7 @@ static int stencil_control_invoke(bContext *C, wmOperator *op, const wmEvent *ev
stencil_set_target(scd); stencil_set_target(scd);
scd->mode = RNA_enum_get(op->ptr, "mode"); scd->mode = StencilControlMode(RNA_enum_get(op->ptr, "mode"));
scd->launch_event = WM_userdef_event_type_from_keymap_type(event->type); scd->launch_event = WM_userdef_event_type_from_keymap_type(event->type);
scd->area_size[0] = region->winx; scd->area_size[0] = region->winx;
scd->area_size[1] = region->winy; scd->area_size[1] = region->winy;
@ -1081,12 +1081,11 @@ static void stencil_restore(StencilControlData *scd)
*scd->rot_target = scd->init_rot; *scd->rot_target = scd->init_rot;
} }
static void stencil_control_cancel(bContext *UNUSED(C), wmOperator *op) static void stencil_control_cancel(bContext * /*C*/, wmOperator *op)
{ {
StencilControlData *scd = op->customdata; StencilControlData *scd = static_cast<StencilControlData *>(op->customdata);
stencil_restore(scd); stencil_restore(scd);
MEM_freeN(op->customdata); MEM_freeN(scd);
} }
static void stencil_control_calculate(StencilControlData *scd, const int mval[2]) static void stencil_control_calculate(StencilControlData *scd, const int mval[2])
@ -1094,7 +1093,7 @@ static void stencil_control_calculate(StencilControlData *scd, const int mval[2]
#define PIXEL_MARGIN 5 #define PIXEL_MARGIN 5
float mdiff[2]; float mdiff[2];
const float mvalf[2] = {mval[0], mval[1]}; const float mvalf[2] = {float(mval[0]), float(mval[1])};
switch (scd->mode) { switch (scd->mode) {
case STENCIL_TRANSLATE: case STENCIL_TRANSLATE:
sub_v2_v2v2(mdiff, mvalf, scd->init_mouse); sub_v2_v2v2(mdiff, mvalf, scd->init_mouse);
@ -1144,11 +1143,11 @@ static void stencil_control_calculate(StencilControlData *scd, const int mval[2]
static int stencil_control_modal(bContext *C, wmOperator *op, const wmEvent *event) static int stencil_control_modal(bContext *C, wmOperator *op, const wmEvent *event)
{ {
StencilControlData *scd = op->customdata; StencilControlData *scd = static_cast<StencilControlData *>(op->customdata);
if (event->type == scd->launch_event && event->val == KM_RELEASE) { if (event->type == scd->launch_event && event->val == KM_RELEASE) {
MEM_freeN(op->customdata); MEM_freeN(op->customdata);
WM_event_add_notifier(C, NC_WINDOW, NULL); WM_event_add_notifier(C, NC_WINDOW, nullptr);
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
} }
@ -1159,7 +1158,7 @@ static int stencil_control_modal(bContext *C, wmOperator *op, const wmEvent *eve
case EVT_ESCKEY: case EVT_ESCKEY:
if (event->val == KM_PRESS) { if (event->val == KM_PRESS) {
stencil_control_cancel(C, op); stencil_control_cancel(C, op);
WM_event_add_notifier(C, NC_WINDOW, NULL); WM_event_add_notifier(C, NC_WINDOW, nullptr);
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
} }
break; break;
@ -1167,7 +1166,7 @@ static int stencil_control_modal(bContext *C, wmOperator *op, const wmEvent *eve
if (event->val == KM_PRESS) { if (event->val == KM_PRESS) {
if (scd->constrain_mode == STENCIL_CONSTRAINT_X) { if (scd->constrain_mode == STENCIL_CONSTRAINT_X) {
scd->constrain_mode = 0; scd->constrain_mode = StencilConstraint(0);
} }
else { else {
scd->constrain_mode = STENCIL_CONSTRAINT_X; scd->constrain_mode = STENCIL_CONSTRAINT_X;
@ -1179,7 +1178,7 @@ static int stencil_control_modal(bContext *C, wmOperator *op, const wmEvent *eve
case EVT_YKEY: case EVT_YKEY:
if (event->val == KM_PRESS) { if (event->val == KM_PRESS) {
if (scd->constrain_mode == STENCIL_CONSTRAINT_Y) { if (scd->constrain_mode == STENCIL_CONSTRAINT_Y) {
scd->constrain_mode = 0; scd->constrain_mode = StencilConstraint(0);
} }
else { else {
scd->constrain_mode = STENCIL_CONSTRAINT_Y; scd->constrain_mode = STENCIL_CONSTRAINT_Y;
@ -1220,13 +1219,13 @@ static void BRUSH_OT_stencil_control(wmOperatorType *ot)
{STENCIL_TRANSLATE, "TRANSLATION", 0, "Translation", ""}, {STENCIL_TRANSLATE, "TRANSLATION", 0, "Translation", ""},
{STENCIL_SCALE, "SCALE", 0, "Scale", ""}, {STENCIL_SCALE, "SCALE", 0, "Scale", ""},
{STENCIL_ROTATE, "ROTATION", 0, "Rotation", ""}, {STENCIL_ROTATE, "ROTATION", 0, "Rotation", ""},
{0, NULL, 0, NULL, NULL}, {0, nullptr, 0, nullptr, nullptr},
}; };
static const EnumPropertyItem stencil_texture_items[] = { static const EnumPropertyItem stencil_texture_items[] = {
{STENCIL_PRIMARY, "PRIMARY", 0, "Primary", ""}, {STENCIL_PRIMARY, "PRIMARY", 0, "Primary", ""},
{STENCIL_SECONDARY, "SECONDARY", 0, "Secondary", ""}, {STENCIL_SECONDARY, "SECONDARY", 0, "Secondary", ""},
{0, NULL, 0, NULL, NULL}, {0, nullptr, 0, nullptr, nullptr},
}; };
/* identifiers */ /* identifiers */
ot->name = "Stencil Brush Control"; ot->name = "Stencil Brush Control";
@ -1244,9 +1243,9 @@ static void BRUSH_OT_stencil_control(wmOperatorType *ot)
PropertyRNA *prop; PropertyRNA *prop;
prop = RNA_def_enum(ot->srna, "mode", stencil_control_items, STENCIL_TRANSLATE, "Tool", ""); prop = RNA_def_enum(ot->srna, "mode", stencil_control_items, STENCIL_TRANSLATE, "Tool", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); RNA_def_property_flag(prop, PropertyFlag(PROP_HIDDEN | PROP_SKIP_SAVE));
prop = RNA_def_enum(ot->srna, "texmode", stencil_texture_items, STENCIL_PRIMARY, "Tool", ""); prop = RNA_def_enum(ot->srna, "texmode", stencil_texture_items, STENCIL_PRIMARY, "Tool", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); RNA_def_property_flag(prop, PropertyFlag(PROP_HIDDEN | PROP_SKIP_SAVE));
} }
static int stencil_fit_image_aspect_exec(bContext *C, wmOperator *op) static int stencil_fit_image_aspect_exec(bContext *C, wmOperator *op)
@ -1256,8 +1255,8 @@ static int stencil_fit_image_aspect_exec(bContext *C, wmOperator *op)
bool use_scale = RNA_boolean_get(op->ptr, "use_scale"); bool use_scale = RNA_boolean_get(op->ptr, "use_scale");
bool use_repeat = RNA_boolean_get(op->ptr, "use_repeat"); bool use_repeat = RNA_boolean_get(op->ptr, "use_repeat");
bool do_mask = RNA_boolean_get(op->ptr, "mask"); bool do_mask = RNA_boolean_get(op->ptr, "mask");
Tex *tex = NULL; Tex *tex = nullptr;
MTex *mtex = NULL; MTex *mtex = nullptr;
if (br) { if (br) {
mtex = do_mask ? &br->mask_mtex : &br->mtex; mtex = do_mask ? &br->mask_mtex : &br->mtex;
tex = mtex->tex; tex = mtex->tex;
@ -1267,7 +1266,7 @@ static int stencil_fit_image_aspect_exec(bContext *C, wmOperator *op)
float aspx, aspy; float aspx, aspy;
Image *ima = tex->ima; Image *ima = tex->ima;
float orig_area, stencil_area, factor; float orig_area, stencil_area, factor;
ED_image_get_uv_aspect(ima, NULL, &aspx, &aspy); ED_image_get_uv_aspect(ima, nullptr, &aspx, &aspy);
if (use_scale) { if (use_scale) {
aspx *= mtex->size[0]; aspx *= mtex->size[0];
@ -1300,7 +1299,7 @@ static int stencil_fit_image_aspect_exec(bContext *C, wmOperator *op)
} }
} }
WM_event_add_notifier(C, NC_WINDOW, NULL); WM_event_add_notifier(C, NC_WINDOW, nullptr);
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
} }
@ -1355,7 +1354,7 @@ static int stencil_reset_transform_exec(bContext *C, wmOperator *op)
br->mtex.rot = 0; br->mtex.rot = 0;
} }
WM_event_add_notifier(C, NC_WINDOW, NULL); WM_event_add_notifier(C, NC_WINDOW, nullptr);
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
} }

View File

@ -5,6 +5,9 @@
* \ingroup edsculpt * \ingroup edsculpt
*/ */
#include <cfloat>
#include <cmath>
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
#include "BLI_listbase.h" #include "BLI_listbase.h"
@ -40,10 +43,7 @@
#include "IMB_imbuf_types.h" #include "IMB_imbuf_types.h"
#include "paint_intern.h" #include "paint_intern.h"
#include "sculpt_intern.h" #include "sculpt_intern.hh"
#include <float.h>
#include <math.h>
//#define DEBUG_TIME //#define DEBUG_TIME
@ -51,16 +51,16 @@
# include "PIL_time_utildefines.h" # include "PIL_time_utildefines.h"
#endif #endif
typedef struct PaintSample { struct PaintSample {
float mouse[2]; float mouse[2];
float pressure; float pressure;
} PaintSample; };
typedef struct PaintStroke { struct PaintStroke {
void *mode_data; void *mode_data;
void *stroke_cursor; void *stroke_cursor;
wmTimer *timer; wmTimer *timer;
struct RNG *rng; RNG *rng;
/* Cached values */ /* Cached values */
ViewContext vc; ViewContext vc;
@ -124,14 +124,14 @@ typedef struct PaintStroke {
StrokeDone done; StrokeDone done;
bool original; /* Ray-cast original mesh at start of stroke. */ bool original; /* Ray-cast original mesh at start of stroke. */
} PaintStroke; };
/*** Cursors ***/ /*** Cursors ***/
static void paint_draw_smooth_cursor(bContext *C, int x, int y, void *customdata) static void paint_draw_smooth_cursor(bContext *C, int x, int y, void *customdata)
{ {
Paint *paint = BKE_paint_get_active_from_context(C); Paint *paint = BKE_paint_get_active_from_context(C);
Brush *brush = BKE_paint_brush(paint); Brush *brush = BKE_paint_brush(paint);
PaintStroke *stroke = customdata; PaintStroke *stroke = static_cast<PaintStroke *>(customdata);
if (stroke && brush) { if (stroke && brush) {
GPU_line_smooth(true); GPU_line_smooth(true);
@ -161,7 +161,7 @@ static void paint_draw_smooth_cursor(bContext *C, int x, int y, void *customdata
static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata) static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata)
{ {
Paint *paint = BKE_paint_get_active_from_context(C); Paint *paint = BKE_paint_get_active_from_context(C);
PaintStroke *stroke = customdata; PaintStroke *stroke = static_cast<PaintStroke *>(customdata);
GPU_line_smooth(true); GPU_line_smooth(true);
@ -247,7 +247,7 @@ static bool paint_stroke_use_scene_spacing(Brush *brush, ePaintMode mode)
return false; return false;
} }
static bool paint_tool_raycast_original(Brush *brush, ePaintMode UNUSED(mode)) static bool paint_tool_raycast_original(Brush *brush, ePaintMode /*mode*/)
{ {
return brush->flag & (BRUSH_ANCHORED | BRUSH_DRAG_DOT); return brush->flag & (BRUSH_ANCHORED | BRUSH_DRAG_DOT);
} }
@ -285,7 +285,7 @@ static bool paint_tool_require_inbetween_mouse_events(Brush *brush, ePaintMode m
static bool paint_brush_update(bContext *C, static bool paint_brush_update(bContext *C,
Brush *brush, Brush *brush,
ePaintMode mode, ePaintMode mode,
struct PaintStroke *stroke, PaintStroke *stroke,
const float mouse_init[2], const float mouse_init[2],
float mouse[2], float mouse[2],
float pressure, float pressure,
@ -315,18 +315,18 @@ static bool paint_brush_update(bContext *C,
stroke->cached_size_pressure = pressure; stroke->cached_size_pressure = pressure;
ups->do_linear_conversion = false; ups->do_linear_conversion = false;
ups->colorspace = NULL; ups->colorspace = nullptr;
/* check here if color sampling the main brush should do color conversion. This is done here /* check here if color sampling the main brush should do color conversion. This is done here
* to avoid locking up to get the image buffer during sampling */ * to avoid locking up to get the image buffer during sampling */
if (brush->mtex.tex && brush->mtex.tex->type == TEX_IMAGE && brush->mtex.tex->ima) { if (brush->mtex.tex && brush->mtex.tex->type == TEX_IMAGE && brush->mtex.tex->ima) {
ImBuf *tex_ibuf = BKE_image_pool_acquire_ibuf( ImBuf *tex_ibuf = BKE_image_pool_acquire_ibuf(
brush->mtex.tex->ima, &brush->mtex.tex->iuser, NULL); brush->mtex.tex->ima, &brush->mtex.tex->iuser, nullptr);
if (tex_ibuf && tex_ibuf->rect_float == NULL) { if (tex_ibuf && tex_ibuf->rect_float == nullptr) {
ups->do_linear_conversion = true; ups->do_linear_conversion = true;
ups->colorspace = tex_ibuf->rect_colorspace; ups->colorspace = tex_ibuf->rect_colorspace;
} }
BKE_image_pool_release_ibuf(brush->mtex.tex->ima, tex_ibuf, NULL); BKE_image_pool_release_ibuf(brush->mtex.tex->ima, tex_ibuf, nullptr);
} }
stroke->brush_init = true; stroke->brush_init = true;
@ -452,7 +452,7 @@ static bool paint_brush_update(bContext *C,
} }
} }
if ((do_random || do_random_mask) && stroke->rng == NULL) { if ((do_random || do_random_mask) && stroke->rng == nullptr) {
/* Lazy initialization. */ /* Lazy initialization. */
uint rng_seed = (uint)(PIL_check_seconds_timer_i() & UINT_MAX); uint rng_seed = (uint)(PIL_check_seconds_timer_i() & UINT_MAX);
rng_seed ^= (uint)POINTER_AS_INT(brush); rng_seed ^= (uint)POINTER_AS_INT(brush);
@ -896,8 +896,8 @@ PaintStroke *paint_stroke_new(bContext *C,
StrokeDone done, StrokeDone done,
int event_type) int event_type)
{ {
struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
PaintStroke *stroke = MEM_callocN(sizeof(PaintStroke), "PaintStroke"); PaintStroke *stroke = MEM_cnew<PaintStroke>(__func__);
ToolSettings *toolsettings = CTX_data_tool_settings(C); ToolSettings *toolsettings = CTX_data_tool_settings(C);
UnifiedPaintSettings *ups = &toolsettings->unified_paint_settings; UnifiedPaintSettings *ups = &toolsettings->unified_paint_settings;
Paint *p = BKE_paint_get_active_from_context(C); Paint *p = BKE_paint_get_active_from_context(C);
@ -948,23 +948,23 @@ PaintStroke *paint_stroke_new(bContext *C,
BKE_curvemapping_init(p->cavity_curve); BKE_curvemapping_init(p->cavity_curve);
} }
BKE_paint_set_overlay_override(br->overlay_flags); BKE_paint_set_overlay_override(eOverlayFlags(br->overlay_flags));
ups->start_pixel_radius = BKE_brush_size_get(CTX_data_scene(C), br); ups->start_pixel_radius = BKE_brush_size_get(CTX_data_scene(C), br);
return stroke; return stroke;
} }
void paint_stroke_free(bContext *C, wmOperator *UNUSED(op), PaintStroke *stroke) void paint_stroke_free(bContext *C, wmOperator * /*op*/, PaintStroke *stroke)
{ {
RegionView3D *rv3d = CTX_wm_region_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C);
if (rv3d) { if (rv3d) {
rv3d->rflag &= ~RV3D_PAINTING; rv3d->rflag &= ~RV3D_PAINTING;
} }
BKE_paint_set_overlay_override(0); BKE_paint_set_overlay_override(eOverlayFlags(0));
if (stroke == NULL) { if (stroke == nullptr) {
return; return;
} }
@ -981,7 +981,7 @@ void paint_stroke_free(bContext *C, wmOperator *UNUSED(op), PaintStroke *stroke)
} }
if (stroke->stroke_cursor) { if (stroke->stroke_cursor) {
WM_paint_cursor_end(stroke->stroke_cursor); WM_paint_cursor_end(static_cast<wmPaintCursor *>(stroke->stroke_cursor));
} }
BLI_freelistN(&stroke->line); BLI_freelistN(&stroke->line);
@ -1035,7 +1035,7 @@ bool paint_space_stroke_enabled(Brush *br, ePaintMode mode)
} }
if (mode == PAINT_MODE_SCULPT_CURVES && if (mode == PAINT_MODE_SCULPT_CURVES &&
!curves_sculpt_brush_uses_spacing(br->curves_sculpt_tool)) { !curves_sculpt_brush_uses_spacing(eBrushCurvesSculptTool(br->curves_sculpt_tool))) {
return false; return false;
} }
@ -1130,16 +1130,16 @@ bool paint_supports_dynamic_tex_coords(Brush *br, ePaintMode mode)
#define PAINT_STROKE_MODAL_CANCEL 1 #define PAINT_STROKE_MODAL_CANCEL 1
struct wmKeyMap *paint_stroke_modal_keymap(struct wmKeyConfig *keyconf) wmKeyMap *paint_stroke_modal_keymap(wmKeyConfig *keyconf)
{ {
static struct EnumPropertyItem modal_items[] = { static EnumPropertyItem modal_items[] = {
{PAINT_STROKE_MODAL_CANCEL, "CANCEL", 0, "Cancel", "Cancel and undo a stroke in progress"}, {PAINT_STROKE_MODAL_CANCEL, "CANCEL", 0, "Cancel", "Cancel and undo a stroke in progress"},
{0}}; {0}};
static const char *name = "Paint Stroke Modal"; static const char *name = "Paint Stroke Modal";
struct wmKeyMap *keymap = WM_modalkeymap_find(keyconf, name); wmKeyMap *keymap = WM_modalkeymap_find(keyconf, name);
/* This function is called for each space-type, only needs to add map once. */ /* This function is called for each space-type, only needs to add map once. */
if (!keymap) { if (!keymap) {
@ -1440,7 +1440,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event, PaintS
/* see if tablet affects event. Line, anchored and drag dot strokes do not support pressure */ /* see if tablet affects event. Line, anchored and drag dot strokes do not support pressure */
pressure = ((br->flag & (BRUSH_LINE | BRUSH_ANCHORED | BRUSH_DRAG_DOT)) ? pressure = ((br->flag & (BRUSH_LINE | BRUSH_ANCHORED | BRUSH_DRAG_DOT)) ?
1.0f : 1.0f :
WM_event_tablet_data(event, &stroke->pen_flip, NULL)); WM_event_tablet_data(event, &stroke->pen_flip, nullptr));
/* When processing a timer event the pressure from the event is 0, so use the last valid /* When processing a timer event the pressure from the event is 0, so use the last valid
* pressure. */ * pressure. */
@ -1473,7 +1473,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event, PaintS
/* one time initialization */ /* one time initialization */
if (!stroke->stroke_init) { if (!stroke->stroke_init) {
if (paint_stroke_curve_end(C, op, stroke)) { if (paint_stroke_curve_end(C, op, stroke)) {
*stroke_p = NULL; *stroke_p = nullptr;
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
} }
@ -1530,14 +1530,14 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event, PaintS
paint_stroke_line_constrain(stroke, mouse); paint_stroke_line_constrain(stroke, mouse);
paint_stroke_line_end(C, op, stroke, mouse); paint_stroke_line_end(C, op, stroke, mouse);
stroke_done(C, op, stroke); stroke_done(C, op, stroke);
*stroke_p = NULL; *stroke_p = nullptr;
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
} }
} }
else if (ELEM(event->type, EVT_RETKEY, EVT_SPACEKEY)) { else if (ELEM(event->type, EVT_RETKEY, EVT_SPACEKEY)) {
paint_stroke_line_end(C, op, stroke, sample_average.mouse); paint_stroke_line_end(C, op, stroke, sample_average.mouse);
stroke_done(C, op, stroke); stroke_done(C, op, stroke);
*stroke_p = NULL; *stroke_p = nullptr;
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
} }
else if (br->flag & BRUSH_LINE) { else if (br->flag & BRUSH_LINE) {
@ -1650,22 +1650,22 @@ ViewContext *paint_stroke_view_context(PaintStroke *stroke)
return &stroke->vc; return &stroke->vc;
} }
void *paint_stroke_mode_data(struct PaintStroke *stroke) void *paint_stroke_mode_data(PaintStroke *stroke)
{ {
return stroke->mode_data; return stroke->mode_data;
} }
bool paint_stroke_flipped(struct PaintStroke *stroke) bool paint_stroke_flipped(PaintStroke *stroke)
{ {
return stroke->pen_flip; return stroke->pen_flip;
} }
bool paint_stroke_inverted(struct PaintStroke *stroke) bool paint_stroke_inverted(PaintStroke *stroke)
{ {
return stroke->stroke_mode == BRUSH_STROKE_INVERT; return stroke->stroke_mode == BRUSH_STROKE_INVERT;
} }
float paint_stroke_distance_get(struct PaintStroke *stroke) float paint_stroke_distance_get(PaintStroke *stroke)
{ {
return stroke->stroke_distance; return stroke->stroke_distance;
} }

View File

@ -65,7 +65,7 @@
#include "bmesh.h" #include "bmesh.h"
#include "paint_intern.h" /* own include */ #include "paint_intern.h" /* own include */
#include "sculpt_intern.h" #include "sculpt_intern.hh"
using blender::IndexRange; using blender::IndexRange;
using namespace blender; using namespace blender;

View File

@ -68,7 +68,7 @@
#include "ED_view3d.h" #include "ED_view3d.h"
#include "paint_intern.h" #include "paint_intern.h"
#include "sculpt_intern.h" #include "sculpt_intern.hh"
#include "RNA_access.h" #include "RNA_access.h"
#include "RNA_define.h" #include "RNA_define.h"

View File

@ -42,7 +42,7 @@
#include "ED_screen.h" #include "ED_screen.h"
#include "ED_sculpt.h" #include "ED_sculpt.h"
#include "paint_intern.h" #include "paint_intern.h"
#include "sculpt_intern.h" #include "sculpt_intern.hh"
#include "RNA_access.h" #include "RNA_access.h"
#include "RNA_define.h" #include "RNA_define.h"

View File

@ -23,7 +23,7 @@
#include "BKE_pbvh.h" #include "BKE_pbvh.h"
#include "paint_intern.h" #include "paint_intern.h"
#include "sculpt_intern.h" #include "sculpt_intern.hh"
#include "GPU_immediate.h" #include "GPU_immediate.h"
#include "GPU_state.h" #include "GPU_state.h"

View File

@ -31,7 +31,7 @@
#include "ED_view3d.h" #include "ED_view3d.h"
#include "paint_intern.h" #include "paint_intern.h"
#include "sculpt_intern.h" #include "sculpt_intern.hh"
#include "bmesh.h" #include "bmesh.h"

View File

@ -35,7 +35,7 @@
#include "WM_api.h" #include "WM_api.h"
#include "WM_types.h" #include "WM_types.h"
#include "sculpt_intern.h" #include "sculpt_intern.hh"
#include "RNA_access.h" #include "RNA_access.h"
#include "RNA_define.h" #include "RNA_define.h"

View File

@ -32,7 +32,7 @@
#include "ED_screen.h" #include "ED_screen.h"
#include "ED_space_api.h" #include "ED_space_api.h"
#include "ED_view3d.h" #include "ED_view3d.h"
#include "sculpt_intern.h" #include "sculpt_intern.hh"
#include "RNA_access.h" #include "RNA_access.h"
#include "RNA_define.h" #include "RNA_define.h"

View File

@ -34,7 +34,7 @@
#include "WM_types.h" #include "WM_types.h"
#include "ED_undo.h" #include "ED_undo.h"
#include "sculpt_intern.h" #include "sculpt_intern.hh"
#include "UI_interface.h" #include "UI_interface.h"
#include "UI_resources.h" #include "UI_resources.h"

View File

@ -44,7 +44,7 @@
#include "ED_screen.h" #include "ED_screen.h"
#include "ED_sculpt.h" #include "ED_sculpt.h"
#include "paint_intern.h" #include "paint_intern.h"
#include "sculpt_intern.h" #include "sculpt_intern.hh"
#include "IMB_colormanagement.h" #include "IMB_colormanagement.h"
#include "IMB_imbuf.h" #include "IMB_imbuf.h"

View File

@ -46,7 +46,7 @@
#include "ED_sculpt.h" #include "ED_sculpt.h"
#include "sculpt_intern.h" #include "sculpt_intern.hh"
#include "RNA_access.h" #include "RNA_access.h"
#include "RNA_define.h" #include "RNA_define.h"

View File

@ -25,7 +25,7 @@
#include "WM_types.h" #include "WM_types.h"
#include "ED_paint.h" #include "ED_paint.h"
#include "sculpt_intern.h" #include "sculpt_intern.hh"
#include "RNA_access.h" #include "RNA_access.h"
#include "RNA_define.h" #include "RNA_define.h"

View File

@ -23,7 +23,7 @@
#include "WM_api.h" #include "WM_api.h"
#include "WM_types.h" #include "WM_types.h"
#include "sculpt_intern.h" #include "sculpt_intern.hh"
#include "RNA_access.h" #include "RNA_access.h"
#include "RNA_define.h" #include "RNA_define.h"

View File

@ -26,7 +26,7 @@
#include "ED_view3d.h" #include "ED_view3d.h"
#include "paint_intern.h" #include "paint_intern.h"
#include "sculpt_intern.h" #include "sculpt_intern.hh"
#include "RNA_access.h" #include "RNA_access.h"
#include "RNA_define.h" #include "RNA_define.h"

View File

@ -28,7 +28,7 @@
#include "BKE_pbvh.h" #include "BKE_pbvh.h"
#include "paint_intern.h" #include "paint_intern.h"
#include "sculpt_intern.h" #include "sculpt_intern.hh"
#include "bmesh.h" #include "bmesh.h"

View File

@ -31,7 +31,7 @@
#include "RNA_define.h" #include "RNA_define.h"
#include "ED_screen.h" #include "ED_screen.h"
#include "sculpt_intern.h" #include "sculpt_intern.hh"
#include "bmesh.h" #include "bmesh.h"

View File

@ -32,7 +32,7 @@
#include "RNA_access.h" #include "RNA_access.h"
#include "RNA_define.h" #include "RNA_define.h"
#include "sculpt_intern.h" #include "sculpt_intern.hh"
#include "bmesh.h" #include "bmesh.h"

View File

@ -17,7 +17,7 @@
#include "BKE_paint.h" #include "BKE_paint.h"
#include "BKE_pbvh.h" #include "BKE_pbvh.h"
#include "sculpt_intern.h" #include "sculpt_intern.hh"
#include "GPU_immediate.h" #include "GPU_immediate.h"
#include "GPU_matrix.h" #include "GPU_matrix.h"

View File

@ -57,7 +57,7 @@
#include "ED_sculpt.h" #include "ED_sculpt.h"
#include "paint_intern.h" #include "paint_intern.h"
#include "sculpt_intern.h" #include "sculpt_intern.hh"
#include "RNA_access.h" #include "RNA_access.h"
#include "RNA_define.h" #include "RNA_define.h"

View File

@ -23,7 +23,7 @@
#include "IMB_colormanagement.h" #include "IMB_colormanagement.h"
#include "sculpt_intern.h" #include "sculpt_intern.hh"
#include "IMB_imbuf.h" #include "IMB_imbuf.h"

View File

@ -26,7 +26,7 @@
#include "bmesh.h" #include "bmesh.h"
#include "sculpt_intern.h" #include "sculpt_intern.hh"
namespace blender::ed::sculpt_paint::paint::image { namespace blender::ed::sculpt_paint::paint::image {
@ -514,8 +514,6 @@ static void do_mark_dirty_regions(void *__restrict userdata,
} // namespace blender::ed::sculpt_paint::paint::image } // namespace blender::ed::sculpt_paint::paint::image
extern "C" {
using namespace blender::ed::sculpt_paint::paint::image; using namespace blender::ed::sculpt_paint::paint::image;
bool SCULPT_paint_image_canvas_get(PaintModeSettings *paint_mode_settings, bool SCULPT_paint_image_canvas_get(PaintModeSettings *paint_mode_settings,
@ -576,4 +574,3 @@ void SCULPT_do_paint_brush_image(PaintModeSettings *paint_mode_settings,
BKE_pbvh_parallel_range_settings(&settings_flush, false, texnodes_num); BKE_pbvh_parallel_range_settings(&settings_flush, false, texnodes_num);
BLI_task_parallel_range(0, texnodes_num, &data, do_mark_dirty_regions, &settings_flush); BLI_task_parallel_range(0, texnodes_num, &data, do_mark_dirty_regions, &settings_flush);
} }
}

View File

@ -22,7 +22,7 @@
#include "BKE_pbvh.h" #include "BKE_pbvh.h"
#include "paint_intern.h" #include "paint_intern.h"
#include "sculpt_intern.h" #include "sculpt_intern.hh"
#include "bmesh.h" #include "bmesh.h"

View File

@ -17,7 +17,7 @@
#include "BKE_paint.h" #include "BKE_paint.h"
#include "BKE_pbvh.h" #include "BKE_pbvh.h"
#include "sculpt_intern.h" #include "sculpt_intern.hh"
#include "bmesh.h" #include "bmesh.h"

View File

@ -27,7 +27,7 @@
#include "ED_sculpt.h" #include "ED_sculpt.h"
#include "ED_view3d.h" #include "ED_view3d.h"
#include "paint_intern.h" #include "paint_intern.h"
#include "sculpt_intern.h" #include "sculpt_intern.hh"
#include "RNA_access.h" #include "RNA_access.h"
#include "RNA_define.h" #include "RNA_define.h"

View File

@ -79,7 +79,7 @@
#include "ED_undo.h" #include "ED_undo.h"
#include "bmesh.h" #include "bmesh.h"
#include "sculpt_intern.h" #include "sculpt_intern.hh"
/* Uncomment to print the undo stack in the console on push/undo/redo. */ /* Uncomment to print the undo stack in the console on push/undo/redo. */
//#define SCULPT_UNDO_DEBUG //#define SCULPT_UNDO_DEBUG

View File

@ -28,7 +28,7 @@ set(INC_SYS
set(SRC set(SRC
ed_draw.c ed_draw.c
ed_transverts.c ed_transverts.c
ed_util.c ed_util.cc
ed_util_imbuf.c ed_util_imbuf.c
ed_util_ops.cc ed_util_ops.cc
ed_viewer_path.cc ed_viewer_path.cc

View File

@ -5,9 +5,9 @@
* \ingroup edutil * \ingroup edutil
*/ */
#include <math.h> #include <cmath>
#include <stdlib.h> #include <cstdlib>
#include <string.h> #include <cstring>
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
@ -59,7 +59,7 @@
void ED_editors_init_for_undo(Main *bmain) void ED_editors_init_for_undo(Main *bmain)
{ {
wmWindowManager *wm = bmain->wm.first; wmWindowManager *wm = static_cast<wmWindowManager *>(bmain->wm.first);
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
Scene *scene = WM_window_get_active_scene(win); Scene *scene = WM_window_get_active_scene(win);
ViewLayer *view_layer = WM_window_get_active_view_layer(win); ViewLayer *view_layer = WM_window_get_active_view_layer(win);
@ -67,14 +67,14 @@ void ED_editors_init_for_undo(Main *bmain)
Object *ob = BKE_view_layer_active_object_get(view_layer); Object *ob = BKE_view_layer_active_object_get(view_layer);
if (ob && (ob->mode & OB_MODE_TEXTURE_PAINT)) { if (ob && (ob->mode & OB_MODE_TEXTURE_PAINT)) {
BKE_texpaint_slots_refresh_object(scene, ob); BKE_texpaint_slots_refresh_object(scene, ob);
ED_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); ED_paint_proj_mesh_data_check(scene, ob, nullptr, nullptr, nullptr, nullptr);
} }
} }
} }
void ED_editors_init(bContext *C) void ED_editors_init(bContext *C)
{ {
struct Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C); Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C);
Main *bmain = CTX_data_main(C); Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C); Scene *scene = CTX_data_scene(C);
wmWindowManager *wm = CTX_wm_manager(C); wmWindowManager *wm = CTX_wm_manager(C);
@ -92,12 +92,12 @@ void ED_editors_init(bContext *C)
* e.g. linked objects we have to ensure that they are actually the * e.g. linked objects we have to ensure that they are actually the
* active object in this scene. */ * active object in this scene. */
Object *obact = CTX_data_active_object(C); Object *obact = CTX_data_active_object(C);
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
int mode = ob->mode; int mode = ob->mode;
if (mode == OB_MODE_OBJECT) { if (mode == OB_MODE_OBJECT) {
continue; continue;
} }
if (BKE_object_has_mode_data(ob, mode)) { if (BKE_object_has_mode_data(ob, eObjectMode(mode))) {
/* For multi-edit mode we may already have mode data. */ /* For multi-edit mode we may already have mode data. */
continue; continue;
} }
@ -113,25 +113,25 @@ void ED_editors_init(bContext *C)
DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
} }
else if (mode & OB_MODE_ALL_PAINT_GPENCIL) { else if (mode & OB_MODE_ALL_PAINT_GPENCIL) {
ED_gpencil_toggle_brush_cursor(C, true, NULL); ED_gpencil_toggle_brush_cursor(C, true, nullptr);
} }
continue; continue;
} }
/* Reset object to Object mode, so that code below can properly re-switch it to its /* Reset object to Object mode, so that code below can properly re-switch it to its
* previous mode if possible, re-creating its mode data, etc. */ * previous mode if possible, re-creating its mode data, etc. */
ID *ob_data = ob->data; ID *ob_data = static_cast<ID *>(ob->data);
ob->mode = OB_MODE_OBJECT; ob->mode = OB_MODE_OBJECT;
DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
/* Object mode is enforced if there is no active object, or if the active object's type is /* Object mode is enforced if there is no active object, or if the active object's type is
* different. */ * different. */
if (obact == NULL || ob->type != obact->type) { if (obact == nullptr || ob->type != obact->type) {
continue; continue;
} }
/* Object mode is enforced for non-editable data (or their obdata). */ /* Object mode is enforced for non-editable data (or their obdata). */
if (!BKE_id_is_editable(bmain, &ob->id) || if (!BKE_id_is_editable(bmain, &ob->id) ||
(ob_data != NULL && !BKE_id_is_editable(bmain, ob_data))) { (ob_data != nullptr && !BKE_id_is_editable(bmain, ob_data))) {
continue; continue;
} }
@ -180,7 +180,7 @@ void ED_editors_init(bContext *C)
else { else {
/* TODO(@ideasman42): avoid operator calls. */ /* TODO(@ideasman42): avoid operator calls. */
if (obact == ob) { if (obact == ob) {
ED_object_mode_set(C, mode); ED_object_mode_set(C, eObjectMode(mode));
} }
} }
} }
@ -216,12 +216,12 @@ void ED_editors_exit(Main *bmain, bool do_undo_system)
/* Frees all edit-mode undo-steps. */ /* Frees all edit-mode undo-steps. */
if (do_undo_system && G_MAIN->wm.first) { if (do_undo_system && G_MAIN->wm.first) {
wmWindowManager *wm = G_MAIN->wm.first; wmWindowManager *wm = static_cast<wmWindowManager *>(G_MAIN->wm.first);
/* normally we don't check for NULL undo stack, /* normally we don't check for null undo stack,
* do here since it may run in different context. */ * do here since it may run in different context. */
if (wm->undo_stack) { if (wm->undo_stack) {
BKE_undosys_stack_destroy(wm->undo_stack); BKE_undosys_stack_destroy(wm->undo_stack);
wm->undo_stack = NULL; wm->undo_stack = nullptr;
} }
} }
@ -236,7 +236,7 @@ void ED_editors_exit(Main *bmain, bool do_undo_system)
* don't handle modes either (doing so isn't always practical). * don't handle modes either (doing so isn't always practical).
* *
* To reproduce the problem where stale data is used, see: T84920. */ * To reproduce the problem where stale data is used, see: T84920. */
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
if (ED_object_editmode_free_ex(bmain, ob)) { if (ED_object_editmode_free_ex(bmain, ob)) {
if (do_undo_system == false) { if (do_undo_system == false) {
DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
@ -245,8 +245,8 @@ void ED_editors_exit(Main *bmain, bool do_undo_system)
} }
/* global in meshtools... */ /* global in meshtools... */
ED_mesh_mirror_spatial_table_end(NULL); ED_mesh_mirror_spatial_table_end(nullptr);
ED_mesh_mirror_topo_table_end(NULL); ED_mesh_mirror_topo_table_end(nullptr);
} }
bool ED_editors_flush_edits_for_object_ex(Main *bmain, bool ED_editors_flush_edits_for_object_ex(Main *bmain,
@ -259,7 +259,7 @@ bool ED_editors_flush_edits_for_object_ex(Main *bmain,
/* Don't allow flushing while in the middle of a stroke (frees data in use). /* Don't allow flushing while in the middle of a stroke (frees data in use).
* Auto-save prevents this from happening but scripts * Auto-save prevents this from happening but scripts
* may cause a flush on saving: T53986. */ * may cause a flush on saving: T53986. */
if (ob->sculpt != NULL && ob->sculpt->cache == NULL) { if (ob->sculpt != nullptr && ob->sculpt->cache == nullptr) {
char *needs_flush_ptr = &ob->sculpt->needs_flush_to_id; char *needs_flush_ptr = &ob->sculpt->needs_flush_to_id;
if (check_needs_flush && (*needs_flush_ptr == 0)) { if (check_needs_flush && (*needs_flush_ptr == 0)) {
return false; return false;
@ -283,8 +283,8 @@ bool ED_editors_flush_edits_for_object_ex(Main *bmain,
} }
else if (ob->mode & OB_MODE_EDIT) { else if (ob->mode & OB_MODE_EDIT) {
char *needs_flush_ptr = BKE_object_data_editmode_flush_ptr_get(ob->data); char *needs_flush_ptr = BKE_object_data_editmode_flush_ptr_get(static_cast<ID *>(ob->data));
if (needs_flush_ptr != NULL) { if (needs_flush_ptr != nullptr) {
if (check_needs_flush && (*needs_flush_ptr == 0)) { if (check_needs_flush && (*needs_flush_ptr == 0)) {
return false; return false;
} }
@ -306,12 +306,11 @@ bool ED_editors_flush_edits_for_object(Main *bmain, Object *ob)
bool ED_editors_flush_edits_ex(Main *bmain, bool for_render, bool check_needs_flush) bool ED_editors_flush_edits_ex(Main *bmain, bool for_render, bool check_needs_flush)
{ {
bool has_edited = false; bool has_edited = false;
Object *ob;
/* loop through all data to find edit mode or object mode, because during /* loop through all data to find edit mode or object mode, because during
* exiting we might not have a context for edit object and multiple sculpt * exiting we might not have a context for edit object and multiple sculpt
* objects can exist at the same time */ * objects can exist at the same time */
for (ob = bmain->objects.first; ob; ob = ob->id.next) { LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
has_edited |= ED_editors_flush_edits_for_object_ex(bmain, ob, for_render, check_needs_flush); has_edited |= ED_editors_flush_edits_for_object_ex(bmain, ob, for_render, check_needs_flush);
} }
@ -357,7 +356,7 @@ void unpack_menu(bContext *C,
const char *id_name, const char *id_name,
const char *abs_name, const char *abs_name,
const char *folder, const char *folder,
struct PackedFile *pf) PackedFile *pf)
{ {
Main *bmain = CTX_data_main(C); Main *bmain = CTX_data_main(C);
PointerRNA props_ptr; PointerRNA props_ptr;
@ -371,7 +370,7 @@ void unpack_menu(bContext *C,
layout = UI_popup_menu_layout(pup); layout = UI_popup_menu_layout(pup);
uiItemFullO_ptr( uiItemFullO_ptr(
layout, ot, IFACE_("Remove Pack"), ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr); layout, ot, IFACE_("Remove Pack"), ICON_NONE, nullptr, WM_OP_EXEC_DEFAULT, 0, &props_ptr);
RNA_enum_set(&props_ptr, "method", PF_REMOVE); RNA_enum_set(&props_ptr, "method", PF_REMOVE);
RNA_string_set(&props_ptr, "id", id_name); RNA_string_set(&props_ptr, "id", id_name);
@ -384,7 +383,7 @@ void unpack_menu(bContext *C,
switch (BKE_packedfile_compare_to_file(blendfile_path, local_name, pf)) { switch (BKE_packedfile_compare_to_file(blendfile_path, local_name, pf)) {
case PF_CMP_NOFILE: case PF_CMP_NOFILE:
BLI_snprintf(line, sizeof(line), TIP_("Create %s"), local_name); BLI_snprintf(line, sizeof(line), TIP_("Create %s"), local_name);
uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr); uiItemFullO_ptr(layout, ot, line, ICON_NONE, nullptr, WM_OP_EXEC_DEFAULT, 0, &props_ptr);
RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL); RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL);
RNA_string_set(&props_ptr, "id", id_name); RNA_string_set(&props_ptr, "id", id_name);
@ -392,7 +391,7 @@ void unpack_menu(bContext *C,
case PF_CMP_EQUAL: case PF_CMP_EQUAL:
BLI_snprintf(line, sizeof(line), TIP_("Use %s (identical)"), local_name); BLI_snprintf(line, sizeof(line), TIP_("Use %s (identical)"), local_name);
// uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL); // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL);
uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr); uiItemFullO_ptr(layout, ot, line, ICON_NONE, nullptr, WM_OP_EXEC_DEFAULT, 0, &props_ptr);
RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL); RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL);
RNA_string_set(&props_ptr, "id", id_name); RNA_string_set(&props_ptr, "id", id_name);
@ -400,13 +399,13 @@ void unpack_menu(bContext *C,
case PF_CMP_DIFFERS: case PF_CMP_DIFFERS:
BLI_snprintf(line, sizeof(line), TIP_("Use %s (differs)"), local_name); BLI_snprintf(line, sizeof(line), TIP_("Use %s (differs)"), local_name);
// uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL); // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL);
uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr); uiItemFullO_ptr(layout, ot, line, ICON_NONE, nullptr, WM_OP_EXEC_DEFAULT, 0, &props_ptr);
RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL); RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL);
RNA_string_set(&props_ptr, "id", id_name); RNA_string_set(&props_ptr, "id", id_name);
BLI_snprintf(line, sizeof(line), TIP_("Overwrite %s"), local_name); BLI_snprintf(line, sizeof(line), TIP_("Overwrite %s"), local_name);
// uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_LOCAL); // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_LOCAL);
uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr); uiItemFullO_ptr(layout, ot, line, ICON_NONE, nullptr, WM_OP_EXEC_DEFAULT, 0, &props_ptr);
RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL); RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL);
RNA_string_set(&props_ptr, "id", id_name); RNA_string_set(&props_ptr, "id", id_name);
break; break;
@ -418,27 +417,27 @@ void unpack_menu(bContext *C,
case PF_CMP_NOFILE: case PF_CMP_NOFILE:
BLI_snprintf(line, sizeof(line), TIP_("Create %s"), abs_name); BLI_snprintf(line, sizeof(line), TIP_("Create %s"), abs_name);
// uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL); // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL);
uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr); uiItemFullO_ptr(layout, ot, line, ICON_NONE, nullptr, WM_OP_EXEC_DEFAULT, 0, &props_ptr);
RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL); RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL);
RNA_string_set(&props_ptr, "id", id_name); RNA_string_set(&props_ptr, "id", id_name);
break; break;
case PF_CMP_EQUAL: case PF_CMP_EQUAL:
BLI_snprintf(line, sizeof(line), TIP_("Use %s (identical)"), abs_name); BLI_snprintf(line, sizeof(line), TIP_("Use %s (identical)"), abs_name);
// uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL); // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL);
uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr); uiItemFullO_ptr(layout, ot, line, ICON_NONE, nullptr, WM_OP_EXEC_DEFAULT, 0, &props_ptr);
RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL); RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL);
RNA_string_set(&props_ptr, "id", id_name); RNA_string_set(&props_ptr, "id", id_name);
break; break;
case PF_CMP_DIFFERS: case PF_CMP_DIFFERS:
BLI_snprintf(line, sizeof(line), TIP_("Use %s (differs)"), abs_name); BLI_snprintf(line, sizeof(line), TIP_("Use %s (differs)"), abs_name);
// uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL); // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL);
uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr); uiItemFullO_ptr(layout, ot, line, ICON_NONE, nullptr, WM_OP_EXEC_DEFAULT, 0, &props_ptr);
RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL); RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL);
RNA_string_set(&props_ptr, "id", id_name); RNA_string_set(&props_ptr, "id", id_name);
BLI_snprintf(line, sizeof(line), TIP_("Overwrite %s"), abs_name); BLI_snprintf(line, sizeof(line), TIP_("Overwrite %s"), abs_name);
// uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL); // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL);
uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr); uiItemFullO_ptr(layout, ot, line, ICON_NONE, nullptr, WM_OP_EXEC_DEFAULT, 0, &props_ptr);
RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL); RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL);
RNA_string_set(&props_ptr, "id", id_name); RNA_string_set(&props_ptr, "id", id_name);
break; break;
@ -447,9 +446,7 @@ void unpack_menu(bContext *C,
UI_popup_menu_end(C, pup); UI_popup_menu_end(C, pup);
} }
void ED_spacedata_id_remap(struct ScrArea *area, void ED_spacedata_id_remap(ScrArea *area, SpaceLink *sl, const IDRemapper *mappings)
struct SpaceLink *sl,
const struct IDRemapper *mappings)
{ {
SpaceType *st = BKE_spacetype_from_id(sl->spacetype); SpaceType *st = BKE_spacetype_from_id(sl->spacetype);
if (st && st->id_remap) { if (st && st->id_remap) {
@ -457,15 +454,12 @@ void ED_spacedata_id_remap(struct ScrArea *area,
} }
} }
void ED_spacedata_id_remap_single(struct ScrArea *area, void ED_spacedata_id_remap_single(ScrArea *area, SpaceLink *sl, ID *old_id, ID *new_id)
struct SpaceLink *sl,
ID *old_id,
ID *new_id)
{ {
SpaceType *st = BKE_spacetype_from_id(sl->spacetype); SpaceType *st = BKE_spacetype_from_id(sl->spacetype);
if (st && st->id_remap) { if (st && st->id_remap) {
struct IDRemapper *mappings = BKE_id_remapper_create(); IDRemapper *mappings = BKE_id_remapper_create();
BKE_id_remapper_add(mappings, old_id, new_id); BKE_id_remapper_add(mappings, old_id, new_id);
st->id_remap(area, sl, mappings); st->id_remap(area, sl, mappings);
BKE_id_remapper_free(mappings); BKE_id_remapper_free(mappings);