Object Mode: use eval_ctx for paint & object

This commit is contained in:
2018-02-06 17:53:19 +11:00
parent 906ed54d28
commit 2a184f3d2b
19 changed files with 150 additions and 62 deletions

View File

@@ -506,13 +506,16 @@ static int layers_poll(bContext *C)
static int mesh_uv_texture_add_exec(bContext *C, wmOperator *UNUSED(op))
{
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_context(C);
Mesh *me = ob->data;
if (ED_mesh_uv_texture_add(me, NULL, true) == -1)
return OPERATOR_CANCELLED;
if (ob->mode & OB_MODE_TEXTURE_PAINT) {
if (eval_ctx.object_mode & OB_MODE_TEXTURE_PAINT) {
Scene *scene = CTX_data_scene(C);
BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
@@ -622,13 +625,16 @@ void MESH_OT_drop_named_image(wmOperatorType *ot)
static int mesh_uv_texture_remove_exec(bContext *C, wmOperator *UNUSED(op))
{
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_context(C);
Mesh *me = ob->data;
if (!ED_mesh_uv_texture_remove_active(me))
return OPERATOR_CANCELLED;
if (ob->mode & OB_MODE_TEXTURE_PAINT) {
if (eval_ctx.object_mode & OB_MODE_TEXTURE_PAINT) {
Scene *scene = CTX_data_scene(C);
BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
@@ -742,13 +748,16 @@ static int mesh_customdata_mask_clear_poll(bContext *C)
{
Object *ob = ED_object_context(C);
if (ob && ob->type == OB_MESH) {
Mesh *me = ob->data;
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
/* special case - can't run this if we're in sculpt mode */
if (ob->mode & OB_MODE_SCULPT) {
if (eval_ctx.object_mode & OB_MODE_SCULPT) {
return false;
}
Mesh *me = ob->data;
if (!ID_IS_LINKED(me)) {
CustomData *data = GET_CD_DATA(me, vdata);
if (CustomData_has_layer(data, CD_PAINT_MASK)) {

View File

@@ -662,8 +662,10 @@ void MESH_OT_navmesh_face_add(struct wmOperatorType *ot)
static int navmesh_obmode_data_poll(bContext *C)
{
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_active_context(C);
if (ob && (ob->mode == OB_MODE_OBJECT) && (ob->type == OB_MESH)) {
if (ob && (eval_ctx.object_mode == OB_MODE_OBJECT) && (ob->type == OB_MESH)) {
Mesh *me = ob->data;
return CustomData_has_layer(&me->pdata, CD_RECAST);
}
@@ -672,8 +674,10 @@ static int navmesh_obmode_data_poll(bContext *C)
static int navmesh_obmode_poll(bContext *C)
{
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_active_context(C);
if (ob && (ob->mode == OB_MODE_OBJECT) && (ob->type == OB_MESH)) {
if (ob && (eval_ctx.object_mode == OB_MODE_OBJECT) && (ob->type == OB_MESH)) {
return true;
}
return false;

View File

@@ -1340,17 +1340,17 @@ bool ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int
MDeformVert *ED_mesh_active_dvert_get_em(Object *ob, BMVert **r_eve)
{
if (ob->mode & OB_MODE_EDIT && ob->type == OB_MESH && ob->defbase.first) {
if (ob->type == OB_MESH && ob->defbase.first) {
Mesh *me = ob->data;
BMesh *bm = me->edit_btmesh->bm;
const int cd_dvert_offset = CustomData_get_offset(&bm->vdata, CD_MDEFORMVERT);
if (cd_dvert_offset != -1) {
BMVert *eve = BM_mesh_active_vert_get(bm);
if (eve) {
if (r_eve) *r_eve = eve;
return BM_ELEM_CD_GET_VOID_P(eve, cd_dvert_offset);
if (me->edit_btmesh != NULL) {
BMesh *bm = me->edit_btmesh->bm;
const int cd_dvert_offset = CustomData_get_offset(&bm->vdata, CD_MDEFORMVERT);
if (cd_dvert_offset != -1) {
BMVert *eve = BM_mesh_active_vert_get(bm);
if (eve) {
if (r_eve) *r_eve = eve;
return BM_ELEM_CD_GET_VOID_P(eve, cd_dvert_offset);
}
}
}
}
@@ -1375,7 +1375,8 @@ MDeformVert *ED_mesh_active_dvert_get_ob(Object *ob, int *r_index)
MDeformVert *ED_mesh_active_dvert_get_only(Object *ob)
{
if (ob->type == OB_MESH) {
if (ob->mode & OB_MODE_EDIT) {
Mesh *me = ob->data;
if (me->edit_btmesh != NULL) {
return ED_mesh_active_dvert_get_em(ob, NULL);
}
else {

View File

@@ -623,8 +623,9 @@ static size_t initialize_internal_images(BakeImages *bake_images, ReportList *re
/* create new mesh with edit mode changes and modifiers applied */
static Mesh *bake_mesh_new_from_object(EvaluationContext *eval_ctx, Main *bmain, Scene *scene, Object *ob)
{
if (ob->mode & OB_MODE_EDIT)
if (eval_ctx->object_mode & OB_MODE_EDIT) {
ED_object_editmode_load(ob);
}
Mesh *me = BKE_mesh_new_from_object(eval_ctx, bmain, scene, ob, 1, 2, 0, 0);
if (me->flag & ME_AUTOSMOOTH) {

View File

@@ -173,7 +173,14 @@ static int face_map_supported_edit_mode_poll(bContext *C)
{
Object *ob = ED_object_context(C);
ID *data = (ob) ? ob->data : NULL;
return (ob && !ob->id.lib && ob->type == OB_MESH && data && !data->lib && ob->mode == OB_MODE_EDIT);
if (ob && !ob->id.lib && ob->type == OB_MESH && data && !data->lib) {
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
if (eval_ctx.object_mode == OB_MODE_EDIT) {
return true;
}
}
return false;
}
static int face_map_add_exec(bContext *C, wmOperator *UNUSED(op))

View File

@@ -677,6 +677,8 @@ static int modifier_apply_obdata(ReportList *reports, const bContext *C, Scene *
int ED_object_modifier_apply(ReportList *reports, const bContext *C, Scene *scene, Object *ob, ModifierData *md, int mode)
{
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
int prev_mode;
if (scene->obedit) {
@@ -687,7 +689,7 @@ int ED_object_modifier_apply(ReportList *reports, const bContext *C, Scene *scen
BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied to multi-user data");
return 0;
}
else if ((ob->mode & OB_MODE_SCULPT) &&
else if ((eval_ctx.object_mode & OB_MODE_SCULPT) &&
(find_multires_modifier_before(scene, md)) &&
(modifier_isSameTopology(md) == false))
{
@@ -881,11 +883,13 @@ ModifierData *edit_modifier_property_get(wmOperator *op, Object *ob, int type)
static int modifier_remove_exec(bContext *C, wmOperator *op)
{
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
Main *bmain = CTX_data_main(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = ED_object_active_context(C);
ModifierData *md = edit_modifier_property_get(op, ob, 0);
int mode_orig = ob->mode;
int mode_orig = eval_ctx.object_mode;
if (!md || !ED_object_modifier_remove(op->reports, bmain, ob, md))
return OPERATOR_CANCELLED;
@@ -893,11 +897,13 @@ static int modifier_remove_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
/* if cloth/softbody was removed, particle mode could be cleared */
if (mode_orig & OB_MODE_PARTICLE_EDIT)
if ((ob->mode & OB_MODE_PARTICLE_EDIT) == 0)
if (view_layer->basact && view_layer->basact->object == ob)
if (mode_orig & OB_MODE_PARTICLE_EDIT) {
if ((eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT) == 0) {
if (view_layer->basact && view_layer->basact->object == ob) {
WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL);
}
}
}
return OPERATOR_FINISHED;
}

View File

@@ -47,6 +47,8 @@
#include "ED_screen.h"
#include "ED_object.h"
#include "DEG_depsgraph.h"
#include "object_intern.h"
@@ -290,8 +292,11 @@ void ED_operatormacros_object(void)
static int object_mode_poll(bContext *C)
{
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = CTX_data_active_object(C);
return (!ob || ob->mode == OB_MODE_OBJECT);
return (!ob || eval_ctx.object_mode == OB_MODE_OBJECT);
}
void ED_keymap_object(wmKeyConfig *keyconf)

View File

@@ -64,6 +64,8 @@
#include "BKE_library.h"
#include "BKE_deform.h"
#include "DEG_depsgraph.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -138,13 +140,14 @@ static int objects_selectable_poll(bContext *C)
{
/* we don't check for linked scenes here, selection is
* still allowed then for inspection of scene */
Object *obact = CTX_data_active_object(C);
if (CTX_data_edit_object(C))
if (CTX_data_edit_object(C)) {
return 0;
if (obact && obact->mode)
}
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
if (eval_ctx.object_mode) {
return 0;
}
return 1;
}

View File

@@ -225,18 +225,22 @@ static bool object_shape_key_mirror(bContext *C, Object *ob,
static int shape_key_mode_poll(bContext *C)
{
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_context(C);
ID *data = (ob) ? ob->data : NULL;
return (ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data) && ob->mode != OB_MODE_EDIT);
return (ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data) && (eval_ctx.object_mode != OB_MODE_EDIT));
}
static int shape_key_mode_exists_poll(bContext *C)
{
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_context(C);
ID *data = (ob) ? ob->data : NULL;
/* same as shape_key_mode_poll */
return (ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data) && ob->mode != OB_MODE_EDIT) &&
return (ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data) && (eval_ctx.object_mode != OB_MODE_EDIT)) &&
/* check a keyblock exists */
(BKE_keyblock_from_object(ob) != NULL);
}
@@ -244,12 +248,14 @@ static int shape_key_mode_exists_poll(bContext *C)
static int shape_key_move_poll(bContext *C)
{
/* Same as shape_key_mode_exists_poll above, but ensure we have at least two shapes! */
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_context(C);
ID *data = (ob) ? ob->data : NULL;
Key *key = BKE_key_from_object(ob);
return (ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data) &&
ob->mode != OB_MODE_EDIT && key && key->totkey > 1);
(eval_ctx.object_mode != OB_MODE_EDIT) && key && key->totkey > 1);
}
static int shape_key_poll(bContext *C)

View File

@@ -245,6 +245,9 @@ static int object_clear_transform_generic_exec(bContext *C, wmOperator *op,
void (*clear_func)(Object *, const bool),
const char default_ksName[])
{
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
Scene *scene = CTX_data_scene(C);
KeyingSet *ks;
const bool clear_delta = RNA_boolean_get(op->ptr, "clear_delta");
@@ -263,7 +266,7 @@ static int object_clear_transform_generic_exec(bContext *C, wmOperator *op,
*/
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
{
if (!(ob->mode & OB_MODE_WEIGHT_PAINT)) {
if (!(eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT)) {
/* run provided clearing function */
clear_func(ob, clear_delta);

View File

@@ -99,6 +99,8 @@
static int material_slot_add_exec(bContext *C, wmOperator *UNUSED(op))
{
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_context(C);
if (!ob)
@@ -106,7 +108,7 @@ static int material_slot_add_exec(bContext *C, wmOperator *UNUSED(op))
BKE_object_material_slot_add(ob);
if (ob->mode & OB_MODE_TEXTURE_PAINT) {
if (eval_ctx.object_mode & OB_MODE_TEXTURE_PAINT) {
Scene *scene = CTX_data_scene(C);
BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
@@ -136,6 +138,8 @@ void OBJECT_OT_material_slot_add(wmOperatorType *ot)
static int material_slot_remove_exec(bContext *C, wmOperator *op)
{
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_context(C);
if (!ob)
@@ -149,7 +153,7 @@ static int material_slot_remove_exec(bContext *C, wmOperator *op)
BKE_object_material_slot_remove(ob);
if (ob->mode & OB_MODE_TEXTURE_PAINT) {
if (eval_ctx.object_mode & OB_MODE_TEXTURE_PAINT) {
Scene *scene = CTX_data_scene(C);
BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);

View File

@@ -40,6 +40,8 @@
#include "BKE_main.h"
#include "BKE_paint.h"
#include "DEG_depsgraph.h"
#include "ED_paint.h"
#include "ED_view3d.h"
@@ -59,12 +61,14 @@
int paint_curve_poll(bContext *C)
{
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = CTX_data_active_object(C);
Paint *p;
RegionView3D *rv3d = CTX_wm_region_view3d(C);
SpaceImage *sima;
if (rv3d && !(ob && ((ob->mode & OB_MODE_ALL_PAINT) != 0)))
if (rv3d && !(ob && ((eval_ctx.object_mode & OB_MODE_ALL_PAINT) != 0)))
return false;
sima = CTX_wm_space_image(C);

View File

@@ -5942,10 +5942,11 @@ static int add_simple_uvs_exec(bContext *C, wmOperator *UNUSED(op))
static int add_simple_uvs_poll(bContext *C)
{
Object *ob = CTX_data_active_object(C);
if (!ob || ob->type != OB_MESH || ob->mode != OB_MODE_TEXTURE_PAINT)
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
if (!ob || (ob->type != OB_MESH) || (eval_ctx.object_mode != OB_MODE_TEXTURE_PAINT)) {
return false;
}
return true;
}

View File

@@ -40,6 +40,8 @@
#include "BKE_paint.h"
#include "BKE_main.h"
#include "DEG_depsgraph.h"
#include "ED_paint.h"
#include "ED_screen.h"
#include "ED_image.h"
@@ -261,6 +263,8 @@ static void PALETTE_OT_color_delete(wmOperatorType *ot)
static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op))
{
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
Paint *paint = BKE_paint_get_active_from_context(C);
Brush *brush = BKE_paint_brush(paint);
Object *ob = CTX_data_active_object(C);
@@ -268,7 +272,7 @@ static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op))
if (!ob || !brush) return OPERATOR_CANCELLED;
/* TODO: other modes */
if (ob->mode & OB_MODE_SCULPT) {
if (eval_ctx.object_mode & OB_MODE_SCULPT) {
BKE_brush_sculpt_reset(brush);
}
else {
@@ -401,6 +405,8 @@ static int brush_generic_tool_set(Main *bmain, Paint *paint, const int tool,
static int brush_select_exec(bContext *C, wmOperator *op)
{
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
Main *bmain = CTX_data_main(C);
ToolSettings *toolsettings = CTX_data_tool_settings(C);
Paint *paint = NULL;
@@ -414,7 +420,7 @@ static int brush_select_exec(bContext *C, wmOperator *op)
Object *ob = CTX_data_active_object(C);
if (ob) {
/* select current paint mode */
paint_mode = ob->mode & OB_MODE_ALL_PAINT;
paint_mode = eval_ctx.object_mode & OB_MODE_ALL_PAINT;
}
else {
return OPERATOR_CANCELLED;

View File

@@ -199,9 +199,13 @@ static void paint_last_stroke_update(Scene *scene, ARegion *ar, const float mval
/* Returns true if vertex paint mode is active */
int vertex_paint_mode_poll(bContext *C)
{
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = CTX_data_active_object(C);
return ob && ob->mode == OB_MODE_VERTEX_PAINT && ((Mesh *)ob->data)->totpoly;
return (ob &&
(ob->type == OB_MESH) &&
((Mesh *)ob->data)->totpoly &&
(eval_ctx.object_mode & OB_MODE_VERTEX_PAINT));
}
int vertex_paint_poll(bContext *C)
@@ -221,18 +225,24 @@ int vertex_paint_poll(bContext *C)
int weight_paint_mode_poll(bContext *C)
{
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = CTX_data_active_object(C);
return ob && ob->mode == OB_MODE_WEIGHT_PAINT && ((Mesh *)ob->data)->totpoly;
return (ob &&
(ob->type == OB_MESH) &&
((Mesh *)ob->data)->totpoly &&
(eval_ctx.object_mode == OB_MODE_WEIGHT_PAINT));
}
int weight_paint_poll(bContext *C)
{
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = CTX_data_active_object(C);
ScrArea *sa;
if ((ob != NULL) &&
(ob->mode & OB_MODE_WEIGHT_PAINT) &&
(eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT) &&
(BKE_paint_brush(&CTX_data_tool_settings(C)->wpaint->paint) != NULL) &&
(sa = CTX_wm_area(C)) &&
(sa->spacetype == SPACE_VIEW3D))
@@ -949,17 +959,18 @@ static void vertex_paint_init_session(const EvaluationContext *eval_ctx, Scene *
}
}
static void vertex_paint_init_session_data(const ToolSettings *ts, Object *ob)
static void vertex_paint_init_session_data(
const EvaluationContext *eval_ctx, const ToolSettings *ts, Object *ob)
{
/* Create maps */
struct SculptVertexPaintGeomMap *gmap = NULL;
const Brush *brush = NULL;
if (ob->mode == OB_MODE_VERTEX_PAINT) {
if (eval_ctx->object_mode == OB_MODE_VERTEX_PAINT) {
gmap = &ob->sculpt->mode.vpaint.gmap;
brush = BKE_paint_brush(&ts->vpaint->paint);
ob->sculpt->mode_type = OB_MODE_VERTEX_PAINT;
}
else if (ob->mode == OB_MODE_WEIGHT_PAINT) {
else if (eval_ctx->object_mode == OB_MODE_WEIGHT_PAINT) {
gmap = &ob->sculpt->mode.wpaint.gmap;
brush = BKE_paint_brush(&ts->wpaint->paint);
ob->sculpt->mode_type = OB_MODE_WEIGHT_PAINT;
@@ -988,7 +999,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 (eval_ctx->object_mode == OB_MODE_VERTEX_PAINT) {
if (!brush_use_accumulate(brush)) {
if (ob->sculpt->mode.vpaint.previous_color == NULL) {
ob->sculpt->mode.vpaint.previous_color =
@@ -999,7 +1010,7 @@ static void vertex_paint_init_session_data(const ToolSettings *ts, Object *ob)
MEM_SAFE_FREE(ob->sculpt->mode.vpaint.previous_color);
}
}
else if (ob->mode == OB_MODE_WEIGHT_PAINT) {
else if (eval_ctx->object_mode == OB_MODE_WEIGHT_PAINT) {
if (!brush_use_accumulate(brush)) {
if (ob->sculpt->mode.wpaint.alpha_weight == NULL) {
ob->sculpt->mode.wpaint.alpha_weight =
@@ -1396,7 +1407,7 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo
/* If not previously created, create vertex/weight paint mode session data */
vertex_paint_init_session(&eval_ctx, scene, ob);
vwpaint_update_cache_invariants(C, vp, ss, op, mouse);
vertex_paint_init_session_data(ts, ob);
vertex_paint_init_session_data(&eval_ctx, ts, ob);
if (ob->sculpt->mode.wpaint.dvert_prev != NULL) {
MDeformVert *dv = ob->sculpt->mode.wpaint.dvert_prev;
@@ -1461,8 +1472,11 @@ static void precompute_weight_values(
return;
/* threaded loop over vertices */
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
SculptThreadedTaskData data = {
.C = C, .ob = ob, .wpd = wpd, .wpi = wpi, .me = me,
.C = C, .eval_ctx = &eval_ctx, .ob = ob, .wpd = wpd, .wpi = wpi, .me = me,
};
ParallelRangeSettings settings;
@@ -1834,8 +1848,12 @@ static void wpaint_paint_leaves(
const Brush *brush = ob->sculpt->cache->brush;
/* threaded loop over nodes */
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
SculptThreadedTaskData data = {
.sd = sd, .ob = ob, .brush = brush, .nodes = nodes, .vp = vp, .wpd = wpd, .wpi = wpi, .me = me, .C = C,
.C = C, .eval_ctx = &eval_ctx, .sd = sd, .ob = ob, .brush = brush, .nodes = nodes,
.vp = vp, .wpd = wpd, .wpi = wpi, .me = me,
};
/* Use this so average can modify its weight without touching the brush. */
@@ -2420,7 +2438,7 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f
/* If not previously created, create vertex/weight paint mode session data */
vertex_paint_init_session(&eval_ctx, scene, ob);
vwpaint_update_cache_invariants(C, vp, ss, op, mouse);
vertex_paint_init_session_data(ts, ob);
vertex_paint_init_session_data(&eval_ctx, ts, ob);
if (ob->sculpt->mode.vpaint.previous_color != NULL) {
memset(ob->sculpt->mode.vpaint.previous_color, 0, sizeof(uint) * me->totloop);
@@ -2873,9 +2891,12 @@ static void vpaint_paint_leaves(
{
const Brush *brush = ob->sculpt->cache->brush;
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
SculptThreadedTaskData data = {
.sd = sd, .ob = ob, .brush = brush, .nodes = nodes, .vp = vp, .vpd = vpd,
.lcol = (uint *)me->mloopcol, .me = me, .C = C,
.C = C, .eval_ctx = &eval_ctx, .sd = sd, .ob = ob, .brush = brush, .nodes = nodes, .vp = vp, .vpd = vpd,
.lcol = (uint *)me->mloopcol, .me = me,
};
ParallelRangeSettings settings;
BLI_parallel_range_settings_defaults(&settings);

View File

@@ -51,9 +51,11 @@
static int vertex_weight_paint_mode_poll(bContext *C)
{
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = CTX_data_active_object(C);
Mesh *me = BKE_mesh_from_object(ob);
return (ob && (ob->mode == OB_MODE_VERTEX_PAINT || ob->mode == OB_MODE_WEIGHT_PAINT)) &&
return (ob && ELEM(eval_ctx.object_mode, OB_MODE_VERTEX_PAINT, OB_MODE_WEIGHT_PAINT)) &&
(me && me->totpoly && me->dvert);
}

View File

@@ -118,9 +118,11 @@ static void wpaint_prev_destroy(struct WPaintPrev *wpp)
static int weight_from_bones_poll(bContext *C)
{
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = CTX_data_active_object(C);
return (ob && (ob->mode & OB_MODE_WEIGHT_PAINT) && modifiers_isDeformedByArmature(ob));
return (ob && (eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT) && modifiers_isDeformedByArmature(ob));
}
static int weight_from_bones_exec(bContext *C, wmOperator *op)

View File

@@ -4082,8 +4082,10 @@ static void sculpt_update_tex(const Scene *scene, Sculpt *sd, SculptSession *ss)
int sculpt_mode_poll(bContext *C)
{
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = CTX_data_active_object(C);
return ob && ob->mode & OB_MODE_SCULPT;
return ob && eval_ctx.object_mode & OB_MODE_SCULPT;
}
int sculpt_mode_poll_view3d(bContext *C)

View File

@@ -130,6 +130,7 @@ struct SculptRakeData {
/* Single struct used by all BLI_task threaded callbacks, let's avoid adding 10's of those... */
typedef struct SculptThreadedTaskData {
struct bContext *C;
const struct EvaluationContext *eval_ctx;
struct Sculpt *sd;
struct Object *ob;
const struct Brush *brush;