Add ORIENTATION_PARENT icon #107763

Merged
Sybren A. Stüvel merged 3 commits from KevinCBurke/blender:parent-icon into main 2023-05-11 14:50:36 +02:00
45 changed files with 906 additions and 916 deletions
Showing only changes of commit ab57eec93f - Show all commits

View File

@ -62,6 +62,7 @@ set(SRC_DNA_INC
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_pointcloud_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_rigidbody_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_scene_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_scene_enums.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_screen_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_sdna_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_sequence_types.h

View File

@ -8,6 +8,8 @@
* used by painting and tools.
*/
#include "DNA_scene_enums.h"
#ifdef __cplusplus
extern "C" {
#endif
@ -92,7 +94,6 @@ void BKE_object_defgroup_index_map_apply(struct MDeformVert *dvert,
/* Select helpers. */
enum eVGroupSelect;
/**
* Return the subset type of the Vertex Group Selection.
*/

View File

@ -19,6 +19,7 @@ class SimulationStateItem {
class GeometrySimulationStateItem : public SimulationStateItem {
public:
GeometrySimulationStateItem(GeometrySet geometry);
GeometrySet geometry;
};

View File

@ -15,6 +15,11 @@
namespace blender::bke::sim {
GeometrySimulationStateItem::GeometrySimulationStateItem(GeometrySet geometry)
: geometry(std::move(geometry))
{
}
PrimitiveSimulationStateItem::PrimitiveSimulationStateItem(const CPPType &type, const void *value)
: type_(type)
{

View File

@ -43,23 +43,23 @@ set(SRC
curves_sculpt_snake_hook.cc
paint_canvas.cc
paint_cursor.cc
paint_curve.c
paint_curve_undo.c
paint_curve.cc
paint_curve_undo.cc
paint_hide.cc
paint_image.cc
paint_image_2d.c
paint_image_2d.cc
paint_image_2d_curve_mask.cc
paint_image_ops_paint.cc
paint_image_proj.cc
paint_mask.cc
paint_ops.cc
paint_stroke.cc
paint_utils.c
paint_utils.cc
paint_vertex.cc
paint_vertex_color_ops.cc
paint_vertex_proj.c
paint_vertex_proj.cc
paint_vertex_weight_ops.cc
paint_vertex_weight_utils.c
paint_vertex_weight_utils.cc
sculpt.cc
sculpt_automasking.cc
sculpt_boundary.cc
@ -83,11 +83,10 @@ set(SRC
sculpt_smooth.cc
sculpt_transform.cc
sculpt_undo.cc
sculpt_uv.c
sculpt_uv.cc
curves_sculpt_intern.h
curves_sculpt_intern.hh
paint_intern.h
paint_intern.hh
sculpt_intern.hh
)

View File

@ -1,16 +0,0 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
struct bContext;
#ifdef __cplusplus
extern "C" {
#endif
bool CURVES_SCULPT_mode_poll(struct bContext *C);
bool CURVES_SCULPT_mode_poll_view3d(struct bContext *C);
#ifdef __cplusplus
}
#endif

View File

@ -4,8 +4,7 @@
#include <optional>
#include "curves_sculpt_intern.h"
#include "paint_intern.h"
#include "paint_intern.hh"
#include "BLI_math_vector.hh"
#include "BLI_vector.hh"
@ -171,3 +170,6 @@ struct CurvesConstraintSolver {
};
} // namespace blender::ed::sculpt_paint
bool CURVES_SCULPT_mode_poll(struct bContext *C);
bool CURVES_SCULPT_mode_poll_view3d(struct bContext *C);

View File

@ -37,9 +37,8 @@
#include "RNA_define.h"
#include "RNA_enum_types.h"
#include "curves_sculpt_intern.h"
#include "curves_sculpt_intern.hh"
#include "paint_intern.h"
#include "paint_intern.hh"
#include "UI_interface.h"
#include "UI_resources.h"

View File

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

View File

@ -4,8 +4,8 @@
* \ingroup edsculpt
*/
#include <limits.h>
#include <string.h>
#include <climits>
#include <cstring>
#include "MEM_guardedalloc.h"
@ -32,7 +32,7 @@
#include "UI_view2d.h"
#include "paint_intern.h"
#include "paint_intern.hh"
#define PAINT_CURVE_SELECT_THRESHOLD 40.0f
#define PAINT_CURVE_POINT_SELECT(pcp, i) (*(&pcp->bez.f1 + i) = SELECT)
@ -71,7 +71,7 @@ bool paint_curve_poll(bContext *C)
static PaintCurvePoint *paintcurve_point_get_closest(
PaintCurve *pc, const float pos[2], bool ignore_pivot, const float threshold, char *point)
{
PaintCurvePoint *pcp, *closest = NULL;
PaintCurvePoint *pcp, *closest = nullptr;
int i;
float closest_dist = threshold;
@ -141,7 +141,7 @@ static char paintcurve_point_side_index(const BezTriple *bezt,
/******************* Operators *********************************/
static int paintcurve_new_exec(bContext *C, wmOperator *UNUSED(op))
static int paintcurve_new_exec(bContext *C, wmOperator * /*op*/)
{
Paint *p = BKE_paint_get_active_from_context(C);
Main *bmain = CTX_data_main(C);
@ -150,7 +150,7 @@ static int paintcurve_new_exec(bContext *C, wmOperator *UNUSED(op))
p->brush->paint_curve = BKE_paint_curve_add(bmain, "PaintCurve");
}
WM_event_add_notifier(C, NC_PAINTCURVE | NA_ADDED, NULL);
WM_event_add_notifier(C, NC_PAINTCURVE | NA_ADDED, nullptr);
return OPERATOR_FINISHED;
}
@ -177,7 +177,7 @@ static void paintcurve_point_add(bContext *C, wmOperator *op, const int loc[2])
Main *bmain = CTX_data_main(C);
wmWindow *window = CTX_wm_window(C);
ARegion *region = CTX_wm_region(C);
const float vec[3] = {loc[0], loc[1], 0.0};
const float vec[3] = {float(loc[0]), float(loc[1]), 0.0f};
PaintCurve *pc = br->paint_curve;
if (!pc) {
@ -186,8 +186,8 @@ static void paintcurve_point_add(bContext *C, wmOperator *op, const int loc[2])
ED_paintcurve_undo_push_begin(op->type->name);
PaintCurvePoint *pcp = MEM_mallocN((pc->tot_points + 1) * sizeof(PaintCurvePoint),
"PaintCurvePoint");
PaintCurvePoint *pcp = static_cast<PaintCurvePoint *>(
MEM_mallocN((pc->tot_points + 1) * sizeof(PaintCurvePoint), "PaintCurvePoint"));
int add_index = pc->add_index;
if (pc->points) {
@ -272,7 +272,7 @@ void PAINTCURVE_OT_add_point(wmOperatorType *ot)
RNA_def_int_vector(ot->srna,
"location",
2,
NULL,
nullptr,
0,
SHRT_MAX,
"Location",
@ -311,9 +311,10 @@ static int paintcurve_delete_point_exec(bContext *C, wmOperator *op)
if (tot_del > 0) {
int j = 0;
int new_tot = pc->tot_points - tot_del;
PaintCurvePoint *points_new = NULL;
PaintCurvePoint *points_new = nullptr;
if (new_tot > 0) {
points_new = MEM_mallocN(new_tot * sizeof(PaintCurvePoint), "PaintCurvePoint");
points_new = static_cast<PaintCurvePoint *>(
MEM_mallocN(new_tot * sizeof(PaintCurvePoint), "PaintCurvePoint"));
}
for (i = 0, pcp = pc->points; i < pc->tot_points; i++, pcp++) {
@ -369,7 +370,7 @@ static bool paintcurve_point_select(
Brush *br = p->brush;
PaintCurve *pc;
int i;
const float loc_fl[2] = {UNPACK2(loc)};
const float loc_fl[2] = {float(loc[0]), float(loc[1])};
pc = br->paint_curve;
@ -463,7 +464,7 @@ static bool paintcurve_point_select(
static int paintcurve_select_point_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
const int loc[2] = {UNPACK2(event->mval)};
const int loc[2] = {event->mval[0], event->mval[1]};
bool toggle = RNA_boolean_get(op->ptr, "toggle");
bool extend = RNA_boolean_get(op->ptr, "extend");
if (paintcurve_point_select(C, op, loc, toggle, extend)) {
@ -510,7 +511,7 @@ void PAINTCURVE_OT_select(wmOperatorType *ot)
RNA_def_int_vector(ot->srna,
"location",
2,
NULL,
nullptr,
0,
SHRT_MAX,
"Location",
@ -523,19 +524,19 @@ void PAINTCURVE_OT_select(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
typedef struct PointSlideData {
struct PointSlideData {
PaintCurvePoint *pcp;
char select;
int initial_loc[2];
float point_initial_loc[3][2];
int event;
bool align;
} PointSlideData;
};
static int paintcurve_slide_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
Paint *p = BKE_paint_get_active_from_context(C);
const float loc_fl[2] = {UNPACK2(event->mval)};
const float loc_fl[2] = {float(event->mval[0]), float(event->mval[1])};
char select;
int i;
bool do_select = RNA_boolean_get(op->ptr, "select");
@ -552,7 +553,7 @@ static int paintcurve_slide_invoke(bContext *C, wmOperator *op, const wmEvent *e
pcp = paintcurve_point_get_closest(pc, loc_fl, align, PAINT_CURVE_SELECT_THRESHOLD, &select);
}
else {
pcp = NULL;
pcp = nullptr;
/* just find first selected point */
for (i = 0; i < pc->tot_points; i++) {
if ((select = paintcurve_point_side_index(&pc->points[i].bez, i == 0, SEL_F3))) {
@ -565,7 +566,8 @@ static int paintcurve_slide_invoke(bContext *C, wmOperator *op, const wmEvent *e
if (pcp) {
ARegion *region = CTX_wm_region(C);
wmWindow *window = CTX_wm_window(C);
PointSlideData *psd = MEM_mallocN(sizeof(PointSlideData), "PointSlideData");
PointSlideData *psd = static_cast<PointSlideData *>(
MEM_mallocN(sizeof(PointSlideData), "PointSlideData"));
copy_v2_v2_int(psd->initial_loc, event->mval);
psd->event = event->type;
psd->pcp = pcp;
@ -595,7 +597,7 @@ static int paintcurve_slide_invoke(bContext *C, wmOperator *op, const wmEvent *e
static int paintcurve_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
PointSlideData *psd = op->customdata;
PointSlideData *psd = static_cast<PointSlideData *>(op->customdata);
if (event->type == psd->event && event->val == KM_RELEASE) {
MEM_freeN(psd);
@ -608,7 +610,8 @@ static int paintcurve_slide_modal(bContext *C, wmOperator *op, const wmEvent *ev
case MOUSEMOVE: {
ARegion *region = CTX_wm_region(C);
wmWindow *window = CTX_wm_window(C);
float diff[2] = {event->mval[0] - psd->initial_loc[0], event->mval[1] - psd->initial_loc[1]};
float diff[2] = {float(event->mval[0] - psd->initial_loc[0]),
float(event->mval[1] - psd->initial_loc[1])};
if (psd->select == 1) {
int i;
for (i = 0; i < 3; i++) {
@ -657,7 +660,7 @@ void PAINTCURVE_OT_slide(wmOperatorType *ot)
ot->srna, "select", true, "Select", "Attempt to select a point handle before transform");
}
static int paintcurve_draw_exec(bContext *C, wmOperator *UNUSED(op))
static int paintcurve_draw_exec(bContext *C, wmOperator * /*op*/)
{
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
const char *name;
@ -683,7 +686,7 @@ static int paintcurve_draw_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_PASS_THROUGH;
}
return WM_operator_name_call(C, name, WM_OP_INVOKE_DEFAULT, NULL, NULL);
return WM_operator_name_call(C, name, WM_OP_INVOKE_DEFAULT, nullptr, nullptr);
}
void PAINTCURVE_OT_draw(wmOperatorType *ot)
@ -701,7 +704,7 @@ void PAINTCURVE_OT_draw(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
}
static int paintcurve_cursor_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
static int paintcurve_cursor_invoke(bContext *C, wmOperator * /*op*/, const wmEvent *event)
{
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
@ -718,7 +721,7 @@ static int paintcurve_cursor_invoke(bContext *C, wmOperator *UNUSED(op), const w
UI_view2d_region_to_view(
&region->v2d, event->mval[0], event->mval[1], &location[0], &location[1]);
copy_v2_v2(sima->cursor, location);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_IMAGE, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_IMAGE, nullptr);
break;
}
default:

View File

@ -4,7 +4,7 @@
* \ingroup edsculpt
*/
#include <string.h>
#include <cstring>
#include "MEM_guardedalloc.h"
@ -19,7 +19,7 @@
#include "WM_api.h"
#include "paint_intern.h"
#include "paint_intern.hh"
#ifndef NDEBUG
# include "BLI_array_utils.h" /* #BLI_array_is_zeroed */
@ -29,16 +29,16 @@
/** \name Undo Conversion
* \{ */
typedef struct UndoCurve {
struct UndoCurve {
PaintCurvePoint *points; /* points of curve */
int tot_points;
int add_index;
} UndoCurve;
};
static void undocurve_from_paintcurve(UndoCurve *uc, const PaintCurve *pc)
{
BLI_assert(BLI_array_is_zeroed(uc, 1));
uc->points = MEM_dupallocN(pc->points);
uc->points = static_cast<PaintCurvePoint *>(MEM_dupallocN(pc->points));
uc->tot_points = pc->tot_points;
uc->add_index = pc->add_index;
}
@ -46,7 +46,7 @@ static void undocurve_from_paintcurve(UndoCurve *uc, const PaintCurve *pc)
static void undocurve_to_paintcurve(const UndoCurve *uc, PaintCurve *pc)
{
MEM_SAFE_FREE(pc->points);
pc->points = MEM_dupallocN(uc->points);
pc->points = static_cast<PaintCurvePoint *>(MEM_dupallocN(uc->points));
pc->tot_points = uc->tot_points;
pc->add_index = uc->add_index;
}
@ -62,32 +62,30 @@ static void undocurve_free_data(UndoCurve *uc)
/** \name Implements ED Undo System
* \{ */
typedef struct PaintCurveUndoStep {
struct PaintCurveUndoStep {
UndoStep step;
UndoRefID_PaintCurve pc_ref;
UndoCurve data;
} PaintCurveUndoStep;
};
static bool paintcurve_undosys_poll(bContext *C)
{
if (C == NULL || !paint_curve_poll(C)) {
if (C == nullptr || !paint_curve_poll(C)) {
return false;
}
Paint *p = BKE_paint_get_active_from_context(C);
return (p->brush && p->brush->paint_curve);
}
static void paintcurve_undosys_step_encode_init(struct bContext *C, UndoStep *us_p)
static void paintcurve_undosys_step_encode_init(bContext *C, UndoStep *us_p)
{
/* XXX, use to set the undo type only. */
UNUSED_VARS(C, us_p);
}
static bool paintcurve_undosys_step_encode(struct bContext *C,
struct Main *UNUSED(bmain),
UndoStep *us_p)
static bool paintcurve_undosys_step_encode(bContext *C, Main * /*bmain*/, UndoStep *us_p)
{
/* FIXME Double check this, it should not be needed here at all? undo system is supposed to
* ensure that. */
@ -96,8 +94,8 @@ static bool paintcurve_undosys_step_encode(struct bContext *C,
}
Paint *p = BKE_paint_get_active_from_context(C);
PaintCurve *pc = p ? (p->brush ? p->brush->paint_curve : NULL) : NULL;
if (pc == NULL) {
PaintCurve *pc = p ? (p->brush ? p->brush->paint_curve : nullptr) : nullptr;
if (pc == nullptr) {
return false;
}
@ -110,11 +108,11 @@ static bool paintcurve_undosys_step_encode(struct bContext *C,
return true;
}
static void paintcurve_undosys_step_decode(struct bContext *UNUSED(C),
struct Main *UNUSED(bmain),
static void paintcurve_undosys_step_decode(bContext * /*C*/,
Main * /*bmain*/,
UndoStep *us_p,
const eUndoStepDir UNUSED(dir),
bool UNUSED(is_final))
const eUndoStepDir /*dir*/,
bool /*is_final*/)
{
PaintCurveUndoStep *us = (PaintCurveUndoStep *)us_p;
undocurve_to_paintcurve(&us->data, us->pc_ref.ptr);
@ -159,14 +157,14 @@ void ED_paintcurve_undosys_type(UndoType *ut)
void ED_paintcurve_undo_push_begin(const char *name)
{
UndoStack *ustack = ED_undo_stack_get();
bContext *C = NULL; /* special case, we never read from this. */
bContext *C = nullptr; /* special case, we never read from this. */
BKE_undosys_step_push_init_with_type(ustack, C, name, BKE_UNDOSYS_TYPE_PAINTCURVE);
}
void ED_paintcurve_undo_push_end(bContext *C)
{
UndoStack *ustack = ED_undo_stack_get();
BKE_undosys_step_push(ustack, C, NULL);
BKE_undosys_step_push(ustack, C, nullptr);
BKE_undosys_stack_limit_steps_and_memory_defaults(ustack);
WM_file_tag_modified();
}

View File

@ -39,7 +39,7 @@
#include "bmesh.h"
#include "paint_intern.h"
#include "paint_intern.hh"
/* For undo push. */
#include "sculpt_intern.hh"

View File

@ -62,9 +62,7 @@
#include "IMB_colormanagement.h"
#include "paint_intern.h"
extern "C" {
#include "paint_intern.hh"
/* -------------------------------------------------------------------- */
/** \name Image Paint Tile Utilities (Partial Update)
@ -1113,6 +1111,5 @@ bool mask_paint_poll(bContext *C)
{
return BKE_paint_select_elem_test(CTX_data_active_object(C));
}
}
/** \} */

View File

@ -4,8 +4,8 @@
/** \file
* \ingroup bke
*/
//#include <math.h>
#include <string.h>
#include <cstring>
#include "MEM_guardedalloc.h"
@ -41,13 +41,13 @@
#include "UI_view2d.h"
#include "paint_intern.h"
#include "paint_intern.hh"
/* Brush Painting for 2D image editor */
/* Defines and Structs */
typedef struct BrushPainterCache {
struct BrushPainterCache {
bool use_float; /* need float imbuf? */
bool use_color_correction; /* use color correction for float */
bool invert;
@ -70,34 +70,34 @@ typedef struct BrushPainterCache {
CurveMaskCache curve_mask_cache;
int image_size[2];
} BrushPainterCache;
};
typedef struct BrushPainter {
struct BrushPainter {
Scene *scene;
Brush *brush;
bool firsttouch; /* first paint op */
struct ImagePool *pool; /* image pool */
rctf tex_mapping; /* texture coordinate mapping */
rctf mask_mapping; /* mask texture coordinate mapping */
ImagePool *pool; /* image pool */
rctf tex_mapping; /* texture coordinate mapping */
rctf mask_mapping; /* mask texture coordinate mapping */
bool cache_invert;
} BrushPainter;
};
typedef struct ImagePaintRegion {
struct ImagePaintRegion {
int destx, desty;
int srcx, srcy;
int width, height;
} ImagePaintRegion;
};
typedef enum ImagePaintTileState {
enum ImagePaintTileState {
PAINT2D_TILE_UNINITIALIZED = 0,
PAINT2D_TILE_MISSING,
PAINT2D_TILE_READY,
} ImagePaintTileState;
};
typedef struct ImagePaintTile {
struct ImagePaintTile {
ImageUser iuser;
ImBuf *canvas;
float radius_fac;
@ -110,9 +110,9 @@ typedef struct ImagePaintTile {
float last_paintpos[2]; /* position of last paint op */
float start_paintpos[2]; /* position of first paint */
} ImagePaintTile;
};
typedef struct ImagePaintState {
struct ImagePaintState {
BrushPainter *painter;
SpaceImage *sima;
View2D *v2d;
@ -131,11 +131,11 @@ typedef struct ImagePaintState {
int num_tiles;
BlurKernel *blurkernel;
} ImagePaintState;
};
static BrushPainter *brush_painter_2d_new(Scene *scene, Brush *brush, bool invert)
{
BrushPainter *painter = MEM_callocN(sizeof(BrushPainter), "BrushPainter");
BrushPainter *painter = MEM_cnew<BrushPainter>(__func__);
painter->brush = brush;
painter->scene = scene;
@ -160,8 +160,8 @@ static void brush_painter_2d_require_imbuf(
if (cache->tex_mask_old) {
MEM_freeN(cache->tex_mask_old);
}
cache->ibuf = NULL;
cache->tex_mask = NULL;
cache->ibuf = nullptr;
cache->tex_mask = nullptr;
cache->lastdiameter = -1; /* force ibuf create in refresh */
cache->invert = invert;
}
@ -203,13 +203,13 @@ static ushort *brush_painter_mask_ibuf_new(BrushPainter *painter, const int size
Scene *scene = painter->scene;
Brush *brush = painter->brush;
rctf mask_mapping = painter->mask_mapping;
struct ImagePool *pool = painter->pool;
ImagePool *pool = painter->pool;
float texco[3];
ushort *mask, *m;
int x, y, thread = 0;
mask = MEM_mallocN(sizeof(ushort) * size * size, "brush_painter_mask");
mask = static_cast<ushort *>(MEM_mallocN(sizeof(ushort) * size * size, __func__));
m = mask;
for (y = 0; y < size; y++) {
@ -217,7 +217,7 @@ static ushort *brush_painter_mask_ibuf_new(BrushPainter *painter, const int size
float res;
brush_imbuf_tex_co(&mask_mapping, x, y, texco);
res = BKE_brush_sample_masktex(scene, brush, texco, thread, pool);
*m = (ushort)(65535.0f * res);
*m = ushort(65535.0f * res);
}
}
@ -240,10 +240,10 @@ static void brush_painter_mask_imbuf_update(BrushPainter *painter,
Brush *brush = painter->brush;
BrushPainterCache *cache = &tile->cache;
rctf tex_mapping = painter->mask_mapping;
struct ImagePool *pool = painter->pool;
ImagePool *pool = painter->pool;
ushort res;
bool use_texture_old = (tex_mask_old != NULL);
bool use_texture_old = (tex_mask_old != nullptr);
int x, y, thread = 0;
@ -294,12 +294,14 @@ static void brush_painter_mask_imbuf_partial_update(BrushPainter *painter,
/* create brush image buffer if it didn't exist yet */
if (!cache->tex_mask) {
cache->tex_mask = MEM_mallocN(sizeof(ushort) * diameter * diameter, "brush_painter_mask");
cache->tex_mask = static_cast<ushort *>(
MEM_mallocN(sizeof(ushort) * diameter * diameter, __func__));
}
/* create new texture image buffer with coordinates relative to old */
tex_mask_old = cache->tex_mask_old;
cache->tex_mask_old = MEM_mallocN(sizeof(ushort) * diameter * diameter, "brush_painter_mask");
cache->tex_mask_old = static_cast<ushort *>(
MEM_mallocN(sizeof(ushort) * diameter * diameter, __func__));
if (tex_mask_old) {
ImBuf maskibuf;
@ -312,8 +314,8 @@ static void brush_painter_mask_imbuf_partial_update(BrushPainter *painter,
srcx = srcy = 0;
w = cache->tex_mask_old_w;
h = cache->tex_mask_old_h;
destx = (int)floorf(tile->last_paintpos[0]) - (int)floorf(pos[0]) + (diameter / 2 - w / 2);
desty = (int)floorf(tile->last_paintpos[1]) - (int)floorf(pos[1]) + (diameter / 2 - h / 2);
destx = int(floorf(tile->last_paintpos[0])) - int(floorf(pos[0])) + (diameter / 2 - w / 2);
desty = int(floorf(tile->last_paintpos[1])) - int(floorf(pos[1])) + (diameter / 2 - h / 2);
/* hack, use temporary rects so that clipping works */
IMB_rectclip(&maskibuf, &maskibuf_old, &destx, &desty, &srcx, &srcy, &w, &h);
@ -341,17 +343,17 @@ static void brush_painter_mask_imbuf_partial_update(BrushPainter *painter,
/* sample texture in new areas */
if ((0 < x1) && (0 < diameter)) {
brush_painter_mask_imbuf_update(painter, tile, NULL, 0, 0, x1, diameter, 0, 0, diameter);
brush_painter_mask_imbuf_update(painter, tile, nullptr, 0, 0, x1, diameter, 0, 0, diameter);
}
if ((x2 < diameter) && (0 < diameter)) {
brush_painter_mask_imbuf_update(
painter, tile, NULL, x2, 0, diameter, diameter, 0, 0, diameter);
painter, tile, nullptr, x2, 0, diameter, diameter, 0, 0, diameter);
}
if ((x1 < x2) && (0 < y1)) {
brush_painter_mask_imbuf_update(painter, tile, NULL, x1, 0, x2, y1, 0, 0, diameter);
brush_painter_mask_imbuf_update(painter, tile, nullptr, x1, 0, x2, y1, 0, 0, diameter);
}
if ((x1 < x2) && (y2 < diameter)) {
brush_painter_mask_imbuf_update(painter, tile, NULL, x1, y2, x2, diameter, 0, 0, diameter);
brush_painter_mask_imbuf_update(painter, tile, nullptr, x1, y2, x2, diameter, 0, 0, diameter);
}
/* through with sampling, now update sizes */
@ -368,10 +370,10 @@ static ImBuf *brush_painter_imbuf_new(
BrushPainterCache *cache = &tile->cache;
const char *display_device = scene->display_settings.display_device;
struct ColorManagedDisplay *display = IMB_colormanagement_display_get_named(display_device);
ColorManagedDisplay *display = IMB_colormanagement_display_get_named(display_device);
rctf tex_mapping = painter->tex_mapping;
struct ImagePool *pool = painter->pool;
ImagePool *pool = painter->pool;
bool use_color_correction = cache->use_color_correction;
bool use_float = cache->use_float;
@ -451,15 +453,15 @@ static void brush_painter_imbuf_update(BrushPainter *painter,
BrushPainterCache *cache = &tile->cache;
const char *display_device = scene->display_settings.display_device;
struct ColorManagedDisplay *display = IMB_colormanagement_display_get_named(display_device);
ColorManagedDisplay *display = IMB_colormanagement_display_get_named(display_device);
rctf tex_mapping = painter->tex_mapping;
struct ImagePool *pool = painter->pool;
ImagePool *pool = painter->pool;
bool use_color_correction = cache->use_color_correction;
bool use_float = cache->use_float;
bool is_texbrush = cache->is_texbrush;
bool use_texture_old = (oldtexibuf != NULL);
bool use_texture_old = (oldtexibuf != nullptr);
int x, y, thread = 0;
float brush_rgb[3];
@ -582,8 +584,8 @@ static void brush_painter_imbuf_partial_update(BrushPainter *painter,
srcx = srcy = 0;
w = oldtexibuf->x;
h = oldtexibuf->y;
destx = (int)floorf(tile->last_paintpos[0]) - (int)floorf(pos[0]) + (diameter / 2 - w / 2);
desty = (int)floorf(tile->last_paintpos[1]) - (int)floorf(pos[1]) + (diameter / 2 - h / 2);
destx = int(floorf(tile->last_paintpos[0])) - int(floorf(pos[0])) + (diameter / 2 - w / 2);
desty = int(floorf(tile->last_paintpos[1])) - int(floorf(pos[1])) + (diameter / 2 - h / 2);
IMB_rectclip(cache->texibuf, oldtexibuf, &destx, &desty, &srcx, &srcy, &w, &h);
}
@ -609,16 +611,16 @@ static void brush_painter_imbuf_partial_update(BrushPainter *painter,
/* sample texture in new areas */
if ((0 < x1) && (0 < ibuf->y)) {
brush_painter_imbuf_update(painter, tile, NULL, 0, 0, x1, ibuf->y, 0, 0);
brush_painter_imbuf_update(painter, tile, nullptr, 0, 0, x1, ibuf->y, 0, 0);
}
if ((x2 < ibuf->x) && (0 < ibuf->y)) {
brush_painter_imbuf_update(painter, tile, NULL, x2, 0, ibuf->x, ibuf->y, 0, 0);
brush_painter_imbuf_update(painter, tile, nullptr, x2, 0, ibuf->x, ibuf->y, 0, 0);
}
if ((x1 < x2) && (0 < y1)) {
brush_painter_imbuf_update(painter, tile, NULL, x1, 0, x2, y1, 0, 0);
brush_painter_imbuf_update(painter, tile, nullptr, x1, 0, x2, y1, 0, 0);
}
if ((x1 < x2) && (y2 < ibuf->y)) {
brush_painter_imbuf_update(painter, tile, NULL, x1, y2, x2, ibuf->y, 0, 0);
brush_painter_imbuf_update(painter, tile, nullptr, x1, y2, x2, ibuf->y, 0, 0);
}
}
@ -630,8 +632,8 @@ static void brush_painter_2d_tex_mapping(ImagePaintState *s,
int mapmode,
rctf *mapping)
{
float invw = 1.0f / (float)tile->canvas->x;
float invh = 1.0f / (float)tile->canvas->y;
float invw = 1.0f / float(tile->canvas->x);
float invh = 1.0f / float(tile->canvas->y);
float start[2];
/* find start coordinate of brush in canvas */
@ -646,8 +648,8 @@ static void brush_painter_2d_tex_mapping(ImagePaintState *s,
s->v2d, (start[0] + diameter) * invw, (start[1] + diameter) * invh, &xmax, &ymax);
/* output mapping from brush ibuf x/y to region coordinates */
mapping->xmax = (xmax - xmin) / (float)diameter;
mapping->ymax = (ymax - ymin) / (float)diameter;
mapping->xmax = (xmax - xmin) / float(diameter);
mapping->ymax = (ymax - ymin) / float(diameter);
mapping->xmin = xmin + (tile->uv_origin[0] * tile->size[0] * mapping->xmax);
mapping->ymin = ymin + (tile->uv_origin[1] * tile->size[1] * mapping->ymax);
}
@ -666,10 +668,10 @@ static void brush_painter_2d_tex_mapping(ImagePaintState *s,
mapping->ymax = 1.0f;
}
else /* if (mapmode == MTEX_MAP_MODE_TILED) */ {
mapping->xmin = (int)(-diameter * 0.5) + (int)floorf(pos[0]) -
(int)floorf(tile->start_paintpos[0]);
mapping->ymin = (int)(-diameter * 0.5) + (int)floorf(pos[1]) -
(int)floorf(tile->start_paintpos[1]);
mapping->xmin = int(-diameter * 0.5) + int(floorf(pos[0])) -
int(floorf(tile->start_paintpos[0]));
mapping->ymin = int(-diameter * 0.5) + int(floorf(pos[1])) -
int(floorf(tile->start_paintpos[1]));
mapping->xmax = 1.0f;
mapping->ymax = 1.0f;
}
@ -765,7 +767,7 @@ static void brush_painter_2d_refresh_cache(ImagePaintState *s,
{
if (cache->ibuf) {
IMB_freeImBuf(cache->ibuf);
cache->ibuf = NULL;
cache->ibuf = nullptr;
}
if (do_partial_update) {
@ -783,8 +785,8 @@ static void brush_painter_2d_refresh_cache(ImagePaintState *s,
}
else if (do_partial_update) {
/* do only partial update of texture */
int dx = (int)floorf(tile->last_paintpos[0]) - (int)floorf(pos[0]);
int dy = (int)floorf(tile->last_paintpos[1]) - (int)floorf(pos[1]);
int dx = int(floorf(tile->last_paintpos[0])) - int(floorf(pos[0]));
int dy = int(floorf(tile->last_paintpos[1])) - int(floorf(pos[1]));
if ((dx != 0) || (dy != 0)) {
brush_painter_imbuf_partial_update(painter, tile, pos, diameter);
@ -792,7 +794,7 @@ static void brush_painter_2d_refresh_cache(ImagePaintState *s,
}
BKE_image_pool_free(painter->pool);
painter->pool = NULL;
painter->pool = nullptr;
}
static bool paint_2d_ensure_tile_canvas(ImagePaintState *s, int i)
@ -813,8 +815,8 @@ static bool paint_2d_ensure_tile_canvas(ImagePaintState *s, int i)
s->tiles[i].cache.lastdiameter = -1;
ImBuf *ibuf = BKE_image_acquire_ibuf(s->image, &s->tiles[i].iuser, NULL);
if (ibuf != NULL) {
ImBuf *ibuf = BKE_image_acquire_ibuf(s->image, &s->tiles[i].iuser, nullptr);
if (ibuf != nullptr) {
if (ibuf->channels != 4) {
s->tiles[i].state = PAINT2D_TILE_MISSING;
}
@ -826,7 +828,7 @@ static bool paint_2d_ensure_tile_canvas(ImagePaintState *s, int i)
else {
s->tiles[i].size[0] = ibuf->x;
s->tiles[i].size[1] = ibuf->y;
s->tiles[i].radius_fac = sqrtf(((float)ibuf->x * (float)ibuf->y) /
s->tiles[i].radius_fac = sqrtf((float(ibuf->x) * float(ibuf->y)) /
(s->tiles[0].size[0] * s->tiles[0].size[1]));
s->tiles[i].state = PAINT2D_TILE_READY;
}
@ -836,7 +838,7 @@ static bool paint_2d_ensure_tile_canvas(ImagePaintState *s, int i)
}
if (s->tiles[i].state == PAINT2D_TILE_MISSING) {
BKE_image_release_ibuf(s->image, ibuf, NULL);
BKE_image_release_ibuf(s->image, ibuf, nullptr);
return false;
}
@ -996,7 +998,7 @@ static void paint_2d_lift_soften(ImagePaintState *s,
}
if (count > 0.0f) {
mul_v4_fl(outrgb, 1.0f / (float)count);
mul_v4_fl(outrgb, 1.0f / float(count));
if (sharpen) {
/* subtract blurred image from normal image gives high pass filter */
@ -1118,9 +1120,9 @@ static void paint_2d_lift_smear(ImBuf *ibuf, ImBuf *ibufb, int *pos, short paint
IMB_rectblend(ibufb,
ibufb,
ibuf,
NULL,
NULL,
NULL,
nullptr,
nullptr,
nullptr,
0,
region[a].destx,
region[a].desty,
@ -1146,9 +1148,9 @@ static ImBuf *paint_2d_lift_clone(ImBuf *ibuf, ImBuf *ibufb, const int *pos)
IMB_rectblend(clonebuf,
clonebuf,
ibufb,
NULL,
NULL,
NULL,
nullptr,
nullptr,
nullptr,
0,
destx,
desty,
@ -1163,9 +1165,9 @@ static ImBuf *paint_2d_lift_clone(ImBuf *ibuf, ImBuf *ibufb, const int *pos)
IMB_rectblend(clonebuf,
clonebuf,
ibuf,
NULL,
NULL,
NULL,
nullptr,
nullptr,
nullptr,
0,
destx,
desty,
@ -1183,8 +1185,8 @@ static ImBuf *paint_2d_lift_clone(ImBuf *ibuf, ImBuf *ibufb, const int *pos)
static void paint_2d_convert_brushco(ImBuf *ibufb, const float pos[2], int ipos[2])
{
ipos[0] = (int)floorf(pos[0] - ibufb->x / 2);
ipos[1] = (int)floorf(pos[1] - ibufb->y / 2);
ipos[0] = int(floorf(pos[0] - ibufb->x / 2));
ipos[1] = int(floorf(pos[1] - ibufb->y / 2));
}
static void paint_2d_do_making_brush(ImagePaintState *s,
@ -1211,12 +1213,12 @@ static void paint_2d_do_making_brush(ImagePaintState *s,
int origy = region->desty - ty * ED_IMAGE_UNDO_TILE_SIZE;
if (tile->canvas->rect_float) {
tmpbuf.rect_float = ED_image_paint_tile_find(
undo_tiles, s->image, tile->canvas, &tile->iuser, tx, ty, &mask, false);
tmpbuf.rect_float = static_cast<float *>(ED_image_paint_tile_find(
undo_tiles, s->image, tile->canvas, &tile->iuser, tx, ty, &mask, false));
}
else {
tmpbuf.rect = ED_image_paint_tile_find(
undo_tiles, s->image, tile->canvas, &tile->iuser, tx, ty, &mask, false);
tmpbuf.rect = static_cast<uint *>(ED_image_paint_tile_find(
undo_tiles, s->image, tile->canvas, &tile->iuser, tx, ty, &mask, false));
}
IMB_rectblend(tile->canvas,
@ -1234,13 +1236,13 @@ static void paint_2d_do_making_brush(ImagePaintState *s,
region->srcy,
region->width,
region->height,
blend,
IMB_BlendMode(blend),
((s->brush->flag & BRUSH_ACCUMULATE) != 0));
}
}
}
typedef struct Paint2DForeachData {
struct Paint2DForeachData {
ImagePaintState *s;
ImagePaintTile *tile;
ImagePaintRegion *region;
@ -1249,11 +1251,11 @@ typedef struct Paint2DForeachData {
short blend;
int tilex;
int tilew;
} Paint2DForeachData;
};
static void paint_2d_op_foreach_do(void *__restrict data_v,
const int iter,
const TaskParallelTLS *__restrict UNUSED(tls))
const TaskParallelTLS *__restrict /*tls*/)
{
Paint2DForeachData *data = (Paint2DForeachData *)data_v;
paint_2d_do_making_brush(data->s,
@ -1274,7 +1276,7 @@ static int paint_2d_op(void *state,
const float pos[2])
{
ImagePaintState *s = ((ImagePaintState *)state);
ImBuf *clonebuf = NULL, *frombuf;
ImBuf *clonebuf = nullptr, *frombuf;
ImBuf *canvas = tile->canvas;
ImBuf *ibufb = tile->cache.ibuf;
ImagePaintRegion region[4];
@ -1371,7 +1373,7 @@ static int paint_2d_op(void *state,
IMB_rectblend_threaded(canvas,
canvas,
frombuf,
NULL,
nullptr,
tile->cache.curve_mask_cache.curve_mask,
tile->cache.tex_mask,
mask_max,
@ -1383,7 +1385,7 @@ static int paint_2d_op(void *state,
region[a].srcy,
region[a].width,
region[a].height,
blend,
IMB_BlendMode(blend),
false);
}
}
@ -1400,10 +1402,10 @@ static int paint_2d_canvas_set(ImagePaintState *s)
/* set clone canvas */
if (s->tool == PAINT_TOOL_CLONE) {
Image *ima = s->brush->clone.image;
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, nullptr, nullptr);
if (!ima || !ibuf || !(ibuf->rect || ibuf->rect_float)) {
BKE_image_release_ibuf(ima, ibuf, NULL);
BKE_image_release_ibuf(ima, ibuf, nullptr);
return 0;
}
@ -1427,9 +1429,9 @@ static int paint_2d_canvas_set(ImagePaintState *s)
static void paint_2d_canvas_free(ImagePaintState *s)
{
for (int i = 0; i < s->num_tiles; i++) {
BKE_image_release_ibuf(s->image, s->tiles[i].canvas, NULL);
BKE_image_release_ibuf(s->image, s->tiles[i].canvas, nullptr);
}
BKE_image_release_ibuf(s->brush->clone.image, s->clonecanvas, NULL);
BKE_image_release_ibuf(s->brush->clone.image, s->clonecanvas, nullptr);
if (s->blurkernel) {
paint_delete_blur_kernel(s->blurkernel);
@ -1463,7 +1465,7 @@ void paint_2d_stroke(void *ps,
float base_size)
{
float new_uv[2], old_uv[2];
ImagePaintState *s = ps;
ImagePaintState *s = static_cast<ImagePaintState *>(ps);
BrushPainter *painter = s->painter;
const bool is_data = s->tiles[0].canvas->colormanage_flag & IMB_COLORMANAGE_IS_DATA;
@ -1534,7 +1536,7 @@ void paint_2d_stroke(void *ps,
* this should probably be changed when texture painting color space is supported
*/
brush_painter_2d_require_imbuf(
painter->brush, tile, (ibuf->rect_float != NULL), !is_data, painter->cache_invert);
painter->brush, tile, (ibuf->rect_float != nullptr), !is_data, painter->cache_invert);
brush_painter_2d_refresh_cache(s, painter, tile, new_coord, mval, pressure, distance, size);
@ -1553,7 +1555,7 @@ void *paint_2d_new_stroke(bContext *C, wmOperator *op, int mode)
ToolSettings *settings = scene->toolsettings;
Brush *brush = BKE_paint_brush(&settings->imapaint.paint);
ImagePaintState *s = MEM_callocN(sizeof(ImagePaintState), "ImagePaintState");
ImagePaintState *s = MEM_cnew<ImagePaintState>(__func__);
s->sima = CTX_wm_space_image(C);
s->v2d = &CTX_wm_region(C)->v2d;
@ -1566,37 +1568,37 @@ void *paint_2d_new_stroke(bContext *C, wmOperator *op, int mode)
s->image = s->sima->image;
s->symmetry = settings->imapaint.paint.symmetry_flags;
if (s->image == NULL) {
if (s->image == nullptr) {
MEM_freeN(s);
return NULL;
return nullptr;
}
if (BKE_image_has_packedfile(s->image) && s->image->rr != NULL) {
if (BKE_image_has_packedfile(s->image) && s->image->rr != nullptr) {
BKE_report(op->reports, RPT_WARNING, "Packed MultiLayer files cannot be painted");
MEM_freeN(s);
return NULL;
return nullptr;
}
s->num_tiles = BLI_listbase_count(&s->image->tiles);
s->tiles = MEM_callocN(sizeof(ImagePaintTile) * s->num_tiles, "ImagePaintTile");
s->tiles = MEM_cnew_array<ImagePaintTile>(s->num_tiles, __func__);
for (int i = 0; i < s->num_tiles; i++) {
s->tiles[i].iuser = sima->iuser;
}
zero_v2(s->tiles[0].uv_origin);
ImBuf *ibuf = BKE_image_acquire_ibuf(s->image, &s->tiles[0].iuser, NULL);
if (ibuf == NULL) {
ImBuf *ibuf = BKE_image_acquire_ibuf(s->image, &s->tiles[0].iuser, nullptr);
if (ibuf == nullptr) {
MEM_freeN(s->tiles);
MEM_freeN(s);
return NULL;
return nullptr;
}
if (ibuf->channels != 4) {
BKE_image_release_ibuf(s->image, ibuf, NULL);
BKE_image_release_ibuf(s->image, ibuf, nullptr);
BKE_report(op->reports, RPT_WARNING, "Image requires 4 color channels to paint");
MEM_freeN(s->tiles);
MEM_freeN(s);
return NULL;
return nullptr;
}
s->tiles[0].size[0] = ibuf->x;
@ -1609,7 +1611,9 @@ void *paint_2d_new_stroke(bContext *C, wmOperator *op, int mode)
/* Initialize offsets here, they're needed for the uv space clip test before lazy-loading the
* tile properly. */
int tile_idx = 0;
for (ImageTile *tile = s->image->tiles.first; tile; tile = tile->next, tile_idx++) {
for (ImageTile *tile = static_cast<ImageTile *>(s->image->tiles.first); tile;
tile = tile->next, tile_idx++)
{
s->tiles[tile_idx].iuser.tile = tile->tile_number;
s->tiles[tile_idx].uv_origin[0] = ((tile->tile_number - 1001) % 10);
s->tiles[tile_idx].uv_origin[1] = ((tile->tile_number - 1001) / 10);
@ -1619,7 +1623,7 @@ void *paint_2d_new_stroke(bContext *C, wmOperator *op, int mode)
MEM_freeN(s->tiles);
MEM_freeN(s);
return NULL;
return nullptr;
}
if (brush->imagepaint_tool == PAINT_TOOL_SOFTEN) {
@ -1636,16 +1640,16 @@ void *paint_2d_new_stroke(bContext *C, wmOperator *op, int mode)
void paint_2d_redraw(const bContext *C, void *ps, bool final)
{
ImagePaintState *s = ps;
ImagePaintState *s = static_cast<ImagePaintState *>(ps);
bool had_redraw = false;
for (int i = 0; i < s->num_tiles; i++) {
if (s->tiles[i].need_redraw) {
ImBuf *ibuf = BKE_image_acquire_ibuf(s->image, &s->tiles[i].iuser, NULL);
ImBuf *ibuf = BKE_image_acquire_ibuf(s->image, &s->tiles[i].iuser, nullptr);
imapaint_image_update(s->sima, s->image, ibuf, &s->tiles[i].iuser, false);
BKE_image_release_ibuf(s->image, ibuf, NULL);
BKE_image_release_ibuf(s->image, ibuf, nullptr);
s->tiles[i].need_redraw = false;
had_redraw = true;
@ -1654,7 +1658,7 @@ void paint_2d_redraw(const bContext *C, void *ps, bool final)
if (had_redraw) {
ED_imapaint_clear_partial_redraw();
if (s->sima == NULL || !s->sima->lock) {
if (s->sima == nullptr || !s->sima->lock) {
ED_region_tag_redraw(CTX_wm_region(C));
}
else {
@ -1675,7 +1679,7 @@ void paint_2d_redraw(const bContext *C, void *ps, bool final)
void paint_2d_stroke_done(void *ps)
{
ImagePaintState *s = ps;
ImagePaintState *s = static_cast<ImagePaintState *>(ps);
paint_2d_canvas_free(s);
for (int i = 0; i < s->num_tiles; i++) {
@ -1747,7 +1751,7 @@ static ImageUser *paint_2d_get_tile_iuser(ImagePaintState *s, int tile_number)
for (int i = 0; i < s->num_tiles; i++) {
if (s->tiles[i].iuser.tile == tile_number) {
if (!paint_2d_ensure_tile_canvas(s, i)) {
return NULL;
return nullptr;
}
iuser = &s->tiles[i].iuser;
break;
@ -1767,7 +1771,7 @@ void paint_2d_bucket_fill(const bContext *C,
SpaceImage *sima = CTX_wm_space_image(C);
Image *ima = sima->image;
ImagePaintState *s = ps;
ImagePaintState *s = static_cast<ImagePaintState *>(ps);
ImBuf *ibuf;
int x_px, y_px;
@ -1789,9 +1793,9 @@ void paint_2d_bucket_fill(const bContext *C,
int tile_number = BKE_image_get_tile_from_pos(ima, image_init, image_init, uv_origin);
ImageUser local_iuser, *iuser;
if (s != NULL) {
if (s != nullptr) {
iuser = paint_2d_get_tile_iuser(s, tile_number);
if (iuser == NULL) {
if (iuser == nullptr) {
return;
}
}
@ -1801,12 +1805,12 @@ void paint_2d_bucket_fill(const bContext *C,
iuser->tile = tile_number;
}
ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
ibuf = BKE_image_acquire_ibuf(ima, iuser, nullptr);
if (!ibuf) {
return;
}
do_float = (ibuf->rect_float != NULL);
do_float = (ibuf->rect_float != nullptr);
/* first check if our image is float. If it is not we should correct the color to
* be in gamma space. strictly speaking this is not correct, but blender does not paint
* byte images in linear space */
@ -1859,7 +1863,7 @@ void paint_2d_bucket_fill(const bContext *C,
y_px = image_init[1] * ibuf->y;
if (x_px >= ibuf->x || x_px < 0 || y_px > ibuf->y || y_px < 0) {
BKE_image_release_ibuf(ima, ibuf, NULL);
BKE_image_release_ibuf(ima, ibuf, nullptr);
return;
}
@ -1890,7 +1894,7 @@ void paint_2d_bucket_fill(const bContext *C,
IMB_blend_color_float(ibuf->rect_float + 4 * (coordinate),
ibuf->rect_float + 4 * (coordinate),
color_f,
br->blend);
IMB_BlendMode(br->blend));
/* reconstruct the coordinates here */
x_px = coordinate % width;
@ -1934,7 +1938,7 @@ void paint_2d_bucket_fill(const bContext *C,
IMB_blend_color_byte((uchar *)(ibuf->rect + coordinate),
(uchar *)(ibuf->rect + coordinate),
(uchar *)&color_b,
br->blend);
IMB_BlendMode(br->blend));
/* reconstruct the coordinates here */
x_px = coordinate % width;
@ -1979,7 +1983,7 @@ void paint_2d_bucket_fill(const bContext *C,
imapaint_image_update(sima, ima, ibuf, iuser, false);
ED_imapaint_clear_partial_redraw();
BKE_image_release_ibuf(ima, ibuf, NULL);
BKE_image_release_ibuf(ima, ibuf, nullptr);
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
}
@ -1989,7 +1993,7 @@ void paint_2d_gradient_fill(
{
SpaceImage *sima = CTX_wm_space_image(C);
Image *ima = sima->image;
ImagePaintState *s = ps;
ImagePaintState *s = static_cast<ImagePaintState *>(ps);
ImBuf *ibuf;
int x_px, y_px;
@ -2002,7 +2006,7 @@ void paint_2d_gradient_fill(
bool do_float;
if (ima == NULL) {
if (ima == nullptr) {
return;
}
@ -2013,8 +2017,8 @@ void paint_2d_gradient_fill(
return;
}
ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
if (ibuf == NULL) {
ibuf = BKE_image_acquire_ibuf(ima, iuser, nullptr);
if (ibuf == nullptr) {
return;
}
@ -2035,7 +2039,7 @@ void paint_2d_gradient_fill(
line_len_sq_inv = 1.0f / line_len;
line_len = sqrtf(line_len);
do_float = (ibuf->rect_float != NULL);
do_float = (ibuf->rect_float != nullptr);
/* this will be substituted by something else when selection is available */
ED_imapaint_dirty_region(ima, ibuf, iuser, 0, 0, ibuf->x, ibuf->y, false);
@ -2064,7 +2068,7 @@ void paint_2d_gradient_fill(
IMB_blend_color_float(ibuf->rect_float + 4 * (((size_t)y_px) * ibuf->x + x_px),
ibuf->rect_float + 4 * (((size_t)y_px) * ibuf->x + x_px),
color_f,
br->blend);
IMB_BlendMode(br->blend));
}
}
}
@ -2093,7 +2097,7 @@ void paint_2d_gradient_fill(
IMB_blend_color_byte((uchar *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px),
(uchar *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px),
(uchar *)&color_b,
br->blend);
IMB_BlendMode(br->blend));
}
}
}
@ -2101,7 +2105,7 @@ void paint_2d_gradient_fill(
imapaint_image_update(sima, ima, ibuf, iuser, false);
ED_imapaint_clear_partial_redraw();
BKE_image_release_ibuf(ima, ibuf, NULL);
BKE_image_release_ibuf(ima, ibuf, nullptr);
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
}

View File

@ -13,7 +13,7 @@
#include "BKE_brush.h"
#include "paint_intern.h"
#include "paint_intern.hh"
namespace blender::ed::sculpt_paint {

View File

@ -32,7 +32,7 @@
#include "ED_image.h"
#include "paint_intern.h"
#include "paint_intern.hh"
namespace blender::ed::sculpt_paint::image::ops::paint {
@ -502,7 +502,6 @@ static void paint_cancel(bContext *C, wmOperator *op)
}
} // namespace blender::ed::sculpt_paint::image::ops::paint
extern "C" {
void PAINT_OT_image_paint(wmOperatorType *ot)
{
using namespace blender::ed::sculpt_paint::image::ops::paint;
@ -524,4 +523,3 @@ void PAINT_OT_image_paint(wmOperatorType *ot)
paint_stroke_operator_properties(ot);
}
}

View File

@ -103,7 +103,7 @@
//#include "bmesh_tools.h"
#include "paint_intern.h"
#include "paint_intern.hh"
static void partial_redraw_array_init(ImagePaintPartialRedraw *pr);

View File

@ -1,536 +0,0 @@
/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2008 Blender Foundation */
/** \file
* \ingroup edsculpt
*/
#pragma once
#include "BKE_paint.h"
#include "BLI_compiler_compat.h"
#include "BLI_math.h"
#include "BLI_rect.h"
#include "ED_select_utils.h"
#include "DNA_scene_types.h"
#ifdef __cplusplus
extern "C" {
#endif
struct ARegion;
struct Brush;
struct ColorManagedDisplay;
struct ColorSpace;
struct ImagePool;
struct MTex;
struct Object;
struct Paint;
struct PaintStroke;
struct PointerRNA;
struct RegionView3D;
struct Scene;
struct VPaint;
struct ViewContext;
struct bContext;
struct wmEvent;
struct wmKeyConfig;
struct wmOperator;
struct wmOperatorType;
typedef struct CoNo {
float co[3];
float no[3];
} CoNo;
/* paint_stroke.cc */
typedef bool (*StrokeGetLocation)(struct bContext *C,
float location[3],
const float mouse[2],
bool force_original);
typedef bool (*StrokeTestStart)(struct bContext *C, struct wmOperator *op, const float mouse[2]);
typedef void (*StrokeUpdateStep)(struct bContext *C,
struct wmOperator *op,
struct PaintStroke *stroke,
struct PointerRNA *itemptr);
typedef void (*StrokeRedraw)(const struct bContext *C, struct PaintStroke *stroke, bool final);
typedef void (*StrokeDone)(const struct bContext *C, struct PaintStroke *stroke);
struct PaintStroke *paint_stroke_new(struct bContext *C,
struct wmOperator *op,
StrokeGetLocation get_location,
StrokeTestStart test_start,
StrokeUpdateStep update_step,
StrokeRedraw redraw,
StrokeDone done,
int event_type);
void paint_stroke_free(struct bContext *C, struct wmOperator *op, struct PaintStroke *stroke);
/**
* Returns zero if the stroke dots should not be spaced, non-zero otherwise.
*/
bool paint_space_stroke_enabled(struct Brush *br, enum ePaintMode mode);
/**
* Return true if the brush size can change during paint (normally used for pressure).
*/
bool paint_supports_dynamic_size(struct Brush *br, enum ePaintMode mode);
/**
* Return true if the brush size can change during paint (normally used for pressure).
*/
bool paint_supports_dynamic_tex_coords(struct Brush *br, enum ePaintMode mode);
bool paint_supports_smooth_stroke(struct Brush *br, enum ePaintMode mode);
bool paint_supports_texture(enum ePaintMode mode);
bool paint_supports_jitter(enum ePaintMode mode);
/**
* Called in paint_ops.cc, on each regeneration of key-maps.
*/
struct wmKeyMap *paint_stroke_modal_keymap(struct wmKeyConfig *keyconf);
int paint_stroke_modal(struct bContext *C,
struct wmOperator *op,
const struct wmEvent *event,
struct PaintStroke **stroke_p);
int paint_stroke_exec(struct bContext *C, struct wmOperator *op, struct PaintStroke *stroke);
void paint_stroke_cancel(struct bContext *C, struct wmOperator *op, struct PaintStroke *stroke);
bool paint_stroke_flipped(struct PaintStroke *stroke);
bool paint_stroke_inverted(struct PaintStroke *stroke);
struct ViewContext *paint_stroke_view_context(struct PaintStroke *stroke);
void *paint_stroke_mode_data(struct PaintStroke *stroke);
float paint_stroke_distance_get(struct PaintStroke *stroke);
void paint_stroke_set_mode_data(struct PaintStroke *stroke, void *mode_data);
bool paint_stroke_started(struct PaintStroke *stroke);
bool PAINT_brush_tool_poll(struct bContext *C);
/**
* Delete overlay cursor textures to preserve memory and invalidate all overlay flags.
*/
void paint_cursor_delete_textures(void);
/* paint_vertex.c */
bool weight_paint_poll(struct bContext *C);
bool weight_paint_poll_ignore_tool(bContext *C);
bool weight_paint_mode_poll(struct bContext *C);
bool vertex_paint_poll(struct bContext *C);
bool vertex_paint_poll_ignore_tool(struct bContext *C);
/**
* Returns true if vertex paint mode is active.
*/
bool vertex_paint_mode_poll(struct bContext *C);
typedef void (*VPaintTransform_Callback)(const float col[3],
const void *user_data,
float r_col[3]);
void PAINT_OT_weight_paint_toggle(struct wmOperatorType *ot);
void PAINT_OT_weight_paint(struct wmOperatorType *ot);
void PAINT_OT_weight_set(struct wmOperatorType *ot);
enum {
WPAINT_GRADIENT_TYPE_LINEAR,
WPAINT_GRADIENT_TYPE_RADIAL,
};
void PAINT_OT_weight_gradient(struct wmOperatorType *ot);
void PAINT_OT_vertex_paint_toggle(struct wmOperatorType *ot);
void PAINT_OT_vertex_paint(struct wmOperatorType *ot);
unsigned int vpaint_get_current_color(struct Scene *scene, struct VPaint *vp, bool secondary);
/**
* \note weight-paint has an equivalent function: #ED_wpaint_blend_tool
*/
unsigned int ED_vpaint_blend_tool(int tool, uint col, uint paintcol, int alpha_i);
/* paint_vertex_weight_utils.c */
/**
* \param weight: Typically the current weight: #MDeformWeight.weight
*
* \return The final weight, note that this is _not_ clamped from [0-1].
* Clamping must be done on the final #MDeformWeight.weight
*
* \note vertex-paint has an equivalent function: #ED_vpaint_blend_tool
*/
float ED_wpaint_blend_tool(int tool, float weight, float paintval, float alpha);
/* Utility for tools to ensure vertex groups exist before they begin. */
enum eWPaintFlag {
WPAINT_ENSURE_MIRROR = (1 << 0),
};
struct WPaintVGroupIndex {
int active;
int mirror;
};
/**
* Ensure we have data on wpaint start, add if needed.
*/
bool ED_wpaint_ensure_data(struct bContext *C,
struct ReportList *reports,
enum eWPaintFlag flag,
struct WPaintVGroupIndex *vgroup_index);
/** Return -1 when invalid. */
int ED_wpaint_mirror_vgroup_ensure(struct Object *ob, int vgroup_active);
/* paint_vertex_color_ops.c */
void PAINT_OT_vertex_color_set(struct wmOperatorType *ot);
void PAINT_OT_vertex_color_from_weight(struct wmOperatorType *ot);
void PAINT_OT_vertex_color_smooth(struct wmOperatorType *ot);
void PAINT_OT_vertex_color_brightness_contrast(struct wmOperatorType *ot);
void PAINT_OT_vertex_color_hsv(struct wmOperatorType *ot);
void PAINT_OT_vertex_color_invert(struct wmOperatorType *ot);
void PAINT_OT_vertex_color_levels(struct wmOperatorType *ot);
/* paint_vertex_weight_ops.c */
void PAINT_OT_weight_from_bones(struct wmOperatorType *ot);
void PAINT_OT_weight_sample(struct wmOperatorType *ot);
void PAINT_OT_weight_sample_group(struct wmOperatorType *ot);
/* paint_vertex_proj.c */
struct VertProjHandle;
struct VertProjHandle *ED_vpaint_proj_handle_create(struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *ob,
struct CoNo **r_vcosnos);
void ED_vpaint_proj_handle_update(struct Depsgraph *depsgraph,
struct VertProjHandle *vp_handle,
/* runtime vars */
struct ARegion *region,
const float mval_fl[2]);
void ED_vpaint_proj_handle_free(struct VertProjHandle *vp_handle);
/* paint_image.c */
typedef struct ImagePaintPartialRedraw {
rcti dirty_region;
} ImagePaintPartialRedraw;
bool image_texture_paint_poll(struct bContext *C);
void imapaint_image_update(struct SpaceImage *sima,
struct Image *image,
struct ImBuf *ibuf,
struct ImageUser *iuser,
short texpaint);
struct ImagePaintPartialRedraw *get_imapaintpartial(void);
void set_imapaintpartial(struct ImagePaintPartialRedraw *ippr);
void imapaint_region_tiles(
struct ImBuf *ibuf, int x, int y, int w, int h, int *tx, int *ty, int *tw, int *th);
bool get_imapaint_zoom(struct bContext *C, float *zoomx, float *zoomy);
void *paint_2d_new_stroke(struct bContext *, struct wmOperator *, int mode);
void paint_2d_redraw(const struct bContext *C, void *ps, bool final);
void paint_2d_stroke_done(void *ps);
void paint_2d_stroke(void *ps,
const float prev_mval[2],
const float mval[2],
bool eraser,
float pressure,
float distance,
float size);
/**
* This function expects linear space color values.
*/
void paint_2d_bucket_fill(const struct bContext *C,
const float color[3],
struct Brush *br,
const float mouse_init[2],
const float mouse_final[2],
void *ps);
void paint_2d_gradient_fill(const struct bContext *C,
struct Brush *br,
const float mouse_init[2],
const float mouse_final[2],
void *ps);
void *paint_proj_new_stroke(struct bContext *C, struct Object *ob, const float mouse[2], int mode);
void paint_proj_stroke(const struct bContext *C,
void *ps_handle_p,
const float prev_pos[2],
const float pos[2],
bool eraser,
float pressure,
float distance,
float size);
void paint_proj_redraw(const struct bContext *C, void *ps_handle_p, bool final);
void paint_proj_stroke_done(void *ps_handle_p);
void paint_brush_color_get(struct Scene *scene,
struct Brush *br,
bool color_correction,
bool invert,
float distance,
float pressure,
float color[3],
struct ColorManagedDisplay *display);
bool paint_use_opacity_masking(struct Brush *brush);
void paint_brush_init_tex(struct Brush *brush);
void paint_brush_exit_tex(struct Brush *brush);
bool image_paint_poll(struct bContext *C);
void PAINT_OT_grab_clone(struct wmOperatorType *ot);
void PAINT_OT_sample_color(struct wmOperatorType *ot);
void PAINT_OT_brush_colors_flip(struct wmOperatorType *ot);
void PAINT_OT_texture_paint_toggle(struct wmOperatorType *ot);
void PAINT_OT_project_image(struct wmOperatorType *ot);
void PAINT_OT_image_from_view(struct wmOperatorType *ot);
void PAINT_OT_add_texture_paint_slot(struct wmOperatorType *ot);
void PAINT_OT_image_paint(struct wmOperatorType *ot);
void PAINT_OT_add_simple_uvs(struct wmOperatorType *ot);
/* paint_image_2d_curve_mask.cc */
/**
* \brief Caching structure for curve mask.
*
* When 2d painting images the curve mask is used as an input.
*/
typedef struct CurveMaskCache {
/**
* \brief Last #CurveMapping.changed_timestamp being read.
*
* When different the input cache needs to be recalculated.
*/
int last_curve_timestamp;
/**
* \brief sampled version of the brush curve-mapping.
*/
float *sampled_curve;
/**
* \brief Size in bytes of the curve_mask field.
*
* Used to determine if the curve_mask needs to be re-allocated.
*/
size_t curve_mask_size;
/**
* \brief Curve mask that can be passed as curve_mask parameter when.
*/
ushort *curve_mask;
} CurveMaskCache;
void paint_curve_mask_cache_free_data(CurveMaskCache *curve_mask_cache);
void paint_curve_mask_cache_update(CurveMaskCache *curve_mask_cache,
const struct Brush *brush,
int diameter,
float radius,
const float cursor_position[2]);
/* sculpt_uv.c */
void SCULPT_OT_uv_sculpt_stroke(struct wmOperatorType *ot);
/* paint_utils.c */
/**
* Convert the object-space axis-aligned bounding box (expressed as
* its minimum and maximum corners) into a screen-space rectangle,
* returns zero if the result is empty.
*/
bool paint_convert_bb_to_rect(struct rcti *rect,
const float bb_min[3],
const float bb_max[3],
const struct ARegion *region,
struct RegionView3D *rv3d,
struct Object *ob);
/**
* Get four planes in object-space that describe the projection of
* screen_rect from screen into object-space (essentially converting a
* 2D screens-space bounding box into four 3D planes).
*/
void paint_calc_redraw_planes(float planes[4][4],
const struct ARegion *region,
struct Object *ob,
const struct rcti *screen_rect);
float paint_calc_object_space_radius(struct ViewContext *vc,
const float center[3],
float pixel_radius);
/**
* Returns true when a color was sampled and false when a value was sampled.
*/
bool paint_get_tex_pixel(const struct MTex *mtex,
float u,
float v,
struct ImagePool *pool,
int thread,
float *r_intensity,
float r_rgba[4]);
/**
* Used for both 3D view and image window.
*/
void paint_sample_color(
struct bContext *C, struct ARegion *region, int x, int y, bool texpaint_proj, bool palette);
void paint_stroke_operator_properties(struct wmOperatorType *ot);
void BRUSH_OT_curve_preset(struct wmOperatorType *ot);
void BRUSH_OT_sculpt_curves_falloff_preset(struct wmOperatorType *ot);
void PAINT_OT_face_select_linked(struct wmOperatorType *ot);
void PAINT_OT_face_select_linked_pick(struct wmOperatorType *ot);
void PAINT_OT_face_select_all(struct wmOperatorType *ot);
void PAINT_OT_face_select_more(struct wmOperatorType *ot);
void PAINT_OT_face_select_less(struct wmOperatorType *ot);
void PAINT_OT_face_select_hide(struct wmOperatorType *ot);
void PAINT_OT_face_vert_reveal(struct wmOperatorType *ot);
void PAINT_OT_vert_select_all(struct wmOperatorType *ot);
void PAINT_OT_vert_select_ungrouped(struct wmOperatorType *ot);
void PAINT_OT_vert_select_hide(struct wmOperatorType *ot);
void PAINT_OT_vert_select_linked(struct wmOperatorType *ot);
void PAINT_OT_vert_select_linked_pick(struct wmOperatorType *ot);
void PAINT_OT_vert_select_more(struct wmOperatorType *ot);
void PAINT_OT_vert_select_less(struct wmOperatorType *ot);
bool vert_paint_poll(struct bContext *C);
bool mask_paint_poll(struct bContext *C);
bool paint_curve_poll(struct bContext *C);
bool facemask_paint_poll(struct bContext *C);
/**
* Uses symm to selectively flip any axis of a coordinate.
*/
BLI_INLINE void flip_v3_v3(float out[3], const float in[3], const ePaintSymmetryFlags symm)
{
if (symm & PAINT_SYMM_X) {
out[0] = -in[0];
}
else {
out[0] = in[0];
}
if (symm & PAINT_SYMM_Y) {
out[1] = -in[1];
}
else {
out[1] = in[1];
}
if (symm & PAINT_SYMM_Z) {
out[2] = -in[2];
}
else {
out[2] = in[2];
}
}
BLI_INLINE void flip_qt_qt(float out[4], const float in[4], const ePaintSymmetryFlags symm)
{
float axis[3], angle;
quat_to_axis_angle(axis, &angle, in);
normalize_v3(axis);
if (symm & PAINT_SYMM_X) {
axis[0] *= -1.0f;
angle *= -1.0f;
}
if (symm & PAINT_SYMM_Y) {
axis[1] *= -1.0f;
angle *= -1.0f;
}
if (symm & PAINT_SYMM_Z) {
axis[2] *= -1.0f;
angle *= -1.0f;
}
axis_angle_normalized_to_quat(out, axis, angle);
}
BLI_INLINE void flip_v3(float v[3], const ePaintSymmetryFlags symm)
{
flip_v3_v3(v, v, symm);
}
BLI_INLINE void flip_qt(float quat[4], const ePaintSymmetryFlags symm)
{
flip_qt_qt(quat, quat, symm);
}
/* stroke operator */
typedef enum BrushStrokeMode {
BRUSH_STROKE_NORMAL,
BRUSH_STROKE_INVERT,
BRUSH_STROKE_SMOOTH,
} BrushStrokeMode;
/* paint_hide.cc */
typedef enum {
PARTIALVIS_HIDE,
PARTIALVIS_SHOW,
} PartialVisAction;
typedef enum {
PARTIALVIS_INSIDE,
PARTIALVIS_OUTSIDE,
PARTIALVIS_ALL,
PARTIALVIS_MASKED,
} PartialVisArea;
void PAINT_OT_hide_show(struct wmOperatorType *ot);
/* paint_mask.c */
/* The gesture API doesn't write to this enum type,
* it writes to eSelectOp from ED_select_utils.h.
* We must thus map the modes here to the desired
* eSelectOp modes.
*
* Fixes #102349.
*/
typedef enum {
PAINT_MASK_FLOOD_VALUE = SEL_OP_SUB,
PAINT_MASK_FLOOD_VALUE_INVERSE = SEL_OP_ADD,
PAINT_MASK_INVERT = SEL_OP_XOR,
} PaintMaskFloodMode;
void PAINT_OT_mask_flood_fill(struct wmOperatorType *ot);
void PAINT_OT_mask_lasso_gesture(struct wmOperatorType *ot);
void PAINT_OT_mask_box_gesture(struct wmOperatorType *ot);
void PAINT_OT_mask_line_gesture(struct wmOperatorType *ot);
/* paint_curve.c */
void PAINTCURVE_OT_new(struct wmOperatorType *ot);
void PAINTCURVE_OT_add_point(struct wmOperatorType *ot);
void PAINTCURVE_OT_delete_point(struct wmOperatorType *ot);
void PAINTCURVE_OT_select(struct wmOperatorType *ot);
void PAINTCURVE_OT_slide(struct wmOperatorType *ot);
void PAINTCURVE_OT_draw(struct wmOperatorType *ot);
void PAINTCURVE_OT_cursor(struct wmOperatorType *ot);
/* image painting blur kernel */
typedef struct {
float *wdata; /* actual kernel */
int side; /* kernel side */
int side_squared; /* data side */
int pixel_len; /* pixels around center that kernel is wide */
} BlurKernel;
enum eBlurKernelType;
/**
* Paint blur kernels. Projective painting enforces use of a 2x2 kernel due to lagging.
* Can be extended to other blur kernels later,
*/
BlurKernel *paint_new_blur_kernel(struct Brush *br, bool proj);
void paint_delete_blur_kernel(BlurKernel *);
/** Initialize viewport pivot from evaluated bounding box center of `ob`. */
void paint_init_pivot(struct Object *ob, struct Scene *scene);
/* paint curve defines */
#define PAINT_CURVE_NUM_SEGMENTS 40
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,519 @@
/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2008 Blender Foundation */
/** \file
* \ingroup edsculpt
*/
#pragma once
#include "BKE_paint.h"
#include "BLI_compiler_compat.h"
#include "BLI_math.h"
#include "BLI_rect.h"
#include "ED_select_utils.h"
#include "DNA_scene_types.h"
struct ARegion;
struct Brush;
struct ColorManagedDisplay;
struct ColorSpace;
struct ImagePool;
struct MTex;
struct Object;
struct Paint;
struct PaintStroke;
struct PointerRNA;
struct RegionView3D;
struct Scene;
struct SpaceImage;
struct VPaint;
struct ViewContext;
struct bContext;
struct wmEvent;
struct wmKeyConfig;
struct wmKeyMap;
struct wmOperator;
struct wmOperatorType;
struct VertProjHandle;
struct CoNo {
float co[3];
float no[3];
};
/* paint_stroke.cc */
using StrokeGetLocation = bool (*)(bContext *C,
float location[3],
const float mouse[2],
bool force_original);
using StrokeTestStart = bool (*)(bContext *C, wmOperator *op, const float mouse[2]);
using StrokeUpdateStep = void (*)(bContext *C,
wmOperator *op,
PaintStroke *stroke,
PointerRNA *itemptr);
using StrokeRedraw = void (*)(const bContext *C, PaintStroke *stroke, bool final);
using StrokeDone = void (*)(const bContext *C, PaintStroke *stroke);
PaintStroke *paint_stroke_new(bContext *C,
wmOperator *op,
StrokeGetLocation get_location,
StrokeTestStart test_start,
StrokeUpdateStep update_step,
StrokeRedraw redraw,
StrokeDone done,
int event_type);
void paint_stroke_free(bContext *C, wmOperator *op, PaintStroke *stroke);
/**
* Returns zero if the stroke dots should not be spaced, non-zero otherwise.
*/
bool paint_space_stroke_enabled(Brush *br, enum ePaintMode mode);
/**
* Return true if the brush size can change during paint (normally used for pressure).
*/
bool paint_supports_dynamic_size(Brush *br, enum ePaintMode mode);
/**
* Return true if the brush size can change during paint (normally used for pressure).
*/
bool paint_supports_dynamic_tex_coords(Brush *br, enum ePaintMode mode);
bool paint_supports_smooth_stroke(Brush *br, enum ePaintMode mode);
bool paint_supports_texture(enum ePaintMode mode);
bool paint_supports_jitter(enum ePaintMode mode);
/**
* Called in paint_ops.cc, on each regeneration of key-maps.
*/
wmKeyMap *paint_stroke_modal_keymap(wmKeyConfig *keyconf);
int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event, PaintStroke **stroke_p);
int paint_stroke_exec(bContext *C, wmOperator *op, PaintStroke *stroke);
void paint_stroke_cancel(bContext *C, wmOperator *op, PaintStroke *stroke);
bool paint_stroke_flipped(PaintStroke *stroke);
bool paint_stroke_inverted(PaintStroke *stroke);
ViewContext *paint_stroke_view_context(PaintStroke *stroke);
void *paint_stroke_mode_data(PaintStroke *stroke);
float paint_stroke_distance_get(PaintStroke *stroke);
void paint_stroke_set_mode_data(PaintStroke *stroke, void *mode_data);
bool paint_stroke_started(PaintStroke *stroke);
bool PAINT_brush_tool_poll(bContext *C);
/**
* Delete overlay cursor textures to preserve memory and invalidate all overlay flags.
*/
void paint_cursor_delete_textures(void);
/* paint_vertex.c */
bool weight_paint_poll(bContext *C);
bool weight_paint_poll_ignore_tool(bContext *C);
bool weight_paint_mode_poll(bContext *C);
bool vertex_paint_poll(bContext *C);
bool vertex_paint_poll_ignore_tool(bContext *C);
/**
* Returns true if vertex paint mode is active.
*/
bool vertex_paint_mode_poll(bContext *C);
typedef void (*VPaintTransform_Callback)(const float col[3],
const void *user_data,
float r_col[3]);
void PAINT_OT_weight_paint_toggle(wmOperatorType *ot);
void PAINT_OT_weight_paint(wmOperatorType *ot);
void PAINT_OT_weight_set(wmOperatorType *ot);
enum {
WPAINT_GRADIENT_TYPE_LINEAR,
WPAINT_GRADIENT_TYPE_RADIAL,
};
void PAINT_OT_weight_gradient(wmOperatorType *ot);
void PAINT_OT_vertex_paint_toggle(wmOperatorType *ot);
void PAINT_OT_vertex_paint(wmOperatorType *ot);
unsigned int vpaint_get_current_color(Scene *scene, VPaint *vp, bool secondary);
/**
* \note weight-paint has an equivalent function: #ED_wpaint_blend_tool
*/
unsigned int ED_vpaint_blend_tool(int tool, uint col, uint paintcol, int alpha_i);
/* paint_vertex_weight_utils.c */
/**
* \param weight: Typically the current weight: #MDeformWeight.weight
*
* \return The final weight, note that this is _not_ clamped from [0-1].
* Clamping must be done on the final #MDeformWeight.weight
*
* \note vertex-paint has an equivalent function: #ED_vpaint_blend_tool
*/
float ED_wpaint_blend_tool(int tool, float weight, float paintval, float alpha);
/* Utility for tools to ensure vertex groups exist before they begin. */
enum eWPaintFlag {
WPAINT_ENSURE_MIRROR = (1 << 0),
};
struct WPaintVGroupIndex {
int active;
int mirror;
};
/**
* Ensure we have data on wpaint start, add if needed.
*/
bool ED_wpaint_ensure_data(bContext *C,
ReportList *reports,
enum eWPaintFlag flag,
WPaintVGroupIndex *vgroup_index);
/** Return -1 when invalid. */
int ED_wpaint_mirror_vgroup_ensure(Object *ob, int vgroup_active);
/* paint_vertex_color_ops.c */
void PAINT_OT_vertex_color_set(wmOperatorType *ot);
void PAINT_OT_vertex_color_from_weight(wmOperatorType *ot);
void PAINT_OT_vertex_color_smooth(wmOperatorType *ot);
void PAINT_OT_vertex_color_brightness_contrast(wmOperatorType *ot);
void PAINT_OT_vertex_color_hsv(wmOperatorType *ot);
void PAINT_OT_vertex_color_invert(wmOperatorType *ot);
void PAINT_OT_vertex_color_levels(wmOperatorType *ot);
/* paint_vertex_weight_ops.c */
void PAINT_OT_weight_from_bones(wmOperatorType *ot);
void PAINT_OT_weight_sample(wmOperatorType *ot);
void PAINT_OT_weight_sample_group(wmOperatorType *ot);
/* paint_vertex_proj.c */
VertProjHandle *ED_vpaint_proj_handle_create(Depsgraph *depsgraph,
Scene *scene,
Object *ob,
CoNo **r_vcosnos);
void ED_vpaint_proj_handle_update(Depsgraph *depsgraph,
VertProjHandle *vp_handle,
/* runtime vars */
ARegion *region,
const float mval_fl[2]);
void ED_vpaint_proj_handle_free(VertProjHandle *vp_handle);
/* paint_image.c */
struct ImagePaintPartialRedraw {
rcti dirty_region;
};
bool image_texture_paint_poll(bContext *C);
void imapaint_image_update(
SpaceImage *sima, Image *image, ImBuf *ibuf, ImageUser *iuser, short texpaint);
ImagePaintPartialRedraw *get_imapaintpartial(void);
void set_imapaintpartial(ImagePaintPartialRedraw *ippr);
void imapaint_region_tiles(
ImBuf *ibuf, int x, int y, int w, int h, int *tx, int *ty, int *tw, int *th);
bool get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy);
void *paint_2d_new_stroke(bContext *, wmOperator *, int mode);
void paint_2d_redraw(const bContext *C, void *ps, bool final);
void paint_2d_stroke_done(void *ps);
void paint_2d_stroke(void *ps,
const float prev_mval[2],
const float mval[2],
bool eraser,
float pressure,
float distance,
float size);
/**
* This function expects linear space color values.
*/
void paint_2d_bucket_fill(const bContext *C,
const float color[3],
Brush *br,
const float mouse_init[2],
const float mouse_final[2],
void *ps);
void paint_2d_gradient_fill(
const bContext *C, Brush *br, const float mouse_init[2], const float mouse_final[2], void *ps);
void *paint_proj_new_stroke(bContext *C, Object *ob, const float mouse[2], int mode);
void paint_proj_stroke(const bContext *C,
void *ps_handle_p,
const float prev_pos[2],
const float pos[2],
bool eraser,
float pressure,
float distance,
float size);
void paint_proj_redraw(const bContext *C, void *ps_handle_p, bool final);
void paint_proj_stroke_done(void *ps_handle_p);
void paint_brush_color_get(Scene *scene,
Brush *br,
bool color_correction,
bool invert,
float distance,
float pressure,
float color[3],
ColorManagedDisplay *display);
bool paint_use_opacity_masking(Brush *brush);
void paint_brush_init_tex(Brush *brush);
void paint_brush_exit_tex(Brush *brush);
bool image_paint_poll(bContext *C);
void PAINT_OT_grab_clone(wmOperatorType *ot);
void PAINT_OT_sample_color(wmOperatorType *ot);
void PAINT_OT_brush_colors_flip(wmOperatorType *ot);
void PAINT_OT_texture_paint_toggle(wmOperatorType *ot);
void PAINT_OT_project_image(wmOperatorType *ot);
void PAINT_OT_image_from_view(wmOperatorType *ot);
void PAINT_OT_add_texture_paint_slot(wmOperatorType *ot);
void PAINT_OT_image_paint(wmOperatorType *ot);
void PAINT_OT_add_simple_uvs(wmOperatorType *ot);
/* paint_image_2d_curve_mask.cc */
/**
* \brief Caching structure for curve mask.
*
* When 2d painting images the curve mask is used as an input.
*/
struct CurveMaskCache {
/**
* \brief Last #CurveMapping.changed_timestamp being read.
*
* When different the input cache needs to be recalculated.
*/
int last_curve_timestamp;
/**
* \brief sampled version of the brush curve-mapping.
*/
float *sampled_curve;
/**
* \brief Size in bytes of the curve_mask field.
*
* Used to determine if the curve_mask needs to be re-allocated.
*/
size_t curve_mask_size;
/**
* \brief Curve mask that can be passed as curve_mask parameter when.
*/
ushort *curve_mask;
};
void paint_curve_mask_cache_free_data(CurveMaskCache *curve_mask_cache);
void paint_curve_mask_cache_update(CurveMaskCache *curve_mask_cache,
const Brush *brush,
int diameter,
float radius,
const float cursor_position[2]);
/* sculpt_uv.c */
void SCULPT_OT_uv_sculpt_stroke(wmOperatorType *ot);
/* paint_utils.cc */
/**
* Convert the object-space axis-aligned bounding box (expressed as
* its minimum and maximum corners) into a screen-space rectangle,
* returns zero if the result is empty.
*/
bool paint_convert_bb_to_rect(rcti *rect,
const float bb_min[3],
const float bb_max[3],
const ARegion *region,
RegionView3D *rv3d,
Object *ob);
/**
* Get four planes in object-space that describe the projection of
* screen_rect from screen into object-space (essentially converting a
* 2D screens-space bounding box into four 3D planes).
*/
void paint_calc_redraw_planes(float planes[4][4],
const ARegion *region,
Object *ob,
const rcti *screen_rect);
float paint_calc_object_space_radius(ViewContext *vc, const float center[3], float pixel_radius);
/**
* Returns true when a color was sampled and false when a value was sampled.
*/
bool paint_get_tex_pixel(const MTex *mtex,
float u,
float v,
ImagePool *pool,
int thread,
float *r_intensity,
float r_rgba[4]);
/**
* Used for both 3D view and image window.
*/
void paint_sample_color(
bContext *C, ARegion *region, int x, int y, bool texpaint_proj, bool palette);
void paint_stroke_operator_properties(wmOperatorType *ot);
void BRUSH_OT_curve_preset(wmOperatorType *ot);
void BRUSH_OT_sculpt_curves_falloff_preset(wmOperatorType *ot);
void PAINT_OT_face_select_linked(wmOperatorType *ot);
void PAINT_OT_face_select_linked_pick(wmOperatorType *ot);
void PAINT_OT_face_select_all(wmOperatorType *ot);
void PAINT_OT_face_select_more(wmOperatorType *ot);
void PAINT_OT_face_select_less(wmOperatorType *ot);
void PAINT_OT_face_select_hide(wmOperatorType *ot);
void PAINT_OT_face_vert_reveal(wmOperatorType *ot);
void PAINT_OT_vert_select_all(wmOperatorType *ot);
void PAINT_OT_vert_select_ungrouped(wmOperatorType *ot);
void PAINT_OT_vert_select_hide(wmOperatorType *ot);
void PAINT_OT_vert_select_linked(wmOperatorType *ot);
void PAINT_OT_vert_select_linked_pick(wmOperatorType *ot);
void PAINT_OT_vert_select_more(wmOperatorType *ot);
void PAINT_OT_vert_select_less(wmOperatorType *ot);
bool vert_paint_poll(bContext *C);
bool mask_paint_poll(bContext *C);
bool paint_curve_poll(bContext *C);
bool facemask_paint_poll(bContext *C);
/**
* Uses symm to selectively flip any axis of a coordinate.
*/
BLI_INLINE void flip_v3_v3(float out[3], const float in[3], const ePaintSymmetryFlags symm)
{
if (symm & PAINT_SYMM_X) {
out[0] = -in[0];
}
else {
out[0] = in[0];
}
if (symm & PAINT_SYMM_Y) {
out[1] = -in[1];
}
else {
out[1] = in[1];
}
if (symm & PAINT_SYMM_Z) {
out[2] = -in[2];
}
else {
out[2] = in[2];
}
}
BLI_INLINE void flip_qt_qt(float out[4], const float in[4], const ePaintSymmetryFlags symm)
{
float axis[3], angle;
quat_to_axis_angle(axis, &angle, in);
normalize_v3(axis);
if (symm & PAINT_SYMM_X) {
axis[0] *= -1.0f;
angle *= -1.0f;
}
if (symm & PAINT_SYMM_Y) {
axis[1] *= -1.0f;
angle *= -1.0f;
}
if (symm & PAINT_SYMM_Z) {
axis[2] *= -1.0f;
angle *= -1.0f;
}
axis_angle_normalized_to_quat(out, axis, angle);
}
BLI_INLINE void flip_v3(float v[3], const ePaintSymmetryFlags symm)
{
flip_v3_v3(v, v, symm);
}
BLI_INLINE void flip_qt(float quat[4], const ePaintSymmetryFlags symm)
{
flip_qt_qt(quat, quat, symm);
}
/* stroke operator */
typedef enum BrushStrokeMode {
BRUSH_STROKE_NORMAL,
BRUSH_STROKE_INVERT,
BRUSH_STROKE_SMOOTH,
} BrushStrokeMode;
/* paint_hide.cc */
typedef enum {
PARTIALVIS_HIDE,
PARTIALVIS_SHOW,
} PartialVisAction;
typedef enum {
PARTIALVIS_INSIDE,
PARTIALVIS_OUTSIDE,
PARTIALVIS_ALL,
PARTIALVIS_MASKED,
} PartialVisArea;
void PAINT_OT_hide_show(wmOperatorType *ot);
/* paint_mask.c */
/* The gesture API doesn't write to this enum type,
* it writes to eSelectOp from ED_select_utils.h.
* We must thus map the modes here to the desired
* eSelectOp modes.
*
* Fixes #102349.
*/
typedef enum {
PAINT_MASK_FLOOD_VALUE = SEL_OP_SUB,
PAINT_MASK_FLOOD_VALUE_INVERSE = SEL_OP_ADD,
PAINT_MASK_INVERT = SEL_OP_XOR,
} PaintMaskFloodMode;
void PAINT_OT_mask_flood_fill(wmOperatorType *ot);
void PAINT_OT_mask_lasso_gesture(wmOperatorType *ot);
void PAINT_OT_mask_box_gesture(wmOperatorType *ot);
void PAINT_OT_mask_line_gesture(wmOperatorType *ot);
/* paint_curve.c */
void PAINTCURVE_OT_new(wmOperatorType *ot);
void PAINTCURVE_OT_add_point(wmOperatorType *ot);
void PAINTCURVE_OT_delete_point(wmOperatorType *ot);
void PAINTCURVE_OT_select(wmOperatorType *ot);
void PAINTCURVE_OT_slide(wmOperatorType *ot);
void PAINTCURVE_OT_draw(wmOperatorType *ot);
void PAINTCURVE_OT_cursor(wmOperatorType *ot);
/* image painting blur kernel */
struct BlurKernel {
float *wdata; /* actual kernel */
int side; /* kernel side */
int side_squared; /* data side */
int pixel_len; /* pixels around center that kernel is wide */
};
enum eBlurKernelType;
/**
* Paint blur kernels. Projective painting enforces use of a 2x2 kernel due to lagging.
* Can be extended to other blur kernels later,
*/
BlurKernel *paint_new_blur_kernel(Brush *br, bool proj);
void paint_delete_blur_kernel(BlurKernel *);
/** Initialize viewport pivot from evaluated bounding box center of `ob`. */
void paint_init_pivot(Object *ob, Scene *scene);
/* paint curve defines */
#define PAINT_CURVE_NUM_SEGMENTS 40

View File

@ -51,7 +51,7 @@
#include "bmesh.h"
#include "tools/bmesh_boolean.h"
#include "paint_intern.h"
#include "paint_intern.hh"
/* For undo push. */
#include "sculpt_intern.hh"

View File

@ -42,8 +42,8 @@
#include "RNA_access.h"
#include "RNA_define.h"
#include "curves_sculpt_intern.h"
#include "paint_intern.h"
#include "curves_sculpt_intern.hh"
#include "paint_intern.hh"
#include "sculpt_intern.hh"
/* Brush operators */

View File

@ -42,7 +42,7 @@
#include "IMB_imbuf_types.h"
#include "paint_intern.h"
#include "paint_intern.hh"
#include "sculpt_intern.hh"
//#define DEBUG_TIME

View File

@ -5,8 +5,8 @@
* \ingroup edsculpt
*/
#include <math.h>
#include <stdlib.h>
#include <cmath>
#include <cstdlib>
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
@ -66,7 +66,7 @@
#include "WM_api.h"
#include "WM_types.h"
#include "paint_intern.h"
#include "paint_intern.hh"
bool paint_convert_bb_to_rect(rcti *rect,
const float bb_min[3],
@ -150,7 +150,7 @@ float paint_calc_object_space_radius(ViewContext *vc, const float center[3], flo
bool paint_get_tex_pixel(const MTex *mtex,
float u,
float v,
struct ImagePool *pool,
ImagePool *pool,
int thread,
/* Return arguments. */
float *r_intensity,
@ -192,7 +192,7 @@ void paint_stroke_operator_properties(wmOperatorType *ot)
PropertyRNA *prop;
prop = RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
RNA_def_property_flag(prop, PropertyFlag(PROP_HIDDEN | PROP_SKIP_SAVE));
RNA_def_enum(ot->srna,
"mode",
@ -268,7 +268,7 @@ static void imapaint_pick_uv(
float p[2], w[3], absw, minabsw;
float matrix[4][4], proj[4][4];
int view[4];
const ePaintCanvasSource mode = scene->toolsettings->imapaint.mode;
const ePaintCanvasSource mode = ePaintCanvasSource(scene->toolsettings->imapaint.mode);
const MLoopTri *lt = BKE_mesh_runtime_looptri_ensure(me_eval);
const int tottri = BKE_mesh_runtime_looptri_len(me_eval);
@ -276,7 +276,8 @@ static void imapaint_pick_uv(
const float(*positions)[3] = BKE_mesh_vert_positions(me_eval);
const int *corner_verts = BKE_mesh_corner_verts(me_eval);
const int *index_mp_to_orig = CustomData_get_layer(&me_eval->pdata, CD_ORIGINDEX);
const int *index_mp_to_orig = static_cast<const int *>(
CustomData_get_layer(&me_eval->pdata, CD_ORIGINDEX));
/* get the needed opengl matrices */
GPU_viewport_size_get_i(view);
@ -311,19 +312,21 @@ static void imapaint_pick_uv(
const Material *ma;
const TexPaintSlot *slot;
ma = BKE_object_material_get(ob_eval,
material_indices == NULL ? 1 : material_indices[poly_i] + 1);
ma = BKE_object_material_get(
ob_eval, material_indices == nullptr ? 1 : material_indices[poly_i] + 1);
slot = &ma->texpaintslot[ma->paint_active_slot];
if (!(slot && slot->uvname &&
(mloopuv = CustomData_get_layer_named(
&me_eval->ldata, CD_PROP_FLOAT2, slot->uvname))))
(mloopuv = static_cast<const float(*)[2]>(
CustomData_get_layer_named(&me_eval->ldata, CD_PROP_FLOAT2, slot->uvname)))))
{
mloopuv = CustomData_get_layer(&me_eval->ldata, CD_PROP_FLOAT2);
mloopuv = static_cast<const float(*)[2]>(
CustomData_get_layer(&me_eval->ldata, CD_PROP_FLOAT2));
}
}
else {
mloopuv = CustomData_get_layer(&me_eval->ldata, CD_PROP_FLOAT2);
mloopuv = static_cast<const float(*)[2]>(
CustomData_get_layer(&me_eval->ldata, CD_PROP_FLOAT2));
}
tri_uv[0] = mloopuv[lt->tri[0]];
@ -371,7 +374,7 @@ void paint_sample_color(
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Paint *paint = BKE_paint_get_active_from_context(C);
Palette *palette = BKE_paint_palette(paint);
PaletteColor *color = NULL;
PaletteColor *color = nullptr;
Brush *br = BKE_paint_brush(BKE_paint_get_active_from_context(C));
CLAMP(x, 0, region->winx);
@ -418,7 +421,7 @@ void paint_sample_color(
view3d_operator_needs_opengl(C);
if (imapaint_pick_face(&vc, mval, &faceindex, totpoly)) {
Image *image = NULL;
Image *image = nullptr;
int interp = SHD_INTERP_LINEAR;
if (use_material) {
@ -452,7 +455,7 @@ void paint_sample_color(
if (image->source == IMA_SRC_TILED) {
float new_uv[2];
iuser.tile = BKE_image_get_tile_from_pos(image, uv, new_uv, NULL);
iuser.tile = BKE_image_get_tile_from_pos(image, uv, new_uv, nullptr);
u = new_uv[0];
v = new_uv[1];
}
@ -468,7 +471,7 @@ void paint_sample_color(
}
}
ImBuf *ibuf = BKE_image_acquire_ibuf(image, &iuser, NULL);
ImBuf *ibuf = BKE_image_acquire_ibuf(image, &iuser, nullptr);
if (ibuf && (ibuf->rect || ibuf->rect_float)) {
u = u * ibuf->x;
v = v * ibuf->y;
@ -476,10 +479,10 @@ void paint_sample_color(
if (ibuf->rect_float) {
float rgba_f[4];
if (interp == SHD_INTERP_CLOSEST) {
nearest_interpolation_color_wrap(ibuf, NULL, rgba_f, u, v);
nearest_interpolation_color_wrap(ibuf, nullptr, rgba_f, u, v);
}
else {
bilinear_interpolation_color_wrap(ibuf, NULL, rgba_f, u, v);
bilinear_interpolation_color_wrap(ibuf, nullptr, rgba_f, u, v);
}
straight_to_premul_v4(rgba_f);
if (use_palette) {
@ -493,10 +496,10 @@ void paint_sample_color(
else {
uchar rgba[4];
if (interp == SHD_INTERP_CLOSEST) {
nearest_interpolation_color_wrap(ibuf, rgba, NULL, u, v);
nearest_interpolation_color_wrap(ibuf, rgba, nullptr, u, v);
}
else {
bilinear_interpolation_color_wrap(ibuf, rgba, NULL, u, v);
bilinear_interpolation_color_wrap(ibuf, rgba, nullptr, u, v);
}
if (use_palette) {
rgb_uchar_to_float(color->rgb, rgba);
@ -507,22 +510,22 @@ void paint_sample_color(
BKE_brush_color_set(scene, br, rgba_f);
}
}
BKE_image_release_ibuf(image, ibuf, NULL);
BKE_image_release_ibuf(image, ibuf, nullptr);
return;
}
BKE_image_release_ibuf(image, ibuf, NULL);
BKE_image_release_ibuf(image, ibuf, nullptr);
}
}
}
}
}
else if (sima != NULL) {
else if (sima != nullptr) {
/* Sample from the active image buffer. The sampled color is in
* Linear Scene Reference Space. */
float rgba_f[3];
bool is_data;
if (ED_space_image_color_sample(sima, region, (int[2]){x, y}, rgba_f, &is_data)) {
if (ED_space_image_color_sample(sima, region, blender::int2(x, y), rgba_f, &is_data)) {
if (!is_data) {
linearrgb_to_srgb_v3_v3(rgba_f, rgba_f);
}
@ -559,7 +562,7 @@ static int brush_curve_preset_exec(bContext *C, wmOperator *op)
if (br) {
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
BKE_brush_curve_preset(br, RNA_enum_get(op->ptr, "shape"));
BKE_brush_curve_preset(br, eCurveMappingPreset(RNA_enum_get(op->ptr, "shape")));
BKE_paint_invalidate_cursor_overlay(scene, view_layer, br->curve);
}
@ -580,7 +583,7 @@ static const EnumPropertyItem prop_shape_items[] = {
{CURVE_PRESET_LINE, "LINE", 0, "Line", ""},
{CURVE_PRESET_ROUND, "ROUND", 0, "Round", ""},
{CURVE_PRESET_ROOT, "ROOT", 0, "Root", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
void BRUSH_OT_curve_preset(wmOperatorType *ot)
@ -630,9 +633,9 @@ void BRUSH_OT_sculpt_curves_falloff_preset(wmOperatorType *ot)
}
/* face-select ops */
static int paint_select_linked_exec(bContext *C, wmOperator *UNUSED(op))
static int paint_select_linked_exec(bContext *C, wmOperator * /*op*/)
{
paintface_select_linked(C, CTX_data_active_object(C), NULL, true);
paintface_select_linked(C, CTX_data_active_object(C), nullptr, true);
ED_region_tag_redraw(CTX_wm_region(C));
return OPERATOR_FINISHED;
}
@ -700,7 +703,7 @@ static int paint_select_more_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
Mesh *mesh = BKE_mesh_from_object(ob);
if (mesh == NULL || mesh->totpoly == 0) {
if (mesh == nullptr || mesh->totpoly == 0) {
return OPERATOR_CANCELLED;
}
@ -731,7 +734,7 @@ static int paint_select_less_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
Mesh *mesh = BKE_mesh_from_object(ob);
if (mesh == NULL || mesh->totpoly == 0) {
if (mesh == nullptr || mesh->totpoly == 0) {
return OPERATOR_CANCELLED;
}
@ -784,9 +787,9 @@ void PAINT_OT_vert_select_all(wmOperatorType *ot)
static int vert_select_ungrouped_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
Mesh *me = ob->data;
Mesh *me = static_cast<Mesh *>(ob->data);
if (BLI_listbase_is_empty(&me->vertex_group_names) || (BKE_mesh_deform_verts(me) == NULL)) {
if (BLI_listbase_is_empty(&me->vertex_group_names) || (BKE_mesh_deform_verts(me) == nullptr)) {
BKE_report(op->reports, RPT_ERROR, "No weights/vertex groups on object");
return OPERATOR_CANCELLED;
}
@ -814,7 +817,7 @@ void PAINT_OT_vert_select_ungrouped(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection");
}
static int paintvert_select_linked_exec(bContext *C, wmOperator *UNUSED(op))
static int paintvert_select_linked_exec(bContext *C, wmOperator * /*op*/)
{
paintvert_select_linked(C, CTX_data_active_object(C));
ED_region_tag_redraw(CTX_wm_region(C));
@ -865,7 +868,7 @@ static int paintvert_select_more_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
Mesh *mesh = BKE_mesh_from_object(ob);
if (mesh == NULL || mesh->totpoly == 0) {
if (mesh == nullptr || mesh->totpoly == 0) {
return OPERATOR_CANCELLED;
}
@ -898,7 +901,7 @@ static int paintvert_select_less_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
Mesh *mesh = BKE_mesh_from_object(ob);
if (mesh == NULL || mesh->totpoly == 0) {
if (mesh == nullptr || mesh->totpoly == 0) {
return OPERATOR_CANCELLED;
}

View File

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

View File

@ -33,7 +33,7 @@
#include "ED_mesh.h"
#include "paint_intern.h" /* own include */
#include "paint_intern.hh" /* own include */
#include "sculpt_intern.hh"
using blender::Array;

View File

@ -26,7 +26,7 @@
#include "ED_screen.h"
#include "ED_view3d.h"
#include "paint_intern.h" /* own include */
#include "paint_intern.hh" /* own include */
/* Opaque Structs for internal use */
@ -45,7 +45,7 @@ struct VertProjHandle {
/* only for passing to the callbacks */
struct VertProjUpdate {
struct VertProjHandle *vp_handle;
VertProjHandle *vp_handle;
/* runtime */
ARegion *region;
@ -60,7 +60,7 @@ static void vpaint_proj_dm_map_cosnos_init__map_cb(void *userData,
const float co[3],
const float no[3])
{
struct VertProjHandle *vp_handle = userData;
VertProjHandle *vp_handle = static_cast<VertProjHandle *>(userData);
CoNo *co_no = &vp_handle->vcosnos[index];
/* check if we've been here before (normal should not be 0) */
@ -74,14 +74,14 @@ static void vpaint_proj_dm_map_cosnos_init__map_cb(void *userData,
copy_v3_v3(co_no->no, no);
}
static void vpaint_proj_dm_map_cosnos_init(struct Depsgraph *depsgraph,
Scene *UNUSED(scene),
static void vpaint_proj_dm_map_cosnos_init(Depsgraph *depsgraph,
Scene * /*scene*/,
Object *ob,
struct VertProjHandle *vp_handle)
VertProjHandle *vp_handle)
{
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
Mesh *me = ob->data;
Mesh *me = static_cast<Mesh *>(ob->data);
CustomData_MeshMasks cddata_masks = CD_MASK_BAREMESH_ORIGINDEX;
Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, &cddata_masks);
@ -101,8 +101,8 @@ static void vpaint_proj_dm_map_cosnos_update__map_cb(void *userData,
const float co[3],
const float no[3])
{
struct VertProjUpdate *vp_update = userData;
struct VertProjHandle *vp_handle = vp_update->vp_handle;
VertProjUpdate *vp_update = static_cast<VertProjUpdate *>(userData);
VertProjHandle *vp_handle = vp_update->vp_handle;
CoNo *co_no = &vp_handle->vcosnos[index];
@ -134,17 +134,17 @@ static void vpaint_proj_dm_map_cosnos_update__map_cb(void *userData,
copy_v3_v3(co_no->no, no);
}
static void vpaint_proj_dm_map_cosnos_update(struct Depsgraph *depsgraph,
struct VertProjHandle *vp_handle,
static void vpaint_proj_dm_map_cosnos_update(Depsgraph *depsgraph,
VertProjHandle *vp_handle,
ARegion *region,
const float mval_fl[2])
{
struct VertProjUpdate vp_update = {vp_handle, region, mval_fl};
VertProjUpdate vp_update = {vp_handle, region, mval_fl};
Object *ob = vp_handle->ob;
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
Mesh *me = ob->data;
Mesh *me = static_cast<Mesh *>(ob->data);
CustomData_MeshMasks cddata_masks = CD_MASK_BAREMESH_ORIGINDEX;
Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, &cddata_masks);
@ -160,40 +160,42 @@ static void vpaint_proj_dm_map_cosnos_update(struct Depsgraph *depsgraph,
/* -------------------------------------------------------------------- */
/* Public Functions */
struct VertProjHandle *ED_vpaint_proj_handle_create(struct Depsgraph *depsgraph,
Scene *scene,
Object *ob,
CoNo **r_vcosnos)
VertProjHandle *ED_vpaint_proj_handle_create(Depsgraph *depsgraph,
Scene *scene,
Object *ob,
CoNo **r_vcosnos)
{
struct VertProjHandle *vp_handle = MEM_mallocN(sizeof(struct VertProjHandle), __func__);
Mesh *me = ob->data;
VertProjHandle *vp_handle = static_cast<VertProjHandle *>(
MEM_mallocN(sizeof(VertProjHandle), __func__));
Mesh *me = static_cast<Mesh *>(ob->data);
/* setup the handle */
vp_handle->vcosnos = MEM_mallocN(sizeof(CoNo) * me->totvert, "vertexcosnos map");
vp_handle->vcosnos = static_cast<CoNo *>(
MEM_mallocN(sizeof(CoNo) * me->totvert, "vertexcosnos map"));
vp_handle->use_update = false;
/* sets 'use_update' if needed */
vpaint_proj_dm_map_cosnos_init(depsgraph, scene, ob, vp_handle);
if (vp_handle->use_update) {
vp_handle->dists_sq = MEM_mallocN(sizeof(float) * me->totvert, __func__);
vp_handle->dists_sq = static_cast<float *>(MEM_mallocN(sizeof(float) * me->totvert, __func__));
vp_handle->ob = ob;
vp_handle->scene = scene;
}
else {
vp_handle->dists_sq = NULL;
vp_handle->dists_sq = nullptr;
vp_handle->ob = NULL;
vp_handle->scene = NULL;
vp_handle->ob = nullptr;
vp_handle->scene = nullptr;
}
*r_vcosnos = vp_handle->vcosnos;
return vp_handle;
}
void ED_vpaint_proj_handle_update(struct Depsgraph *depsgraph,
struct VertProjHandle *vp_handle,
void ED_vpaint_proj_handle_update(Depsgraph *depsgraph,
VertProjHandle *vp_handle,
ARegion *region,
const float mval_fl[2])
{
@ -202,7 +204,7 @@ void ED_vpaint_proj_handle_update(struct Depsgraph *depsgraph,
}
}
void ED_vpaint_proj_handle_free(struct VertProjHandle *vp_handle)
void ED_vpaint_proj_handle_free(VertProjHandle *vp_handle)
{
if (vp_handle->use_update) {
MEM_freeN(vp_handle->dists_sq);

View File

@ -43,7 +43,7 @@
#include "ED_screen.h"
#include "ED_view3d.h"
#include "paint_intern.h" /* own include */
#include "paint_intern.hh" /* own include */
/* -------------------------------------------------------------------- */
/** \name Store Previous Weights

View File

@ -31,16 +31,16 @@
#include "WM_api.h"
#include "WM_types.h"
#include "paint_intern.h" /* own include */
#include "paint_intern.hh" /* own include */
/* -------------------------------------------------------------------- */
/** \name Weight Paint Sanity Checks
* \{ */
bool ED_wpaint_ensure_data(bContext *C,
struct ReportList *reports,
enum eWPaintFlag flag,
struct WPaintVGroupIndex *vgroup_index)
ReportList *reports,
eWPaintFlag flag,
WPaintVGroupIndex *vgroup_index)
{
Object *ob = CTX_data_active_object(C);
Mesh *me = BKE_mesh_from_object(ob);
@ -54,12 +54,12 @@ bool ED_wpaint_ensure_data(bContext *C,
return false;
}
if (me == NULL || me->totpoly == 0) {
if (me == nullptr || me->totpoly == 0) {
return false;
}
/* if nothing was added yet, we make dverts and a vertex deform group */
if (BKE_mesh_deform_verts(me) == NULL) {
if (BKE_mesh_deform_verts(me) == nullptr) {
BKE_object_defgroup_data_create(&me->id);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
}
@ -76,7 +76,7 @@ bool ED_wpaint_ensure_data(bContext *C,
if (pchan) {
bDeformGroup *dg = BKE_object_defgroup_find_name(ob, pchan->name);
if (dg == NULL) {
if (dg == nullptr) {
dg = BKE_object_defgroup_add_name(ob, pchan->name); /* sets actdef */
DEG_relations_tag_update(CTX_data_main(C));
}
@ -122,7 +122,7 @@ bool ED_wpaint_ensure_data(bContext *C,
int ED_wpaint_mirror_vgroup_ensure(Object *ob, const int vgroup_active)
{
const ListBase *defbase = BKE_object_defgroup_list(ob);
bDeformGroup *defgroup = BLI_findlink(defbase, vgroup_active);
bDeformGroup *defgroup = static_cast<bDeformGroup *>(BLI_findlink(defbase, vgroup_active));
if (defgroup) {
int mirrdef;
@ -136,7 +136,7 @@ int ED_wpaint_mirror_vgroup_ensure(Object *ob, const int vgroup_active)
}
}
/* curdef should never be NULL unless this is
/* curdef should never be nullptr unless this is
* a light and BKE_object_defgroup_add_name fails */
return mirrdef;
}

View File

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

View File

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

View File

@ -21,7 +21,7 @@
#include "BKE_paint.h"
#include "BKE_pbvh.h"
#include "paint_intern.h"
#include "paint_intern.hh"
#include "sculpt_intern.hh"
#include "GPU_immediate.h"

View File

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

View File

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

View File

@ -34,7 +34,7 @@
#include "ED_util.h"
#include "ED_view3d.h"
#include "paint_intern.h"
#include "paint_intern.hh"
#include "sculpt_intern.hh"
#include "RNA_access.h"

View File

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

View File

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

View File

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

View File

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

View File

@ -39,7 +39,7 @@
#include "RNA_access.h"
#include "RNA_define.h"
#include "paint_intern.h"
#include "paint_intern.hh"
#include "uvedit_intern.h"
#include "UI_view2d.h"
@ -49,7 +49,7 @@
* Visually, UV elements on the graph boundary appear as borders of the UV Island. */
#define MARK_BOUNDARY 1
typedef struct UvAdjacencyElement {
struct UvAdjacencyElement {
/** pointer to original UV-element. */
UvElement *element;
/** UV pointer for convenience. Caution, this points to the original UVs! */
@ -58,16 +58,16 @@ typedef struct UvAdjacencyElement {
bool is_locked;
/** Are we on the boundary? */
bool is_boundary;
} UvAdjacencyElement;
};
typedef struct UvEdge {
struct UvEdge {
uint uv1;
uint uv2;
/** Are we in the interior? */
bool is_interior;
} UvEdge;
};
typedef struct UVInitialStrokeElement {
struct UVInitialStrokeElement {
/** index to unique UV. */
int uv;
@ -76,9 +76,9 @@ typedef struct UVInitialStrokeElement {
/** initial UV position. */
float initial_uv[2];
} UVInitialStrokeElement;
};
typedef struct UVInitialStroke {
struct UVInitialStroke {
/** Initial Selection,for grab brushes for instance. */
UVInitialStrokeElement *initialSelection;
@ -87,10 +87,10 @@ typedef struct UVInitialStroke {
/** Initial mouse coordinates. */
float init_coord[2];
} UVInitialStroke;
};
/** Custom data for UV smoothing brush. */
typedef struct UvSculptData {
struct UvSculptData {
/**
* Contains the first of each set of coincident UVs.
* These will be used to perform smoothing on and propagate the changes to their coincident UVs.
@ -129,7 +129,7 @@ typedef struct UvSculptData {
/** Base for constrain_to_bounds. */
float uv_base_offset[2];
} UvSculptData;
};
static void apply_sculpt_data_constraints(UvSculptData *sculptdata, float uv[2])
{
@ -147,10 +147,10 @@ static void apply_sculpt_data_constraints(UvSculptData *sculptdata, float uv[2])
* adapted to uv smoothing by Antony Riakiatakis *
***************************************************************************/
typedef struct Temp_UvData {
struct Temp_UVData {
float sum_co[2], p[2], b[2], sum_b[2];
int ncounter;
} Temp_UVData;
};
static void HC_relaxation_iteration_uv(UvSculptData *sculptdata,
const int cd_loop_uv_offset,
@ -371,7 +371,7 @@ static void relaxation_iteration_uv(UvSculptData *sculptdata,
return;
}
struct UvElement **head_table = BM_uv_element_map_ensure_head_table(sculptdata->elementMap);
UvElement **head_table = BM_uv_element_map_ensure_head_table(sculptdata->elementMap);
const int total_uvs = sculptdata->elementMap->total_uvs;
float(*delta_buf)[3] = (float(*)[3])MEM_callocN(total_uvs * sizeof(float[3]), __func__);
@ -484,7 +484,7 @@ static void uv_sculpt_stroke_apply(bContext *C,
ED_space_image_get_zoom(sima, region, &zoomx, &zoomy);
radius = BKE_brush_size_get(scene, brush) / (width * zoomx);
aspectRatio = width / (float)height;
aspectRatio = width / float(height);
/* We will compare squares to save some computation */
radius = radius * radius;
@ -581,12 +581,12 @@ static void uv_sculpt_stroke_exit(bContext *C, wmOperator *op)
if (sima->flag & SI_LIVE_UNWRAP) {
ED_uvedit_live_unwrap_end(false);
}
UvSculptData *data = op->customdata;
UvSculptData *data = static_cast<UvSculptData *>(op->customdata);
if (data->timer) {
WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), data->timer);
}
BM_uv_element_map_free(data->elementMap);
data->elementMap = NULL;
data->elementMap = nullptr;
MEM_SAFE_FREE(data->uv);
MEM_SAFE_FREE(data->uvedges);
if (data->initial_stroke) {
@ -595,7 +595,7 @@ static void uv_sculpt_stroke_exit(bContext *C, wmOperator *op)
}
MEM_SAFE_FREE(data);
op->customdata = NULL;
op->customdata = nullptr;
}
static int uv_element_offset_from_face_get(
@ -610,14 +610,14 @@ static int uv_element_offset_from_face_get(
static uint uv_edge_hash(const void *key)
{
const UvEdge *edge = key;
const UvEdge *edge = static_cast<const UvEdge *>(key);
return (BLI_ghashutil_uinthash(edge->uv2) + BLI_ghashutil_uinthash(edge->uv1));
}
static bool uv_edge_compare(const void *a, const void *b)
{
const UvEdge *edge1 = a;
const UvEdge *edge2 = b;
const UvEdge *edge1 = static_cast<const UvEdge *>(a);
const UvEdge *edge2 = static_cast<const UvEdge *>(b);
if ((edge1->uv1 == edge2->uv1) && (edge1->uv2 == edge2->uv2)) {
return false;
@ -641,7 +641,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
ToolSettings *ts = scene->toolsettings;
UvSculptData *data = MEM_callocN(sizeof(*data), "UV Smooth Brush Data");
UvSculptData *data = MEM_cnew<UvSculptData>(__func__);
BMEditMesh *em = BKE_editmesh_from_object(obedit);
BMesh *bm = em->bm;
@ -680,7 +680,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
if (!data->elementMap) {
uv_sculpt_stroke_exit(C, op);
return NULL;
return nullptr;
}
/* Mouse coordinates, useful for some functions like grab and sculpt all islands */
@ -689,7 +689,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
/* we need to find the active island here */
if (do_island_optimization) {
UvElement *element;
UvNearestHit hit = UV_NEAREST_HIT_INIT_MAX(&region->v2d);
UvNearestHit hit = uv_nearest_hit_init_max(&region->v2d);
uv_find_nearest_vert(scene, obedit, co, 0.0f, &hit);
element = BM_uv_element_get(data->elementMap, hit.efa, hit.l);
@ -703,21 +703,21 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
}
/* Allocate the unique uv buffers */
data->uv = MEM_callocN(sizeof(*data->uv) * unique_uvs, "uv_brush_unique_uvs");
data->uv = MEM_cnew_array<UvAdjacencyElement>(unique_uvs, __func__);
/* Holds, for each UvElement in elementMap, an index of its unique UV. */
int *uniqueUv = MEM_mallocN(sizeof(*uniqueUv) * data->elementMap->total_uvs,
"uv_brush_unique_uv_map");
int *uniqueUv = static_cast<int *>(
MEM_mallocN(sizeof(*uniqueUv) * data->elementMap->total_uvs, __func__));
edgeHash = BLI_ghash_new(uv_edge_hash, uv_edge_compare, "uv_brush_edge_hash");
/* we have at most totalUVs edges */
edges = MEM_callocN(sizeof(*edges) * data->elementMap->total_uvs, "uv_brush_all_edges");
edges = MEM_cnew_array<UvEdge>(data->elementMap->total_uvs, __func__);
if (!data->uv || !uniqueUv || !edgeHash || !edges) {
MEM_SAFE_FREE(edges);
MEM_SAFE_FREE(uniqueUv);
if (edgeHash) {
BLI_ghash_free(edgeHash, NULL, NULL);
BLI_ghash_free(edgeHash, nullptr, nullptr);
}
uv_sculpt_stroke_exit(C, op);
return NULL;
return nullptr;
}
data->totalUniqueUvs = unique_uvs;
@ -782,7 +782,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
edges[counter].uv1 = offset2;
edges[counter].uv2 = offset1;
}
UvEdge *prev_edge = BLI_ghash_lookup(edgeHash, &edges[counter]);
UvEdge *prev_edge = static_cast<UvEdge *>(BLI_ghash_lookup(edgeHash, &edges[counter]));
if (prev_edge) {
prev_edge->is_interior = true;
edges[counter].is_interior = true;
@ -797,13 +797,12 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
MEM_SAFE_FREE(uniqueUv);
/* Allocate connectivity data, we allocate edges once */
data->uvedges = MEM_callocN(sizeof(*data->uvedges) * BLI_ghash_len(edgeHash),
"uv_brush_edge_connectivity_data");
data->uvedges = MEM_cnew_array<UvEdge>(BLI_ghash_len(edgeHash), __func__);
if (!data->uvedges) {
BLI_ghash_free(edgeHash, NULL, NULL);
BLI_ghash_free(edgeHash, nullptr, nullptr);
MEM_SAFE_FREE(edges);
uv_sculpt_stroke_exit(C, op);
return NULL;
return nullptr;
}
/* fill the edges with data */
@ -816,7 +815,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
}
/* cleanup temporary stuff */
BLI_ghash_free(edgeHash, NULL, NULL);
BLI_ghash_free(edgeHash, nullptr, nullptr);
MEM_SAFE_FREE(edges);
/* transfer boundary edge property to UVs */
@ -852,20 +851,19 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
ED_space_image_get_size(sima, &width, &height);
ED_space_image_get_zoom(sima, region, &zoomx, &zoomy);
aspectRatio = width / (float)height;
aspectRatio = width / float(height);
radius /= (width * zoomx);
radius = radius * radius;
radius_root = sqrtf(radius);
/* Allocate selection stack */
data->initial_stroke = MEM_mallocN(sizeof(*data->initial_stroke),
"uv_sculpt_initial_stroke");
data->initial_stroke = static_cast<UVInitialStroke *>(
MEM_mallocN(sizeof(*data->initial_stroke), __func__));
if (!data->initial_stroke) {
uv_sculpt_stroke_exit(C, op);
}
data->initial_stroke->initialSelection = MEM_mallocN(
sizeof(*data->initial_stroke->initialSelection) * data->totalUniqueUvs,
"uv_sculpt_initial_selection");
data->initial_stroke->initialSelection = static_cast<UVInitialStrokeElement *>(MEM_mallocN(
sizeof(*data->initial_stroke->initialSelection) * data->totalUniqueUvs, __func__));
if (!data->initial_stroke->initialSelection) {
uv_sculpt_stroke_exit(C, op);
}
@ -900,7 +898,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
}
}
return op->customdata;
return static_cast<UvSculptData *>(op->customdata);
}
static int uv_sculpt_stroke_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@ -952,7 +950,7 @@ static int uv_sculpt_stroke_modal(bContext *C, wmOperator *op, const wmEvent *ev
ED_region_tag_redraw(CTX_wm_region(C));
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
return OPERATOR_RUNNING_MODAL;
}
@ -966,7 +964,7 @@ static bool uv_sculpt_stroke_poll(bContext *C)
Scene *scene = CTX_data_scene(C);
ToolSettings *ts = scene->toolsettings;
Brush *brush = BKE_paint_brush(&ts->uvsculpt->paint);
if (brush != NULL) {
if (brush != nullptr) {
return true;
}
}

View File

@ -29,7 +29,7 @@ typedef struct UvNearestHit {
/**
* Needs to be set before calling nearest functions.
*
* \note When #UV_NEAREST_HIT_INIT_DIST_PX or #UV_NEAREST_HIT_INIT_MAX are used,
* \note When #uv_nearest_hit_init_dist_px or #uv_nearest_hit_init_max are used,
* this value is pixels squared.
*/
float dist_sq;
@ -38,23 +38,8 @@ typedef struct UvNearestHit {
float scale[2];
} UvNearestHit;
#define UV_NEAREST_HIT_INIT_DIST_PX(v2d, dist_px) \
{ \
.dist_sq = square_f(U.pixelsize * dist_px), \
.scale = { \
UI_view2d_scale_get_x(v2d), \
UI_view2d_scale_get_y(v2d), \
}, \
}
#define UV_NEAREST_HIT_INIT_MAX(v2d) \
{ \
.dist_sq = FLT_MAX, \
.scale = { \
UI_view2d_scale_get_x(v2d), \
UI_view2d_scale_get_y(v2d), \
}, \
}
UvNearestHit uv_nearest_hit_init_dist_px(const struct View2D *v2d, const float dist_px);
UvNearestHit uv_nearest_hit_init_max(const struct View2D *v2d);
bool uv_find_nearest_vert(struct Scene *scene,
struct Object *obedit,

View File

@ -579,7 +579,7 @@ static int uv_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmEve
BMElem *ele_src = NULL, *ele_dst = NULL;
/* Detect the hit. */
UvNearestHit hit = UV_NEAREST_HIT_INIT_MAX(&region->v2d);
UvNearestHit hit = uv_nearest_hit_init_max(&region->v2d);
bool hit_found = false;
if (uv_selectmode == UV_SELECT_FACE) {
if (uv_find_nearest_face_multi(scene, objects, objects_len, co, &hit)) {

View File

@ -793,6 +793,24 @@ static BMLoop *uvedit_loop_find_other_boundary_loop_with_visible_face(const Scen
/** \name Find Nearest Elements
* \{ */
UvNearestHit uv_nearest_hit_init_dist_px(const View2D *v2d, const float dist_px)
{
UvNearestHit hit = {0};
hit.dist_sq = square_f(U.pixelsize * dist_px);
hit.scale[0] = UI_view2d_scale_get_x(v2d);
hit.scale[1] = UI_view2d_scale_get_y(v2d);
return hit;
}
UvNearestHit uv_nearest_hit_init_max(const View2D *v2d)
{
UvNearestHit hit = {0};
hit.dist_sq = FLT_MAX;
hit.scale[0] = UI_view2d_scale_get_x(v2d);
hit.scale[1] = UI_view2d_scale_get_y(v2d);
return hit;
}
bool uv_find_nearest_edge(
Scene *scene, Object *obedit, const float co[2], const float penalty, UvNearestHit *hit)
{
@ -2427,7 +2445,7 @@ static bool uv_mouse_select_multi(bContext *C,
const ARegion *region = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
const ToolSettings *ts = scene->toolsettings;
UvNearestHit hit = UV_NEAREST_HIT_INIT_DIST_PX(&region->v2d, 75.0f);
UvNearestHit hit = uv_nearest_hit_init_dist_px(&region->v2d, 75.0f);
int selectmode, sticky;
bool found_item = false;
/* 0 == don't flush, 1 == sel, -1 == deselect; only use when selection sync is enabled. */
@ -2743,7 +2761,7 @@ static int uv_mouse_select_loop_generic_multi(bContext *C,
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene = CTX_data_scene(C);
const ToolSettings *ts = scene->toolsettings;
UvNearestHit hit = UV_NEAREST_HIT_INIT_MAX(&region->v2d);
UvNearestHit hit = uv_nearest_hit_init_max(&region->v2d);
bool found_item = false;
/* 0 == don't flush, 1 == sel, -1 == deselect; only use when selection sync is enabled. */
int flush = 0;
@ -2953,7 +2971,7 @@ static int uv_select_linked_internal(bContext *C, wmOperator *op, const wmEvent
bool deselect = false;
bool select_faces = (ts->uv_flag & UV_SYNC_SELECTION) && (ts->selectmode & SCE_SELECT_FACE);
UvNearestHit hit = UV_NEAREST_HIT_INIT_MAX(&region->v2d);
UvNearestHit hit = uv_nearest_hit_init_max(&region->v2d);
if (pick) {
extend = RNA_boolean_get(op->ptr, "extend");

View File

@ -2465,7 +2465,7 @@ static StitchState *stitch_select(bContext *C,
/* add uv under mouse to processed uv's */
float co[2];
ARegion *region = CTX_wm_region(C);
UvNearestHit hit = UV_NEAREST_HIT_INIT_MAX(&region->v2d);
UvNearestHit hit = uv_nearest_hit_init_max(&region->v2d);
UI_view2d_region_to_view(&region->v2d, event->mval[0], event->mval[1], &co[0], &co[1]);

View File

@ -0,0 +1,17 @@
/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2001-2002 NaN Holding BV. All rights reserved. */
/** \file
* \ingroup DNA
*/
#pragma once
/** #ToolSettings.vgroupsubset */
typedef enum eVGroupSelect {
WT_VGROUP_ALL = 0,
WT_VGROUP_ACTIVE = 1,
WT_VGROUP_BONE_SELECT = 2,
WT_VGROUP_BONE_DEFORM = 3,
WT_VGROUP_BONE_DEFORM_OFF = 4,
} eVGroupSelect;

View File

@ -23,6 +23,7 @@
#include "DNA_customdata_types.h" /* Scene's runtime custom-data masks. */
#include "DNA_layer_types.h"
#include "DNA_listBase.h"
#include "DNA_scene_enums.h"
#include "DNA_vec_types.h"
#include "DNA_view3d_types.h"
@ -2377,15 +2378,6 @@ enum {
/* object_vgroup.cc */
/** #ToolSettings.vgroupsubset */
typedef enum eVGroupSelect {
WT_VGROUP_ALL = 0,
WT_VGROUP_ACTIVE = 1,
WT_VGROUP_BONE_SELECT = 2,
WT_VGROUP_BONE_DEFORM = 3,
WT_VGROUP_BONE_DEFORM_OFF = 4,
} eVGroupSelect;
#define WT_VGROUP_MASK_ALL \
((1 << WT_VGROUP_ACTIVE) | (1 << WT_VGROUP_BONE_SELECT) | (1 << WT_VGROUP_BONE_DEFORM) | \
(1 << WT_VGROUP_BONE_DEFORM_OFF) | (1 << WT_VGROUP_ALL))