Brush: split out vertex paint tool & blend mode

- Vertex & weight paint now use the 'blend' setting.
- Weight paint now has it's own tool setting,
  since weight paint doesn't deal with color - we'll likely
  support different tools eventually.
This commit is contained in:
Campbell Barton 2018-11-06 18:06:33 +11:00
parent 900c562b71
commit 80109c976c
18 changed files with 302 additions and 199 deletions

View File

@ -816,7 +816,7 @@ def keymap_from_context(context, space_type):
mode = context.active_object.mode
attr_op, attr_brush = {
'SCULPT': ("sculpt_tool", "sculpt_tool"),
'WEIGHT_PAINT': ("weight_paint_tool", "vertex_tool"),
'WEIGHT_PAINT': ("weight_paint_tool", "weight_tool"),
'VERTEX_PAINT': ("vertex_paint_tool", "vertex_tool"),
'TEXTURE_PAINT': ("texture_paint_tool", "image_tool"),
}.get(mode, (None, None))

View File

@ -1040,7 +1040,7 @@ class _defs_weight_paint:
context,
icon_prefix="brush.paint_weight.",
type=bpy.types.Brush,
attr="vertex_tool",
attr="weight_tool",
)
@ToolDef.from_fn

View File

@ -2107,8 +2107,10 @@ class VIEW3D_MT_brush(Menu):
layout.prop_menu_enum(brush, "sculpt_tool")
elif context.image_paint_object:
layout.prop_menu_enum(brush, "image_tool")
elif context.vertex_paint_object or context.weight_paint_object:
elif context.vertex_paint_object:
layout.prop_menu_enum(brush, "vertex_tool")
elif context.weight_paint_object:
layout.prop_menu_enum(brush, "weight_tool")
# TODO: still missing a lot of brush options here

View File

@ -399,9 +399,9 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
self.prop_unified_strength(row, context, brush, "use_pressure_strength")
col.separator()
col.prop(brush, "vertex_tool", text="Blend")
col.prop(brush, "blend", text="Blend")
if brush.vertex_tool != 'SMEAR':
if brush.weight_tool != 'SMEAR':
col.prop(brush, "use_accumulate")
col.separator()
@ -440,7 +440,7 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
self.prop_unified_strength(row, context, brush, "use_pressure_strength")
col.separator()
col.prop(brush, "vertex_tool", text="Blend")
col.prop(brush, "blend", text="Blend")
col.prop(brush, "use_alpha")
if brush.vertex_tool != 'SMEAR':

View File

@ -81,8 +81,9 @@ typedef enum ePaintMode {
ePaintTextureProjective = 3,
ePaintTexture2D = 4,
ePaintSculptUV = 5,
ePaintInvalid = 6,
ePaintGpencil = 7
ePaintGpencil = 6,
ePaintInvalid = 7,
} ePaintMode;
/* overlay invalidation */
@ -139,6 +140,7 @@ void BKE_paint_cavity_curve_preset(struct Paint *p, int preset);
eObjectMode BKE_paint_object_mode_from_paint_mode(ePaintMode mode);
struct Paint *BKE_paint_get_active_from_paintmode(struct Scene *sce, ePaintMode mode);
const struct EnumPropertyItem *BKE_paint_get_tool_enum_from_paintmode(ePaintMode mode);
uint BKE_paint_get_brush_tool_offset_from_paint_mode(const ePaintMode mode);
struct Paint *BKE_paint_get_active(struct Scene *sce, struct ViewLayer *view_layer);
struct Paint *BKE_paint_get_active_from_context(const struct bContext *C);
ePaintMode BKE_paintmode_get_active_from_context(const struct bContext *C);

View File

@ -182,9 +182,9 @@ const EnumPropertyItem *BKE_paint_get_tool_enum_from_paintmode(ePaintMode mode)
case ePaintVertex:
return rna_enum_brush_vertex_tool_items;
case ePaintWeight:
return rna_enum_brush_vertex_tool_items;
case ePaintTextureProjective:
return rna_enum_brush_weight_tool_items;
case ePaintTexture2D:
case ePaintTextureProjective:
return rna_enum_brush_image_tool_items;
case ePaintSculptUV:
return NULL;
@ -369,7 +369,7 @@ void BKE_paint_runtime_init(const ToolSettings *ts, Paint *paint)
paint->runtime.ob_mode = OB_MODE_VERTEX_PAINT;
}
else if (paint == &ts->wpaint->paint) {
paint->runtime.tool_offset = offsetof(Brush, vertexpaint_tool);
paint->runtime.tool_offset = offsetof(Brush, weightpaint_tool);
paint->runtime.ob_mode = OB_MODE_WEIGHT_PAINT;
}
else if (paint == &ts->gp_paint->paint) {
@ -386,6 +386,26 @@ void BKE_paint_runtime_init(const ToolSettings *ts, Paint *paint)
}
}
uint BKE_paint_get_brush_tool_offset_from_paint_mode(const ePaintMode mode)
{
switch (mode) {
case ePaintTexture2D:
case ePaintTextureProjective:
return offsetof(Brush, imagepaint_tool);
case ePaintSculpt:
return offsetof(Brush, sculpt_tool);
case ePaintVertex:
return offsetof(Brush, vertexpaint_tool);
case ePaintWeight:
return offsetof(Brush, weightpaint_tool);
case ePaintGpencil:
return offsetof(Brush, gpencil_tool);
case ePaintSculptUV:
case ePaintInvalid:
break; /* We don't use these yet. */
}
return 0;
}
/** Free (or release) any data used by this paint curve (does not free the pcurve itself). */
void BKE_paint_curve_free(PaintCurve *pc)
@ -591,9 +611,8 @@ eObjectMode BKE_paint_object_mode_from_paint_mode(ePaintMode mode)
return OB_MODE_VERTEX_PAINT;
case ePaintWeight:
return OB_MODE_WEIGHT_PAINT;
case ePaintTextureProjective:
return OB_MODE_TEXTURE_PAINT;
case ePaintTexture2D:
case ePaintTextureProjective:
return OB_MODE_TEXTURE_PAINT;
case ePaintSculptUV:
return OB_MODE_EDIT;

View File

@ -89,6 +89,9 @@
#include "BKE_key.h"
#include "BKE_unit.h"
/* Only for IMB_BlendMode */
#include "IMB_imbuf.h"
#include "DEG_depsgraph.h"
#include "BLT_translation.h"
@ -2253,6 +2256,106 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
scene->eevee.overscan = 3.0f;
}
}
if (!DNA_struct_elem_find(fd->filesdna, "Brush", "char", "weightpaint_tool")) {
/* Magic defines from old files (2.7x) */
#define PAINT_BLEND_MIX 0
#define PAINT_BLEND_ADD 1
#define PAINT_BLEND_SUB 2
#define PAINT_BLEND_MUL 3
#define PAINT_BLEND_BLUR 4
#define PAINT_BLEND_LIGHTEN 5
#define PAINT_BLEND_DARKEN 6
#define PAINT_BLEND_AVERAGE 7
#define PAINT_BLEND_SMEAR 8
#define PAINT_BLEND_COLORDODGE 9
#define PAINT_BLEND_DIFFERENCE 10
#define PAINT_BLEND_SCREEN 11
#define PAINT_BLEND_HARDLIGHT 12
#define PAINT_BLEND_OVERLAY 13
#define PAINT_BLEND_SOFTLIGHT 14
#define PAINT_BLEND_EXCLUSION 15
#define PAINT_BLEND_LUMINOSITY 16
#define PAINT_BLEND_SATURATION 17
#define PAINT_BLEND_HUE 18
#define PAINT_BLEND_ALPHA_SUB 19
#define PAINT_BLEND_ALPHA_ADD 20
for (Brush *brush = bmain->brush.first; brush; brush = brush->id.next) {
if (brush->ob_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) {
const char tool_init = brush->vertexpaint_tool;
bool is_blend = false;
{
char tool = tool_init;
switch (tool_init) {
case PAINT_BLEND_MIX: tool = VPAINT_TOOL_DRAW; break;
case PAINT_BLEND_BLUR: tool = VPAINT_TOOL_BLUR; break;
case PAINT_BLEND_AVERAGE: tool = VPAINT_TOOL_AVERAGE; break;
case PAINT_BLEND_SMEAR: tool = VPAINT_TOOL_SMEAR; break;
default:
tool = VPAINT_TOOL_DRAW;
is_blend = true;
break;
}
brush->vertexpaint_tool = tool;
}
if (is_blend == false) {
brush->blend = IMB_BLEND_MIX;
}
else {
short blend = IMB_BLEND_MIX;
switch (tool_init) {
case PAINT_BLEND_ADD: blend = IMB_BLEND_ADD; break;
case PAINT_BLEND_SUB: blend = IMB_BLEND_SUB; break;
case PAINT_BLEND_MUL: blend = IMB_BLEND_MUL; break;
case PAINT_BLEND_LIGHTEN: blend = IMB_BLEND_LIGHTEN; break;
case PAINT_BLEND_DARKEN: blend = IMB_BLEND_DARKEN; break;
case PAINT_BLEND_COLORDODGE: blend = IMB_BLEND_COLORDODGE; break;
case PAINT_BLEND_DIFFERENCE: blend = IMB_BLEND_DIFFERENCE; break;
case PAINT_BLEND_SCREEN: blend = IMB_BLEND_SCREEN; break;
case PAINT_BLEND_HARDLIGHT: blend = IMB_BLEND_HARDLIGHT; break;
case PAINT_BLEND_OVERLAY: blend = IMB_BLEND_OVERLAY; break;
case PAINT_BLEND_SOFTLIGHT: blend = IMB_BLEND_SOFTLIGHT; break;
case PAINT_BLEND_EXCLUSION: blend = IMB_BLEND_EXCLUSION; break;
case PAINT_BLEND_LUMINOSITY: blend = IMB_BLEND_LUMINOSITY; break;
case PAINT_BLEND_SATURATION: blend = IMB_BLEND_SATURATION; break;
case PAINT_BLEND_HUE: blend = IMB_BLEND_HUE; break;
case PAINT_BLEND_ALPHA_SUB: blend = IMB_BLEND_ERASE_ALPHA; break;
case PAINT_BLEND_ALPHA_ADD: blend = IMB_BLEND_ADD_ALPHA; break;
}
brush->blend = blend;
}
}
/* For now these match, in the future new items may not. */
brush->weightpaint_tool = brush->vertexpaint_tool;
}
#undef PAINT_BLEND_MIX
#undef PAINT_BLEND_ADD
#undef PAINT_BLEND_SUB
#undef PAINT_BLEND_MUL
#undef PAINT_BLEND_BLUR
#undef PAINT_BLEND_LIGHTEN
#undef PAINT_BLEND_DARKEN
#undef PAINT_BLEND_AVERAGE
#undef PAINT_BLEND_SMEAR
#undef PAINT_BLEND_COLORDODGE
#undef PAINT_BLEND_DIFFERENCE
#undef PAINT_BLEND_SCREEN
#undef PAINT_BLEND_HARDLIGHT
#undef PAINT_BLEND_OVERLAY
#undef PAINT_BLEND_SOFTLIGHT
#undef PAINT_BLEND_EXCLUSION
#undef PAINT_BLEND_LUMINOSITY
#undef PAINT_BLEND_SATURATION
#undef PAINT_BLEND_HUE
#undef PAINT_BLEND_ALPHA_SUB
#undef PAINT_BLEND_ALPHA_ADD
}
}
}

View File

@ -58,6 +58,7 @@
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_paint.h"
#include "BKE_icons.h"
#include "BKE_appdir.h"
#include "BKE_studiolight.h"
@ -1679,7 +1680,7 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = CTX_data_active_object(C);
const EnumPropertyItem *items = NULL;
int tool = PAINT_TOOL_DRAW, mode = 0;
ePaintMode paint_mode = ePaintInvalid;
ScrArea *sa = CTX_wm_area(C);
char space_type = sa->spacetype;
/* When in an unsupported space. */
@ -1692,12 +1693,18 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
* checking various context stuff here */
if ((space_type == SPACE_VIEW3D) && ob) {
if (ob->mode & OB_MODE_SCULPT)
mode = OB_MODE_SCULPT;
else if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT))
mode = OB_MODE_VERTEX_PAINT;
else if (ob->mode & OB_MODE_TEXTURE_PAINT)
mode = OB_MODE_TEXTURE_PAINT;
if (ob->mode & OB_MODE_SCULPT) {
paint_mode = ePaintSculpt;
}
else if (ob->mode & OB_MODE_VERTEX_PAINT) {
paint_mode = ePaintVertex;
}
else if (ob->mode & OB_MODE_WEIGHT_PAINT) {
paint_mode = ePaintWeight;
}
else if (ob->mode & OB_MODE_TEXTURE_PAINT) {
paint_mode = ePaintTextureProjective;
}
}
else if (space_type == SPACE_IMAGE) {
int sima_mode;
@ -1710,7 +1717,7 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
}
if (sima_mode == SI_MODE_PAINT) {
mode = OB_MODE_TEXTURE_PAINT;
paint_mode = ePaintTexture2D;
}
}
@ -1756,21 +1763,17 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
}
return id->icon_id;
}
else if (mode == OB_MODE_SCULPT) {
items = rna_enum_brush_sculpt_tool_items;
tool = br->sculpt_tool;
else if (paint_mode != ePaintInvalid) {
items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
const uint tool_offset = BKE_paint_get_brush_tool_offset_from_paint_mode(paint_mode);
const int tool_type = *(char *)POINTER_OFFSET(br, tool_offset);
if (!items || !RNA_enum_icon_from_value(items, tool_type, &id->icon_id)) {
id->icon_id = 0;
}
}
else if (mode == OB_MODE_VERTEX_PAINT) {
items = rna_enum_brush_vertex_tool_items;
tool = br->vertexpaint_tool;
}
else if (mode == OB_MODE_TEXTURE_PAINT) {
items = rna_enum_brush_image_tool_items;
tool = br->imagepaint_tool;
}
if (!items || !RNA_enum_icon_from_value(items, tool, &id->icon_id))
else {
id->icon_id = 0;
}
}
return id->icon_id;

View File

@ -472,7 +472,7 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is
break;
case CTX_MODE_PAINT_WEIGHT:
tool_attr = "weight_paint_tool";
tool_offset = offsetof(Brush, vertexpaint_tool);
tool_offset = offsetof(Brush, weightpaint_tool);
break;
case CTX_MODE_PAINT_TEXTURE:
tool_attr = "texture_paint_tool";

View File

@ -483,10 +483,9 @@ static int brush_select_exec(bContext *C, wmOperator *op)
RNA_enum_name_from_value(rna_enum_brush_vertex_tool_items, tool, &tool_name);
break;
case OB_MODE_WEIGHT_PAINT:
/* vertexpaint_tool is used for weight paint mode */
tool_offset = offsetof(Brush, vertexpaint_tool);
tool_offset = offsetof(Brush, weightpaint_tool);
tool = RNA_enum_get(op->ptr, "weight_paint_tool");
RNA_enum_name_from_value(rna_enum_brush_vertex_tool_items, tool, &tool_name);
RNA_enum_name_from_value(rna_enum_brush_weight_tool_items, tool, &tool_name);
break;
case OB_MODE_TEXTURE_PAINT:
tool_offset = offsetof(Brush, imagepaint_tool);
@ -567,7 +566,7 @@ static void PAINT_OT_brush_select(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_HIDDEN);
prop = RNA_def_enum(ot->srna, "vertex_paint_tool", rna_enum_brush_vertex_tool_items, 0, "Vertex Paint Tool", "");
RNA_def_property_flag(prop, PROP_HIDDEN);
prop = RNA_def_enum(ot->srna, "weight_paint_tool", rna_enum_brush_vertex_tool_items, 0, "Weight Paint Tool", "");
prop = RNA_def_enum(ot->srna, "weight_paint_tool", rna_enum_brush_weight_tool_items, 0, "Weight Paint Tool", "");
RNA_def_property_flag(prop, PROP_HIDDEN);
prop = RNA_def_enum(ot->srna, "texture_paint_tool", rna_enum_brush_image_tool_items, 0, "Texture Paint Tool", "");
RNA_def_property_flag(prop, PROP_HIDDEN);

View File

@ -76,6 +76,9 @@
#include "ED_screen.h"
#include "ED_view3d.h"
/* For IMB_BlendMode only. */
#include "IMB_imbuf.h"
#include "bmesh.h"
#include "BKE_ccg.h"
@ -153,9 +156,17 @@ static bool vwpaint_use_normal(const VPaint *vp)
((vp->paint.brush->flag & BRUSH_FRONTFACE_FALLOFF) != 0);
}
static bool brush_use_accumulate(const Brush *brush)
static bool brush_use_accumulate_ex(const Brush *brush, const int ob_mode)
{
return (brush->flag & BRUSH_ACCUMULATE) != 0 || brush->vertexpaint_tool == PAINT_BLEND_SMEAR;
return ((brush->flag & BRUSH_ACCUMULATE) != 0 ||
(ob_mode == OB_MODE_VERTEX_PAINT ?
(brush->vertexpaint_tool == VPAINT_TOOL_SMEAR) :
(brush->weightpaint_tool == WPAINT_TOOL_SMEAR)));
}
static bool brush_use_accumulate(const VPaint *vp)
{
return brush_use_accumulate_ex(vp->paint.brush, vp->paint.runtime.ob_mode);
}
static MDeformVert *defweight_prev_init(MDeformVert *dvert_prev, MDeformVert *dvert_curr, int index)
@ -291,16 +302,16 @@ static uint vpaint_blend(
const int brush_alpha_value_i)
{
const Brush *brush = vp->paint.brush;
const int tool = brush->vertexpaint_tool;
const IMB_BlendMode blend = brush->blend;
uint color_blend = ED_vpaint_blend_tool(tool, color_curr, color_paint, alpha_i);
uint color_blend = ED_vpaint_blend_tool(blend, color_curr, color_paint, alpha_i);
/* if no accumulate, clip color adding with colorig & orig alpha */
if (!brush_use_accumulate(brush)) {
if (!brush_use_accumulate(vp)) {
uint color_test, a;
char *cp, *ct, *co;
color_test = ED_vpaint_blend_tool(tool, color_orig, color_paint, brush_alpha_value_i);
color_test = ED_vpaint_blend_tool(blend, color_orig, color_paint, brush_alpha_value_i);
cp = (char *)&color_blend;
ct = (char *)&color_test;
@ -319,7 +330,7 @@ static uint vpaint_blend(
}
if ((brush->flag & BRUSH_LOCK_ALPHA) &&
!ELEM(tool, PAINT_BLEND_ALPHA_SUB, PAINT_BLEND_ALPHA_ADD))
!ELEM(blend, IMB_BLEND_ERASE_ALPHA, IMB_BLEND_ADD_ALPHA))
{
char *cp, *cc;
cp = (char *)&color_blend;
@ -363,24 +374,25 @@ static float wpaint_blend(
const short do_flip)
{
const Brush *brush = wp->paint.brush;
int tool = brush->vertexpaint_tool;
IMB_BlendMode blend = brush->blend;
if (do_flip) {
switch (tool) {
case PAINT_BLEND_MIX:
switch (blend) {
case IMB_BLEND_MIX:
paintval = 1.f - paintval; break;
case PAINT_BLEND_ADD:
tool = PAINT_BLEND_SUB; break;
case PAINT_BLEND_SUB:
tool = PAINT_BLEND_ADD; break;
case PAINT_BLEND_LIGHTEN:
tool = PAINT_BLEND_DARKEN; break;
case PAINT_BLEND_DARKEN:
tool = PAINT_BLEND_LIGHTEN; break;
case IMB_BLEND_ADD:
blend = IMB_BLEND_SUB; break;
case IMB_BLEND_SUB:
blend = IMB_BLEND_ADD; break;
case IMB_BLEND_LIGHTEN:
blend = IMB_BLEND_DARKEN; break;
case IMB_BLEND_DARKEN:
blend = IMB_BLEND_LIGHTEN; break;
default: break;
}
}
weight = ED_wpaint_blend_tool(tool, weight, paintval, alpha);
weight = ED_wpaint_blend_tool(blend, weight, paintval, alpha);
CLAMP(weight, 0.0f, 1.0f);
@ -759,7 +771,7 @@ static void do_weight_paint_vertex_single(
dw_mirr = NULL;
}
if (!brush_use_accumulate(wp->paint.brush)) {
if (!brush_use_accumulate(wp)) {
MDeformVert *dvert_prev = ob->sculpt->mode.wpaint.dvert_prev;
MDeformVert *dv_prev = defweight_prev_init(dvert_prev, me->dvert, index);
if (index_mirr != -1) {
@ -875,7 +887,7 @@ static void do_weight_paint_vertex_multi(
return;
}
if (!brush_use_accumulate(wp->paint.brush)) {
if (!brush_use_accumulate(wp)) {
MDeformVert *dvert_prev = ob->sculpt->mode.wpaint.dvert_prev;
MDeformVert *dv_prev = defweight_prev_init(dvert_prev, me->dvert, index);
if (index_mirr != -1) {
@ -978,15 +990,12 @@ static void vertex_paint_init_session_data(const ToolSettings *ts, Object *ob)
{
/* Create maps */
struct SculptVertexPaintGeomMap *gmap = NULL;
const Brush *brush = NULL;
if (ob->mode == OB_MODE_VERTEX_PAINT) {
gmap = &ob->sculpt->mode.vpaint.gmap;
brush = BKE_paint_brush(&ts->vpaint->paint);
BLI_assert(ob->sculpt->mode_type == OB_MODE_VERTEX_PAINT);
}
else if (ob->mode == OB_MODE_WEIGHT_PAINT) {
gmap = &ob->sculpt->mode.wpaint.gmap;
brush = BKE_paint_brush(&ts->wpaint->paint);
BLI_assert(ob->sculpt->mode_type == OB_MODE_WEIGHT_PAINT);
}
else {
@ -1014,7 +1023,7 @@ static void vertex_paint_init_session_data(const ToolSettings *ts, Object *ob)
/* Create average brush arrays */
if (ob->mode == OB_MODE_VERTEX_PAINT) {
if (!brush_use_accumulate(brush)) {
if (!brush_use_accumulate(ts->vpaint)) {
if (ob->sculpt->mode.vpaint.previous_color == NULL) {
ob->sculpt->mode.vpaint.previous_color =
MEM_callocN(me->totloop * sizeof(uint), __func__);
@ -1025,7 +1034,7 @@ static void vertex_paint_init_session_data(const ToolSettings *ts, Object *ob)
}
}
else if (ob->mode == OB_MODE_WEIGHT_PAINT) {
if (!brush_use_accumulate(brush)) {
if (!brush_use_accumulate(ts->wpaint)) {
if (ob->sculpt->mode.wpaint.alpha_weight == NULL) {
ob->sculpt->mode.wpaint.alpha_weight =
MEM_callocN(me->totvert * sizeof(float), __func__);
@ -1544,7 +1553,7 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo
wpd->mirror.lock = tmpflags;
}
if (ELEM(vp->paint.brush->vertexpaint_tool, PAINT_BLEND_SMEAR, PAINT_BLEND_BLUR)) {
if (ELEM(vp->paint.brush->weightpaint_tool, WPAINT_TOOL_SMEAR, WPAINT_TOOL_BLUR)) {
wpd->precomputed_weight = MEM_mallocN(sizeof(float) * me->totvert, __func__);
}
@ -1612,7 +1621,7 @@ static void do_wpaint_precompute_weight_cb_ex(
static void precompute_weight_values(
bContext *C, Object *ob, Brush *brush, struct WPaintData *wpd, WeightPaintInfo *wpi, Mesh *me)
{
if (wpd->precomputed_weight_ready && !brush_use_accumulate(brush))
if (wpd->precomputed_weight_ready && !brush_use_accumulate_ex(brush, ob->mode))
return;
/* threaded loop over vertices */
@ -2006,8 +2015,8 @@ static void wpaint_paint_leaves(
/* NOTE: current mirroring code cannot be run in parallel */
settings.use_threading = !(me->editflag & ME_EDIT_MIRROR_X);
switch (brush->vertexpaint_tool) {
case PAINT_BLEND_AVERAGE:
switch ((eBrushWeightPaintTool)brush->weightpaint_tool) {
case WPAINT_TOOL_AVERAGE:
calculate_average_weight(&data, nodes, totnode);
BLI_task_parallel_range(
0, totnode,
@ -2015,21 +2024,21 @@ static void wpaint_paint_leaves(
do_wpaint_brush_draw_task_cb_ex,
&settings);
break;
case PAINT_BLEND_SMEAR:
case WPAINT_TOOL_SMEAR:
BLI_task_parallel_range(
0, totnode,
&data,
do_wpaint_brush_smear_task_cb_ex,
&settings);
break;
case PAINT_BLEND_BLUR:
case WPAINT_TOOL_BLUR:
BLI_task_parallel_range(
0, totnode,
&data,
do_wpaint_brush_blur_task_cb_ex,
&settings);
break;
default:
case WPAINT_TOOL_DRAW:
BLI_task_parallel_range(
0, totnode,
&data,
@ -2512,7 +2521,7 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f
vpd->paintcol = vpaint_get_current_col(scene, vp, (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_INVERT));
vpd->is_texbrush = !(brush->vertexpaint_tool == PAINT_BLEND_BLUR) && brush->mtex.tex;
vpd->is_texbrush = !(brush->vertexpaint_tool == VPAINT_TOOL_BLUR) && brush->mtex.tex;
/* are we painting onto a modified mesh?,
* if not we can skip face map trickiness */
@ -2526,11 +2535,11 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f
}
/* to keep tracked of modified loops for shared vertex color blending */
if (brush->vertexpaint_tool == PAINT_BLEND_BLUR) {
if (brush->vertexpaint_tool == VPAINT_TOOL_BLUR) {
vpd->mlooptag = MEM_mallocN(sizeof(bool) * me->totloop, "VPaintData mlooptag");
}
if (brush->vertexpaint_tool == PAINT_BLEND_SMEAR) {
if (brush->vertexpaint_tool == VPAINT_TOOL_SMEAR) {
vpd->smear.color_prev = MEM_mallocN(sizeof(uint) * me->totloop, __func__);
memcpy(vpd->smear.color_prev, me->mloopcol, sizeof(uint) * me->totloop);
vpd->smear.color_curr = MEM_dupallocN(vpd->smear.color_prev);
@ -3009,8 +3018,8 @@ static void vpaint_paint_leaves(
};
ParallelRangeSettings settings;
BLI_parallel_range_settings_defaults(&settings);
switch (brush->vertexpaint_tool) {
case PAINT_BLEND_AVERAGE:
switch ((eBrushVertexPaintTool)brush->vertexpaint_tool) {
case VPAINT_TOOL_AVERAGE:
calculate_average_color(&data, nodes, totnode);
BLI_task_parallel_range(
0, totnode,
@ -3018,21 +3027,21 @@ static void vpaint_paint_leaves(
do_vpaint_brush_draw_task_cb_ex,
&settings);
break;
case PAINT_BLEND_BLUR:
case VPAINT_TOOL_BLUR:
BLI_task_parallel_range(
0, totnode,
&data,
do_vpaint_brush_blur_task_cb_ex,
&settings);
break;
case PAINT_BLEND_SMEAR:
case VPAINT_TOOL_SMEAR:
BLI_task_parallel_range(
0, totnode,
&data,
do_vpaint_brush_smear_task_cb_ex,
&settings);
break;
default:
case VPAINT_TOOL_DRAW:
BLI_task_parallel_range(
0, totnode,
&data,
@ -3144,7 +3153,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
BKE_mesh_batch_cache_dirty_tag(ob->data, BKE_MESH_BATCH_DIRTY_ALL);
if (vp->paint.brush->vertexpaint_tool == PAINT_BLEND_SMEAR) {
if (vp->paint.brush->vertexpaint_tool == PAINT_TOOL_SMEAR) {
memcpy(vpd->smear.color_prev, vpd->smear.color_curr, sizeof(uint) * ((Mesh *)ob->data)->totloop);
}

View File

@ -36,6 +36,7 @@
#include "BLI_math_color.h"
#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
#include "BKE_context.h"
#include "BKE_mesh.h"
@ -617,29 +618,26 @@ uint ED_vpaint_blend_tool(
const int tool, const uint col,
const uint paintcol, const int alpha_i)
{
switch (tool) {
case PAINT_BLEND_MIX:
case PAINT_BLEND_BLUR: return mcol_blend(col, paintcol, alpha_i);
case PAINT_BLEND_AVERAGE: return mcol_blend(col, paintcol, alpha_i);
case PAINT_BLEND_SMEAR: return mcol_blend(col, paintcol, alpha_i);
case PAINT_BLEND_ADD: return mcol_add(col, paintcol, alpha_i);
case PAINT_BLEND_SUB: return mcol_sub(col, paintcol, alpha_i);
case PAINT_BLEND_MUL: return mcol_mul(col, paintcol, alpha_i);
case PAINT_BLEND_LIGHTEN: return mcol_lighten(col, paintcol, alpha_i);
case PAINT_BLEND_DARKEN: return mcol_darken(col, paintcol, alpha_i);
case PAINT_BLEND_COLORDODGE: return mcol_colordodge(col, paintcol, alpha_i);
case PAINT_BLEND_DIFFERENCE: return mcol_difference(col, paintcol, alpha_i);
case PAINT_BLEND_SCREEN: return mcol_screen(col, paintcol, alpha_i);
case PAINT_BLEND_HARDLIGHT: return mcol_hardlight(col, paintcol, alpha_i);
case PAINT_BLEND_OVERLAY: return mcol_overlay(col, paintcol, alpha_i);
case PAINT_BLEND_SOFTLIGHT: return mcol_softlight(col, paintcol, alpha_i);
case PAINT_BLEND_EXCLUSION: return mcol_exclusion(col, paintcol, alpha_i);
case PAINT_BLEND_LUMINOCITY: return mcol_luminosity(col, paintcol, alpha_i);
case PAINT_BLEND_SATURATION: return mcol_saturation(col, paintcol, alpha_i);
case PAINT_BLEND_HUE: return mcol_hue(col, paintcol, alpha_i);
switch ((IMB_BlendMode)tool) {
case IMB_BLEND_MIX: return mcol_blend(col, paintcol, alpha_i);
case IMB_BLEND_ADD: return mcol_add(col, paintcol, alpha_i);
case IMB_BLEND_SUB: return mcol_sub(col, paintcol, alpha_i);
case IMB_BLEND_MUL: return mcol_mul(col, paintcol, alpha_i);
case IMB_BLEND_LIGHTEN: return mcol_lighten(col, paintcol, alpha_i);
case IMB_BLEND_DARKEN: return mcol_darken(col, paintcol, alpha_i);
case IMB_BLEND_COLORDODGE: return mcol_colordodge(col, paintcol, alpha_i);
case IMB_BLEND_DIFFERENCE: return mcol_difference(col, paintcol, alpha_i);
case IMB_BLEND_SCREEN: return mcol_screen(col, paintcol, alpha_i);
case IMB_BLEND_HARDLIGHT: return mcol_hardlight(col, paintcol, alpha_i);
case IMB_BLEND_OVERLAY: return mcol_overlay(col, paintcol, alpha_i);
case IMB_BLEND_SOFTLIGHT: return mcol_softlight(col, paintcol, alpha_i);
case IMB_BLEND_EXCLUSION: return mcol_exclusion(col, paintcol, alpha_i);
case IMB_BLEND_LUMINOSITY: return mcol_luminosity(col, paintcol, alpha_i);
case IMB_BLEND_SATURATION: return mcol_saturation(col, paintcol, alpha_i);
case IMB_BLEND_HUE: return mcol_hue(col, paintcol, alpha_i);
/* non-color */
case PAINT_BLEND_ALPHA_SUB: return mcol_alpha_sub(col, alpha_i);
case PAINT_BLEND_ALPHA_ADD: return mcol_alpha_add(col, alpha_i);
case IMB_BLEND_ERASE_ALPHA: return mcol_alpha_sub(col, alpha_i);
case IMB_BLEND_ADD_ALPHA: return mcol_alpha_add(col, alpha_i);
default:
BLI_assert(0);
return 0;

View File

@ -591,7 +591,7 @@ static void gradientVert_update(WPGradient_userData *grad_data, int index)
MDeformVert *dv = &me->dvert[index];
MDeformWeight *dw = defvert_verify_index(dv, grad_data->def_nr);
// dw->weight = alpha; // testing
int tool = grad_data->brush->vertexpaint_tool;
int tool = grad_data->brush->blend;
float testw;
/* init if we just added */

View File

@ -45,6 +45,9 @@
#include "BKE_report.h"
#include "BKE_object.h"
/* Only for blend modes. */
#include "IMB_imbuf.h"
#include "WM_api.h"
#include "WM_types.h"
@ -280,31 +283,24 @@ float ED_wpaint_blend_tool(
const float weight,
const float paintval, const float alpha)
{
switch (tool) {
case PAINT_BLEND_MIX:
case PAINT_BLEND_AVERAGE:
case PAINT_BLEND_SMEAR:
case PAINT_BLEND_BLUR: return wval_blend(weight, paintval, alpha);
case PAINT_BLEND_ADD: return wval_add(weight, paintval, alpha);
case PAINT_BLEND_SUB: return wval_sub(weight, paintval, alpha);
case PAINT_BLEND_MUL: return wval_mul(weight, paintval, alpha);
case PAINT_BLEND_LIGHTEN: return wval_lighten(weight, paintval, alpha);
case PAINT_BLEND_DARKEN: return wval_darken(weight, paintval, alpha);
switch ((IMB_BlendMode)tool) {
case IMB_BLEND_MIX: return wval_blend(weight, paintval, alpha);
case IMB_BLEND_ADD: return wval_add(weight, paintval, alpha);
case IMB_BLEND_SUB: return wval_sub(weight, paintval, alpha);
case IMB_BLEND_MUL: return wval_mul(weight, paintval, alpha);
case IMB_BLEND_LIGHTEN: return wval_lighten(weight, paintval, alpha);
case IMB_BLEND_DARKEN: return wval_darken(weight, paintval, alpha);
/* Mostly make sense for color: support anyway. */
case PAINT_BLEND_COLORDODGE: return wval_colordodge(weight, paintval, alpha);
case PAINT_BLEND_DIFFERENCE: return wval_difference(weight, paintval, alpha);
case PAINT_BLEND_SCREEN: return wval_screen(weight, paintval, alpha);
case PAINT_BLEND_HARDLIGHT: return wval_hardlight(weight, paintval, alpha);
case PAINT_BLEND_OVERLAY: return wval_overlay(weight, paintval, alpha);
case PAINT_BLEND_SOFTLIGHT: return wval_softlight(weight, paintval, alpha);
case PAINT_BLEND_EXCLUSION: return wval_exclusion(weight, paintval, alpha);
case IMB_BLEND_COLORDODGE: return wval_colordodge(weight, paintval, alpha);
case IMB_BLEND_DIFFERENCE: return wval_difference(weight, paintval, alpha);
case IMB_BLEND_SCREEN: return wval_screen(weight, paintval, alpha);
case IMB_BLEND_HARDLIGHT: return wval_hardlight(weight, paintval, alpha);
case IMB_BLEND_OVERLAY: return wval_overlay(weight, paintval, alpha);
case IMB_BLEND_SOFTLIGHT: return wval_softlight(weight, paintval, alpha);
case IMB_BLEND_EXCLUSION: return wval_exclusion(weight, paintval, alpha);
/* Only for color: just use blend. */
case PAINT_BLEND_LUMINOCITY:
case PAINT_BLEND_SATURATION:
case PAINT_BLEND_HUE:
case PAINT_BLEND_ALPHA_SUB:
case PAINT_BLEND_ALPHA_ADD:
default: return wval_blend(weight, paintval, alpha);
default:
return wval_blend(weight, paintval, alpha);
}
}

View File

@ -205,11 +205,12 @@ typedef struct Brush {
float falloff_angle;
char sculpt_tool; /* active sculpt tool */
char vertexpaint_tool; /* active vertex/weight paint blend mode (poorly named) */
char vertexpaint_tool; /* active vertex paint */
char weightpaint_tool; /* active weight paint */
char imagepaint_tool; /* active image paint tool */
char mask_tool; /* enum eBrushMaskTool, only used if sculpt_tool is SCULPT_TOOL_MASK */
char gpencil_tool; /* Active grease pencil tool. */
char _pad0[7];
char _pad0[6];
float autosmooth_factor;
@ -410,6 +411,19 @@ typedef enum eBrushImagePaintTool {
PAINT_TOOL_MASK = 5
} eBrushImagePaintTool;
typedef enum eBrushVertexPaintTool {
VPAINT_TOOL_DRAW = 0,
VPAINT_TOOL_BLUR = 1,
VPAINT_TOOL_AVERAGE = 2,
VPAINT_TOOL_SMEAR = 3,
} eBrushVertexPaintTool;
typedef enum eBrushWeightPaintTool {
WPAINT_TOOL_DRAW = 0,
WPAINT_TOOL_BLUR = 1,
WPAINT_TOOL_AVERAGE = 2,
WPAINT_TOOL_SMEAR = 3,
} eBrushWeightPaintTool;
/* BrushGpencilSettings->brush type */
typedef enum eBrushGPaintTool {
@ -428,30 +442,6 @@ enum {
SCULPT_DISP_DIR_Z = 4
};
enum {
PAINT_BLEND_MIX = 0,
PAINT_BLEND_ADD = 1,
PAINT_BLEND_SUB = 2,
PAINT_BLEND_MUL = 3,
PAINT_BLEND_BLUR = 4,
PAINT_BLEND_LIGHTEN = 5,
PAINT_BLEND_DARKEN = 6,
PAINT_BLEND_AVERAGE = 7,
PAINT_BLEND_SMEAR = 8,
PAINT_BLEND_COLORDODGE = 9,
PAINT_BLEND_DIFFERENCE = 10,
PAINT_BLEND_SCREEN = 11,
PAINT_BLEND_HARDLIGHT = 12,
PAINT_BLEND_OVERLAY = 13,
PAINT_BLEND_SOFTLIGHT = 14,
PAINT_BLEND_EXCLUSION = 15,
PAINT_BLEND_LUMINOCITY = 16,
PAINT_BLEND_SATURATION = 17,
PAINT_BLEND_HUE = 18,
PAINT_BLEND_ALPHA_SUB = 19,
PAINT_BLEND_ALPHA_ADD = 20,
};
typedef enum {
BRUSH_MASK_DRAW = 0,
BRUSH_MASK_SMOOTH = 1

View File

@ -120,6 +120,7 @@ extern const EnumPropertyItem rna_enum_operator_property_tags[];
extern const EnumPropertyItem rna_enum_brush_sculpt_tool_items[];
extern const EnumPropertyItem rna_enum_brush_vertex_tool_items[];
extern const EnumPropertyItem rna_enum_brush_weight_tool_items[];
extern const EnumPropertyItem rna_enum_brush_gpencil_types_items[];
extern const EnumPropertyItem rna_enum_brush_image_tool_items[];

View File

@ -87,30 +87,19 @@ const EnumPropertyItem rna_enum_brush_sculpt_tool_items[] = {
{0, NULL, 0, NULL, NULL}
};
const EnumPropertyItem rna_enum_brush_vertex_tool_items[] = {
{PAINT_BLEND_MIX, "MIX", ICON_BRUSH_MIX, "Mix", "Use mix blending mode while painting"},
{PAINT_BLEND_ADD, "ADD", ICON_BRUSH_ADD, "Add", "Use add blending mode while painting"},
{PAINT_BLEND_SUB, "SUB", ICON_BRUSH_SUBTRACT, "Subtract", "Use subtract blending mode while painting"},
{PAINT_BLEND_MUL, "MUL", ICON_BRUSH_MULTIPLY, "Multiply", "Use multiply blending mode while painting"},
{PAINT_BLEND_BLUR, "BLUR", ICON_BRUSH_BLUR, "Blur", "Blur the color with surrounding values"},
{PAINT_BLEND_LIGHTEN, "LIGHTEN", ICON_BRUSH_LIGHTEN, "Lighten", "Use lighten blending mode while painting"},
{PAINT_BLEND_DARKEN, "DARKEN", ICON_BRUSH_DARKEN, "Darken", "Use darken blending mode while painting"},
{PAINT_BLEND_AVERAGE, "AVERAGE", ICON_BRUSH_BLUR, "Average", "Use average blending mode while painting"},
{PAINT_BLEND_SMEAR, "SMEAR", ICON_BRUSH_BLUR, "Smear", "Use smear blending mode while painting"},
{PAINT_BLEND_COLORDODGE, "COLORDODGE", ICON_BRUSH_BLUR, "Color Dodge", "Use color dodge blending mode while painting" },
{PAINT_BLEND_DIFFERENCE, "DIFFERENCE", ICON_BRUSH_BLUR, "Difference", "Use difference blending mode while painting"},
{PAINT_BLEND_SCREEN, "SCREEN", ICON_BRUSH_BLUR, "Screen", "Use screen blending mode while painting"},
{PAINT_BLEND_HARDLIGHT, "HARDLIGHT", ICON_BRUSH_BLUR, "Hardlight", "Use hardlight blending mode while painting"},
{PAINT_BLEND_OVERLAY, "OVERLAY", ICON_BRUSH_BLUR, "Overlay", "Use overlay blending mode while painting"},
{PAINT_BLEND_SOFTLIGHT, "SOFTLIGHT", ICON_BRUSH_BLUR, "Softlight", "Use softlight blending mode while painting"},
{PAINT_BLEND_EXCLUSION, "EXCLUSION", ICON_BRUSH_BLUR, "Exclusion", "Use exclusion blending mode while painting"},
{PAINT_BLEND_LUMINOCITY, "LUMINOCITY", ICON_BRUSH_BLUR, "Luminocity", "Use luminocity blending mode while painting"},
{PAINT_BLEND_SATURATION, "SATURATION", ICON_BRUSH_BLUR, "Saturation", "Use saturation blending mode while painting"},
{PAINT_BLEND_HUE, "HUE", ICON_BRUSH_BLUR, "Hue", "Use hue blending mode while painting"},
{PAINT_BLEND_ALPHA_SUB, "ERASE_ALPHA", 0, "Erase Alpha", "Erase alpha while painting"},
{PAINT_BLEND_ALPHA_ADD, "ADD_ALPHA", 0, "Add Alpha", "Add alpha while painting"},
{VPAINT_TOOL_DRAW, "DRAW", ICON_BRUSH_MIX, "Draw", ""},
{VPAINT_TOOL_BLUR, "BLUR", ICON_BRUSH_BLUR, "Blur", ""},
{VPAINT_TOOL_AVERAGE, "AVERAGE", ICON_BRUSH_BLUR, "Average", ""},
{VPAINT_TOOL_SMEAR, "SMEAR", ICON_BRUSH_BLUR, "Smear", ""},
{0, NULL, 0, NULL, NULL}
};
const EnumPropertyItem rna_enum_brush_weight_tool_items[] = {
{WPAINT_TOOL_DRAW, "DRAW", ICON_BRUSH_MIX, "Draw", ""},
{WPAINT_TOOL_BLUR, "BLUR", ICON_BRUSH_BLUR, "Blur", ""},
{WPAINT_TOOL_AVERAGE, "AVERAGE", ICON_BRUSH_BLUR, "Average", ""},
{WPAINT_TOOL_SMEAR, "SMEAR", ICON_BRUSH_BLUR, "Smear", ""},
{0, NULL, 0, NULL, NULL}
};
@ -390,7 +379,7 @@ static PointerRNA rna_Brush_capabilities_get(PointerRNA *ptr)
return rna_pointer_inherit_refine(ptr, &RNA_BrushCapabilities, ptr->id.data);
}
static void rna_Brush_reset_icon(Brush *br, const char *UNUSED(type))
static void rna_Brush_reset_icon(Brush *br)
{
ID *id = &br->id;
@ -463,24 +452,10 @@ static void rna_Brush_size_update(Main *bmain, Scene *scene, PointerRNA *ptr)
rna_Brush_update(bmain, scene, ptr);
}
static void rna_Brush_sculpt_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr)
static void rna_Brush_update_and_reset_icon(Main *bmain, Scene *scene, PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
rna_Brush_reset_icon(br, "sculpt");
rna_Brush_update(bmain, scene, ptr);
}
static void rna_Brush_vertex_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
rna_Brush_reset_icon(br, "vertex_paint");
rna_Brush_update(bmain, scene, ptr);
}
static void rna_Brush_imagepaint_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
rna_Brush_reset_icon(br, "image_paint");
Brush *br = ptr->data;
rna_Brush_reset_icon(br);
rna_Brush_update(bmain, scene, ptr);
}
@ -1344,19 +1319,25 @@ static void rna_def_brush(BlenderRNA *brna)
prop = RNA_def_property(srna, "sculpt_tool", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, rna_enum_brush_sculpt_tool_items);
RNA_def_property_ui_text(prop, "Sculpt Tool", "");
RNA_def_property_update(prop, 0, "rna_Brush_sculpt_tool_update");
RNA_def_property_update(prop, 0, "rna_Brush_update_and_reset_icon");
prop = RNA_def_property(srna, "vertex_tool", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "vertexpaint_tool");
RNA_def_property_enum_items(prop, rna_enum_brush_vertex_tool_items);
RNA_def_property_ui_text(prop, "Blending mode", "Brush blending mode");
RNA_def_property_update(prop, 0, "rna_Brush_vertex_tool_update");
RNA_def_property_ui_text(prop, "Vertex Paint Tool", "");
RNA_def_property_update(prop, 0, "rna_Brush_update_and_reset_icon");
prop = RNA_def_property(srna, "weight_tool", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "weightpaint_tool");
RNA_def_property_enum_items(prop, rna_enum_brush_weight_tool_items);
RNA_def_property_ui_text(prop, "Weight Paint Tool", "");
RNA_def_property_update(prop, 0, "rna_Brush_update_and_reset_icon");
prop = RNA_def_property(srna, "image_tool", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "imagepaint_tool");
RNA_def_property_enum_items(prop, rna_enum_brush_image_tool_items);
RNA_def_property_ui_text(prop, "Image Paint Tool", "");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_Brush_imagepaint_tool_update");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_Brush_update_and_reset_icon");
prop = RNA_def_property(srna, "gpencil_tool", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "gpencil_tool");

View File

@ -333,7 +333,7 @@ static bool rna_Brush_mode_with_tool_poll(PointerRNA *ptr, PointerRNA value)
mode = OB_MODE_VERTEX_PAINT;
}
else if (paint_contains_brush_slot(&ts->wpaint->paint, tslot, &slot_index)) {
if (slot_index != brush->vertexpaint_tool) {
if (slot_index != brush->weightpaint_tool) {
return false;
}
mode = OB_MODE_WEIGHT_PAINT;
@ -453,7 +453,7 @@ static void rna_ImaPaint_viewport_update(Main *UNUSED(bmain), Scene *UNUSED(scen
static void rna_ImaPaint_mode_update(bContext *C, PointerRNA *UNUSED(ptr))
{
Scene *scene = CTX_data_scene(C);\
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);