Cleanup: Use enum class and forward declaration for paint mode
This commit is contained in:
@@ -13,8 +13,7 @@
|
||||
#include "DNA_color_types.h"
|
||||
#include "DNA_object_enums.h"
|
||||
|
||||
#include "BKE_paint.hh" /* for ePaintMode */
|
||||
|
||||
enum class PaintMode : int8_t;
|
||||
struct Brush;
|
||||
struct ImBuf;
|
||||
struct ImagePool;
|
||||
@@ -176,7 +175,7 @@ void BKE_brush_scale_size(int *r_brush_size,
|
||||
/* Returns true if a brush requires a cube
|
||||
* (often presented to the user as a square) tip inside a specific paint mode.
|
||||
*/
|
||||
bool BKE_brush_has_cube_tip(const Brush *brush, ePaintMode paint_mode);
|
||||
bool BKE_brush_has_cube_tip(const Brush *brush, PaintMode paint_mode);
|
||||
|
||||
/* Accessors */
|
||||
#define BKE_brush_tool_get(brush, p) \
|
||||
|
||||
@@ -87,29 +87,29 @@ extern const uchar PAINT_CURSOR_WEIGHT_PAINT[3];
|
||||
extern const uchar PAINT_CURSOR_TEXTURE_PAINT[3];
|
||||
extern const uchar PAINT_CURSOR_SCULPT_CURVES[3];
|
||||
|
||||
enum ePaintMode {
|
||||
PAINT_MODE_SCULPT = 0,
|
||||
enum class PaintMode : int8_t {
|
||||
Sculpt = 0,
|
||||
/** Vertex color. */
|
||||
PAINT_MODE_VERTEX = 1,
|
||||
PAINT_MODE_WEIGHT = 2,
|
||||
Vertex = 1,
|
||||
Weight = 2,
|
||||
/** 3D view (projection painting). */
|
||||
PAINT_MODE_TEXTURE_3D = 3,
|
||||
Texture3D = 3,
|
||||
/** Image space (2D painting). */
|
||||
PAINT_MODE_TEXTURE_2D = 4,
|
||||
PAINT_MODE_SCULPT_UV = 5,
|
||||
PAINT_MODE_GPENCIL = 6,
|
||||
Texture2D = 4,
|
||||
SculptUV = 5,
|
||||
GPencil = 6,
|
||||
/* Grease Pencil Vertex Paint */
|
||||
PAINT_MODE_VERTEX_GPENCIL = 7,
|
||||
PAINT_MODE_SCULPT_GPENCIL = 8,
|
||||
PAINT_MODE_WEIGHT_GPENCIL = 9,
|
||||
VertexGPencil = 7,
|
||||
SculptGPencil = 8,
|
||||
WeightGPencil = 9,
|
||||
/** Curves. */
|
||||
PAINT_MODE_SCULPT_CURVES = 10,
|
||||
SculptCurves = 10,
|
||||
|
||||
/** Keep last. */
|
||||
PAINT_MODE_INVALID = 11,
|
||||
Invalid = 11,
|
||||
};
|
||||
|
||||
#define PAINT_MODE_HAS_BRUSH(mode) !ELEM(mode, PAINT_MODE_SCULPT_UV)
|
||||
#define PAINT_MODE_HAS_BRUSH(mode) !ELEM(mode, PaintMode::SculptUV)
|
||||
|
||||
/* overlay invalidation */
|
||||
enum ePaintOverlayControlFlags {
|
||||
@@ -174,7 +174,7 @@ PaintCurve *BKE_paint_curve_add(Main *bmain, const char *name);
|
||||
* Call when entering each respective paint mode.
|
||||
*/
|
||||
bool BKE_paint_ensure(ToolSettings *ts, Paint **r_paint);
|
||||
void BKE_paint_init(Main *bmain, Scene *sce, ePaintMode mode, const uchar col[3]);
|
||||
void BKE_paint_init(Main *bmain, Scene *sce, PaintMode mode, const uchar col[3]);
|
||||
void BKE_paint_free(Paint *p);
|
||||
/**
|
||||
* Called when copying scene settings, so even if 'src' and 'tar' are the same still do a
|
||||
@@ -187,17 +187,17 @@ void BKE_paint_runtime_init(const ToolSettings *ts, Paint *paint);
|
||||
|
||||
void BKE_paint_cavity_curve_preset(Paint *p, int preset);
|
||||
|
||||
eObjectMode BKE_paint_object_mode_from_paintmode(ePaintMode mode);
|
||||
bool BKE_paint_ensure_from_paintmode(Scene *sce, ePaintMode mode);
|
||||
Paint *BKE_paint_get_active_from_paintmode(Scene *sce, ePaintMode mode);
|
||||
const EnumPropertyItem *BKE_paint_get_tool_enum_from_paintmode(ePaintMode mode);
|
||||
const char *BKE_paint_get_tool_enum_translation_context_from_paintmode(ePaintMode mode);
|
||||
const char *BKE_paint_get_tool_prop_id_from_paintmode(ePaintMode mode);
|
||||
uint BKE_paint_get_brush_tool_offset_from_paintmode(ePaintMode mode);
|
||||
eObjectMode BKE_paint_object_mode_from_paintmode(PaintMode mode);
|
||||
bool BKE_paint_ensure_from_paintmode(Scene *sce, PaintMode mode);
|
||||
Paint *BKE_paint_get_active_from_paintmode(Scene *sce, PaintMode mode);
|
||||
const EnumPropertyItem *BKE_paint_get_tool_enum_from_paintmode(PaintMode mode);
|
||||
const char *BKE_paint_get_tool_enum_translation_context_from_paintmode(PaintMode mode);
|
||||
const char *BKE_paint_get_tool_prop_id_from_paintmode(PaintMode mode);
|
||||
uint BKE_paint_get_brush_tool_offset_from_paintmode(PaintMode mode);
|
||||
Paint *BKE_paint_get_active(Scene *sce, ViewLayer *view_layer);
|
||||
Paint *BKE_paint_get_active_from_context(const bContext *C);
|
||||
ePaintMode BKE_paintmode_get_active_from_context(const bContext *C);
|
||||
ePaintMode BKE_paintmode_get_from_tool(const bToolRef *tref);
|
||||
PaintMode BKE_paintmode_get_active_from_context(const bContext *C);
|
||||
PaintMode BKE_paintmode_get_from_tool(const bToolRef *tref);
|
||||
Brush *BKE_paint_brush(Paint *paint);
|
||||
const Brush *BKE_paint_brush_for_read(const Paint *p);
|
||||
void BKE_paint_brush_set(Paint *paint, Brush *br);
|
||||
@@ -247,7 +247,7 @@ void BKE_paint_face_set_overlay_color_get(int face_set, int seed, uchar r_color[
|
||||
bool paint_calculate_rake_rotation(UnifiedPaintSettings *ups,
|
||||
Brush *brush,
|
||||
const float mouse_pos[2],
|
||||
ePaintMode paint_mode,
|
||||
PaintMode paint_mode,
|
||||
bool stroke_has_started);
|
||||
void paint_update_brush_rake_rotation(UnifiedPaintSettings *ups, Brush *brush, float rotation);
|
||||
|
||||
|
||||
@@ -2630,10 +2630,10 @@ ImBuf *BKE_brush_gen_radial_control_imbuf(Brush *br, bool secondary, bool displa
|
||||
return im;
|
||||
}
|
||||
|
||||
bool BKE_brush_has_cube_tip(const Brush *brush, ePaintMode paint_mode)
|
||||
bool BKE_brush_has_cube_tip(const Brush *brush, PaintMode paint_mode)
|
||||
{
|
||||
switch (paint_mode) {
|
||||
case PAINT_MODE_SCULPT: {
|
||||
case PaintMode::Sculpt: {
|
||||
if (brush->sculpt_tool == SCULPT_TOOL_MULTIPLANE_SCRAPE) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -312,7 +312,7 @@ void BKE_paint_reset_overlay_invalid(ePaintOverlayControlFlags flag)
|
||||
overlay_flags &= ~(flag);
|
||||
}
|
||||
|
||||
bool BKE_paint_ensure_from_paintmode(Scene *sce, ePaintMode mode)
|
||||
bool BKE_paint_ensure_from_paintmode(Scene *sce, PaintMode mode)
|
||||
{
|
||||
ToolSettings *ts = sce->toolsettings;
|
||||
Paint **paint_ptr = nullptr;
|
||||
@@ -321,39 +321,39 @@ bool BKE_paint_ensure_from_paintmode(Scene *sce, ePaintMode mode)
|
||||
Paint *paint_tmp = nullptr;
|
||||
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PaintMode::Sculpt:
|
||||
paint_ptr = (Paint **)&ts->sculpt;
|
||||
break;
|
||||
case PAINT_MODE_VERTEX:
|
||||
case PaintMode::Vertex:
|
||||
paint_ptr = (Paint **)&ts->vpaint;
|
||||
break;
|
||||
case PAINT_MODE_WEIGHT:
|
||||
case PaintMode::Weight:
|
||||
paint_ptr = (Paint **)&ts->wpaint;
|
||||
break;
|
||||
case PAINT_MODE_TEXTURE_2D:
|
||||
case PAINT_MODE_TEXTURE_3D:
|
||||
case PaintMode::Texture2D:
|
||||
case PaintMode::Texture3D:
|
||||
paint_tmp = (Paint *)&ts->imapaint;
|
||||
paint_ptr = &paint_tmp;
|
||||
break;
|
||||
case PAINT_MODE_SCULPT_UV:
|
||||
case PaintMode::SculptUV:
|
||||
paint_ptr = (Paint **)&ts->uvsculpt;
|
||||
break;
|
||||
case PAINT_MODE_GPENCIL:
|
||||
case PaintMode::GPencil:
|
||||
paint_ptr = (Paint **)&ts->gp_paint;
|
||||
break;
|
||||
case PAINT_MODE_VERTEX_GPENCIL:
|
||||
case PaintMode::VertexGPencil:
|
||||
paint_ptr = (Paint **)&ts->gp_vertexpaint;
|
||||
break;
|
||||
case PAINT_MODE_SCULPT_GPENCIL:
|
||||
case PaintMode::SculptGPencil:
|
||||
paint_ptr = (Paint **)&ts->gp_sculptpaint;
|
||||
break;
|
||||
case PAINT_MODE_WEIGHT_GPENCIL:
|
||||
case PaintMode::WeightGPencil:
|
||||
paint_ptr = (Paint **)&ts->gp_weightpaint;
|
||||
break;
|
||||
case PAINT_MODE_SCULPT_CURVES:
|
||||
case PaintMode::SculptCurves:
|
||||
paint_ptr = (Paint **)&ts->curves_sculpt;
|
||||
break;
|
||||
case PAINT_MODE_INVALID:
|
||||
case PaintMode::Invalid:
|
||||
break;
|
||||
}
|
||||
if (paint_ptr) {
|
||||
@@ -363,34 +363,34 @@ bool BKE_paint_ensure_from_paintmode(Scene *sce, ePaintMode mode)
|
||||
return false;
|
||||
}
|
||||
|
||||
Paint *BKE_paint_get_active_from_paintmode(Scene *sce, ePaintMode mode)
|
||||
Paint *BKE_paint_get_active_from_paintmode(Scene *sce, PaintMode mode)
|
||||
{
|
||||
if (sce) {
|
||||
ToolSettings *ts = sce->toolsettings;
|
||||
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PaintMode::Sculpt:
|
||||
return &ts->sculpt->paint;
|
||||
case PAINT_MODE_VERTEX:
|
||||
case PaintMode::Vertex:
|
||||
return &ts->vpaint->paint;
|
||||
case PAINT_MODE_WEIGHT:
|
||||
case PaintMode::Weight:
|
||||
return &ts->wpaint->paint;
|
||||
case PAINT_MODE_TEXTURE_2D:
|
||||
case PAINT_MODE_TEXTURE_3D:
|
||||
case PaintMode::Texture2D:
|
||||
case PaintMode::Texture3D:
|
||||
return &ts->imapaint.paint;
|
||||
case PAINT_MODE_SCULPT_UV:
|
||||
case PaintMode::SculptUV:
|
||||
return &ts->uvsculpt->paint;
|
||||
case PAINT_MODE_GPENCIL:
|
||||
case PaintMode::GPencil:
|
||||
return &ts->gp_paint->paint;
|
||||
case PAINT_MODE_VERTEX_GPENCIL:
|
||||
case PaintMode::VertexGPencil:
|
||||
return &ts->gp_vertexpaint->paint;
|
||||
case PAINT_MODE_SCULPT_GPENCIL:
|
||||
case PaintMode::SculptGPencil:
|
||||
return &ts->gp_sculptpaint->paint;
|
||||
case PAINT_MODE_WEIGHT_GPENCIL:
|
||||
case PaintMode::WeightGPencil:
|
||||
return &ts->gp_weightpaint->paint;
|
||||
case PAINT_MODE_SCULPT_CURVES:
|
||||
case PaintMode::SculptCurves:
|
||||
return &ts->curves_sculpt->paint;
|
||||
case PAINT_MODE_INVALID:
|
||||
case PaintMode::Invalid:
|
||||
return nullptr;
|
||||
default:
|
||||
return &ts->imapaint.paint;
|
||||
@@ -400,61 +400,61 @@ Paint *BKE_paint_get_active_from_paintmode(Scene *sce, ePaintMode mode)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const EnumPropertyItem *BKE_paint_get_tool_enum_from_paintmode(const ePaintMode mode)
|
||||
const EnumPropertyItem *BKE_paint_get_tool_enum_from_paintmode(const PaintMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PaintMode::Sculpt:
|
||||
return rna_enum_brush_sculpt_tool_items;
|
||||
case PAINT_MODE_VERTEX:
|
||||
case PaintMode::Vertex:
|
||||
return rna_enum_brush_vertex_tool_items;
|
||||
case PAINT_MODE_WEIGHT:
|
||||
case PaintMode::Weight:
|
||||
return rna_enum_brush_weight_tool_items;
|
||||
case PAINT_MODE_TEXTURE_2D:
|
||||
case PAINT_MODE_TEXTURE_3D:
|
||||
case PaintMode::Texture2D:
|
||||
case PaintMode::Texture3D:
|
||||
return rna_enum_brush_image_tool_items;
|
||||
case PAINT_MODE_SCULPT_UV:
|
||||
case PaintMode::SculptUV:
|
||||
return rna_enum_brush_uv_sculpt_tool_items;
|
||||
case PAINT_MODE_GPENCIL:
|
||||
case PaintMode::GPencil:
|
||||
return rna_enum_brush_gpencil_types_items;
|
||||
case PAINT_MODE_VERTEX_GPENCIL:
|
||||
case PaintMode::VertexGPencil:
|
||||
return rna_enum_brush_gpencil_vertex_types_items;
|
||||
case PAINT_MODE_SCULPT_GPENCIL:
|
||||
case PaintMode::SculptGPencil:
|
||||
return rna_enum_brush_gpencil_sculpt_types_items;
|
||||
case PAINT_MODE_WEIGHT_GPENCIL:
|
||||
case PaintMode::WeightGPencil:
|
||||
return rna_enum_brush_gpencil_weight_types_items;
|
||||
case PAINT_MODE_SCULPT_CURVES:
|
||||
case PaintMode::SculptCurves:
|
||||
return rna_enum_brush_curves_sculpt_tool_items;
|
||||
case PAINT_MODE_INVALID:
|
||||
case PaintMode::Invalid:
|
||||
break;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char *BKE_paint_get_tool_prop_id_from_paintmode(const ePaintMode mode)
|
||||
const char *BKE_paint_get_tool_prop_id_from_paintmode(const PaintMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PaintMode::Sculpt:
|
||||
return "sculpt_tool";
|
||||
case PAINT_MODE_VERTEX:
|
||||
case PaintMode::Vertex:
|
||||
return "vertex_tool";
|
||||
case PAINT_MODE_WEIGHT:
|
||||
case PaintMode::Weight:
|
||||
return "weight_tool";
|
||||
case PAINT_MODE_TEXTURE_2D:
|
||||
case PAINT_MODE_TEXTURE_3D:
|
||||
case PaintMode::Texture2D:
|
||||
case PaintMode::Texture3D:
|
||||
return "image_tool";
|
||||
case PAINT_MODE_SCULPT_UV:
|
||||
case PaintMode::SculptUV:
|
||||
return "uv_sculpt_tool";
|
||||
case PAINT_MODE_GPENCIL:
|
||||
case PaintMode::GPencil:
|
||||
return "gpencil_tool";
|
||||
case PAINT_MODE_VERTEX_GPENCIL:
|
||||
case PaintMode::VertexGPencil:
|
||||
return "gpencil_vertex_tool";
|
||||
case PAINT_MODE_SCULPT_GPENCIL:
|
||||
case PaintMode::SculptGPencil:
|
||||
return "gpencil_sculpt_tool";
|
||||
case PAINT_MODE_WEIGHT_GPENCIL:
|
||||
case PaintMode::WeightGPencil:
|
||||
return "gpencil_weight_tool";
|
||||
case PAINT_MODE_SCULPT_CURVES:
|
||||
case PaintMode::SculptCurves:
|
||||
return "curves_sculpt_tool";
|
||||
case PAINT_MODE_INVALID:
|
||||
case PaintMode::Invalid:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -462,22 +462,22 @@ const char *BKE_paint_get_tool_prop_id_from_paintmode(const ePaintMode mode)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char *BKE_paint_get_tool_enum_translation_context_from_paintmode(const ePaintMode mode)
|
||||
const char *BKE_paint_get_tool_enum_translation_context_from_paintmode(const PaintMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PAINT_MODE_GPENCIL:
|
||||
case PAINT_MODE_TEXTURE_2D:
|
||||
case PAINT_MODE_TEXTURE_3D:
|
||||
case PaintMode::Sculpt:
|
||||
case PaintMode::GPencil:
|
||||
case PaintMode::Texture2D:
|
||||
case PaintMode::Texture3D:
|
||||
return BLT_I18NCONTEXT_ID_BRUSH;
|
||||
case PAINT_MODE_VERTEX:
|
||||
case PAINT_MODE_WEIGHT:
|
||||
case PAINT_MODE_SCULPT_UV:
|
||||
case PAINT_MODE_VERTEX_GPENCIL:
|
||||
case PAINT_MODE_SCULPT_GPENCIL:
|
||||
case PAINT_MODE_WEIGHT_GPENCIL:
|
||||
case PAINT_MODE_SCULPT_CURVES:
|
||||
case PAINT_MODE_INVALID:
|
||||
case PaintMode::Vertex:
|
||||
case PaintMode::Weight:
|
||||
case PaintMode::SculptUV:
|
||||
case PaintMode::VertexGPencil:
|
||||
case PaintMode::SculptGPencil:
|
||||
case PaintMode::WeightGPencil:
|
||||
case PaintMode::SculptCurves:
|
||||
case PaintMode::Invalid:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -560,7 +560,7 @@ Paint *BKE_paint_get_active_from_context(const bContext *C)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ePaintMode BKE_paintmode_get_active_from_context(const bContext *C)
|
||||
PaintMode BKE_paintmode_get_active_from_context(const bContext *C)
|
||||
{
|
||||
Scene *sce = CTX_data_scene(C);
|
||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
@@ -573,81 +573,81 @@ ePaintMode BKE_paintmode_get_active_from_context(const bContext *C)
|
||||
if ((sima = CTX_wm_space_image(C)) != nullptr) {
|
||||
if (obact && obact->mode == OB_MODE_EDIT) {
|
||||
if (sima->mode == SI_MODE_PAINT) {
|
||||
return PAINT_MODE_TEXTURE_2D;
|
||||
return PaintMode::Texture2D;
|
||||
}
|
||||
if (sima->mode == SI_MODE_UV) {
|
||||
return PAINT_MODE_SCULPT_UV;
|
||||
return PaintMode::SculptUV;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return PAINT_MODE_TEXTURE_2D;
|
||||
return PaintMode::Texture2D;
|
||||
}
|
||||
}
|
||||
else if (obact) {
|
||||
switch (obact->mode) {
|
||||
case OB_MODE_SCULPT:
|
||||
return PAINT_MODE_SCULPT;
|
||||
return PaintMode::Sculpt;
|
||||
case OB_MODE_VERTEX_PAINT:
|
||||
return PAINT_MODE_VERTEX;
|
||||
return PaintMode::Vertex;
|
||||
case OB_MODE_WEIGHT_PAINT:
|
||||
return PAINT_MODE_WEIGHT;
|
||||
return PaintMode::Weight;
|
||||
case OB_MODE_TEXTURE_PAINT:
|
||||
return PAINT_MODE_TEXTURE_3D;
|
||||
return PaintMode::Texture3D;
|
||||
case OB_MODE_EDIT:
|
||||
return PAINT_MODE_SCULPT_UV;
|
||||
return PaintMode::SculptUV;
|
||||
case OB_MODE_SCULPT_CURVES:
|
||||
return PAINT_MODE_SCULPT_CURVES;
|
||||
return PaintMode::SculptCurves;
|
||||
case OB_MODE_PAINT_GREASE_PENCIL:
|
||||
return PAINT_MODE_GPENCIL;
|
||||
return PaintMode::GPencil;
|
||||
default:
|
||||
return PAINT_MODE_TEXTURE_2D;
|
||||
return PaintMode::Texture2D;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* default to image paint */
|
||||
return PAINT_MODE_TEXTURE_2D;
|
||||
return PaintMode::Texture2D;
|
||||
}
|
||||
}
|
||||
|
||||
return PAINT_MODE_INVALID;
|
||||
return PaintMode::Invalid;
|
||||
}
|
||||
|
||||
ePaintMode BKE_paintmode_get_from_tool(const bToolRef *tref)
|
||||
PaintMode BKE_paintmode_get_from_tool(const bToolRef *tref)
|
||||
{
|
||||
if (tref->space_type == SPACE_VIEW3D) {
|
||||
switch (tref->mode) {
|
||||
case CTX_MODE_SCULPT:
|
||||
return PAINT_MODE_SCULPT;
|
||||
return PaintMode::Sculpt;
|
||||
case CTX_MODE_PAINT_VERTEX:
|
||||
return PAINT_MODE_VERTEX;
|
||||
return PaintMode::Vertex;
|
||||
case CTX_MODE_PAINT_WEIGHT:
|
||||
return PAINT_MODE_WEIGHT;
|
||||
return PaintMode::Weight;
|
||||
case CTX_MODE_PAINT_GPENCIL_LEGACY:
|
||||
return PAINT_MODE_GPENCIL;
|
||||
return PaintMode::GPencil;
|
||||
case CTX_MODE_PAINT_TEXTURE:
|
||||
return PAINT_MODE_TEXTURE_3D;
|
||||
return PaintMode::Texture3D;
|
||||
case CTX_MODE_VERTEX_GPENCIL_LEGACY:
|
||||
return PAINT_MODE_VERTEX_GPENCIL;
|
||||
return PaintMode::VertexGPencil;
|
||||
case CTX_MODE_SCULPT_GPENCIL_LEGACY:
|
||||
return PAINT_MODE_SCULPT_GPENCIL;
|
||||
return PaintMode::SculptGPencil;
|
||||
case CTX_MODE_WEIGHT_GPENCIL_LEGACY:
|
||||
return PAINT_MODE_WEIGHT_GPENCIL;
|
||||
return PaintMode::WeightGPencil;
|
||||
case CTX_MODE_SCULPT_CURVES:
|
||||
return PAINT_MODE_SCULPT_CURVES;
|
||||
return PaintMode::SculptCurves;
|
||||
case CTX_MODE_PAINT_GREASE_PENCIL:
|
||||
return PAINT_MODE_GPENCIL;
|
||||
return PaintMode::GPencil;
|
||||
}
|
||||
}
|
||||
else if (tref->space_type == SPACE_IMAGE) {
|
||||
switch (tref->mode) {
|
||||
case SI_MODE_PAINT:
|
||||
return PAINT_MODE_TEXTURE_2D;
|
||||
return PaintMode::Texture2D;
|
||||
case SI_MODE_UV:
|
||||
return PAINT_MODE_SCULPT_UV;
|
||||
return PaintMode::SculptUV;
|
||||
}
|
||||
}
|
||||
|
||||
return PAINT_MODE_INVALID;
|
||||
return PaintMode::Invalid;
|
||||
}
|
||||
|
||||
Brush *BKE_paint_brush(Paint *p)
|
||||
@@ -723,31 +723,31 @@ void BKE_paint_runtime_init(const ToolSettings *ts, Paint *paint)
|
||||
}
|
||||
}
|
||||
|
||||
uint BKE_paint_get_brush_tool_offset_from_paintmode(const ePaintMode mode)
|
||||
uint BKE_paint_get_brush_tool_offset_from_paintmode(const PaintMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case PAINT_MODE_TEXTURE_2D:
|
||||
case PAINT_MODE_TEXTURE_3D:
|
||||
case PaintMode::Texture2D:
|
||||
case PaintMode::Texture3D:
|
||||
return offsetof(Brush, imagepaint_tool);
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PaintMode::Sculpt:
|
||||
return offsetof(Brush, sculpt_tool);
|
||||
case PAINT_MODE_VERTEX:
|
||||
case PaintMode::Vertex:
|
||||
return offsetof(Brush, vertexpaint_tool);
|
||||
case PAINT_MODE_WEIGHT:
|
||||
case PaintMode::Weight:
|
||||
return offsetof(Brush, weightpaint_tool);
|
||||
case PAINT_MODE_SCULPT_UV:
|
||||
case PaintMode::SculptUV:
|
||||
return offsetof(Brush, uv_sculpt_tool);
|
||||
case PAINT_MODE_GPENCIL:
|
||||
case PaintMode::GPencil:
|
||||
return offsetof(Brush, gpencil_tool);
|
||||
case PAINT_MODE_VERTEX_GPENCIL:
|
||||
case PaintMode::VertexGPencil:
|
||||
return offsetof(Brush, gpencil_vertex_tool);
|
||||
case PAINT_MODE_SCULPT_GPENCIL:
|
||||
case PaintMode::SculptGPencil:
|
||||
return offsetof(Brush, gpencil_sculpt_tool);
|
||||
case PAINT_MODE_WEIGHT_GPENCIL:
|
||||
case PaintMode::WeightGPencil:
|
||||
return offsetof(Brush, gpencil_weight_tool);
|
||||
case PAINT_MODE_SCULPT_CURVES:
|
||||
case PaintMode::SculptCurves:
|
||||
return offsetof(Brush, curves_sculpt_tool);
|
||||
case PAINT_MODE_INVALID:
|
||||
case PaintMode::Invalid:
|
||||
break; /* We don't use these yet. */
|
||||
}
|
||||
return 0;
|
||||
@@ -1063,25 +1063,25 @@ void BKE_paint_cavity_curve_preset(Paint *p, int preset)
|
||||
BKE_curvemapping_changed(cumap, false);
|
||||
}
|
||||
|
||||
eObjectMode BKE_paint_object_mode_from_paintmode(const ePaintMode mode)
|
||||
eObjectMode BKE_paint_object_mode_from_paintmode(const PaintMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PaintMode::Sculpt:
|
||||
return OB_MODE_SCULPT;
|
||||
case PAINT_MODE_VERTEX:
|
||||
case PaintMode::Vertex:
|
||||
return OB_MODE_VERTEX_PAINT;
|
||||
case PAINT_MODE_WEIGHT:
|
||||
case PaintMode::Weight:
|
||||
return OB_MODE_WEIGHT_PAINT;
|
||||
case PAINT_MODE_TEXTURE_2D:
|
||||
case PAINT_MODE_TEXTURE_3D:
|
||||
case PaintMode::Texture2D:
|
||||
case PaintMode::Texture3D:
|
||||
return OB_MODE_TEXTURE_PAINT;
|
||||
case PAINT_MODE_SCULPT_UV:
|
||||
case PaintMode::SculptUV:
|
||||
return OB_MODE_EDIT;
|
||||
case PAINT_MODE_SCULPT_CURVES:
|
||||
case PaintMode::SculptCurves:
|
||||
return OB_MODE_SCULPT_CURVES;
|
||||
case PAINT_MODE_GPENCIL:
|
||||
case PaintMode::GPencil:
|
||||
return OB_MODE_PAINT_GREASE_PENCIL;
|
||||
case PAINT_MODE_INVALID:
|
||||
case PaintMode::Invalid:
|
||||
default:
|
||||
return OB_MODE_OBJECT;
|
||||
}
|
||||
@@ -1172,7 +1172,7 @@ bool BKE_paint_ensure(ToolSettings *ts, Paint **r_paint)
|
||||
return false;
|
||||
}
|
||||
|
||||
void BKE_paint_init(Main *bmain, Scene *sce, ePaintMode mode, const uchar col[3])
|
||||
void BKE_paint_init(Main *bmain, Scene *sce, PaintMode mode, const uchar col[3])
|
||||
{
|
||||
UnifiedPaintSettings *ups = &sce->toolsettings->unified_paint_settings;
|
||||
Paint *paint = BKE_paint_get_active_from_paintmode(sce, mode);
|
||||
@@ -1329,7 +1329,7 @@ static bool paint_rake_rotation_active(const MTex &mtex)
|
||||
return mtex.tex && mtex.brush_angle_mode & MTEX_ANGLE_RAKE;
|
||||
}
|
||||
|
||||
static const bool paint_rake_rotation_active(const Brush &brush, ePaintMode paint_mode)
|
||||
static const bool paint_rake_rotation_active(const Brush &brush, PaintMode paint_mode)
|
||||
{
|
||||
return paint_rake_rotation_active(brush.mtex) || paint_rake_rotation_active(brush.mask_mtex) ||
|
||||
BKE_brush_has_cube_tip(&brush, paint_mode);
|
||||
@@ -1338,7 +1338,7 @@ static const bool paint_rake_rotation_active(const Brush &brush, ePaintMode pain
|
||||
bool paint_calculate_rake_rotation(UnifiedPaintSettings *ups,
|
||||
Brush *brush,
|
||||
const float mouse_pos[2],
|
||||
ePaintMode paint_mode,
|
||||
PaintMode paint_mode,
|
||||
bool stroke_has_started)
|
||||
{
|
||||
bool ok = false;
|
||||
|
||||
@@ -2884,10 +2884,10 @@ void do_versions_after_linking_280(FileData *fd, Main *bmain)
|
||||
ToolSettings *ts = scene->toolsettings;
|
||||
|
||||
/* Ensure new Paint modes. */
|
||||
BKE_paint_ensure_from_paintmode(scene, PAINT_MODE_GPENCIL);
|
||||
BKE_paint_ensure_from_paintmode(scene, PAINT_MODE_VERTEX_GPENCIL);
|
||||
BKE_paint_ensure_from_paintmode(scene, PAINT_MODE_SCULPT_GPENCIL);
|
||||
BKE_paint_ensure_from_paintmode(scene, PAINT_MODE_WEIGHT_GPENCIL);
|
||||
BKE_paint_ensure_from_paintmode(scene, PaintMode::GPencil);
|
||||
BKE_paint_ensure_from_paintmode(scene, PaintMode::VertexGPencil);
|
||||
BKE_paint_ensure_from_paintmode(scene, PaintMode::SculptGPencil);
|
||||
BKE_paint_ensure_from_paintmode(scene, PaintMode::WeightGPencil);
|
||||
|
||||
/* Set default Draw brush. */
|
||||
if (brush != nullptr) {
|
||||
@@ -2928,9 +2928,9 @@ void do_versions_after_linking_280(FileData *fd, Main *bmain)
|
||||
/* Reset all grease pencil brushes. */
|
||||
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
|
||||
/* Ensure new Paint modes. */
|
||||
BKE_paint_ensure_from_paintmode(scene, PAINT_MODE_VERTEX_GPENCIL);
|
||||
BKE_paint_ensure_from_paintmode(scene, PAINT_MODE_SCULPT_GPENCIL);
|
||||
BKE_paint_ensure_from_paintmode(scene, PAINT_MODE_WEIGHT_GPENCIL);
|
||||
BKE_paint_ensure_from_paintmode(scene, PaintMode::VertexGPencil);
|
||||
BKE_paint_ensure_from_paintmode(scene, PaintMode::SculptGPencil);
|
||||
BKE_paint_ensure_from_paintmode(scene, PaintMode::WeightGPencil);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -497,9 +497,9 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
|
||||
}
|
||||
|
||||
/* Ensure new Paint modes. */
|
||||
BKE_paint_ensure_from_paintmode(scene, PAINT_MODE_VERTEX_GPENCIL);
|
||||
BKE_paint_ensure_from_paintmode(scene, PAINT_MODE_SCULPT_GPENCIL);
|
||||
BKE_paint_ensure_from_paintmode(scene, PAINT_MODE_WEIGHT_GPENCIL);
|
||||
BKE_paint_ensure_from_paintmode(scene, PaintMode::VertexGPencil);
|
||||
BKE_paint_ensure_from_paintmode(scene, PaintMode::SculptGPencil);
|
||||
BKE_paint_ensure_from_paintmode(scene, PaintMode::WeightGPencil);
|
||||
|
||||
/* Enable cursor. */
|
||||
if (ts->gp_paint) {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "DNA_view3d_enums.h"
|
||||
|
||||
enum class PaintMode : int8_t;
|
||||
struct bContext;
|
||||
struct bToolRef;
|
||||
struct PaintModeSettings;
|
||||
@@ -57,7 +58,7 @@ bool ED_paint_proj_mesh_data_check(Scene *scene,
|
||||
* The caller is responsible for running #ED_image_undo_push_end,
|
||||
* failure to do so causes an invalid state for the undo system.
|
||||
*/
|
||||
void ED_image_undo_push_begin(const char *name, int paint_mode);
|
||||
void ED_image_undo_push_begin(const char *name, PaintMode paint_mode);
|
||||
void ED_image_undo_push_begin_with_image(const char *name,
|
||||
Image *image,
|
||||
ImBuf *ibuf,
|
||||
|
||||
@@ -970,7 +970,7 @@ static void ui_apply_but_undo(uiBut *but)
|
||||
/* XXX: disable all undo pushes from UI changes from sculpt mode as they cause memfile undo
|
||||
* steps to be written which cause lag: #71434. */
|
||||
if (BKE_paintmode_get_active_from_context(static_cast<bContext *>(but->block->evil_C)) ==
|
||||
PAINT_MODE_SCULPT)
|
||||
PaintMode::Sculpt)
|
||||
{
|
||||
skip_undo = true;
|
||||
}
|
||||
|
||||
@@ -2105,7 +2105,7 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
|
||||
else {
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
const EnumPropertyItem *items = nullptr;
|
||||
ePaintMode paint_mode = PAINT_MODE_INVALID;
|
||||
PaintMode paint_mode = PaintMode::Invalid;
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
char space_type = area->spacetype;
|
||||
/* Fallback to 3D view. */
|
||||
@@ -2119,26 +2119,26 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
|
||||
|
||||
if ((space_type == SPACE_VIEW3D) && ob) {
|
||||
if (ob->mode & OB_MODE_SCULPT) {
|
||||
paint_mode = PAINT_MODE_SCULPT;
|
||||
paint_mode = PaintMode::Sculpt;
|
||||
}
|
||||
else if (ob->mode & OB_MODE_VERTEX_PAINT) {
|
||||
paint_mode = PAINT_MODE_VERTEX;
|
||||
paint_mode = PaintMode::Vertex;
|
||||
}
|
||||
else if (ob->mode & OB_MODE_WEIGHT_PAINT) {
|
||||
paint_mode = PAINT_MODE_WEIGHT;
|
||||
paint_mode = PaintMode::Weight;
|
||||
}
|
||||
else if (ob->mode & OB_MODE_TEXTURE_PAINT) {
|
||||
paint_mode = PAINT_MODE_TEXTURE_3D;
|
||||
paint_mode = PaintMode::Texture3D;
|
||||
}
|
||||
else if (ob->mode & OB_MODE_SCULPT_CURVES) {
|
||||
paint_mode = PAINT_MODE_SCULPT_CURVES;
|
||||
paint_mode = PaintMode::SculptCurves;
|
||||
}
|
||||
}
|
||||
else if (space_type == SPACE_IMAGE) {
|
||||
if (area->spacetype == space_type) {
|
||||
const SpaceImage *sima = static_cast<const SpaceImage *>(area->spacedata.first);
|
||||
if (sima->mode == SI_MODE_PAINT) {
|
||||
paint_mode = PAINT_MODE_TEXTURE_2D;
|
||||
paint_mode = PaintMode::Texture2D;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2248,7 +2248,7 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
|
||||
return id->icon_id;
|
||||
}
|
||||
|
||||
if (paint_mode != PAINT_MODE_INVALID) {
|
||||
if (paint_mode != PaintMode::Invalid) {
|
||||
items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
|
||||
const uint tool_offset = BKE_paint_get_brush_tool_offset_from_paintmode(paint_mode);
|
||||
const int tool_type = *(char *)POINTER_OFFSET(br, tool_offset);
|
||||
|
||||
@@ -576,7 +576,7 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is
|
||||
std::string shortcut = UI_but_string_get_operator_keymap(*C, *but);
|
||||
|
||||
if (shortcut.empty()) {
|
||||
const ePaintMode paint_mode = BKE_paintmode_get_active_from_context(C);
|
||||
const PaintMode paint_mode = BKE_paintmode_get_active_from_context(C);
|
||||
const char *tool_attr = BKE_paint_get_tool_prop_id_from_paintmode(paint_mode);
|
||||
if (tool_attr != nullptr) {
|
||||
const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
|
||||
|
||||
@@ -203,7 +203,7 @@ static void stroke_done(const bContext *C, PaintStroke *stroke)
|
||||
static int sculpt_curves_stroke_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Paint *paint = BKE_paint_get_active_from_paintmode(scene, PAINT_MODE_SCULPT_CURVES);
|
||||
Paint *paint = BKE_paint_get_active_from_paintmode(scene, PaintMode::SculptCurves);
|
||||
const Brush *brush = paint ? BKE_paint_brush_for_read(paint) : nullptr;
|
||||
if (brush == nullptr) {
|
||||
return OPERATOR_CANCELLED;
|
||||
@@ -288,7 +288,7 @@ static void curves_sculptmode_enter(bContext *C)
|
||||
ob->mode = OB_MODE_SCULPT_CURVES;
|
||||
|
||||
/* Setup cursor color. BKE_paint_init() could be used, but creates an additional brush. */
|
||||
Paint *paint = BKE_paint_get_active_from_paintmode(scene, PAINT_MODE_SCULPT_CURVES);
|
||||
Paint *paint = BKE_paint_get_active_from_paintmode(scene, PaintMode::SculptCurves);
|
||||
copy_v3_v3_uchar(paint->paint_cursor_col, PAINT_CURSOR_SCULPT_CURVES);
|
||||
paint->paint_cursor_col[3] = 128;
|
||||
|
||||
|
||||
@@ -544,7 +544,7 @@ static bool paint_draw_tex_overlay(UnifiedPaintSettings *ups,
|
||||
int x,
|
||||
int y,
|
||||
float zoom,
|
||||
const ePaintMode mode,
|
||||
const PaintMode mode,
|
||||
bool col,
|
||||
bool primary)
|
||||
{
|
||||
@@ -556,7 +556,7 @@ static bool paint_draw_tex_overlay(UnifiedPaintSettings *ups,
|
||||
(brush->overlay_flags & BRUSH_OVERLAY_SECONDARY) != 0);
|
||||
int overlay_alpha = (primary) ? brush->texture_overlay_alpha : brush->mask_overlay_alpha;
|
||||
|
||||
if (mode == PAINT_MODE_TEXTURE_3D) {
|
||||
if (mode == PaintMode::Texture3D) {
|
||||
if (primary && brush->imagepaint_tool != PAINT_TOOL_DRAW) {
|
||||
/* All non-draw tools don't use the primary texture (clone, smear, soften.. etc). */
|
||||
return false;
|
||||
@@ -781,11 +781,11 @@ static bool paint_draw_alpha_overlay(UnifiedPaintSettings *ups,
|
||||
int x,
|
||||
int y,
|
||||
float zoom,
|
||||
ePaintMode mode)
|
||||
PaintMode mode)
|
||||
{
|
||||
/* Color means that primary brush texture is colored and
|
||||
* secondary is used for alpha/mask control. */
|
||||
bool col = ELEM(mode, PAINT_MODE_TEXTURE_3D, PAINT_MODE_TEXTURE_2D, PAINT_MODE_VERTEX);
|
||||
bool col = ELEM(mode, PaintMode::Texture3D, PaintMode::Texture2D, PaintMode::Vertex);
|
||||
|
||||
bool alpha_overlay_active = false;
|
||||
|
||||
@@ -813,7 +813,7 @@ static bool paint_draw_alpha_overlay(UnifiedPaintSettings *ups,
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!(flags & PAINT_OVERLAY_OVERRIDE_PRIMARY) && (mode != PAINT_MODE_WEIGHT)) {
|
||||
if (!(flags & PAINT_OVERLAY_OVERRIDE_PRIMARY) && (mode != PaintMode::Weight)) {
|
||||
alpha_overlay_active = paint_draw_tex_overlay(ups, brush, vc, x, y, zoom, mode, false, true);
|
||||
}
|
||||
if (!(flags & PAINT_OVERLAY_OVERRIDE_CURSOR)) {
|
||||
@@ -1205,23 +1205,23 @@ static void SCULPT_layer_brush_height_preview_draw(const uint gpuattr,
|
||||
GPU_matrix_pop();
|
||||
}
|
||||
|
||||
static bool paint_use_2d_cursor(ePaintMode mode)
|
||||
static bool paint_use_2d_cursor(PaintMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PAINT_MODE_VERTEX:
|
||||
case PAINT_MODE_WEIGHT:
|
||||
case PaintMode::Sculpt:
|
||||
case PaintMode::Vertex:
|
||||
case PaintMode::Weight:
|
||||
return false;
|
||||
case PAINT_MODE_TEXTURE_3D:
|
||||
case PAINT_MODE_TEXTURE_2D:
|
||||
case PAINT_MODE_SCULPT_UV:
|
||||
case PAINT_MODE_VERTEX_GPENCIL:
|
||||
case PAINT_MODE_SCULPT_GPENCIL:
|
||||
case PAINT_MODE_WEIGHT_GPENCIL:
|
||||
case PAINT_MODE_SCULPT_CURVES:
|
||||
case PAINT_MODE_GPENCIL:
|
||||
case PaintMode::Texture3D:
|
||||
case PaintMode::Texture2D:
|
||||
case PaintMode::SculptUV:
|
||||
case PaintMode::VertexGPencil:
|
||||
case PaintMode::SculptGPencil:
|
||||
case PaintMode::WeightGPencil:
|
||||
case PaintMode::SculptCurves:
|
||||
case PaintMode::GPencil:
|
||||
return true;
|
||||
case PAINT_MODE_INVALID:
|
||||
case PaintMode::Invalid:
|
||||
BLI_assert_unreachable();
|
||||
}
|
||||
return true;
|
||||
@@ -1243,7 +1243,7 @@ struct PaintCursorContext {
|
||||
UnifiedPaintSettings *ups;
|
||||
Brush *brush;
|
||||
Paint *paint;
|
||||
ePaintMode mode;
|
||||
PaintMode mode;
|
||||
ViewContext vc;
|
||||
|
||||
/* Sculpt related data. */
|
||||
@@ -1389,7 +1389,7 @@ static void paint_cursor_update_pixel_radius(PaintCursorContext *pcontext)
|
||||
static void paint_cursor_sculpt_session_update_and_init(PaintCursorContext *pcontext)
|
||||
{
|
||||
BLI_assert(pcontext->ss != nullptr);
|
||||
BLI_assert(pcontext->mode == PAINT_MODE_SCULPT);
|
||||
BLI_assert(pcontext->mode == PaintMode::Sculpt);
|
||||
|
||||
bContext *C = pcontext->C;
|
||||
SculptSession *ss = pcontext->ss;
|
||||
@@ -1440,7 +1440,7 @@ static void paint_update_mouse_cursor(PaintCursorContext *pcontext)
|
||||
* with the UI (dragging a number button for e.g.), see: #102792. */
|
||||
return;
|
||||
}
|
||||
if (pcontext->mode == PAINT_MODE_GPENCIL) {
|
||||
if (pcontext->mode == PaintMode::GPencil) {
|
||||
WM_cursor_set(pcontext->win, WM_CURSOR_DOT);
|
||||
}
|
||||
else {
|
||||
@@ -1523,7 +1523,7 @@ static void grease_pencil_brush_cursor_draw(PaintCursorContext *pcontext)
|
||||
const int y = pcontext->y;
|
||||
|
||||
/* for paint use paint brush size and color */
|
||||
if (pcontext->mode == PAINT_MODE_GPENCIL) {
|
||||
if (pcontext->mode == PaintMode::GPencil) {
|
||||
Paint *paint = pcontext->paint;
|
||||
Brush *brush = pcontext->brush;
|
||||
if ((brush == nullptr) || (brush->gpencil_settings == nullptr)) {
|
||||
@@ -1602,7 +1602,7 @@ static void grease_pencil_brush_cursor_draw(PaintCursorContext *pcontext)
|
||||
static void paint_draw_2D_view_brush_cursor(PaintCursorContext *pcontext)
|
||||
{
|
||||
switch (pcontext->mode) {
|
||||
case PAINT_MODE_GPENCIL: {
|
||||
case PaintMode::GPencil: {
|
||||
grease_pencil_brush_cursor_draw(pcontext);
|
||||
break;
|
||||
}
|
||||
@@ -1914,7 +1914,7 @@ static void paint_cursor_cursor_draw_3d_view_brush_cursor_active(PaintCursorCont
|
||||
{
|
||||
using namespace blender::ed::sculpt_paint;
|
||||
BLI_assert(pcontext->ss != nullptr);
|
||||
BLI_assert(pcontext->mode == PAINT_MODE_SCULPT);
|
||||
BLI_assert(pcontext->mode == PaintMode::Sculpt);
|
||||
|
||||
SculptSession *ss = pcontext->ss;
|
||||
Brush *brush = pcontext->brush;
|
||||
@@ -1995,7 +1995,7 @@ static void paint_cursor_draw_3D_view_brush_cursor(PaintCursorContext *pcontext)
|
||||
|
||||
/* These paint tools are not using the SculptSession, so they need to use the default 2D brush
|
||||
* cursor in the 3D view. */
|
||||
if (pcontext->mode != PAINT_MODE_SCULPT || !pcontext->ss) {
|
||||
if (pcontext->mode != PaintMode::Sculpt || !pcontext->ss) {
|
||||
paint_draw_legacy_3D_view_brush_cursor(pcontext);
|
||||
return;
|
||||
}
|
||||
@@ -2019,7 +2019,7 @@ static bool paint_cursor_is_3d_view_navigating(PaintCursorContext *pcontext)
|
||||
static bool paint_cursor_is_brush_cursor_enabled(PaintCursorContext *pcontext)
|
||||
{
|
||||
if (pcontext->paint->flags & PAINT_SHOW_BRUSH) {
|
||||
if (ELEM(pcontext->mode, PAINT_MODE_TEXTURE_2D, PAINT_MODE_TEXTURE_3D) &&
|
||||
if (ELEM(pcontext->mode, PaintMode::Texture2D, PaintMode::Texture3D) &&
|
||||
pcontext->brush->imagepaint_tool == PAINT_TOOL_FILL)
|
||||
{
|
||||
return false;
|
||||
|
||||
@@ -666,27 +666,27 @@ void PAINTCURVE_OT_slide(wmOperatorType *ot)
|
||||
|
||||
static int paintcurve_draw_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
const char *name;
|
||||
|
||||
switch (mode) {
|
||||
case PAINT_MODE_TEXTURE_2D:
|
||||
case PAINT_MODE_TEXTURE_3D:
|
||||
case PaintMode::Texture2D:
|
||||
case PaintMode::Texture3D:
|
||||
name = "PAINT_OT_image_paint";
|
||||
break;
|
||||
case PAINT_MODE_WEIGHT:
|
||||
case PaintMode::Weight:
|
||||
name = "PAINT_OT_weight_paint";
|
||||
break;
|
||||
case PAINT_MODE_VERTEX:
|
||||
case PaintMode::Vertex:
|
||||
name = "PAINT_OT_vertex_paint";
|
||||
break;
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PaintMode::Sculpt:
|
||||
name = "SCULPT_OT_brush_stroke";
|
||||
break;
|
||||
case PAINT_MODE_SCULPT_CURVES:
|
||||
case PaintMode::SculptCurves:
|
||||
name = "SCULPT_CURVES_OT_brush_stroke";
|
||||
break;
|
||||
case PAINT_MODE_GPENCIL:
|
||||
case PaintMode::GPencil:
|
||||
name = "GREASE_PENCIL_OT_brush_stroke";
|
||||
break;
|
||||
default:
|
||||
@@ -713,10 +713,10 @@ void PAINTCURVE_OT_draw(wmOperatorType *ot)
|
||||
|
||||
static int paintcurve_cursor_invoke(bContext *C, wmOperator * /*op*/, const wmEvent *event)
|
||||
{
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
|
||||
switch (mode) {
|
||||
case PAINT_MODE_TEXTURE_2D: {
|
||||
case PaintMode::Texture2D: {
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
SpaceImage *sima = CTX_wm_space_image(C);
|
||||
float location[2];
|
||||
|
||||
@@ -489,7 +489,7 @@ void ED_space_image_paint_update(Main *bmain, wmWindowManager *wm, Scene *scene)
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
BKE_paint_init(bmain, scene, PAINT_MODE_TEXTURE_2D, PAINT_CURSOR_TEXTURE_PAINT);
|
||||
BKE_paint_init(bmain, scene, PaintMode::Texture2D, PAINT_CURSOR_TEXTURE_PAINT);
|
||||
|
||||
ED_paint_cursor_start(&imapaint->paint, ED_image_tools_paint_poll);
|
||||
}
|
||||
@@ -642,7 +642,7 @@ static int sample_color_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
Brush *brush = BKE_paint_brush(paint);
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
const bool show_cursor = ((paint->flags & PAINT_SHOW_BRUSH) != 0);
|
||||
@@ -655,7 +655,7 @@ static int sample_color_exec(bContext *C, wmOperator *op)
|
||||
|
||||
RNA_int_get_array(op->ptr, "location", location);
|
||||
const bool use_palette = RNA_boolean_get(op->ptr, "palette");
|
||||
const bool use_sample_texture = (mode == PAINT_MODE_TEXTURE_3D) &&
|
||||
const bool use_sample_texture = (mode == PaintMode::Texture3D) &&
|
||||
!RNA_boolean_get(op->ptr, "merged");
|
||||
|
||||
paint_sample_color(C, region, location[0], location[1], use_sample_texture, use_palette);
|
||||
@@ -695,8 +695,8 @@ static int sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *event
|
||||
|
||||
RNA_int_set_array(op->ptr, "location", event->mval);
|
||||
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
const bool use_sample_texture = (mode == PAINT_MODE_TEXTURE_3D) &&
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
const bool use_sample_texture = (mode == PaintMode::Texture3D) &&
|
||||
!RNA_boolean_get(op->ptr, "merged");
|
||||
|
||||
paint_sample_color(C, region, event->mval[0], event->mval[1], use_sample_texture, false);
|
||||
@@ -730,8 +730,8 @@ static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
const bool use_sample_texture = (mode == PAINT_MODE_TEXTURE_3D) &&
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
const bool use_sample_texture = (mode == PaintMode::Texture3D) &&
|
||||
!RNA_boolean_get(op->ptr, "merged");
|
||||
|
||||
switch (event->type) {
|
||||
@@ -898,7 +898,7 @@ void ED_object_texture_paint_mode_enter_ex(Main *bmain,
|
||||
|
||||
ob->mode |= OB_MODE_TEXTURE_PAINT;
|
||||
|
||||
BKE_paint_init(bmain, scene, PAINT_MODE_TEXTURE_3D, PAINT_CURSOR_TEXTURE_PAINT);
|
||||
BKE_paint_init(bmain, scene, PaintMode::Texture3D, PAINT_CURSOR_TEXTURE_PAINT);
|
||||
|
||||
BKE_paint_toolslots_brush_validate(bmain, &imapaint->paint);
|
||||
|
||||
@@ -1091,7 +1091,7 @@ void ED_imapaint_bucket_fill(bContext *C, float color[3], wmOperator *op, const
|
||||
if (sima && sima->image) {
|
||||
Image *ima = sima->image;
|
||||
|
||||
ED_image_undo_push_begin(op->type->name, PAINT_MODE_TEXTURE_2D);
|
||||
ED_image_undo_push_begin(op->type->name, PaintMode::Texture2D);
|
||||
|
||||
const float mouse_init[2] = {float(mouse[0]), float(mouse[1])};
|
||||
paint_2d_bucket_fill(C, color, nullptr, mouse_init, nullptr, nullptr);
|
||||
|
||||
@@ -319,7 +319,7 @@ static PaintOperation *texture_paint_init(bContext *C, wmOperator *op, const flo
|
||||
}
|
||||
|
||||
settings->imapaint.flag |= IMAGEPAINT_DRAWING;
|
||||
ED_image_undo_push_begin(op->type->name, PAINT_MODE_TEXTURE_2D);
|
||||
ED_image_undo_push_begin(op->type->name, PaintMode::Texture2D);
|
||||
|
||||
return pop;
|
||||
}
|
||||
|
||||
@@ -6164,7 +6164,7 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
ED_image_undo_push_begin(op->type->name, PAINT_MODE_TEXTURE_3D);
|
||||
ED_image_undo_push_begin(op->type->name, PaintMode::Texture3D);
|
||||
|
||||
const float pos[2] = {0.0, 0.0};
|
||||
const float lastpos[2] = {0.0, 0.0};
|
||||
|
||||
@@ -79,17 +79,17 @@ 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);
|
||||
bool paint_space_stroke_enabled(Brush *br, PaintMode 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);
|
||||
bool paint_supports_dynamic_size(Brush *br, PaintMode 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_dynamic_tex_coords(Brush *br, PaintMode mode);
|
||||
bool paint_supports_smooth_stroke(Brush *br, PaintMode mode);
|
||||
bool paint_supports_texture(PaintMode mode);
|
||||
|
||||
/**
|
||||
* Called in paint_ops.cc, on each regeneration of key-maps.
|
||||
|
||||
@@ -56,7 +56,7 @@ static int brush_add_exec(bContext *C, wmOperator * /*op*/)
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
Brush *br = BKE_paint_brush(paint);
|
||||
Main *bmain = CTX_data_main(C);
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
|
||||
if (br) {
|
||||
br = (Brush *)BKE_id_copy(bmain, &br->id);
|
||||
@@ -377,7 +377,7 @@ static int palette_color_add_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
Palette *palette = paint->palette;
|
||||
PaletteColor *color;
|
||||
|
||||
@@ -387,15 +387,15 @@ static int palette_color_add_exec(bContext *C, wmOperator * /*op*/)
|
||||
if (paint->brush) {
|
||||
const Brush *brush = paint->brush;
|
||||
if (ELEM(mode,
|
||||
PAINT_MODE_TEXTURE_3D,
|
||||
PAINT_MODE_TEXTURE_2D,
|
||||
PAINT_MODE_VERTEX,
|
||||
PAINT_MODE_SCULPT))
|
||||
PaintMode::Texture3D,
|
||||
PaintMode::Texture2D,
|
||||
PaintMode::Vertex,
|
||||
PaintMode::Sculpt))
|
||||
{
|
||||
copy_v3_v3(color->rgb, BKE_brush_color_get(scene, brush));
|
||||
color->value = 0.0;
|
||||
}
|
||||
else if (mode == PAINT_MODE_WEIGHT) {
|
||||
else if (mode == PaintMode::Weight) {
|
||||
zero_v3(color->rgb);
|
||||
color->value = brush->weight;
|
||||
}
|
||||
@@ -916,9 +916,9 @@ static bool brush_generic_tool_set(bContext *C,
|
||||
* In case we are toggling (and the brush changed to the toggle_brush), we need to get the
|
||||
* tool_name again. */
|
||||
int tool_result = brush_tool(brush, paint->runtime.tool_offset);
|
||||
ePaintMode paint_mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintMode paint_mode = BKE_paintmode_get_active_from_context(C);
|
||||
|
||||
if (paint_mode == PAINT_MODE_SCULPT_CURVES) {
|
||||
if (paint_mode == PaintMode::SculptCurves) {
|
||||
tool_name = curves_active_tool_name_get(eBrushCurvesSculptTool(tool)).c_str();
|
||||
}
|
||||
else {
|
||||
@@ -935,16 +935,16 @@ static bool brush_generic_tool_set(bContext *C,
|
||||
return false;
|
||||
}
|
||||
|
||||
static const ePaintMode brush_select_paint_modes[] = {
|
||||
PAINT_MODE_SCULPT,
|
||||
PAINT_MODE_VERTEX,
|
||||
PAINT_MODE_WEIGHT,
|
||||
PAINT_MODE_TEXTURE_3D,
|
||||
PAINT_MODE_GPENCIL,
|
||||
PAINT_MODE_VERTEX_GPENCIL,
|
||||
PAINT_MODE_SCULPT_GPENCIL,
|
||||
PAINT_MODE_WEIGHT_GPENCIL,
|
||||
PAINT_MODE_SCULPT_CURVES,
|
||||
static const PaintMode brush_select_paint_modes[] = {
|
||||
PaintMode::Sculpt,
|
||||
PaintMode::Vertex,
|
||||
PaintMode::Weight,
|
||||
PaintMode::Texture3D,
|
||||
PaintMode::GPencil,
|
||||
PaintMode::VertexGPencil,
|
||||
PaintMode::SculptGPencil,
|
||||
PaintMode::WeightGPencil,
|
||||
PaintMode::SculptCurves,
|
||||
};
|
||||
|
||||
static int brush_select_exec(bContext *C, wmOperator *op)
|
||||
@@ -956,7 +956,7 @@ static int brush_select_exec(bContext *C, wmOperator *op)
|
||||
const char *tool_name = "Brush";
|
||||
int tool = 0;
|
||||
|
||||
ePaintMode paint_mode = PAINT_MODE_INVALID;
|
||||
PaintMode paint_mode = PaintMode::Invalid;
|
||||
for (int i = 0; i < ARRAY_SIZE(brush_select_paint_modes); i++) {
|
||||
paint_mode = brush_select_paint_modes[i];
|
||||
const char *op_prop_id = BKE_paint_get_tool_prop_id_from_paintmode(paint_mode);
|
||||
@@ -967,7 +967,7 @@ static int brush_select_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
}
|
||||
|
||||
if (paint_mode == PAINT_MODE_INVALID) {
|
||||
if (paint_mode == PaintMode::Invalid) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
@@ -976,7 +976,7 @@ static int brush_select_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
if (paint_mode == PAINT_MODE_SCULPT_CURVES) {
|
||||
if (paint_mode == PaintMode::SculptCurves) {
|
||||
tool_name = curves_active_tool_name_get(eBrushCurvesSculptTool(tool)).c_str();
|
||||
}
|
||||
else {
|
||||
@@ -1008,7 +1008,7 @@ static void PAINT_OT_brush_select(wmOperatorType *ot)
|
||||
/* props */
|
||||
/* All properties are hidden, so as not to show the redo panel. */
|
||||
for (int i = 0; i < ARRAY_SIZE(brush_select_paint_modes); i++) {
|
||||
const ePaintMode paint_mode = brush_select_paint_modes[i];
|
||||
const PaintMode paint_mode = brush_select_paint_modes[i];
|
||||
const char *prop_id = BKE_paint_get_tool_prop_id_from_paintmode(paint_mode);
|
||||
prop = RNA_def_enum(
|
||||
ot->srna, prop_id, BKE_paint_get_tool_enum_from_paintmode(paint_mode), 0, prop_id, "");
|
||||
@@ -1260,7 +1260,7 @@ static int stencil_control_modal(bContext *C, wmOperator *op, const wmEvent *eve
|
||||
|
||||
static bool stencil_control_poll(bContext *C)
|
||||
{
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
|
||||
Paint *paint;
|
||||
Brush *br;
|
||||
|
||||
@@ -208,10 +208,10 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata)
|
||||
GPU_line_smooth(false);
|
||||
}
|
||||
|
||||
static bool paint_tool_require_location(Brush *brush, ePaintMode mode)
|
||||
static bool paint_tool_require_location(Brush *brush, PaintMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PaintMode::Sculpt:
|
||||
if (ELEM(brush->sculpt_tool,
|
||||
SCULPT_TOOL_GRAB,
|
||||
SCULPT_TOOL_ELASTIC_DEFORM,
|
||||
@@ -236,10 +236,10 @@ static bool paint_tool_require_location(Brush *brush, ePaintMode mode)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool paint_stroke_use_scene_spacing(Brush *brush, ePaintMode mode)
|
||||
static bool paint_stroke_use_scene_spacing(Brush *brush, PaintMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PaintMode::Sculpt:
|
||||
return brush->flag & BRUSH_SCENE_SPACING;
|
||||
default:
|
||||
break;
|
||||
@@ -247,19 +247,19 @@ static bool paint_stroke_use_scene_spacing(Brush *brush, ePaintMode mode)
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool paint_tool_raycast_original(Brush *brush, ePaintMode /*mode*/)
|
||||
static bool paint_tool_raycast_original(Brush *brush, PaintMode /*mode*/)
|
||||
{
|
||||
return brush->flag & (BRUSH_ANCHORED | BRUSH_DRAG_DOT);
|
||||
}
|
||||
|
||||
static bool paint_tool_require_inbetween_mouse_events(Brush *brush, ePaintMode mode)
|
||||
static bool paint_tool_require_inbetween_mouse_events(Brush *brush, PaintMode mode)
|
||||
{
|
||||
if (brush->flag & BRUSH_ANCHORED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PaintMode::Sculpt:
|
||||
if (ELEM(brush->sculpt_tool,
|
||||
SCULPT_TOOL_GRAB,
|
||||
SCULPT_TOOL_ROTATE,
|
||||
@@ -285,7 +285,7 @@ static bool paint_tool_require_inbetween_mouse_events(Brush *brush, ePaintMode m
|
||||
/* Initialize the stroke cache variants from operator properties */
|
||||
static bool paint_brush_update(bContext *C,
|
||||
Brush *brush,
|
||||
ePaintMode mode,
|
||||
PaintMode mode,
|
||||
PaintStroke *stroke,
|
||||
const float mouse_init[2],
|
||||
float mouse[2],
|
||||
@@ -500,7 +500,7 @@ static bool paint_stroke_use_dash(Brush *brush)
|
||||
return brush->flag & BRUSH_SPACE || brush->flag & BRUSH_LINE || brush->flag & BRUSH_CURVE;
|
||||
}
|
||||
|
||||
static bool paint_stroke_use_jitter(ePaintMode mode, Brush *brush, bool invert)
|
||||
static bool paint_stroke_use_jitter(PaintMode mode, Brush *brush, bool invert)
|
||||
{
|
||||
bool use_jitter = (brush->flag & BRUSH_ABSOLUTE_JITTER) ? (brush->jitter_absolute != 0) :
|
||||
(brush->jitter != 0);
|
||||
@@ -508,7 +508,7 @@ static bool paint_stroke_use_jitter(ePaintMode mode, Brush *brush, bool invert)
|
||||
/* jitter-ed brush gives weird and unpredictable result for this
|
||||
* kinds of stroke, so manually disable jitter usage (sergey) */
|
||||
use_jitter &= (brush->flag & (BRUSH_DRAG_DOT | BRUSH_ANCHORED)) == 0;
|
||||
use_jitter &= (!ELEM(mode, PAINT_MODE_TEXTURE_2D, PAINT_MODE_TEXTURE_3D) ||
|
||||
use_jitter &= (!ELEM(mode, PaintMode::Texture2D, PaintMode::Texture3D) ||
|
||||
!(invert && brush->imagepaint_tool == PAINT_TOOL_CLONE));
|
||||
|
||||
return use_jitter;
|
||||
@@ -520,7 +520,7 @@ static void paint_brush_stroke_add_step(
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
Brush *brush = BKE_paint_brush(paint);
|
||||
UnifiedPaintSettings *ups = stroke->ups;
|
||||
float mouse_out[2];
|
||||
@@ -643,7 +643,7 @@ static void paint_brush_stroke_add_step(
|
||||
/* Returns zero if no sculpt changes should be made, non-zero otherwise */
|
||||
static bool paint_smooth_stroke(PaintStroke *stroke,
|
||||
const PaintSample *sample,
|
||||
ePaintMode mode,
|
||||
PaintMode mode,
|
||||
float r_mouse[2],
|
||||
float *r_pressure)
|
||||
{
|
||||
@@ -676,7 +676,7 @@ static float paint_space_stroke_spacing(bContext *C,
|
||||
float spacing_pressure)
|
||||
{
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
Brush *brush = BKE_paint_brush(paint);
|
||||
float size_clamp = 0.0f;
|
||||
float size = BKE_brush_size_get(scene, stroke->brush) * size_pressure;
|
||||
@@ -816,7 +816,7 @@ static int paint_space_stroke(bContext *C,
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
UnifiedPaintSettings *ups = stroke->ups;
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
Brush *brush = BKE_paint_brush(paint);
|
||||
int count = 0;
|
||||
|
||||
@@ -1022,7 +1022,7 @@ static bool curves_sculpt_brush_uses_spacing(const eBrushCurvesSculptTool tool)
|
||||
return ELEM(tool, CURVES_SCULPT_TOOL_ADD, CURVES_SCULPT_TOOL_DENSITY);
|
||||
}
|
||||
|
||||
bool paint_space_stroke_enabled(Brush *br, ePaintMode mode)
|
||||
bool paint_space_stroke_enabled(Brush *br, PaintMode mode)
|
||||
{
|
||||
if ((br->flag & BRUSH_SPACE) == 0) {
|
||||
return false;
|
||||
@@ -1036,13 +1036,13 @@ bool paint_space_stroke_enabled(Brush *br, ePaintMode mode)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mode == PAINT_MODE_SCULPT_CURVES &&
|
||||
if (mode == PaintMode::SculptCurves &&
|
||||
!curves_sculpt_brush_uses_spacing(eBrushCurvesSculptTool(br->curves_sculpt_tool)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mode == PAINT_MODE_GPENCIL) {
|
||||
if (mode == PaintMode::GPencil) {
|
||||
/* No spacing needed for now. */
|
||||
return false;
|
||||
}
|
||||
@@ -1066,21 +1066,21 @@ static bool sculpt_is_grab_tool(Brush *br)
|
||||
SCULPT_TOOL_SNAKE_HOOK);
|
||||
}
|
||||
|
||||
bool paint_supports_dynamic_size(Brush *br, ePaintMode mode)
|
||||
bool paint_supports_dynamic_size(Brush *br, PaintMode mode)
|
||||
{
|
||||
if (br->flag & BRUSH_ANCHORED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PaintMode::Sculpt:
|
||||
if (sculpt_is_grab_tool(br)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case PAINT_MODE_TEXTURE_2D: /* fall through */
|
||||
case PAINT_MODE_TEXTURE_3D:
|
||||
case PaintMode::Texture2D: /* fall through */
|
||||
case PaintMode::Texture3D:
|
||||
if ((br->imagepaint_tool == PAINT_TOOL_FILL) && (br->flag & BRUSH_USE_GRADIENT)) {
|
||||
return false;
|
||||
}
|
||||
@@ -1092,7 +1092,7 @@ bool paint_supports_dynamic_size(Brush *br, ePaintMode mode)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool paint_supports_smooth_stroke(Brush *br, ePaintMode mode)
|
||||
bool paint_supports_smooth_stroke(Brush *br, PaintMode mode)
|
||||
{
|
||||
if (!(br->flag & BRUSH_SMOOTH_STROKE) ||
|
||||
(br->flag & (BRUSH_ANCHORED | BRUSH_DRAG_DOT | BRUSH_LINE)))
|
||||
@@ -1101,7 +1101,7 @@ bool paint_supports_smooth_stroke(Brush *br, ePaintMode mode)
|
||||
}
|
||||
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PaintMode::Sculpt:
|
||||
if (sculpt_is_grab_tool(br)) {
|
||||
return false;
|
||||
}
|
||||
@@ -1112,21 +1112,21 @@ bool paint_supports_smooth_stroke(Brush *br, ePaintMode mode)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool paint_supports_texture(ePaintMode mode)
|
||||
bool paint_supports_texture(PaintMode mode)
|
||||
{
|
||||
/* omit: PAINT_WEIGHT, PAINT_SCULPT_UV, PAINT_INVALID */
|
||||
return ELEM(
|
||||
mode, PAINT_MODE_SCULPT, PAINT_MODE_VERTEX, PAINT_MODE_TEXTURE_3D, PAINT_MODE_TEXTURE_2D);
|
||||
mode, PaintMode::Sculpt, PaintMode::Vertex, PaintMode::Texture3D, PaintMode::Texture2D);
|
||||
}
|
||||
|
||||
bool paint_supports_dynamic_tex_coords(Brush *br, ePaintMode mode)
|
||||
bool paint_supports_dynamic_tex_coords(Brush *br, PaintMode mode)
|
||||
{
|
||||
if (br->flag & BRUSH_ANCHORED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PaintMode::Sculpt:
|
||||
if (sculpt_is_grab_tool(br)) {
|
||||
return false;
|
||||
}
|
||||
@@ -1208,7 +1208,7 @@ static void paint_line_strokes_spacing(bContext *C,
|
||||
UnifiedPaintSettings *ups = stroke->ups;
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
Brush *brush = BKE_paint_brush(paint);
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
|
||||
const bool use_scene_spacing = paint_stroke_use_scene_spacing(brush, mode);
|
||||
@@ -1432,7 +1432,7 @@ static void paint_stroke_line_constrain(PaintStroke *stroke, float mouse[2])
|
||||
int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event, PaintStroke **stroke_p)
|
||||
{
|
||||
Paint *p = BKE_paint_get_active_from_context(C);
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintStroke *stroke = *stroke_p;
|
||||
Brush *br = stroke->brush = BKE_paint_brush(p);
|
||||
PaintSample sample_average;
|
||||
|
||||
@@ -314,7 +314,7 @@ void mode_enter_generic(
|
||||
BKE_object_free_derived_caches(ob);
|
||||
|
||||
if (mode_flag == OB_MODE_VERTEX_PAINT) {
|
||||
const ePaintMode paint_mode = PAINT_MODE_VERTEX;
|
||||
const PaintMode paint_mode = PaintMode::Vertex;
|
||||
ED_mesh_color_ensure(mesh, nullptr);
|
||||
|
||||
BKE_paint_ensure(scene->toolsettings, (Paint **)&scene->toolsettings->vpaint);
|
||||
@@ -323,7 +323,7 @@ void mode_enter_generic(
|
||||
BKE_paint_init(bmain, scene, paint_mode, PAINT_CURSOR_VERTEX_PAINT);
|
||||
}
|
||||
else if (mode_flag == OB_MODE_WEIGHT_PAINT) {
|
||||
const ePaintMode paint_mode = PAINT_MODE_WEIGHT;
|
||||
const PaintMode paint_mode = PaintMode::Weight;
|
||||
|
||||
BKE_paint_ensure(scene->toolsettings, (Paint **)&scene->toolsettings->wpaint);
|
||||
Paint *paint = BKE_paint_get_active_from_paintmode(scene, paint_mode);
|
||||
@@ -522,7 +522,7 @@ void update_cache_variants(bContext *C, VPaint *vp, Object *ob, PointerRNA *ptr)
|
||||
* brush coord/pressure/etc.
|
||||
* It's more an events design issue, which doesn't split coordinate/pressure/angle
|
||||
* changing events. We should avoid this after events system re-design */
|
||||
if (paint_supports_dynamic_size(brush, PAINT_MODE_SCULPT) || cache->first_time) {
|
||||
if (paint_supports_dynamic_size(brush, PaintMode::Sculpt) || cache->first_time) {
|
||||
cache->pressure = RNA_float_get(ptr, "pressure");
|
||||
}
|
||||
|
||||
@@ -533,7 +533,7 @@ void update_cache_variants(bContext *C, VPaint *vp, Object *ob, PointerRNA *ptr)
|
||||
BKE_brush_unprojected_radius_set(scene, brush, cache->initial_radius);
|
||||
}
|
||||
|
||||
if (BKE_brush_use_size_pressure(brush) && paint_supports_dynamic_size(brush, PAINT_MODE_SCULPT))
|
||||
if (BKE_brush_use_size_pressure(brush) && paint_supports_dynamic_size(brush, PaintMode::Sculpt))
|
||||
{
|
||||
cache->radius = cache->initial_radius * cache->pressure;
|
||||
}
|
||||
|
||||
@@ -1177,7 +1177,7 @@ static int sculpt_brush_needs_normal(const SculptSession *ss, Sculpt *sd, const
|
||||
|
||||
(mask_tex->brush_map_mode == MTEX_MAP_MODE_AREA)) ||
|
||||
sculpt_brush_use_topology_rake(ss, brush) ||
|
||||
BKE_brush_has_cube_tip(brush, PAINT_MODE_SCULPT);
|
||||
BKE_brush_has_cube_tip(brush, PaintMode::Sculpt);
|
||||
}
|
||||
|
||||
static bool sculpt_brush_needs_rake_rotation(const Brush *brush)
|
||||
@@ -3324,7 +3324,7 @@ static void do_brush_action(Sculpt *sd,
|
||||
float radius_scale = 1.0f;
|
||||
|
||||
/* Corners of square brushes can go outside the brush radius. */
|
||||
if (BKE_brush_has_cube_tip(brush, PAINT_MODE_SCULPT)) {
|
||||
if (BKE_brush_has_cube_tip(brush, PaintMode::Sculpt)) {
|
||||
radius_scale = M_SQRT2;
|
||||
}
|
||||
|
||||
@@ -4628,7 +4628,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, Po
|
||||
* thumb). They depends on initial state and brush coord/pressure/etc.
|
||||
* It's more an events design issue, which doesn't split coordinate/pressure/angle changing
|
||||
* events. We should avoid this after events system re-design. */
|
||||
if (paint_supports_dynamic_size(brush, PAINT_MODE_SCULPT) || cache->first_time) {
|
||||
if (paint_supports_dynamic_size(brush, PaintMode::Sculpt) || cache->first_time) {
|
||||
cache->pressure = RNA_float_get(ptr, "pressure");
|
||||
}
|
||||
|
||||
@@ -4661,7 +4661,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, Po
|
||||
}
|
||||
}
|
||||
|
||||
if (BKE_brush_use_size_pressure(brush) && paint_supports_dynamic_size(brush, PAINT_MODE_SCULPT))
|
||||
if (BKE_brush_use_size_pressure(brush) && paint_supports_dynamic_size(brush, PaintMode::Sculpt))
|
||||
{
|
||||
cache->radius = sculpt_brush_dynamic_size_get(brush, cache, cache->initial_radius);
|
||||
cache->dyntopo_pixel_radius = sculpt_brush_dynamic_size_get(
|
||||
@@ -5401,7 +5401,7 @@ static void sculpt_stroke_undo_begin(const bContext *C, wmOperator *op)
|
||||
if (brush && brush->sculpt_tool == SCULPT_TOOL_PAINT &&
|
||||
SCULPT_use_image_paint_brush(&tool_settings->paint_mode, ob))
|
||||
{
|
||||
ED_image_undo_push_begin(op->type->name, PAINT_MODE_SCULPT);
|
||||
ED_image_undo_push_begin(op->type->name, PaintMode::Sculpt);
|
||||
}
|
||||
else {
|
||||
undo::push_begin_ex(ob, sculpt_tool_name(sd));
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <queue>
|
||||
|
||||
#include "BKE_attribute.hh"
|
||||
#include "BKE_paint.hh"
|
||||
#include "BKE_pbvh_api.hh"
|
||||
|
||||
#include "BLI_array.hh"
|
||||
|
||||
@@ -358,8 +358,8 @@ void ED_object_sculptmode_enter_ex(Main *bmain,
|
||||
BKE_report(reports, RPT_WARNING, "Object has negative scale, sculpting may be unpredictable");
|
||||
}
|
||||
|
||||
Paint *paint = BKE_paint_get_active_from_paintmode(scene, PAINT_MODE_SCULPT);
|
||||
BKE_paint_init(bmain, scene, PAINT_MODE_SCULPT, PAINT_CURSOR_SCULPT);
|
||||
Paint *paint = BKE_paint_get_active_from_paintmode(scene, PaintMode::Sculpt);
|
||||
BKE_paint_init(bmain, scene, PaintMode::Sculpt, PAINT_CURSOR_SCULPT);
|
||||
|
||||
ED_paint_cursor_start(paint, SCULPT_mode_poll_view3d);
|
||||
|
||||
|
||||
@@ -1993,7 +1993,7 @@ static UndoSculpt *get_nodes()
|
||||
|
||||
static bool use_multires_mesh(bContext *C)
|
||||
{
|
||||
if (BKE_paintmode_get_active_from_context(C) != PAINT_MODE_SCULPT) {
|
||||
if (BKE_paintmode_get_active_from_context(C) != PaintMode::Sculpt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -756,7 +756,7 @@ struct ImageUndoStep {
|
||||
PaintTileMap *paint_tile_map;
|
||||
|
||||
bool is_encode_init;
|
||||
ePaintMode paint_mode;
|
||||
PaintMode paint_mode;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -943,8 +943,8 @@ static bool image_undosys_step_encode(bContext *C, Main * /*bmain*/, UndoStep *u
|
||||
else {
|
||||
BLI_assert(C != nullptr);
|
||||
/* Happens when switching modes. */
|
||||
ePaintMode paint_mode = BKE_paintmode_get_active_from_context(C);
|
||||
BLI_assert(ELEM(paint_mode, PAINT_MODE_TEXTURE_2D, PAINT_MODE_TEXTURE_3D));
|
||||
PaintMode paint_mode = BKE_paintmode_get_active_from_context(C);
|
||||
BLI_assert(ELEM(paint_mode, PaintMode::Texture2D, PaintMode::Texture3D));
|
||||
us->paint_mode = paint_mode;
|
||||
}
|
||||
|
||||
@@ -1020,7 +1020,7 @@ static void image_undosys_step_decode(
|
||||
image_undosys_step_decode_redo(us);
|
||||
}
|
||||
|
||||
if (us->paint_mode == PAINT_MODE_TEXTURE_3D) {
|
||||
if (us->paint_mode == PaintMode::Texture3D) {
|
||||
ED_object_mode_set_ex(C, OB_MODE_TEXTURE_PAINT, false, nullptr);
|
||||
}
|
||||
|
||||
@@ -1093,7 +1093,7 @@ PaintTileMap *ED_image_paint_tile_map_get()
|
||||
BLI_assert(us_p == us_prev);
|
||||
if (us_p != us_prev) {
|
||||
/* Fallback value until we can be sure this never happens. */
|
||||
us->paint_mode = PAINT_MODE_TEXTURE_2D;
|
||||
us->paint_mode = PaintMode::Texture2D;
|
||||
}
|
||||
return us->paint_tile_map;
|
||||
}
|
||||
@@ -1105,18 +1105,18 @@ void ED_image_undo_restore(UndoStep *us)
|
||||
ptile_invalidate_map(paint_tile_map);
|
||||
}
|
||||
|
||||
static ImageUndoStep *image_undo_push_begin(const char *name, int paint_mode)
|
||||
static ImageUndoStep *image_undo_push_begin(const char *name, PaintMode paint_mode)
|
||||
{
|
||||
UndoStack *ustack = ED_undo_stack_get();
|
||||
bContext *C = nullptr; /* special case, we never read from this. */
|
||||
UndoStep *us_p = BKE_undosys_step_push_init_with_type(ustack, C, name, BKE_UNDOSYS_TYPE_IMAGE);
|
||||
ImageUndoStep *us = reinterpret_cast<ImageUndoStep *>(us_p);
|
||||
BLI_assert(ELEM(paint_mode, PAINT_MODE_TEXTURE_2D, PAINT_MODE_TEXTURE_3D, PAINT_MODE_SCULPT));
|
||||
us->paint_mode = (ePaintMode)paint_mode;
|
||||
BLI_assert(ELEM(paint_mode, PaintMode::Texture2D, PaintMode::Texture3D, PaintMode::Sculpt));
|
||||
us->paint_mode = (PaintMode)paint_mode;
|
||||
return us;
|
||||
}
|
||||
|
||||
void ED_image_undo_push_begin(const char *name, int paint_mode)
|
||||
void ED_image_undo_push_begin(const char *name, PaintMode paint_mode)
|
||||
{
|
||||
image_undo_push_begin(name, paint_mode);
|
||||
}
|
||||
@@ -1126,7 +1126,7 @@ void ED_image_undo_push_begin_with_image(const char *name,
|
||||
ImBuf *ibuf,
|
||||
ImageUser *iuser)
|
||||
{
|
||||
ImageUndoStep *us = image_undo_push_begin(name, PAINT_MODE_TEXTURE_2D);
|
||||
ImageUndoStep *us = image_undo_push_begin(name, PaintMode::Texture2D);
|
||||
|
||||
BLI_assert(BKE_image_get_tile(image, iuser->tile));
|
||||
UndoImageHandle *uh = uhandle_ensure(&us->handles, image, iuser);
|
||||
|
||||
@@ -896,7 +896,7 @@ static const EnumPropertyItem *rna_Brush_direction_itemf(bContext *C,
|
||||
PropertyRNA * /*prop*/,
|
||||
bool * /*r_free*/)
|
||||
{
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
|
||||
/* sculpt mode */
|
||||
static const EnumPropertyItem prop_flatten_contrast_items[] = {
|
||||
@@ -939,7 +939,7 @@ static const EnumPropertyItem *rna_Brush_direction_itemf(bContext *C,
|
||||
Brush *me = (Brush *)(ptr->data);
|
||||
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PaintMode::Sculpt:
|
||||
switch (me->sculpt_tool) {
|
||||
case SCULPT_TOOL_DRAW:
|
||||
case SCULPT_TOOL_DRAW_SHARP:
|
||||
@@ -982,8 +982,8 @@ static const EnumPropertyItem *rna_Brush_direction_itemf(bContext *C,
|
||||
return rna_enum_dummy_DEFAULT_items;
|
||||
}
|
||||
|
||||
case PAINT_MODE_TEXTURE_2D:
|
||||
case PAINT_MODE_TEXTURE_3D:
|
||||
case PaintMode::Texture2D:
|
||||
case PaintMode::Texture3D:
|
||||
switch (me->imagepaint_tool) {
|
||||
case PAINT_TOOL_SOFTEN:
|
||||
return prop_soften_sharpen_items;
|
||||
@@ -991,7 +991,7 @@ static const EnumPropertyItem *rna_Brush_direction_itemf(bContext *C,
|
||||
default:
|
||||
return rna_enum_dummy_DEFAULT_items;
|
||||
}
|
||||
case PAINT_MODE_SCULPT_CURVES:
|
||||
case PaintMode::SculptCurves:
|
||||
switch (me->curves_sculpt_tool) {
|
||||
case CURVES_SCULPT_TOOL_GROW_SHRINK:
|
||||
case CURVES_SCULPT_TOOL_SELECTION_PAINT:
|
||||
@@ -1010,7 +1010,7 @@ static const EnumPropertyItem *rna_Brush_stroke_itemf(bContext *C,
|
||||
PropertyRNA * /*prop*/,
|
||||
bool * /*r_free*/)
|
||||
{
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
|
||||
static const EnumPropertyItem brush_stroke_method_items[] = {
|
||||
{0, "DOTS", 0, "Dots", "Apply paint on each mouse move step"},
|
||||
@@ -1034,9 +1034,9 @@ static const EnumPropertyItem *rna_Brush_stroke_itemf(bContext *C,
|
||||
};
|
||||
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PAINT_MODE_TEXTURE_2D:
|
||||
case PAINT_MODE_TEXTURE_3D:
|
||||
case PaintMode::Sculpt:
|
||||
case PaintMode::Texture2D:
|
||||
case PaintMode::Texture3D:
|
||||
return sculpt_stroke_method_items;
|
||||
|
||||
default:
|
||||
@@ -1170,8 +1170,8 @@ static const EnumPropertyItem *rna_BrushTextureSlot_map_mode_itemf(bContext *C,
|
||||
# define rna_enum_brush_texture_slot_map_sculpt_mode_items \
|
||||
rna_enum_brush_texture_slot_map_all_mode_items;
|
||||
|
||||
const ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
if (mode == PAINT_MODE_SCULPT) {
|
||||
const PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
if (mode == PaintMode::Sculpt) {
|
||||
return rna_enum_brush_texture_slot_map_sculpt_mode_items;
|
||||
}
|
||||
return rna_enum_brush_texture_slot_map_texture_mode_items;
|
||||
|
||||
@@ -175,8 +175,8 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
|
||||
}
|
||||
}
|
||||
else {
|
||||
const ePaintMode paint_mode = BKE_paintmode_get_from_tool(tref);
|
||||
BLI_assert(paint_mode != PAINT_MODE_INVALID);
|
||||
const PaintMode paint_mode = BKE_paintmode_get_from_tool(tref);
|
||||
BLI_assert(paint_mode != PaintMode::Invalid);
|
||||
const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
|
||||
BLI_assert(items != nullptr);
|
||||
|
||||
@@ -201,7 +201,7 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
|
||||
|
||||
BKE_brush_tool_set(brush, paint, slot_index);
|
||||
|
||||
if (paint_mode == PAINT_MODE_SCULPT) {
|
||||
if (paint_mode == PaintMode::Sculpt) {
|
||||
BKE_brush_sculpt_reset(brush);
|
||||
}
|
||||
}
|
||||
@@ -384,7 +384,7 @@ void WM_toolsystem_ref_sync_from_context(Main *bmain, WorkSpace *workspace, bToo
|
||||
}
|
||||
}
|
||||
else {
|
||||
const ePaintMode paint_mode = BKE_paintmode_get_from_tool(tref);
|
||||
const PaintMode paint_mode = BKE_paintmode_get_from_tool(tref);
|
||||
Paint *paint = BKE_paint_get_active_from_paintmode(scene, paint_mode);
|
||||
const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
|
||||
if (paint && paint->brush && items) {
|
||||
|
||||
Reference in New Issue
Block a user