Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-02-06 09:06:20 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-02-06 10:03:28 +0300
commitc7fecab2efd3b28a18b56dbd321616728d8b7cce (patch)
tree0169ab63925ce3d6730f519a4a54822e7f77c652 /source
parentef11113399e3273ee647b3710b346356a2b5f8f0 (diff)
Object Mode: Use eval_ctx mode for drawing, paint & modifiers
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_object.h10
-rw-r--r--source/blender/blenkernel/BKE_paint.h12
-rw-r--r--source/blender/blenkernel/BKE_particle.h3
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c40
-rw-r--r--source/blender/blenkernel/intern/object.c24
-rw-r--r--source/blender/blenkernel/intern/paint.c40
-rw-r--r--source/blender/blenkernel/intern/particle.c14
-rw-r--r--source/blender/blenkernel/intern/particle_system.c7
-rw-r--r--source/blender/draw/intern/draw_view.c2
-rw-r--r--source/blender/editors/armature/pose_select.c12
-rw-r--r--source/blender/editors/include/ED_armature.h1
-rw-r--r--source/blender/editors/interface/interface_handlers.c6
-rw-r--r--source/blender/editors/mesh/editmesh_select.c4
-rw-r--r--source/blender/editors/object/object_vgroup.c46
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c41
-rw-r--r--source/blender/editors/space_buttons/CMakeLists.txt1
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c6
-rw-r--r--source/blender/editors/space_view3d/drawmesh.c18
-rw-r--r--source/blender/editors/space_view3d/drawobject.c209
-rw-r--r--source/blender/editors/space_view3d/view3d_buttons.c9
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c46
-rw-r--r--source/blender/editors/space_view3d/view3d_draw_legacy.c32
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c36
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h26
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c76
-rw-r--r--source/blender/editors/transform/transform_generics.c2
-rw-r--r--source/blender/gpu/GPU_draw.h8
-rw-r--r--source/blender/gpu/intern/gpu_draw.c8
-rw-r--r--source/blender/makesrna/intern/rna_scene.c4
-rw-r--r--source/blender/makesrna/intern/rna_scene_api.c6
-rw-r--r--source/blender/modifiers/intern/MOD_subsurf.c6
31 files changed, 453 insertions, 302 deletions
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index d98c52aa91a..71ffa630e61 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -79,9 +79,9 @@ void BKE_object_make_proxy(struct Object *ob, struct Object *target, struct Obje
void BKE_object_copy_proxy_drivers(struct Object *ob, struct Object *target);
bool BKE_object_exists_check(struct Object *obtest);
-bool BKE_object_is_in_editmode(struct Object *ob);
+bool BKE_object_is_in_editmode(const struct Object *ob);
bool BKE_object_is_in_editmode_vgroup(struct Object *ob);
-bool BKE_object_is_in_wpaint_select_vert(struct Object *ob);
+bool BKE_object_is_in_wpaint_select_vert(const struct EvaluationContext *eval_ctx, const struct Object *ob);
typedef enum eObjectVisibilityCheck {
OB_VISIBILITY_CHECK_FOR_VIEWPORT,
@@ -113,9 +113,9 @@ void BKE_object_lod_add(struct Object *ob);
void BKE_object_lod_sort(struct Object *ob);
bool BKE_object_lod_remove(struct Object *ob, int level);
void BKE_object_lod_update(struct Object *ob, const float camera_position[3]);
-bool BKE_object_lod_is_usable(struct Object *ob, struct ViewLayer *view_layer);
-struct Object *BKE_object_lod_meshob_get(struct Object *ob, struct ViewLayer *view_layer);
-struct Object *BKE_object_lod_matob_get(struct Object *ob, struct ViewLayer *view_layer);
+bool BKE_object_lod_is_usable(struct Object *ob, struct ViewLayer *view_layer, const short object_mode);
+struct Object *BKE_object_lod_meshob_get(struct Object *ob, struct ViewLayer *view_layer, const short object_mode);
+struct Object *BKE_object_lod_matob_get(struct Object *ob, struct ViewLayer *view_layer, const short object_mode);
void BKE_object_copy_data(struct Main *bmain, struct Object *ob_dst, const struct Object *ob_src, const int flag);
struct Object *BKE_object_copy(struct Main *bmain, const struct Object *ob);
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 7fd08ba541f..5ca0843e667 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -126,7 +126,8 @@ void BKE_paint_cavity_curve_preset(struct Paint *p, int preset);
short BKE_paint_object_mode_from_paint_mode(ePaintMode mode);
struct Paint *BKE_paint_get_active_from_paintmode(struct Scene *sce, ePaintMode mode);
-struct Paint *BKE_paint_get_active(struct Scene *sce, struct ViewLayer *view_layer);
+struct Paint *BKE_paint_get_active(
+ struct Scene *sce, struct ViewLayer *view_layer, const short object_mode);
struct Paint *BKE_paint_get_active_from_context(const struct bContext *C);
ePaintMode BKE_paintmode_get_active_from_context(const struct bContext *C);
struct Brush *BKE_paint_brush(struct Paint *paint);
@@ -142,9 +143,12 @@ bool BKE_paint_proj_mesh_data_check(struct Scene *scene, struct Object *ob, bool
/* testing face select mode
* Texture paint could be removed since selected faces are not used
* however hiding faces is useful */
-bool BKE_paint_select_face_test(struct Object *ob);
-bool BKE_paint_select_vert_test(struct Object *ob);
-bool BKE_paint_select_elem_test(struct Object *ob);
+bool BKE_paint_select_face_test(
+ const struct EvaluationContext *eval_ctx, struct Object *ob);
+bool BKE_paint_select_vert_test(
+ const struct EvaluationContext *eval_ctx, struct Object *ob);
+bool BKE_paint_select_elem_test(
+ const struct EvaluationContext *eval_ctx, struct Object *ob);
/* partial visibility */
bool paint_is_face_hidden(const struct MLoopTri *lt, const struct MVert *mvert, const struct MLoop *mloop);
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index 8bc521c515f..9492f7e32fa 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -298,7 +298,8 @@ void psys_set_current_num(Object *ob, int index);
struct LatticeDeformData *psys_create_lattice_deform_data(struct ParticleSimulationData *sim);
-bool psys_in_edit_mode(struct ViewLayer *view_layer, struct ParticleSystem *psys);
+bool psys_in_edit_mode(
+ const struct EvaluationContext *eval_ctx, struct ViewLayer *view_layer, struct ParticleSystem *psys);
bool psys_check_enabled(struct Object *ob, struct ParticleSystem *psys, const bool use_render_params);
bool psys_check_edited(struct ParticleSystem *psys);
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index d71735ca8c4..5229cb35645 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -51,6 +51,8 @@
#include "BLI_linklist.h"
#include "BLI_task.h"
+#include "DEG_depsgraph.h"
+
#include "BKE_cdderivedmesh.h"
#include "BKE_colorband.h"
#include "BKE_editmesh.h"
@@ -1776,17 +1778,19 @@ static void mesh_calc_modifiers(
MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0);
const bool has_multires = (mmd && mmd->sculptlvl != 0);
bool multires_applied = false;
- const bool sculpt_mode = ob->mode & OB_MODE_SCULPT && ob->sculpt && !useRenderParams;
+ const bool sculpt_mode = eval_ctx->object_mode & OB_MODE_SCULPT && ob->sculpt && !useRenderParams;
const bool sculpt_dyntopo = (sculpt_mode && ob->sculpt->bm) && !useRenderParams;
const int draw_flag = dm_drawflag_calc(scene->toolsettings, me);
/* Generic preview only in object mode! */
- const bool do_mod_mcol = (ob->mode == OB_MODE_OBJECT);
+ const bool do_mod_mcol = (eval_ctx->object_mode == OB_MODE_OBJECT);
#if 0 /* XXX Will re-enable this when we have global mod stack options. */
const bool do_final_wmcol = (scene->toolsettings->weights_preview == WP_WPREVIEW_FINAL) && do_wmcol;
#endif
const bool do_final_wmcol = false;
- const bool do_init_wmcol = ((dataMask & CD_MASK_PREVIEW_MLOOPCOL) && (ob->mode & OB_MODE_WEIGHT_PAINT) && !do_final_wmcol);
+ const bool do_init_wmcol = (
+ (dataMask & CD_MASK_PREVIEW_MLOOPCOL) &&
+ (eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) && !do_final_wmcol);
/* XXX Same as above... For now, only weights preview in WPaint mode. */
const bool do_mod_wmcol = do_init_wmcol;
@@ -2624,7 +2628,7 @@ static bool calc_modifiers_skip_orco(const EvaluationContext *eval_ctx,
if (U.opensubdiv_compute_type == USER_OPENSUBDIV_COMPUTE_NONE) {
return false;
}
- else if ((ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) != 0) {
+ else if ((eval_ctx->object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) != 0) {
return false;
}
else if ((DEG_get_eval_flags_for_id(eval_ctx->depsgraph, &ob->id) & DAG_EVAL_NEED_CPU) != 0) {
@@ -2665,7 +2669,7 @@ static void mesh_build_data(
ob->lastDataMask = dataMask;
ob->lastNeedMapping = need_mapping;
- if ((ob->mode & OB_MODE_ALL_SCULPT) && ob->sculpt) {
+ if ((eval_ctx->object_mode & OB_MODE_ALL_SCULPT) && ob->sculpt) {
/* create PBVH immediately (would be created on the fly too,
* but this avoids waiting on first stroke) */
@@ -2703,7 +2707,9 @@ static void editbmesh_build_data(
BLI_assert(!(em->derivedFinal->dirty & DM_DIRTY_NORMALS));
}
-static CustomDataMask object_get_datamask(const Scene *scene, Object *ob, bool *r_need_mapping)
+static CustomDataMask object_get_datamask(
+ const EvaluationContext *eval_ctx,
+ const Scene *scene, Object *ob, bool *r_need_mapping)
{
/* TODO(sergey): Avoid this linear list lookup. */
ViewLayer *view_layer = BKE_view_layer_context_active_PLACEHOLDER(scene);
@@ -2715,28 +2721,28 @@ static CustomDataMask object_get_datamask(const Scene *scene, Object *ob, bool *
}
if (ob == actob) {
- bool editing = BKE_paint_select_face_test(ob);
+ bool editing = BKE_paint_select_face_test(eval_ctx, ob);
/* weight paint and face select need original indices because of selection buffer drawing */
if (r_need_mapping) {
- *r_need_mapping = (editing || (ob->mode & (OB_MODE_WEIGHT_PAINT | OB_MODE_VERTEX_PAINT)));
+ *r_need_mapping = (editing || (eval_ctx->object_mode & (OB_MODE_WEIGHT_PAINT | OB_MODE_VERTEX_PAINT)));
}
/* check if we need tfaces & mcols due to face select or texture paint */
- if ((ob->mode & OB_MODE_TEXTURE_PAINT) || editing) {
+ if ((eval_ctx->object_mode & OB_MODE_TEXTURE_PAINT) || editing) {
mask |= CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL;
}
/* check if we need mcols due to vertex paint or weightpaint */
- if (ob->mode & OB_MODE_VERTEX_PAINT) {
+ if (eval_ctx->object_mode & OB_MODE_VERTEX_PAINT) {
mask |= CD_MASK_MLOOPCOL;
}
- if (ob->mode & OB_MODE_WEIGHT_PAINT) {
+ if (eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) {
mask |= CD_MASK_PREVIEW_MLOOPCOL;
}
- if (ob->mode & OB_MODE_EDIT)
+ if (eval_ctx->object_mode & OB_MODE_EDIT)
mask |= CD_MASK_MVERT_SKIN;
}
@@ -2748,7 +2754,7 @@ void makeDerivedMesh(
CustomDataMask dataMask, const bool build_shapekey_layers)
{
bool need_mapping;
- dataMask |= object_get_datamask(scene, ob, &need_mapping);
+ dataMask |= object_get_datamask(eval_ctx, scene, ob, &need_mapping);
if (em) {
editbmesh_build_data(eval_ctx, scene, ob, em, dataMask);
@@ -2767,7 +2773,7 @@ DerivedMesh *mesh_get_derived_final(
* the data we need, rebuild the derived mesh
*/
bool need_mapping;
- dataMask |= object_get_datamask(scene, ob, &need_mapping);
+ dataMask |= object_get_datamask(eval_ctx, scene, ob, &need_mapping);
if (!ob->derivedFinal ||
((dataMask & ob->lastDataMask) != dataMask) ||
@@ -2787,7 +2793,7 @@ DerivedMesh *mesh_get_derived_deform(const struct EvaluationContext *eval_ctx, S
*/
bool need_mapping;
- dataMask |= object_get_datamask(scene, ob, &need_mapping);
+ dataMask |= object_get_datamask(eval_ctx, scene, ob, &need_mapping);
if (!ob->derivedDeform ||
((dataMask & ob->lastDataMask) != dataMask) ||
@@ -2906,7 +2912,7 @@ DerivedMesh *editbmesh_get_derived_cage_and_final(
/* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
*/
- dataMask |= object_get_datamask(scene, obedit, NULL);
+ dataMask |= object_get_datamask(eval_ctx, scene, obedit, NULL);
if (!em->derivedCage ||
(em->lastDataMask & dataMask) != dataMask)
@@ -2926,7 +2932,7 @@ DerivedMesh *editbmesh_get_derived_cage(
/* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
*/
- dataMask |= object_get_datamask(scene, obedit, NULL);
+ dataMask |= object_get_datamask(eval_ctx, scene, obedit, NULL);
if (!em->derivedCage ||
(em->lastDataMask & dataMask) != dataMask)
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 8c85a0413b8..2e257a329ea 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -486,7 +486,7 @@ void BKE_object_free(Object *ob)
}
/* actual check for internal data, not context or flags */
-bool BKE_object_is_in_editmode(Object *ob)
+bool BKE_object_is_in_editmode(const Object *ob)
{
if (ob->data == NULL)
return false;
@@ -535,11 +535,11 @@ bool BKE_object_is_in_editmode_vgroup(Object *ob)
BKE_object_is_in_editmode(ob));
}
-bool BKE_object_is_in_wpaint_select_vert(Object *ob)
+bool BKE_object_is_in_wpaint_select_vert(const EvaluationContext *eval_ctx, const Object *ob)
{
if (ob->type == OB_MESH) {
- Mesh *me = ob->data;
- return ((ob->mode & OB_MODE_WEIGHT_PAINT) &&
+ const Mesh *me = ob->data;
+ return ((eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) &&
(me->edit_btmesh == NULL) &&
(ME_EDIT_PAINT_SEL_MODE(me) == SCE_SELECT_VERTEX));
}
@@ -884,10 +884,10 @@ static LodLevel *lod_level_select(Object *ob, const float camera_position[3])
return current;
}
-bool BKE_object_lod_is_usable(Object *ob, ViewLayer *view_layer)
+bool BKE_object_lod_is_usable(Object *ob, ViewLayer *view_layer, const short object_mode)
{
bool active = (view_layer) ? ob == OBACT(view_layer) : false;
- return (ob->mode == OB_MODE_OBJECT || !active);
+ return (object_mode == OB_MODE_OBJECT || !active);
}
void BKE_object_lod_update(Object *ob, const float camera_position[3])
@@ -900,11 +900,11 @@ void BKE_object_lod_update(Object *ob, const float camera_position[3])
}
}
-static Object *lod_ob_get(Object *ob, ViewLayer *view_layer, int flag)
+static Object *lod_ob_get(Object *ob, ViewLayer *view_layer, int flag, const short object_mode)
{
LodLevel *current = ob->currentlod;
- if (!current || !BKE_object_lod_is_usable(ob, view_layer))
+ if (!current || !BKE_object_lod_is_usable(ob, view_layer, object_mode))
return ob;
while (current->prev && (!(current->flags & flag) || !current->source || current->source->type != OB_MESH)) {
@@ -914,14 +914,14 @@ static Object *lod_ob_get(Object *ob, ViewLayer *view_layer, int flag)
return current->source;
}
-struct Object *BKE_object_lod_meshob_get(Object *ob, ViewLayer *view_layer)
+struct Object *BKE_object_lod_meshob_get(Object *ob, ViewLayer *view_layer, const short object_mode)
{
- return lod_ob_get(ob, view_layer, OB_LOD_USE_MESH);
+ return lod_ob_get(ob, view_layer, OB_LOD_USE_MESH, object_mode);
}
-struct Object *BKE_object_lod_matob_get(Object *ob, ViewLayer *view_layer)
+struct Object *BKE_object_lod_matob_get(Object *ob, ViewLayer *view_layer, const short object_mode)
{
- return lod_ob_get(ob, view_layer, OB_LOD_USE_MAT);
+ return lod_ob_get(ob, view_layer, OB_LOD_USE_MAT, object_mode);
}
#endif /* WITH_GAMEENGINE */
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 2bf5d12e50e..f0ad8de33b9 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -77,7 +77,8 @@ static eOverlayControlFlags overlay_flags = 0;
void BKE_paint_invalidate_overlay_tex(Scene *scene, ViewLayer *view_layer, const Tex *tex)
{
- Paint *p = BKE_paint_get_active(scene, view_layer);
+ /* TODO/OBMODE (we should combine all) */
+ Paint *p = BKE_paint_get_active(scene, view_layer, G.main->eval_ctx->object_mode);
Brush *br = p->brush;
if (!br)
@@ -91,7 +92,8 @@ void BKE_paint_invalidate_overlay_tex(Scene *scene, ViewLayer *view_layer, const
void BKE_paint_invalidate_cursor_overlay(Scene *scene, ViewLayer *view_layer, CurveMapping *curve)
{
- Paint *p = BKE_paint_get_active(scene, view_layer);
+ /* TODO/OBMODE (we should combine all) */
+ Paint *p = BKE_paint_get_active(scene, view_layer, G.main->eval_ctx->object_mode);
Brush *br = p->brush;
if (br && br->curve == curve)
@@ -157,13 +159,13 @@ Paint *BKE_paint_get_active_from_paintmode(Scene *sce, ePaintMode mode)
return NULL;
}
-Paint *BKE_paint_get_active(Scene *sce, ViewLayer *view_layer)
+Paint *BKE_paint_get_active(Scene *sce, ViewLayer *view_layer, const short object_mode)
{
if (sce && view_layer) {
ToolSettings *ts = sce->toolsettings;
if (view_layer->basact && view_layer->basact->object) {
- switch (view_layer->basact->object->mode) {
+ switch (object_mode) {
case OB_MODE_SCULPT:
return &ts->sculpt->paint;
case OB_MODE_VERTEX_PAINT:
@@ -193,6 +195,9 @@ Paint *BKE_paint_get_active_from_context(const bContext *C)
SpaceImage *sima;
if (sce && view_layer) {
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
ToolSettings *ts = sce->toolsettings;
Object *obact = NULL;
@@ -200,7 +205,7 @@ Paint *BKE_paint_get_active_from_context(const bContext *C)
obact = view_layer->basact->object;
if ((sima = CTX_wm_space_image(C)) != NULL) {
- if (obact && obact->mode == OB_MODE_EDIT) {
+ if (obact && eval_ctx.object_mode == OB_MODE_EDIT) {
if (sima->mode == SI_MODE_PAINT)
return &ts->imapaint.paint;
else if (ts->use_uv_sculpt)
@@ -211,7 +216,7 @@ Paint *BKE_paint_get_active_from_context(const bContext *C)
}
}
else if (obact) {
- switch (obact->mode) {
+ switch (eval_ctx.object_mode) {
case OB_MODE_SCULPT:
return &ts->sculpt->paint;
case OB_MODE_VERTEX_PAINT:
@@ -244,6 +249,9 @@ ePaintMode BKE_paintmode_get_active_from_context(const bContext *C)
SpaceImage *sima;
if (sce && view_layer) {
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
ToolSettings *ts = sce->toolsettings;
Object *obact = NULL;
@@ -251,7 +259,7 @@ ePaintMode BKE_paintmode_get_active_from_context(const bContext *C)
obact = view_layer->basact->object;
if ((sima = CTX_wm_space_image(C)) != NULL) {
- if (obact && obact->mode == OB_MODE_EDIT) {
+ if (obact && eval_ctx.object_mode == OB_MODE_EDIT) {
if (sima->mode == SI_MODE_PAINT)
return ePaintTexture2D;
else if (ts->use_uv_sculpt)
@@ -262,7 +270,7 @@ ePaintMode BKE_paintmode_get_active_from_context(const bContext *C)
}
}
else if (obact) {
- switch (obact->mode) {
+ switch (eval_ctx.object_mode) {
case OB_MODE_SCULPT:
return ePaintSculpt;
case OB_MODE_VERTEX_PAINT:
@@ -453,24 +461,24 @@ bool BKE_palette_is_empty(const struct Palette *palette)
/* are we in vertex paint or weight pain face select mode? */
-bool BKE_paint_select_face_test(Object *ob)
+bool BKE_paint_select_face_test(const EvaluationContext *eval_ctx, Object *ob)
{
return ( (ob != NULL) &&
(ob->type == OB_MESH) &&
(ob->data != NULL) &&
(((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_FACE_SEL) &&
- (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))
+ (eval_ctx->object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))
);
}
/* are we in weight paint vertex select mode? */
-bool BKE_paint_select_vert_test(Object *ob)
+bool BKE_paint_select_vert_test(const EvaluationContext *eval_ctx, Object *ob)
{
return ( (ob != NULL) &&
(ob->type == OB_MESH) &&
(ob->data != NULL) &&
(((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_VERT_SEL) &&
- (ob->mode & OB_MODE_WEIGHT_PAINT || ob->mode & OB_MODE_VERTEX_PAINT)
+ (eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT || eval_ctx->object_mode & OB_MODE_VERTEX_PAINT)
);
}
@@ -478,10 +486,10 @@ bool BKE_paint_select_vert_test(Object *ob)
* used to check if selection is possible
* (when we don't care if its face or vert)
*/
-bool BKE_paint_select_elem_test(Object *ob)
+bool BKE_paint_select_elem_test(const EvaluationContext *eval_ctx, Object *ob)
{
- return (BKE_paint_select_vert_test(ob) ||
- BKE_paint_select_face_test(ob));
+ return (BKE_paint_select_vert_test(eval_ctx, ob) ||
+ BKE_paint_select_face_test(eval_ctx, ob));
}
void BKE_paint_cavity_curve_preset(Paint *p, int preset)
@@ -921,7 +929,7 @@ void BKE_sculpt_update_mesh_elements(
dm = mesh_get_derived_final(eval_ctx, scene, ob, CD_MASK_BAREMESH);
/* VWPaint require mesh info for loop lookup, so require sculpt mode here */
- if (mmd && ob->mode & OB_MODE_SCULPT) {
+ if (mmd && eval_ctx->object_mode & OB_MODE_SCULPT) {
ss->multires = mmd;
ss->totvert = dm->getNumVerts(dm);
ss->totpoly = dm->getNumPolys(dm);
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 5e2cd89a750..0ca83fba4b5 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -252,7 +252,7 @@ struct LatticeDeformData *psys_create_lattice_deform_data(ParticleSimulationData
{
struct LatticeDeformData *lattice_deform_data = NULL;
- if (psys_in_edit_mode(sim->eval_ctx->view_layer, sim->psys) == 0) {
+ if (psys_in_edit_mode(sim->eval_ctx, sim->eval_ctx->view_layer, sim->psys) == 0) {
Object *lattice = NULL;
ModifierData *md = (ModifierData *)psys_get_modifier(sim->ob, sim->psys);
int mode = G.is_rendering ? eModifierMode_Render : eModifierMode_Realtime;
@@ -289,10 +289,10 @@ void psys_enable_all(Object *ob)
psys->flag &= ~PSYS_DISABLED;
}
-bool psys_in_edit_mode(ViewLayer *view_layer, ParticleSystem *psys)
+bool psys_in_edit_mode(const EvaluationContext *eval_ctx, ViewLayer *view_layer, ParticleSystem *psys)
{
return (view_layer->basact &&
- (view_layer->basact->object->mode & OB_MODE_PARTICLE_EDIT) &&
+ (eval_ctx->object_mode & OB_MODE_PARTICLE_EDIT) &&
psys == psys_get_current((view_layer->basact)->object) &&
(psys->edit || psys->pointcache->edit) &&
!psys->renderdata);
@@ -2098,7 +2098,7 @@ static bool psys_thread_context_init_path(
psys_thread_context_init(ctx, sim);
/*---start figuring out what is actually wanted---*/
- if (psys_in_edit_mode(sim->eval_ctx->view_layer, psys)) {
+ if (psys_in_edit_mode(sim->eval_ctx, sim->eval_ctx->view_layer, psys)) {
ParticleEditSettings *pset = &scene->toolsettings->particle;
if ((psys->renderdata == 0 && use_render_params == 0) && (psys->edit == NULL || pset->flag & PE_DRAW_PART) == 0)
@@ -2187,7 +2187,7 @@ static void psys_thread_create_path(ParticleTask *task, struct ChildParticle *cp
ParticleSystem *psys = ctx->sim.psys;
ParticleSettings *part = psys->part;
ParticleCacheKey **cache = psys->childcache;
- ParticleCacheKey **pcache = psys_in_edit_mode(ctx->sim.eval_ctx->view_layer, psys) && psys->edit ? psys->edit->pathcache : psys->pathcache;
+ ParticleCacheKey **pcache = psys_in_edit_mode(ctx->sim.eval_ctx, ctx->sim.eval_ctx->view_layer, psys) && psys->edit ? psys->edit->pathcache : psys->pathcache;
ParticleCacheKey *child, *key[4];
ParticleTexture ptex;
float *cpa_fuv = 0, *par_rot = 0, rot[4];
@@ -2596,7 +2596,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re
if ((psys->flag & PSYS_HAIR_DONE || psys->flag & PSYS_KEYED || psys->pointcache) == 0)
return;
- if (psys_in_edit_mode(sim->eval_ctx->view_layer, psys))
+ if (psys_in_edit_mode(sim->eval_ctx, sim->eval_ctx->view_layer, psys))
if (psys->renderdata == 0 && (psys->edit == NULL || pset->flag & PE_DRAW_PART) == 0)
return;
@@ -3789,7 +3789,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *
pind.bspline = (psys->part->flag & PART_HAIR_BSPLINE);
/* pind.dm disabled in editmode means we don't get effectors taken into
* account when subdividing for instance */
- pind.dm = psys_in_edit_mode(sim->eval_ctx->view_layer, psys) ? NULL : psys->hair_out_dm;
+ pind.dm = psys_in_edit_mode(sim->eval_ctx, sim->eval_ctx->view_layer, psys) ? NULL : psys->hair_out_dm;
init_particle_interpolation(sim->ob, psys, pa, &pind);
do_particle_interpolation(psys, p, pa, t, &pind, state);
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index ac10ad44bf1..8ece77737b7 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -2904,8 +2904,11 @@ static void psys_update_path_cache(ParticleSimulationData *sim, float cfra, cons
if ((psys->part->childtype && psys->totchild != psys_get_tot_child(sim->scene, psys)) || psys->recalc&PSYS_RECALC_RESET)
alloc=1;
- if (alloc || psys->recalc&PSYS_RECALC_CHILD || (psys->vgroup[PSYS_VG_DENSITY] && (sim->ob && sim->ob->mode & OB_MODE_WEIGHT_PAINT)))
+ if (alloc || psys->recalc&PSYS_RECALC_CHILD ||
+ (psys->vgroup[PSYS_VG_DENSITY] && (sim->ob && sim->eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT)))
+ {
distr=1;
+ }
if (distr) {
if (alloc)
@@ -2933,7 +2936,7 @@ static void psys_update_path_cache(ParticleSimulationData *sim, float cfra, cons
skip = 1; /* draw visualization */
else if (psys->pointcache->flag & PTCACHE_BAKING)
skip = 1; /* no need to cache paths while baking dynamics */
- else if (psys_in_edit_mode(sim->eval_ctx->view_layer, psys)) {
+ else if (psys_in_edit_mode(sim->eval_ctx, sim->eval_ctx->view_layer, psys)) {
if ((pset->flag & PE_DRAW_PART)==0)
skip = 1;
else if (part->childtype==0 && (psys->flag & PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED)==0)
diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c
index 1e1f9da3c97..d9ffbde38e7 100644
--- a/source/blender/draw/intern/draw_view.c
+++ b/source/blender/draw/intern/draw_view.c
@@ -625,7 +625,7 @@ static bool is_cursor_visible(const DRWContextState *draw_ctx, Scene *scene, Vie
}
/* exception: object in texture paint mode, clone brush, use_clone_layer disabled */
else if (draw_ctx->object_mode & OB_MODE_TEXTURE_PAINT) {
- const Paint *p = BKE_paint_get_active(scene, view_layer);
+ const Paint *p = BKE_paint_get_active(scene, view_layer, draw_ctx->object_mode);
if (p && p->brush && p->brush->imagepaint_tool == PAINT_TOOL_CLONE) {
if ((scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_LAYER_CLONE) == 0) {
diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c
index 9bc678cd9e6..e7107ca5b20 100644
--- a/source/blender/editors/armature/pose_select.c
+++ b/source/blender/editors/armature/pose_select.c
@@ -134,6 +134,7 @@ void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select)
/* called from editview.c, for mode-less pose selection */
/* assumes scene obact and basact is still on old situation */
bool ED_do_pose_selectbuffer(
+ const EvaluationContext *eval_ctx,
Scene *scene, ViewLayer *view_layer, Base *base, const unsigned int *buffer, short hits,
bool extend, bool deselect, bool toggle, bool do_nearest)
{
@@ -154,7 +155,7 @@ bool ED_do_pose_selectbuffer(
* note, special exception for armature mode so we can do multi-select
* we could check for multi-select explicitly but think its fine to
* always give predictable behavior in weight paint mode - campbell */
- if ((ob_act == NULL) || ((ob_act != ob) && (ob_act->mode & OB_MODE_WEIGHT_PAINT) == 0)) {
+ if ((ob_act == NULL) || ((ob_act != ob) && (eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) == 0)) {
/* when we are entering into posemode via toggle-select,
* from another active object - always select the bone. */
if (!extend && !deselect && toggle) {
@@ -873,6 +874,9 @@ void POSE_OT_select_grouped(wmOperatorType *ot)
*/
static int pose_select_mirror_exec(bContext *C, wmOperator *op)
{
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
Object *ob_act = CTX_data_active_object(C);
Object *ob = BKE_object_pose_armature_get(ob_act);
bArmature *arm;
@@ -880,10 +884,6 @@ static int pose_select_mirror_exec(bContext *C, wmOperator *op)
const bool active_only = RNA_boolean_get(op->ptr, "only_active");
const bool extend = RNA_boolean_get(op->ptr, "extend");
- if ((ob && (ob->mode & OB_MODE_POSE)) == 0) {
- return OPERATOR_CANCELLED;
- }
-
arm = ob->data;
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
@@ -920,7 +920,7 @@ static int pose_select_mirror_exec(bContext *C, wmOperator *op)
arm->act_bone = pchan_mirror_act->bone;
/* in weightpaint we select the associated vertex group too */
- if (ob_act->mode & OB_MODE_WEIGHT_PAINT) {
+ if (eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT) {
ED_vgroup_select_by_name(ob_act, pchan_mirror_act->name);
DEG_id_tag_update(&ob_act->id, OB_RECALC_DATA);
}
diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h
index 4595bcfa86d..5ad242003e3 100644
--- a/source/blender/editors/include/ED_armature.h
+++ b/source/blender/editors/include/ED_armature.h
@@ -143,6 +143,7 @@ void ED_armature_deselect_all(struct Object *obedit);
void ED_armature_deselect_all_visible(struct Object *obedit);
bool ED_do_pose_selectbuffer(
+ const struct EvaluationContext *eval_ctx,
struct Scene *scene, struct ViewLayer *view_layer, struct Base *base, const unsigned int *buffer, short hits,
bool extend, bool deselect, bool toggle, bool do_nearest);
bool ED_armature_select_pick(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle);
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index c76ad1570b3..34a347979a8 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -73,6 +73,8 @@
#include "BKE_unit.h"
#include "BKE_paint.h"
+#include "DEG_depsgraph.h"
+
#include "ED_screen.h"
#include "ED_util.h"
#include "ED_keyframing.h"
@@ -5230,10 +5232,12 @@ static int ui_do_but_COLOR(
if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
if ((int)(but->a1) == UI_PALETTE_COLOR) {
if (!event->ctrl) {
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
float color[3];
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- Paint *paint = BKE_paint_get_active(scene, view_layer);
+ Paint *paint = BKE_paint_get_active(scene, view_layer, eval_ctx.object_mode);
Brush *brush = BKE_paint_brush(paint);
if (brush->flag & BRUSH_USE_GRADIENT) {
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index 3e0afd3095e..c607707729d 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -280,7 +280,7 @@ bool EDBM_backbuf_border_mask_init(const struct EvaluationContext *eval_ctx, Vie
/* method in use for face selecting too */
if (vc->obedit == NULL) {
- if (!BKE_paint_select_elem_test(vc->obact)) {
+ if (!BKE_paint_select_elem_test(eval_ctx, vc->obact)) {
return false;
}
}
@@ -332,7 +332,7 @@ bool EDBM_backbuf_circle_init(
/* method in use for face selecting too */
if (vc->obedit == NULL) {
- if (!BKE_paint_select_elem_test(vc->obact)) {
+ if (!BKE_paint_select_elem_test(eval_ctx, vc->obact)) {
return false;
}
}
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index 8a172f86624..035d3d38436 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -84,9 +84,9 @@
#include "object_intern.h"
/************************ Exported Functions **********************/
-static bool vertex_group_use_vert_sel(Object *ob)
+static bool vertex_group_use_vert_sel(const Object *ob)
{
- if (ob->mode == OB_MODE_EDIT) {
+ if (BKE_object_is_in_editmode(ob)) {
return true;
}
else if (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_VERT_SEL) {
@@ -107,13 +107,15 @@ static Lattice *vgroup_edit_lattice(Object *ob)
bool ED_vgroup_sync_from_pose(Object *ob)
{
Object *armobj = BKE_object_pose_armature_get(ob);
- if (armobj && (armobj->mode & OB_MODE_POSE)) {
+ if (armobj) {
struct bArmature *arm = armobj->data;
- if (arm->act_bone) {
- int def_num = defgroup_name_index(ob, arm->act_bone->name);
- if (def_num != -1) {
- ob->actdef = def_num + 1;
- return true;
+ if (arm->flag & ARM_POSEMODE) {
+ if (arm->act_bone) {
+ int def_num = defgroup_name_index(ob, arm->act_bone->name);
+ if (def_num != -1) {
+ ob->actdef = def_num + 1;
+ return true;
+ }
}
}
}
@@ -2537,6 +2539,8 @@ static int UNUSED_FUNCTION(vertex_group_poll_edit) (bContext *C)
/* editmode _or_ weight paint vertex sel */
static int vertex_group_vert_poll_ex(bContext *C, const bool needs_select, const short ob_type_flag)
{
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_context(C);
ID *data = (ob) ? ob->data : NULL;
@@ -2550,9 +2554,9 @@ static int vertex_group_vert_poll_ex(bContext *C, const bool needs_select, const
if (BKE_object_is_in_editmode_vgroup(ob)) {
return true;
}
- else if (ob->mode & OB_MODE_WEIGHT_PAINT) {
+ else if (eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT) {
if (needs_select) {
- if (BKE_object_is_in_wpaint_select_vert(ob)) {
+ if (BKE_object_is_in_wpaint_select_vert(&eval_ctx, ob)) {
return true;
}
else {
@@ -2604,8 +2608,10 @@ static int vertex_group_vert_select_unlocked_poll(bContext *C)
if (!(ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data)))
return 0;
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
if (!(BKE_object_is_in_editmode_vgroup(ob) ||
- BKE_object_is_in_wpaint_select_vert(ob)))
+ BKE_object_is_in_wpaint_select_vert(&eval_ctx, ob)))
{
return 0;
}
@@ -2631,8 +2637,11 @@ static int vertex_group_vert_select_mesh_poll(bContext *C)
if (ob->type != OB_MESH)
return 0;
+
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
return (BKE_object_is_in_editmode_vgroup(ob) ||
- BKE_object_is_in_wpaint_select_vert(ob));
+ BKE_object_is_in_wpaint_select_vert(&eval_ctx, ob));
}
static int vertex_group_add_exec(bContext *C, wmOperator *UNUSED(op))
@@ -3516,7 +3525,8 @@ static char *vgroup_init_remap(Object *ob)
return name_array;
}
-static int vgroup_do_remap(Object *ob, const char *name_array, wmOperator *op)
+static int vgroup_do_remap(
+ const EvaluationContext *eval_ctx, Object *ob, const char *name_array, wmOperator *op)
{
MDeformVert *dvert = NULL;
bDeformGroup *def;
@@ -3537,7 +3547,7 @@ static int vgroup_do_remap(Object *ob, const char *name_array, wmOperator *op)
BLI_assert(sort_map[i] != -1);
}
- if (ob->mode == OB_MODE_EDIT) {
+ if (eval_ctx->object_mode == OB_MODE_EDIT) {
if (ob->type == OB_MESH) {
BMEditMesh *em = BKE_editmesh_from_object(ob);
const int cd_dvert_offset = CustomData_get_offset(&em->bm->vdata, CD_MDEFORMVERT);
@@ -3635,6 +3645,8 @@ enum {
static int vertex_group_sort_exec(bContext *C, wmOperator *op)
{
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_context(C);
char *name_array;
int ret;
@@ -3654,7 +3666,7 @@ static int vertex_group_sort_exec(bContext *C, wmOperator *op)
}
/*remap vgroup data to map to correct names*/
- ret = vgroup_do_remap(ob, name_array, op);
+ ret = vgroup_do_remap(&eval_ctx, ob, name_array, op);
if (ret != OPERATOR_CANCELLED) {
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -3690,6 +3702,8 @@ void OBJECT_OT_vertex_group_sort(wmOperatorType *ot)
static int vgroup_move_exec(bContext *C, wmOperator *op)
{
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_context(C);
bDeformGroup *def;
char *name_array;
@@ -3704,7 +3718,7 @@ static int vgroup_move_exec(bContext *C, wmOperator *op)
name_array = vgroup_init_remap(ob);
if (BLI_listbase_link_move(&ob->defbase, def, dir)) {
- ret = vgroup_do_remap(ob, name_array, op);
+ ret = vgroup_do_remap(&eval_ctx, ob, name_array, op);
if (ret != OPERATOR_CANCELLED) {
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index aebd0c10e9c..1ae13fcaec0 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -588,13 +588,15 @@ static Brush *image_paint_brush(bContext *C)
static int image_paint_poll(bContext *C)
{
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
Object *obact;
- if (!image_paint_brush(C))
+ if (!image_paint_brush(C)) {
return 0;
-
+ }
obact = CTX_data_active_object(C);
- if ((obact && obact->mode & OB_MODE_TEXTURE_PAINT) && CTX_wm_region_view3d(C)) {
+ if ((obact && eval_ctx.object_mode & OB_MODE_TEXTURE_PAINT) && CTX_wm_region_view3d(C)) {
return 1;
}
else {
@@ -1469,11 +1471,13 @@ void PAINT_OT_texture_paint_toggle(wmOperatorType *ot)
static int brush_colors_flip_exec(bContext *C, wmOperator *UNUSED(op))
{
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings;
Brush *br;
Object *ob = CTX_data_active_object(C);
- if (!(ob && (ob->mode & OB_MODE_VERTEX_PAINT))) {
+ if (!(ob && (eval_ctx.object_mode & OB_MODE_VERTEX_PAINT))) {
br = image_paint_brush(C);
}
else {
@@ -1504,8 +1508,12 @@ static int brush_colors_flip_poll(bContext *C)
}
else {
Object *ob = CTX_data_active_object(C);
- if (ob && (ob->mode & OB_MODE_VERTEX_PAINT)) {
- return 1;
+ if (ob) {
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+ if (eval_ctx.object_mode & OB_MODE_VERTEX_PAINT) {
+ return 1;
+ }
}
}
return 0;
@@ -1545,10 +1553,13 @@ void ED_imapaint_bucket_fill(struct bContext *C, float color[3], wmOperator *op)
static int texture_paint_poll(bContext *C)
{
- if (texture_paint_toggle_poll(C))
- if (CTX_data_active_object(C)->mode & OB_MODE_TEXTURE_PAINT)
+ if (texture_paint_toggle_poll(C)) {
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+ if (eval_ctx.object_mode & OB_MODE_TEXTURE_PAINT) {
return 1;
-
+ }
+ }
return 0;
}
@@ -1559,16 +1570,22 @@ int image_texture_paint_poll(bContext *C)
int facemask_paint_poll(bContext *C)
{
- return BKE_paint_select_face_test(CTX_data_active_object(C));
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+ return BKE_paint_select_face_test(&eval_ctx, CTX_data_active_object(C));
}
int vert_paint_poll(bContext *C)
{
- return BKE_paint_select_vert_test(CTX_data_active_object(C));
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+ return BKE_paint_select_vert_test(&eval_ctx, CTX_data_active_object(C));
}
int mask_paint_poll(bContext *C)
{
- return BKE_paint_select_elem_test(CTX_data_active_object(C));
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+ return BKE_paint_select_elem_test(&eval_ctx, CTX_data_active_object(C));
}
diff --git a/source/blender/editors/space_buttons/CMakeLists.txt b/source/blender/editors/space_buttons/CMakeLists.txt
index 397d79e1dbe..ec866780122 100644
--- a/source/blender/editors/space_buttons/CMakeLists.txt
+++ b/source/blender/editors/space_buttons/CMakeLists.txt
@@ -23,6 +23,7 @@ set(INC
../../blenkernel
../../blenlib
../../blentranslation
+ ../../depsgraph
../../gpu
../../makesdna
../../makesrna
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index 8866c6b6c40..42ff57472e7 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -62,6 +62,8 @@
#include "RNA_access.h"
+#include "DEG_depsgraph.h"
+
#include "ED_buttons.h"
#include "ED_armature.h"
#include "ED_screen.h"
@@ -423,8 +425,10 @@ static int buttons_context_path_brush(const bContext *C, ButsContextPath *path)
scene = path->ptr[path->len - 1].data;
if (scene) {
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
ViewLayer *view_layer = CTX_data_view_layer(C);
- br = BKE_paint_brush(BKE_paint_get_active(scene, view_layer));
+ br = BKE_paint_brush(BKE_paint_get_active(scene, view_layer, eval_ctx.object_mode));
}
if (br) {
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c
index f8f2d5598de..ce36d9b58c4 100644
--- a/source/blender/editors/space_view3d/drawmesh.c
+++ b/source/blender/editors/space_view3d/drawmesh.c
@@ -59,6 +59,8 @@
#include "UI_resources.h"
+#include "DEG_depsgraph.h"
+
#include "GPU_draw.h"
#include "GPU_material.h"
#include "GPU_basic_shader.h"
@@ -325,8 +327,10 @@ void draw_mesh_paint_weight_edges(RegionView3D *rv3d, DerivedMesh *dm,
}
}
-void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d,
- Object *ob, DerivedMesh *dm, const int draw_flags)
+void draw_mesh_paint(
+ const EvaluationContext *eval_ctx,
+ View3D *v3d, RegionView3D *rv3d,
+ Object *ob, DerivedMesh *dm, const int draw_flags)
{
DMSetDrawOptions facemask = NULL;
Mesh *me = ob->data;
@@ -336,21 +340,21 @@ void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d,
if (me->editflag & (ME_EDIT_PAINT_VERT_SEL | ME_EDIT_PAINT_FACE_SEL))
facemask = wpaint__setSolidDrawOptions_facemask;
- if (ob->mode & OB_MODE_WEIGHT_PAINT) {
+ if (eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) {
draw_mesh_paint_weight_faces(dm, use_light, facemask, me);
}
- else if (ob->mode & OB_MODE_VERTEX_PAINT) {
+ else if (eval_ctx->object_mode & OB_MODE_VERTEX_PAINT) {
draw_mesh_paint_vcolor_faces(dm, use_light, facemask, me, me);
}
/* draw face selection on top */
if (draw_flags & DRAW_FACE_SELECT) {
- bool draw_select_edges = (ob->mode & OB_MODE_TEXTURE_PAINT) == 0;
+ bool draw_select_edges = (eval_ctx->object_mode & OB_MODE_TEXTURE_PAINT) == 0;
draw_mesh_face_select(rv3d, me, dm, draw_select_edges);
}
else if ((use_light == false) || (ob->dtx & OB_DRAWWIRE)) {
- const bool use_depth = (v3d->flag & V3D_ZBUF_SELECT) || !(ob->mode & OB_MODE_WEIGHT_PAINT);
- const bool use_alpha = (ob->mode & OB_MODE_VERTEX_PAINT) == 0;
+ const bool use_depth = (v3d->flag & V3D_ZBUF_SELECT) || !(eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT);
+ const bool use_alpha = (eval_ctx->object_mode & OB_MODE_VERTEX_PAINT) == 0;
if (use_alpha == false) {
set_inverted_drawing(1);
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 51dc56bafaf..8bbbc4ac489 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -314,13 +314,15 @@ static bool check_ob_drawface_dot(Scene *sce, View3D *vd, char dt)
/* check for glsl drawing */
-bool draw_glsl_material(Scene *scene, ViewLayer *view_layer, Object *ob, View3D *v3d, const char dt)
+bool draw_glsl_material(
+ const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer,
+ Object *ob, View3D *v3d, const char dt)
{
if (G.f & G_PICKSEL)
return false;
if (!check_object_draw_texture(scene, v3d, dt))
return false;
- if (ob == OBACT(view_layer) && (ob && ob->mode & OB_MODE_WEIGHT_PAINT))
+ if (ob == OBACT(view_layer) && (ob && eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT))
return false;
if (v3d->flag2 & V3D_SHOW_SOLID_MATCAP)
@@ -334,7 +336,7 @@ bool draw_glsl_material(Scene *scene, ViewLayer *view_layer, Object *ob, View3D
return false;
}
-static bool check_alpha_pass(Base *base)
+static bool check_alpha_pass(const EvaluationContext *eval_ctx, Base *base)
{
if (base->flag_legacy & OB_FROMDUPLI)
return false;
@@ -342,8 +344,9 @@ static bool check_alpha_pass(Base *base)
if (G.f & G_PICKSEL)
return false;
- if (base->object->mode & OB_MODE_ALL_PAINT)
+ if (eval_ctx->object_mode & OB_MODE_ALL_PAINT) {
return false;
+ }
return (base->object->dtx & OB_DRAWTRANSP);
}
@@ -3892,8 +3895,9 @@ static DMDrawOption draw_em_fancy__setGLSLFaceOpts(void *userData, int index)
}
}
-static void draw_em_fancy(Scene *scene, ViewLayer *view_layer, ARegion *ar, View3D *v3d,
- Object *ob, BMEditMesh *em, DerivedMesh *cageDM, DerivedMesh *finalDM, const char dt)
+static void draw_em_fancy(
+ const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, ARegion *ar, View3D *v3d,
+ Object *ob, BMEditMesh *em, DerivedMesh *cageDM, DerivedMesh *finalDM, const char dt)
{
RegionView3D *rv3d = ar->regiondata;
@@ -3930,7 +3934,7 @@ static void draw_em_fancy(Scene *scene, ViewLayer *view_layer, ARegion *ar, View
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
}
else if (check_object_draw_texture(scene, v3d, dt)) {
- if (draw_glsl_material(scene, view_layer, ob, v3d, dt)) {
+ if (draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt)) {
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
finalDM->drawMappedFacesGLSL(finalDM, GPU_object_material_bind,
@@ -4223,10 +4227,12 @@ static void draw_em_fancy_new(Scene *UNUSED(scene), ARegion *UNUSED(ar), View3D
/* Mesh drawing routines */
-void draw_mesh_object_outline(View3D *v3d, Object *ob, DerivedMesh *dm, const unsigned char ob_wire_col[4]) /* LEGACY */
+void draw_mesh_object_outline(
+ const EvaluationContext *eval_ctx, View3D *v3d,
+ Object *ob, DerivedMesh *dm, const unsigned char ob_wire_col[4]) /* LEGACY */
{
if ((v3d->transp == false) && /* not when we draw the transparent pass */
- (ob->mode & OB_MODE_ALL_PAINT) == false) /* not when painting (its distracting) - campbell */
+ (eval_ctx->object_mode & OB_MODE_ALL_PAINT) == false) /* not when painting (its distracting) - campbell */
{
glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f);
glDepthMask(GL_FALSE);
@@ -4249,10 +4255,12 @@ void draw_mesh_object_outline(View3D *v3d, Object *ob, DerivedMesh *dm, const un
}
}
-static void draw_mesh_object_outline_new(View3D *v3d, RegionView3D *rv3d, Object *ob, Mesh *me, const bool is_active)
+static void draw_mesh_object_outline_new(
+ const EvaluationContext *eval_ctx, View3D *v3d, RegionView3D *rv3d,
+ Mesh *me, const bool is_active)
{
if ((v3d->transp == false) && /* not when we draw the transparent pass */
- (ob->mode & OB_MODE_ALL_PAINT) == false) /* not when painting (its distracting) - campbell */
+ (eval_ctx->object_mode & OB_MODE_ALL_PAINT) == false) /* not when painting (its distracting) - campbell */
{
glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f);
glDepthMask(GL_FALSE);
@@ -4302,7 +4310,9 @@ static void draw_mesh_fancy(
const char dt, const unsigned char ob_wire_col[4], const short dflag)
{
#ifdef WITH_GAMEENGINE
- Object *ob = (rv3d->rflag & RV3D_IS_GAME_ENGINE) ? BKE_object_lod_meshob_get(base->object, view_layer) : base->object;
+ Object *ob = (
+ (rv3d->rflag & RV3D_IS_GAME_ENGINE) ?
+ BKE_object_lod_meshob_get(base->object, view_layer, eval_ctx->object_mode) : base->object);
#else
Object *ob = base->object;
#endif
@@ -4311,7 +4321,7 @@ static void draw_mesh_fancy(
bool /* no_verts,*/ no_edges, no_faces;
DerivedMesh *dm = mesh_get_derived_final(eval_ctx, scene, ob, scene->customdata_mask);
const bool is_obact = (ob == OBACT(view_layer));
- int draw_flags = (is_obact && BKE_paint_select_face_test(ob)) ? DRAW_FACE_SELECT : 0;
+ int draw_flags = (is_obact && BKE_paint_select_face_test(eval_ctx, ob)) ? DRAW_FACE_SELECT : 0;
if (!dm)
return;
@@ -4349,7 +4359,7 @@ static void draw_mesh_fancy(
draw_bounding_volume(ob, ob->boundtype, ob_wire_col);
}
else if ((no_faces && no_edges) ||
- ((!is_obact || (ob->mode == OB_MODE_OBJECT)) && object_is_halo(scene, ob)))
+ ((!is_obact || (eval_ctx->object_mode == OB_MODE_OBJECT)) && object_is_halo(scene, ob)))
{
glPointSize(1.5f);
dm->drawVerts(dm);
@@ -4357,7 +4367,7 @@ static void draw_mesh_fancy(
else if ((dt == OB_WIRE) || no_faces) {
draw_wire = OBDRAW_WIRE_ON; /* draw wire only, no depth buffer stuff */
}
- else if (((is_obact && ob->mode & OB_MODE_TEXTURE_PAINT)) ||
+ else if (((is_obact && eval_ctx->object_mode & OB_MODE_TEXTURE_PAINT)) ||
check_object_draw_texture(scene, v3d, dt))
{
bool draw_loose = true;
@@ -4368,15 +4378,17 @@ static void draw_mesh_fancy(
!(G.f & G_PICKSEL || (draw_flags & DRAW_FACE_SELECT)) &&
(draw_wire == OBDRAW_WIRE_OFF))
{
- draw_mesh_object_outline(v3d, ob, dm, ob_wire_col);
+ draw_mesh_object_outline(eval_ctx, v3d, ob, dm, ob_wire_col);
}
- if (draw_glsl_material(scene, view_layer, ob, v3d, dt) && !(draw_flags & DRAW_MODIFIERS_PREVIEW)) {
+ if (draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt) && !(draw_flags & DRAW_MODIFIERS_PREVIEW)) {
Paint *p;
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
- if ((v3d->flag2 & V3D_SHOW_SOLID_MATCAP) && ob->sculpt && (p = BKE_paint_get_active(scene, view_layer))) {
+ if ((v3d->flag2 & V3D_SHOW_SOLID_MATCAP) && ob->sculpt &&
+ (p = BKE_paint_get_active(scene, view_layer, eval_ctx->object_mode)))
+ {
GPUVertexAttribs gattribs;
float planes[4][4];
float (*fpl)[4] = NULL;
@@ -4439,7 +4451,7 @@ static void draw_mesh_fancy(
(draw_wire == OBDRAW_WIRE_OFF) &&
(ob->sculpt == NULL))
{
- draw_mesh_object_outline(v3d, ob, dm, ob_wire_col);
+ draw_mesh_object_outline(eval_ctx, v3d, ob, dm, ob_wire_col);
}
/* materials arent compatible with vertex colors */
@@ -4463,12 +4475,12 @@ static void draw_mesh_fancy(
(draw_wire == OBDRAW_WIRE_OFF) &&
(ob->sculpt == NULL))
{
- draw_mesh_object_outline(v3d, ob, dm, ob_wire_col);
+ draw_mesh_object_outline(eval_ctx, v3d, ob, dm, ob_wire_col);
}
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
- if (ob->sculpt && (p = BKE_paint_get_active(scene, view_layer))) {
+ if (ob->sculpt && (p = BKE_paint_get_active(scene, view_layer, eval_ctx->object_mode))) {
float planes[4][4];
float (*fpl)[4] = NULL;
const bool fast = (p->flags & PAINT_FAST_NAVIGATE) && (rv3d->rflag & RV3D_NAVIGATING);
@@ -4500,7 +4512,7 @@ static void draw_mesh_fancy(
}
}
else if (dt == OB_PAINT) {
- draw_mesh_paint(v3d, rv3d, ob, dm, draw_flags);
+ draw_mesh_paint(eval_ctx, v3d, rv3d, ob, dm, draw_flags);
/* since we already draw wire as wp guide, don't draw over the top */
draw_wire = OBDRAW_WIRE_OFF;
@@ -4515,7 +4527,7 @@ static void draw_mesh_fancy(
* with the background. */
if ((dflag & DRAW_CONSTCOLOR) == 0) {
- if (is_obact && (ob->mode & OB_MODE_PARTICLE_EDIT)) {
+ if (is_obact && (eval_ctx->object_mode & OB_MODE_PARTICLE_EDIT)) {
float color[3];
ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.15f, color);
glColor3fv(color);
@@ -4548,7 +4560,7 @@ static void draw_mesh_fancy(
}
}
- if (is_obact && BKE_paint_select_vert_test(ob)) {
+ if (is_obact && BKE_paint_select_vert_test(eval_ctx, ob)) {
const bool use_depth = (v3d->flag & V3D_ZBUF_SELECT) != 0;
glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
@@ -4617,13 +4629,13 @@ static bool draw_mesh_object(
if (use_material) {
if (dt > OB_WIRE) {
- const bool glsl = draw_glsl_material(scene, view_layer, ob, v3d, dt);
+ const bool glsl = draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt);
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl, NULL);
+ GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl, eval_ctx->object_mode, NULL);
}
}
- draw_em_fancy(scene, view_layer, ar, v3d, ob, em, cageDM, finalDM, dt);
+ draw_em_fancy(eval_ctx, scene, view_layer, ar, v3d, ob, em, cageDM, finalDM, dt);
if (use_material) {
GPU_end_object_materials();
@@ -4636,12 +4648,13 @@ static bool draw_mesh_object(
/* ob->bb was set by derived mesh system, do NULL check just to be sure */
if (me->totpoly <= 4 || (!ob->bb || ED_view3d_boundbox_clip(rv3d, ob->bb))) {
if (dt > OB_WIRE) {
- const bool glsl = draw_glsl_material(scene, view_layer, ob, v3d, dt);
+ const bool glsl = draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt);
if (dt == OB_SOLID || glsl) {
- const bool check_alpha = check_alpha_pass(base);
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl,
- (check_alpha) ? &do_alpha_after : NULL);
+ const bool check_alpha = check_alpha_pass(eval_ctx, base);
+ GPU_begin_object_materials(
+ v3d, rv3d, scene, view_layer, ob,
+ glsl, eval_ctx->object_mode, (check_alpha) ? &do_alpha_after : NULL);
}
}
@@ -4718,7 +4731,9 @@ static void draw_mesh_fancy_new(EvaluationContext *eval_ctx, Scene *scene, ViewL
}
#ifdef WITH_GAMEENGINE
- Object *ob = (rv3d->rflag & RV3D_IS_GAME_ENGINE) ? BKE_object_lod_meshob_get(base->object, view_layer) : base->object;
+ Object *ob = (
+ (rv3d->rflag & RV3D_IS_GAME_ENGINE) ?
+ BKE_object_lod_meshob_get(base->object, view_layer, eval_ctx->object_mode) : base->object);
#else
Object *ob = base->object;
#endif
@@ -4727,7 +4742,7 @@ static void draw_mesh_fancy_new(EvaluationContext *eval_ctx, Scene *scene, ViewL
bool no_edges, no_faces;
DerivedMesh *dm = mesh_get_derived_final(eval_ctx, scene, ob, scene->customdata_mask);
const bool is_obact = (ob == OBACT(view_layer));
- int draw_flags = (is_obact && BKE_paint_select_face_test(ob)) ? DRAW_FACE_SELECT : 0;
+ int draw_flags = (is_obact && BKE_paint_select_face_test(eval_ctx, ob)) ? DRAW_FACE_SELECT : 0;
if (!dm)
return;
@@ -4770,7 +4785,7 @@ static void draw_mesh_fancy_new(EvaluationContext *eval_ctx, Scene *scene, ViewL
draw_bounding_volume(ob, ob->boundtype, ob_wire_col);
}
else if ((no_faces && no_edges) ||
- ((!is_obact || (ob->mode == OB_MODE_OBJECT)) && object_is_halo(scene, ob)))
+ ((!is_obact || (eval_ctx->object_mode == OB_MODE_OBJECT)) && object_is_halo(scene, ob)))
{
glPointSize(1.5f);
// dm->drawVerts(dm);
@@ -4836,7 +4851,7 @@ static void draw_mesh_fancy_new(EvaluationContext *eval_ctx, Scene *scene, ViewL
GWN_batch_draw(batch);
#endif
}
- else if (((is_obact && ob->mode & OB_MODE_TEXTURE_PAINT)) ||
+ else if (((is_obact && eval_ctx->object_mode & OB_MODE_TEXTURE_PAINT)) ||
check_object_draw_texture(scene, v3d, dt))
{
bool draw_loose = true;
@@ -4847,15 +4862,17 @@ static void draw_mesh_fancy_new(EvaluationContext *eval_ctx, Scene *scene, ViewL
!(G.f & G_PICKSEL || (draw_flags & DRAW_FACE_SELECT)) &&
(draw_wire == OBDRAW_WIRE_OFF))
{
- draw_mesh_object_outline_new(v3d, rv3d, ob, me, (ob == OBACT(view_layer)));
+ draw_mesh_object_outline_new(eval_ctx, v3d, rv3d, me, (ob == OBACT(view_layer)));
}
- if (draw_glsl_material(scene, view_layer, ob, v3d, dt) && !(draw_flags & DRAW_MODIFIERS_PREVIEW)) {
+ if (draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt) && !(draw_flags & DRAW_MODIFIERS_PREVIEW)) {
Paint *p;
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
- if ((v3d->flag2 & V3D_SHOW_SOLID_MATCAP) && ob->sculpt && (p = BKE_paint_get_active(scene, view_layer))) {
+ if ((v3d->flag2 & V3D_SHOW_SOLID_MATCAP) && ob->sculpt &&
+ (p = BKE_paint_get_active(scene, view_layer, eval_ctx->object_mode)))
+ {
GPUVertexAttribs gattribs;
float planes[4][4];
float (*fpl)[4] = NULL;
@@ -4914,7 +4931,7 @@ static void draw_mesh_fancy_new(EvaluationContext *eval_ctx, Scene *scene, ViewL
(draw_wire == OBDRAW_WIRE_OFF) &&
(ob->sculpt == NULL))
{
- draw_mesh_object_outline_new(v3d, rv3d, ob, me, (ob == OBACT(view_layer)));
+ draw_mesh_object_outline_new(eval_ctx, v3d, rv3d, me, (ob == OBACT(view_layer)));
}
/* materials arent compatible with vertex colors */
@@ -4939,12 +4956,12 @@ static void draw_mesh_fancy_new(EvaluationContext *eval_ctx, Scene *scene, ViewL
(ob->sculpt == NULL))
{
/* TODO: move this into a separate pass */
- draw_mesh_object_outline_new(v3d, rv3d, ob, me, (ob == OBACT(view_layer)));
+ draw_mesh_object_outline_new(eval_ctx, v3d, rv3d, me, (ob == OBACT(view_layer)));
}
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
- if (ob->sculpt && (p = BKE_paint_get_active(scene, view_layer))) {
+ if (ob->sculpt && (p = BKE_paint_get_active(scene, view_layer, eval_ctx->object_mode))) {
float planes[4][4];
float (*fpl)[4] = NULL;
const bool fast = (p->flags & PAINT_FAST_NAVIGATE) && (rv3d->rflag & RV3D_NAVIGATING);
@@ -4976,7 +4993,7 @@ static void draw_mesh_fancy_new(EvaluationContext *eval_ctx, Scene *scene, ViewL
}
}
else if (dt == OB_PAINT) {
- draw_mesh_paint(v3d, rv3d, ob, dm, draw_flags);
+ draw_mesh_paint(eval_ctx, v3d, rv3d, ob, dm, draw_flags);
/* since we already draw wire as wp guide, don't draw over the top */
draw_wire = OBDRAW_WIRE_OFF;
@@ -5085,9 +5102,9 @@ static bool UNUSED_FUNCTION(draw_mesh_object_new)(const bContext *C, Scene *scen
DM_update_materials(cageDM, ob);
}
- const bool glsl = draw_glsl_material(scene, view_layer, ob, v3d, dt);
+ const bool glsl = draw_glsl_material(&eval_ctx, scene, view_layer, ob, v3d, dt);
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl, NULL);
+ GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl, eval_ctx.object_mode, NULL);
}
draw_em_fancy_new(scene, ar, v3d, ob, me, em, cageDM, finalDM, dt);
@@ -5103,12 +5120,13 @@ static bool UNUSED_FUNCTION(draw_mesh_object_new)(const bContext *C, Scene *scen
/* ob->bb was set by derived mesh system, do NULL check just to be sure */
if (me->totpoly <= 4 || (!ob->bb || ED_view3d_boundbox_clip(rv3d, ob->bb))) {
if (solid) {
- const bool glsl = draw_glsl_material(scene, view_layer, ob, v3d, dt);
+ const bool glsl = draw_glsl_material(&eval_ctx, scene, view_layer, ob, v3d, dt);
if (dt == OB_SOLID || glsl) {
- const bool check_alpha = check_alpha_pass(base);
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl,
- (check_alpha) ? &do_alpha_after : NULL);
+ const bool check_alpha = check_alpha_pass(&eval_ctx, base);
+ GPU_begin_object_materials(
+ v3d, rv3d, scene, view_layer, ob,
+ eval_ctx.object_mode, glsl, (check_alpha) ? &do_alpha_after : NULL);
}
}
@@ -5425,7 +5443,9 @@ static void drawCurveDMWired(Object *ob)
}
/* return true when nothing was drawn */
-static bool drawCurveDerivedMesh(Scene *scene, ViewLayer *view_layer, View3D *v3d, RegionView3D *rv3d, Base *base, const char dt)
+static bool drawCurveDerivedMesh(
+ const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, View3D *v3d, RegionView3D *rv3d,
+ Base *base, const char dt)
{
Object *ob = base->object;
DerivedMesh *dm = ob->derivedFinal;
@@ -5439,8 +5459,10 @@ static bool drawCurveDerivedMesh(Scene *scene, ViewLayer *view_layer, View3D *v3
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
if (dt > OB_WIRE && dm->getNumPolys(dm)) {
- bool glsl = draw_glsl_material(scene, view_layer, ob, v3d, dt);
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl, NULL);
+ bool glsl = draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt);
+ GPU_begin_object_materials(
+ v3d, rv3d, scene, view_layer, ob,
+ eval_ctx->object_mode, glsl, NULL);
if (!glsl)
dm->drawFacesSolid(dm, NULL, 0, GPU_object_material_bind);
@@ -5461,8 +5483,9 @@ static bool drawCurveDerivedMesh(Scene *scene, ViewLayer *view_layer, View3D *v3
* Only called by #drawDispList
* \return true when nothing was drawn
*/
-static bool drawDispList_nobackface(Scene *scene, ViewLayer *view_layer, View3D *v3d, RegionView3D *rv3d, Base *base,
- const char dt, const short dflag, const unsigned char ob_wire_col[4])
+static bool drawDispList_nobackface(
+ const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, View3D *v3d, RegionView3D *rv3d,
+ Base *base, const char dt, const short dflag, const unsigned char ob_wire_col[4])
{
Object *ob = base->object;
ListBase *lb = NULL;
@@ -5502,13 +5525,13 @@ static bool drawDispList_nobackface(Scene *scene, ViewLayer *view_layer, View3D
/* pass */
}
else {
- if (draw_glsl_material(scene, view_layer, ob, v3d, dt)) {
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 1, NULL);
+ if (draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt)) {
+ GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 1, eval_ctx->object_mode, NULL);
drawDispListsolid(lb, ob, dflag, ob_wire_col, true);
GPU_end_object_materials();
}
else {
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 0, NULL);
+ GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 0, eval_ctx->object_mode, NULL);
drawDispListsolid(lb, ob, dflag, ob_wire_col, false);
GPU_end_object_materials();
}
@@ -5537,13 +5560,13 @@ static bool drawDispList_nobackface(Scene *scene, ViewLayer *view_layer, View3D
if (dl->nors == NULL) BKE_displist_normals_add(lb);
- if (draw_glsl_material(scene, view_layer, ob, v3d, dt)) {
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 1, NULL);
+ if (draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt)) {
+ GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 1, eval_ctx->object_mode, NULL);
drawDispListsolid(lb, ob, dflag, ob_wire_col, true);
GPU_end_object_materials();
}
else {
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 0, NULL);
+ GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 0, eval_ctx->object_mode, NULL);
drawDispListsolid(lb, ob, dflag, ob_wire_col, false);
GPU_end_object_materials();
}
@@ -5562,13 +5585,13 @@ static bool drawDispList_nobackface(Scene *scene, ViewLayer *view_layer, View3D
if (solid) {
- if (draw_glsl_material(scene, view_layer, ob, v3d, dt)) {
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 1, NULL);
+ if (draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt)) {
+ GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 1, eval_ctx->object_mode, NULL);
drawDispListsolid(lb, ob, dflag, ob_wire_col, true);
GPU_end_object_materials();
}
else {
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 0, NULL);
+ GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 0, eval_ctx->object_mode, NULL);
drawDispListsolid(lb, ob, dflag, ob_wire_col, false);
GPU_end_object_materials();
}
@@ -5599,7 +5622,7 @@ static bool drawDispList(
ensure_curve_cache(eval_ctx, scene, base->object);
#endif
- if (drawCurveDerivedMesh(scene, view_layer, v3d, rv3d, base, dt) == false) {
+ if (drawCurveDerivedMesh(eval_ctx, scene, view_layer, v3d, rv3d, base, dt) == false) {
retval = false;
}
else {
@@ -5615,7 +5638,7 @@ static bool drawDispList(
glFrontFace(mode);
- retval = drawDispList_nobackface(scene, view_layer, v3d, rv3d, base, dt, dflag, ob_wire_col);
+ retval = drawDispList_nobackface(eval_ctx, scene, view_layer, v3d, rv3d, base, dt, dflag, ob_wire_col);
if (mode != GL_CCW) {
glFrontFace(GL_CCW);
@@ -5939,7 +5962,7 @@ static void draw_new_particle_system(
if (pars == NULL) return;
/* don't draw normal paths in edit mode */
- if (psys_in_edit_mode(eval_ctx->view_layer, psys) && (pset->flag & PE_DRAW_PART) == 0)
+ if (psys_in_edit_mode(eval_ctx, eval_ctx->view_layer, psys) && (pset->flag & PE_DRAW_PART) == 0)
return;
if (part->draw_as == PART_DRAW_REND)
@@ -8296,7 +8319,7 @@ static void draw_object_selected_outline(
if (has_faces && ED_view3d_boundbox_clip(rv3d, ob->bb)) {
glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f);
if (dm) {
- draw_mesh_object_outline(v3d, ob, dm, ob_wire_col);
+ draw_mesh_object_outline(eval_ctx, v3d, ob, dm, ob_wire_col);
}
else {
/* only draw 'solid' parts of the display list as wire. */
@@ -8313,7 +8336,7 @@ static void draw_object_selected_outline(
}
}
else if (ob->type == OB_ARMATURE) {
- if (!(ob->mode & OB_MODE_POSE && base == view_layer->basact)) {
+ if (!(eval_ctx->object_mode & OB_MODE_POSE && base == view_layer->basact)) {
glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f);
draw_armature(eval_ctx, scene, view_layer, v3d, ar, base, OB_WIRE, 0, ob_wire_col, true);
}
@@ -8423,11 +8446,13 @@ static void draw_rigid_body_pivot(bRigidBodyJointConstraint *data,
immUnbindProgram();
}
-void draw_object_wire_color(Scene *scene, ViewLayer *view_layer, Base *base, unsigned char r_ob_wire_col[4])
+void draw_object_wire_color(
+ const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer,
+ Base *base, unsigned char r_ob_wire_col[4])
{
Object *ob = base->object;
int colindex = 0;
- const bool is_edit = (ob->mode & OB_MODE_EDIT) != 0;
+ const bool is_edit = (eval_ctx->object_mode & OB_MODE_EDIT) != 0;
/* confusing logic here, there are 2 methods of setting the color
* 'colortab[colindex]' and 'theme_id', colindex overrides theme_id.
*
@@ -8489,10 +8514,12 @@ void draw_object_wire_color(Scene *scene, ViewLayer *view_layer, Base *base, uns
r_ob_wire_col[3] = 255;
}
-static void draw_object_matcap_check(View3D *v3d, Object *ob)
+static void draw_object_matcap_check(
+ const EvaluationContext *eval_ctx, View3D *v3d, Object *ob)
{
/* fixed rule, active object draws as matcap */
- BLI_assert((ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) == 0);
+ BLI_assert((eval_ctx->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) == 0);
+ UNUSED_VARS_NDEBUG(eval_ctx);
(void)ob;
if (v3d->defmaterial == NULL) {
@@ -8604,7 +8631,7 @@ void draw_object(
return;
}
- if (ob->mode == OB_MODE_OBJECT) {
+ if (eval_ctx->object_mode == OB_MODE_OBJECT) {
ParticleSystem *psys;
skip_object = render_override;
@@ -8644,7 +8671,7 @@ void draw_object(
/* xray delay? */
if ((dflag & DRAW_PICKING) == 0 && (base->flag_legacy & OB_FROMDUPLI) == 0 && (v3d->flag2 & V3D_RENDER_SHADOW) == 0) {
/* don't do xray in particle mode, need the z-buffer */
- if (!(ob->mode & OB_MODE_PARTICLE_EDIT)) {
+ if (!(eval_ctx->object_mode & OB_MODE_PARTICLE_EDIT)) {
/* xray and transp are set when it is drawing the 2nd/3rd pass */
if (!v3d->xray && !v3d->transp && (ob->dtx & OB_DRAWXRAY) && !(ob->dtx & OB_DRAWTRANSP)) {
ED_view3d_after_add(&v3d->afterdraw_xray, base, dflag);
@@ -8695,7 +8722,7 @@ void draw_object(
ED_view3d_project_base(ar, base);
- draw_object_wire_color(scene, view_layer, base, _ob_wire_col);
+ draw_object_wire_color(eval_ctx, scene, view_layer, base, _ob_wire_col);
ob_wire_col = _ob_wire_col;
//glColor3ubv(ob_wire_col);
@@ -8711,14 +8738,14 @@ void draw_object(
/* faceselect exception: also draw solid when (dt == wire), except in editmode */
if (is_obact) {
- if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) {
+ if (eval_ctx->object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) {
if (ob->type == OB_MESH) {
if (dt < OB_SOLID) {
zbufoff = true;
dt = OB_SOLID;
}
- if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) {
+ if (eval_ctx->object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) {
dt = OB_PAINT;
}
@@ -8734,13 +8761,13 @@ void draw_object(
(is_paint == false && is_picking == false) &&
((v3d->flag2 & V3D_RENDER_SHADOW) == 0))
{
- draw_object_matcap_check(v3d, ob);
+ draw_object_matcap_check(eval_ctx, v3d, ob);
}
/* draw-extra supported for boundbox drawmode too */
if (dt >= OB_BOUNDBOX) {
dtx = ob->dtx;
- if (ob->mode & OB_MODE_EDIT) {
+ if (eval_ctx->object_mode & OB_MODE_EDIT) {
/* the only 2 extra drawtypes alowed in editmode */
dtx = dtx & (OB_DRAWWIRE | OB_TEXSPACE);
}
@@ -8749,7 +8776,7 @@ void draw_object(
if (!skip_object) {
/* draw outline for selected objects, mesh does itself */
if ((v3d->flag & V3D_SELECT_OUTLINE) && !render_override && ob->type != OB_MESH) {
- if (dt > OB_WIRE && (ob->mode & OB_MODE_EDIT) == 0 && (dflag & DRAW_SCENESET) == 0) {
+ if (dt > OB_WIRE && (eval_ctx->object_mode & OB_MODE_EDIT) == 0 && (dflag & DRAW_SCENESET) == 0) {
if (!(ob->dtx & OB_DRAWWIRE) && (base->flag & BASE_SELECTED) && !(dflag & (DRAW_PICKING | DRAW_CONSTCOLOR))) {
draw_object_selected_outline(eval_ctx, scene, view_layer, v3d, ar, base, ob_wire_col);
}
@@ -8857,7 +8884,7 @@ void draw_object(
case OB_LATTICE:
if (!render_override) {
/* Do not allow boundbox in edit nor pose mode! */
- if ((dt == OB_BOUNDBOX) && (ob->mode & OB_MODE_EDIT))
+ if ((dt == OB_BOUNDBOX) && (eval_ctx->object_mode & OB_MODE_EDIT))
dt = OB_WIRE;
if (dt == OB_BOUNDBOX) {
draw_bounding_volume(ob, ob->boundtype, ob_wire_col);
@@ -8873,7 +8900,7 @@ void draw_object(
case OB_ARMATURE:
if (!render_override) {
/* Do not allow boundbox in edit nor pose mode! */
- if ((dt == OB_BOUNDBOX) && (ob->mode & (OB_MODE_EDIT | OB_MODE_POSE)))
+ if ((dt == OB_BOUNDBOX) && (eval_ctx->object_mode & (OB_MODE_EDIT | OB_MODE_POSE)))
dt = OB_WIRE;
if (dt == OB_BOUNDBOX) {
draw_bounding_volume(ob, ob->boundtype, ob_wire_col);
@@ -8941,7 +8968,7 @@ afterdraw:
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
/* run this so that possible child particles get cached */
- if (ob->mode & OB_MODE_PARTICLE_EDIT && is_obact) {
+ if (eval_ctx->object_mode & OB_MODE_PARTICLE_EDIT && is_obact) {
PTCacheEdit *edit = PE_create_current(eval_ctx, scene, ob);
if (edit && edit->psys == psys)
draw_update_ptcache_edit(eval_ctx, scene, view_layer, ob, edit);
@@ -8962,7 +8989,7 @@ afterdraw:
(!scene->obedit))
{
- if (ob->mode & OB_MODE_PARTICLE_EDIT && is_obact) {
+ if (eval_ctx->object_mode & OB_MODE_PARTICLE_EDIT && is_obact) {
PTCacheEdit *edit = PE_create_current(eval_ctx, scene, ob);
if (edit) {
gpuLoadMatrix(rv3d->viewmat);
@@ -9063,7 +9090,7 @@ afterdraw:
}
}
- if ((ob->gameflag & OB_BOUNDS) && (ob->mode == OB_MODE_OBJECT)) {
+ if ((ob->gameflag & OB_BOUNDS) && (eval_ctx->object_mode == OB_MODE_OBJECT)) {
if (ob->boundtype != ob->collision_boundtype || (dtx & OB_DRAWBOUNDOX) == 0) {
setlinestyle(2);
draw_bounding_volume(ob, ob->collision_boundtype, ob_wire_col);
@@ -9159,7 +9186,7 @@ afterdraw:
}
/* object centers, need to be drawn in viewmat space for speed, but OK for picking select */
- if (!is_obact || !(ob->mode & OB_MODE_ALL_PAINT)) {
+ if (!is_obact || !(eval_ctx->object_mode & OB_MODE_ALL_PAINT)) {
int do_draw_center = -1; /* defines below are zero or positive... */
if (render_override) {
@@ -9759,7 +9786,7 @@ void draw_object_backbufsel(
switch (ob->type) {
case OB_MESH:
- if (ob->mode & OB_MODE_EDIT) {
+ if (eval_ctx->object_mode & OB_MODE_EDIT) {
Mesh *me = ob->data;
BMEditMesh *em = me->edit_btmesh;
@@ -9805,7 +9832,7 @@ void draw_object_backbufsel(
Mesh *me = ob->data;
if ((me->editflag & ME_EDIT_PAINT_VERT_SEL) &&
/* currently vertex select supports weight paint and vertex paint*/
- ((ob->mode & OB_MODE_WEIGHT_PAINT) || (ob->mode & OB_MODE_VERTEX_PAINT)))
+ ((eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) || (eval_ctx->object_mode & OB_MODE_VERTEX_PAINT)))
{
bbs_mesh_solid_verts(eval_ctx, scene, ob);
}
@@ -9834,7 +9861,7 @@ static void draw_object_mesh_instance(
Mesh *me = ob->data;
DerivedMesh *dm = NULL, *edm = NULL;
- if (ob->mode & OB_MODE_EDIT) {
+ if (eval_ctx->object_mode & OB_MODE_EDIT) {
edm = editbmesh_get_derived_base(ob, me->edit_btmesh, CD_MASK_BAREMESH);
DM_update_materials(edm, ob);
}
@@ -9852,11 +9879,11 @@ static void draw_object_mesh_instance(
}
else {
if (outline)
- draw_mesh_object_outline(v3d, ob, dm ? dm : edm, ob_wire_col);
+ draw_mesh_object_outline(eval_ctx, v3d, ob, dm ? dm : edm, ob_wire_col);
if (dm) {
- bool glsl = draw_glsl_material(scene, view_layer, ob, v3d, dt);
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl, NULL);
+ bool glsl = draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt);
+ GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl, eval_ctx->object_mode, NULL);
}
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c
index 644a6956e54..b87637ef081 100644
--- a/source/blender/editors/space_view3d/view3d_buttons.c
+++ b/source/blender/editors/space_view3d/view3d_buttons.c
@@ -789,8 +789,11 @@ static int view3d_panel_vgroup_poll(const bContext *C, PanelType *UNUSED(pt))
{
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);
+
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
if (ob && (BKE_object_is_in_editmode_vgroup(ob) ||
- BKE_object_is_in_wpaint_select_vert(ob)))
+ BKE_object_is_in_wpaint_select_vert(&eval_ctx, ob)))
{
MDeformVert *dvert_act = ED_mesh_active_dvert_get_only(ob);
if (dvert_act) {
@@ -1127,6 +1130,8 @@ static int view3d_panel_transform_poll(const bContext *C, PanelType *UNUSED(pt))
static void view3d_panel_transform(const bContext *C, Panel *pa)
{
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
uiBlock *block;
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -1152,7 +1157,7 @@ static void view3d_panel_transform(const bContext *C, Panel *pa)
v3d_editvertex_buts(col, v3d, ob, lim);
}
}
- else if (ob->mode & OB_MODE_POSE) {
+ else if (eval_ctx.object_mode & OB_MODE_POSE) {
v3d_posearmature_buts(col, ob);
}
else {
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 3c4cc4d11b9..af8a3369732 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -1326,7 +1326,7 @@ float ED_view3d_grid_scale(Scene *scene, View3D *v3d, const char **grid_unit)
return v3d->grid * ED_scene_grid_scale(scene, grid_unit);
}
-static bool is_cursor_visible(Scene *scene, ViewLayer *view_layer)
+static bool is_cursor_visible(const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer)
{
if (U.app_flag & USER_APP_VIEW3D_HIDE_CURSOR) {
return false;
@@ -1335,16 +1335,16 @@ static bool is_cursor_visible(Scene *scene, ViewLayer *view_layer)
Object *ob = OBACT(view_layer);
/* don't draw cursor in paint modes, but with a few exceptions */
- if (ob && ob->mode & OB_MODE_ALL_PAINT) {
+ if (ob && eval_ctx->object_mode & OB_MODE_ALL_PAINT) {
/* exception: object is in weight paint and has deforming armature in pose mode */
- if (ob->mode & OB_MODE_WEIGHT_PAINT) {
+ if (eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) {
if (BKE_object_pose_armature_get(ob) != NULL) {
return true;
}
}
/* exception: object in texture paint mode, clone brush, use_clone_layer disabled */
- else if (ob->mode & OB_MODE_TEXTURE_PAINT) {
- const Paint *p = BKE_paint_get_active(scene, view_layer);
+ else if (eval_ctx->object_mode & OB_MODE_TEXTURE_PAINT) {
+ const Paint *p = BKE_paint_get_active(scene, view_layer, eval_ctx->object_mode);
if (p && p->brush && p->brush->imagepaint_tool == PAINT_TOOL_CLONE) {
if ((scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_LAYER_CLONE) == 0) {
@@ -1718,7 +1718,8 @@ static void draw_viewport_name(ARegion *ar, View3D *v3d, rcti *rect)
* framenum, object name, bone name (if available), marker name (if available)
*/
-static void draw_selected_name(Scene *scene, Object *ob, rcti *rect)
+static void draw_selected_name(
+ const EvaluationContext *eval_ctx, Scene *scene, Object *ob, rcti *rect)
{
const int cfra = CFRA;
const char *msg_pin = " (Pinned)";
@@ -1760,7 +1761,7 @@ static void draw_selected_name(Scene *scene, Object *ob, rcti *rect)
s += BLI_strcpy_rlen(s, arm->act_edbone->name);
}
}
- else if (ob->mode & OB_MODE_POSE) {
+ else if (eval_ctx->object_mode & OB_MODE_POSE) {
if (arm->act_bone) {
if (arm->act_bone->layer & arm->layer) {
@@ -1773,14 +1774,16 @@ static void draw_selected_name(Scene *scene, Object *ob, rcti *rect)
else if (ELEM(ob->type, OB_MESH, OB_LATTICE, OB_CURVE)) {
/* try to display active bone and active shapekey too (if they exist) */
- if (ob->type == OB_MESH && ob->mode & OB_MODE_WEIGHT_PAINT) {
+ if (ob->type == OB_MESH && eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) {
Object *armobj = BKE_object_pose_armature_get(ob);
- if (armobj && armobj->mode & OB_MODE_POSE) {
+ if (armobj) {
bArmature *arm = armobj->data;
- if (arm->act_bone) {
- if (arm->act_bone->layer & arm->layer) {
- s += BLI_strcpy_rlen(s, msg_sep);
- s += BLI_strcpy_rlen(s, arm->act_bone->name);
+ if (arm->flag & ARM_POSEMODE) {
+ if (arm->act_bone) {
+ if (arm->act_bone->layer & arm->layer) {
+ s += BLI_strcpy_rlen(s, msg_sep);
+ s += BLI_strcpy_rlen(s, arm->act_bone->name);
+ }
}
}
}
@@ -1832,6 +1835,8 @@ static void draw_selected_name(Scene *scene, Object *ob, rcti *rect)
*/
void view3d_draw_region_info(const bContext *C, ARegion *ar, const int offset)
{
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
RegionView3D *rv3d = ar->regiondata;
View3D *v3d = CTX_wm_view3d(C);
Scene *scene = CTX_data_scene(C);
@@ -1864,7 +1869,7 @@ void view3d_draw_region_info(const bContext *C, ARegion *ar, const int offset)
if (U.uiflag & USER_DRAWVIEWINFO) {
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);
- draw_selected_name(scene, ob, &rect);
+ draw_selected_name(&eval_ctx, scene, ob, &rect);
}
#if 0 /* TODO */
if (grid_unit) { /* draw below the viewport name */
@@ -1951,7 +1956,7 @@ void ED_view3d_draw_offscreen_init(const EvaluationContext *eval_ctx, Scene *sce
RenderEngineType *engine_type = eval_ctx->engine_type;
if (engine_type->flag & RE_USE_LEGACY_PIPELINE) {
/* shadow buffers, before we setup matrices */
- if (draw_glsl_material(scene, view_layer, NULL, v3d, v3d->drawtype)) {
+ if (draw_glsl_material(eval_ctx, scene, view_layer, NULL, v3d, v3d->drawtype)) {
VP_deprecated_gpu_update_lamps_shadows_world(eval_ctx, scene, v3d);
}
}
@@ -2077,7 +2082,7 @@ void ED_view3d_draw_offscreen(
}
else {
DRW_draw_render_loop_offscreen(
- depsgraph, eval_ctx->engine_type, ar, v3d, eval_ctx->object_mode,
+ eval_ctx->depsgraph, eval_ctx->engine_type, ar, v3d, eval_ctx->object_mode,
do_sky, ofs, viewport);
}
@@ -2354,9 +2359,10 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(
*
* \{ */
-void VP_legacy_drawcursor(Scene *scene, ViewLayer *view_layer, ARegion *ar, View3D *v3d)
+void VP_legacy_drawcursor(
+ const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, ARegion *ar, View3D *v3d)
{
- if (is_cursor_visible(scene, view_layer)) {
+ if (is_cursor_visible(eval_ctx, scene, view_layer)) {
drawcursor(scene, ar, v3d);
}
}
@@ -2371,9 +2377,9 @@ void VP_legacy_draw_viewport_name(ARegion *ar, View3D *v3d, rcti *rect)
draw_viewport_name(ar, v3d, rect);
}
-void VP_legacy_draw_selected_name(Scene *scene, Object *ob, rcti *rect)
+void VP_legacy_draw_selected_name(const EvaluationContext *eval_ctx, Scene *scene, Object *ob, rcti *rect)
{
- draw_selected_name(scene, ob, rect);
+ draw_selected_name(eval_ctx, scene, ob, rect);
}
void VP_legacy_drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **grid_unit)
diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c
index 7cb362ffb92..5b7f7e78310 100644
--- a/source/blender/editors/space_view3d/view3d_draw_legacy.c
+++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c
@@ -211,7 +211,9 @@ static void draw_view_icon(RegionView3D *rv3d, rcti *rect)
/* *********************** backdraw for selection *************** */
-static void backdrawview3d(const struct EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, wmWindow *win, ARegion *ar, View3D *v3d)
+static void backdrawview3d(
+ const struct EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer,
+ wmWindow *win, ARegion *ar, View3D *v3d)
{
RegionView3D *rv3d = ar->regiondata;
struct Base *base = view_layer->basact;
@@ -219,18 +221,18 @@ static void backdrawview3d(const struct EvaluationContext *eval_ctx, Scene *scen
BLI_assert(ar->regiontype == RGN_TYPE_WINDOW);
- if (base && (base->object->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT) ||
- BKE_paint_select_face_test(base->object)))
+ if (base && (eval_ctx->object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT) ||
+ BKE_paint_select_face_test(eval_ctx, base->object)))
{
/* do nothing */
}
/* texture paint mode sampling */
- else if (base && (base->object->mode & OB_MODE_TEXTURE_PAINT) &&
+ else if (base && (eval_ctx->object_mode & OB_MODE_TEXTURE_PAINT) &&
(v3d->drawtype > OB_WIRE))
{
/* do nothing */
}
- else if ((base && (base->object->mode & OB_MODE_PARTICLE_EDIT)) &&
+ else if ((base && (eval_ctx->object_mode & OB_MODE_PARTICLE_EDIT)) &&
V3D_IS_ZBUF(v3d))
{
/* do nothing */
@@ -1946,8 +1948,9 @@ static void update_lods(Scene *scene, float camera_pos[3])
}
#endif
-static void view3d_main_region_draw_objects(const bContext *C, Scene *scene, ViewLayer *view_layer, View3D *v3d,
- ARegion *ar, const char **grid_unit)
+static void view3d_main_region_draw_objects(
+ const bContext *C, Scene *scene, ViewLayer *view_layer, View3D *v3d,
+ ARegion *ar, const char **grid_unit)
{
wmWindow *win = CTX_wm_window(C);
EvaluationContext eval_ctx;
@@ -1960,7 +1963,7 @@ static void view3d_main_region_draw_objects(const bContext *C, Scene *scene, Vie
bool do_compositing = false;
/* shadow buffers, before we setup matrices */
- if (draw_glsl_material(scene, view_layer, NULL, v3d, v3d->drawtype))
+ if (draw_glsl_material(&eval_ctx, scene, view_layer, NULL, v3d, v3d->drawtype))
gpu_update_lamps_shadows_world(&eval_ctx, scene, v3d);
/* reset default OpenGL lights if needed (i.e. after preferences have been altered) */
@@ -2033,10 +2036,13 @@ static void view3d_main_region_draw_objects(const bContext *C, Scene *scene, Vie
}
}
-static void view3d_main_region_draw_info(const bContext *C, Scene *scene,
- ARegion *ar, View3D *v3d,
- const char *grid_unit, bool render_border)
+static void view3d_main_region_draw_info(
+ const bContext *C, Scene *scene,
+ ARegion *ar, View3D *v3d,
+ const char *grid_unit, bool render_border)
{
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
const Depsgraph *depsgraph = CTX_data_depsgraph(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
wmWindowManager *wm = CTX_wm_manager(C);
@@ -2059,7 +2065,7 @@ static void view3d_main_region_draw_info(const bContext *C, Scene *scene,
}
if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
- VP_legacy_drawcursor(scene, view_layer, ar, v3d); /* 3D cursor */
+ VP_legacy_drawcursor(&eval_ctx, scene, view_layer, ar, v3d); /* 3D cursor */
if (U.uiflag & USER_SHOW_ROTVIEWICON)
VP_legacy_draw_view_axis(rv3d, &rect);
@@ -2068,7 +2074,7 @@ static void view3d_main_region_draw_info(const bContext *C, Scene *scene,
if (U.uiflag & USER_DRAWVIEWINFO) {
Object *ob = OBACT(view_layer);
- VP_legacy_draw_selected_name(scene, ob, &rect);
+ VP_legacy_draw_selected_name(&eval_ctx, scene, ob, &rect);
}
}
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index ba9432b932d..6c80033f9df 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -244,21 +244,24 @@ void view3d_orbit_apply_dyn_ofs(
static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3])
{
static float lastofs[3] = {0, 0, 0};
+
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
bool is_set = false;
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob_act = OBACT(view_layer);
- if (ob_act && (ob_act->mode & OB_MODE_ALL_PAINT) &&
+ if (ob_act && (eval_ctx.object_mode & OB_MODE_ALL_PAINT) &&
/* with weight-paint + pose-mode, fall through to using calculateTransformCenter */
- ((ob_act->mode & OB_MODE_WEIGHT_PAINT) && BKE_object_pose_armature_get(ob_act)) == 0)
+ ((eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT) && BKE_object_pose_armature_get(ob_act)) == 0)
{
/* in case of sculpting use last average stroke position as a rotation
* center, in other cases it's not clear what rotation center shall be
* so just rotate around object origin
*/
- if (ob_act->mode & (OB_MODE_SCULPT | OB_MODE_TEXTURE_PAINT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) {
+ if (eval_ctx.object_mode & (OB_MODE_SCULPT | OB_MODE_TEXTURE_PAINT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) {
float stroke[3];
BKE_paint_stroke_get_average(scene, ob_act, stroke);
copy_v3_v3(lastofs, stroke);
@@ -268,7 +271,7 @@ static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3])
}
is_set = true;
}
- else if (ob_act && (ob_act->mode & OB_MODE_EDIT) && (ob_act->type == OB_FONT)) {
+ else if (ob_act && (eval_ctx.object_mode & OB_MODE_EDIT) && (ob_act->type == OB_FONT)) {
Curve *cu = ob_act->data;
EditFont *ef = cu->editfont;
int i;
@@ -283,7 +286,7 @@ static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3])
is_set = true;
}
- else if (ob_act == NULL || ob_act->mode == OB_MODE_OBJECT) {
+ else if (ob_act == NULL || eval_ctx.object_mode == OB_MODE_OBJECT) {
/* object mode use boundbox centers */
Base *base;
unsigned int tot = 0;
@@ -2792,6 +2795,8 @@ void VIEW3D_OT_view_all(wmOperatorType *ot)
/* like a localview without local!, was centerview() in 2.4x */
static int viewselected_exec(bContext *C, wmOperator *op)
{
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
ARegion *ar = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
Scene *scene = CTX_data_scene(C);
@@ -2815,15 +2820,18 @@ static int viewselected_exec(bContext *C, wmOperator *op)
ob = NULL;
}
- if (ob && (ob->mode & OB_MODE_WEIGHT_PAINT)) {
+ if (ob && (eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT)) {
/* hard-coded exception, we look for the one selected armature */
/* this is weak code this way, we should make a generic active/selection callback interface once... */
Base *base;
for (base = view_layer->object_bases.first; base; base = base->next) {
if (TESTBASELIB(base)) {
- if (base->object->type == OB_ARMATURE)
- if (base->object->mode & OB_MODE_POSE)
+ if (base->object->type == OB_ARMATURE) {
+ const bArmature *arm = base->object->data;
+ if (arm->flag & ARM_POSEMODE) {
break;
+ }
+ }
}
}
if (base)
@@ -2849,17 +2857,17 @@ static int viewselected_exec(bContext *C, wmOperator *op)
else if (obedit) {
ok = ED_view3d_minmax_verts(obedit, min, max); /* only selected */
}
- else if (ob && (ob->mode & OB_MODE_POSE)) {
+ else if (ob && (eval_ctx.object_mode & OB_MODE_POSE)) {
ok = BKE_pose_minmax(ob, min, max, true, true);
}
- else if (BKE_paint_select_face_test(ob)) {
+ else if (BKE_paint_select_face_test(&eval_ctx, ob)) {
ok = paintface_minmax(ob, min, max);
}
- else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT)) {
+ else if (ob && (eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT)) {
ok = PE_minmax(scene, view_layer, min, max);
}
else if (ob &&
- (ob->mode & (OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)))
+ (eval_ctx.object_mode & (OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)))
{
BKE_paint_stroke_get_average(scene, ob, min);
copy_v3_v3(max, min);
@@ -2966,13 +2974,15 @@ static int view_lock_to_active_exec(bContext *C, wmOperator *UNUSED(op))
Object *obact = CTX_data_active_object(C);
if (v3d) {
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
ED_view3d_lock_clear(v3d);
v3d->ob_centre = obact; /* can be NULL */
if (obact && obact->type == OB_ARMATURE) {
- if (obact->mode & OB_MODE_POSE) {
+ if (eval_ctx.object_mode & OB_MODE_POSE) {
bPoseChannel *pcham_act = BKE_pose_channel_active(obact);
if (pcham_act) {
BLI_strncpy(v3d->ob_centre_bone, pcham_act->name, sizeof(v3d->ob_centre_bone));
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index 5e34bc188f0..16731336d00 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -54,6 +54,7 @@ struct wmKeyConfig;
struct wmManipulatorGroupType;
struct wmManipulatorType;
struct wmWindowManager;
+struct EvaluationContext;
/* drawing flags: */
enum {
@@ -154,13 +155,19 @@ void draw_object_select(
const struct EvaluationContext *eval_ctx, Scene *scene, struct ViewLayer *view_layer, struct ARegion *ar, View3D *v3d,
Base *base, const short dflag);
-void draw_mesh_object_outline(View3D *v3d, struct Object *ob, struct DerivedMesh *dm, const unsigned char ob_wire_col[4]);
+void draw_mesh_object_outline(
+ const struct EvaluationContext *eval_ctx, View3D *v3d,
+ struct Object *ob, struct DerivedMesh *dm, const unsigned char ob_wire_col[4]);
-bool draw_glsl_material(Scene *scene, struct ViewLayer *view_layer, struct Object *ob, View3D *v3d, const char dt);
+bool draw_glsl_material(
+ const struct EvaluationContext *eval_ctx, Scene *scene, struct ViewLayer *view_layer,
+ struct Object *ob, View3D *v3d, const char dt);
void draw_object_instance(const struct EvaluationContext *eval_ctx, Scene *scene, struct ViewLayer *view_layer, View3D *v3d, RegionView3D *rv3d, struct Object *ob, const char dt, int outline, const float wire_col[4]);
void draw_object_backbufsel(const struct EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, RegionView3D *rv3d, struct Object *ob);
-void draw_object_wire_color(Scene *scene, struct ViewLayer *, Base *base, unsigned char r_ob_wire_col[4]);
+void draw_object_wire_color(
+ const struct EvaluationContext *eval_ctx, Scene *scene, struct ViewLayer *,
+ Base *base, unsigned char r_ob_wire_col[4]);
void drawaxes(const float viewmat_local[4][4], float size, char drawtype, const unsigned char color[4]);
void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base,
const char dt, const short dflag, const unsigned char ob_wire_col[4],
@@ -209,8 +216,10 @@ void draw_mesh_paint_vcolor_faces(struct DerivedMesh *dm, const bool use_light,
void draw_mesh_paint_weight_edges(RegionView3D *rv3d, struct DerivedMesh *dm,
const bool use_depth, const bool use_alpha,
void *edgemask_cb, void *user_data);
-void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d,
- struct Object *ob, struct DerivedMesh *dm, const int draw_flags);
+void draw_mesh_paint(
+ const struct EvaluationContext *eval_ctx,
+ View3D *v3d, RegionView3D *rv3d,
+ struct Object *ob, struct DerivedMesh *dm, const int draw_flags);
/* drawsimdebug.c */
void draw_sim_debug_data(Scene *scene, View3D *v3d, ARegion *ar);
@@ -367,10 +376,13 @@ extern bool view3d_camera_border_hack_test;
#endif
/* temporary for legacy viewport to work */
-void VP_legacy_drawcursor(Scene *scene, struct ViewLayer *view_layer, ARegion *ar, View3D *v3d);
+void VP_legacy_drawcursor(
+ const struct EvaluationContext *eval_ctx, Scene *scene,
+ struct ViewLayer *view_layer, ARegion *ar, View3D *v3d);
void VP_legacy_draw_view_axis(RegionView3D *rv3d, rcti *rect);
void VP_legacy_draw_viewport_name(ARegion *ar, View3D *v3d, rcti *rect);
-void VP_legacy_draw_selected_name(Scene *scene, struct Object *ob, rcti *rect);
+void VP_legacy_draw_selected_name(
+ const struct EvaluationContext *eval_ctx, Scene *scene, struct Object *ob, rcti *rect);
void VP_legacy_drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **grid_unit);
void VP_legacy_drawfloor(Scene *scene, View3D *v3d, const char **grid_unit, bool write_depth);
void VP_legacy_view3d_main_region_setup_view(const struct EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, ARegion *ar, float viewmat[4][4], float winmat[4][4]);
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 28e15b3bfee..ce3c30d50e0 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -209,6 +209,7 @@ static void edbm_backbuf_check_and_select_tfaces(Mesh *me, const bool select)
/* *********************** GESTURE AND LASSO ******************* */
typedef struct LassoSelectUserData {
+ const EvaluationContext *eval_ctx;
ViewContext *vc;
const rcti *rect;
const rctf *rect_fl;
@@ -251,14 +252,16 @@ static int view3d_selectable_data(bContext *C)
return 0;
if (ob) {
- if (ob->mode & OB_MODE_EDIT) {
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+ if (eval_ctx.object_mode & OB_MODE_EDIT) {
if (ob->type == OB_FONT) {
return 0;
}
}
else {
- if ((ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) &&
- !BKE_paint_select_elem_test(ob))
+ if ((eval_ctx.object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) &&
+ !BKE_paint_select_elem_test(&eval_ctx, ob))
{
return 0;
}
@@ -387,8 +390,10 @@ static void object_deselect_all_visible(ViewLayer *view_layer)
}
}
-static void do_lasso_select_objects(ViewContext *vc, const int mcords[][2], const short moves,
- const bool extend, const bool select)
+static void do_lasso_select_objects(
+ const EvaluationContext *eval_ctx,
+ ViewContext *vc, const int mcords[][2], const short moves,
+ const bool extend, const bool select)
{
Base *base;
@@ -403,7 +408,7 @@ static void do_lasso_select_objects(ViewContext *vc, const int mcords[][2], cons
ED_object_base_select(base, select ? BA_SELECT : BA_DESELECT);
}
}
- if (vc->obact == base->object && (base->object->mode & OB_MODE_POSE)) {
+ if (vc->obact == base->object && (eval_ctx->object_mode & OB_MODE_POSE)) {
do_lasso_select_pose(vc, base->object, mcords, moves, select);
}
}
@@ -810,20 +815,20 @@ static void view3d_lasso_select(bContext *C, ViewContext *vc,
CTX_data_eval_ctx(C, &eval_ctx);
if (vc->obedit == NULL) { /* Object Mode */
- if (BKE_paint_select_face_test(ob)) {
+ if (BKE_paint_select_face_test(&eval_ctx, ob)) {
do_lasso_select_paintface(&eval_ctx, vc, mcords, moves, extend, select);
}
- else if (BKE_paint_select_vert_test(ob)) {
+ else if (BKE_paint_select_vert_test(&eval_ctx, ob)) {
do_lasso_select_paintvert(&eval_ctx, vc, mcords, moves, extend, select);
}
- else if (ob && (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) {
+ else if (ob && (eval_ctx.object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) {
/* pass */
}
- else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT)) {
+ else if (ob && (eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT)) {
PE_lasso_select(C, mcords, moves, extend, select);
}
else {
- do_lasso_select_objects(vc, mcords, moves, extend, select);
+ do_lasso_select_objects(&eval_ctx, vc, mcords, moves, extend, select);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, vc->scene);
}
}
@@ -1544,7 +1549,10 @@ static bool ed_object_select_pick(
}
}
}
- else if (ED_do_pose_selectbuffer(scene, view_layer, basact, buffer, hits, extend, deselect, toggle, do_nearest)) {
+ else if (ED_do_pose_selectbuffer(
+ &eval_ctx, scene, view_layer,
+ basact, buffer, hits, extend, deselect, toggle, do_nearest))
+ {
/* then bone is found */
/* we make the armature selected:
@@ -1557,7 +1565,7 @@ static bool ed_object_select_pick(
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, basact->object);
/* in weightpaint, we use selected bone to select vertexgroup, so no switch to new active object */
- if (BASACT(view_layer) && (BASACT(view_layer)->object->mode & OB_MODE_WEIGHT_PAINT)) {
+ if (BASACT(view_layer) && (eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT)) {
/* prevent activating */
basact = NULL;
}
@@ -2050,7 +2058,7 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b
CTX_data_eval_ctx(C, &eval_ctx);
- if ((ob) && (ob->mode & OB_MODE_POSE))
+ if ((ob) && (eval_ctx.object_mode & OB_MODE_POSE))
bone_only = 1;
else
bone_only = 0;
@@ -2205,16 +2213,16 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
}
}
else { /* no editmode, unified for bones and objects */
- if (vc.obact && vc.obact->mode & OB_MODE_SCULPT) {
+ if (vc.obact && eval_ctx.object_mode & OB_MODE_SCULPT) {
ret = ED_sculpt_mask_box_select(C, &vc, &rect, select, extend);
}
- else if (vc.obact && BKE_paint_select_face_test(vc.obact)) {
+ else if (vc.obact && BKE_paint_select_face_test(&eval_ctx, vc.obact)) {
ret = do_paintface_box_select(&eval_ctx, &vc, &rect, select, extend);
}
- else if (vc.obact && BKE_paint_select_vert_test(vc.obact)) {
+ else if (vc.obact && BKE_paint_select_vert_test(&eval_ctx, vc.obact)) {
ret = do_paintvert_box_select(&eval_ctx, &vc, &rect, select, extend);
}
- else if (vc.obact && vc.obact->mode & OB_MODE_PARTICLE_EDIT) {
+ else if (vc.obact && eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT) {
ret = PE_border_select(C, &rect, select, extend);
}
else { /* object mode with none active */
@@ -2300,6 +2308,8 @@ static bool ed_wpaint_vertex_select_pick(
static int view3d_select_exec(bContext *C, wmOperator *op)
{
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
Object *obedit = CTX_data_edit_object(C);
Object *obact = CTX_data_active_object(C);
bool extend = RNA_boolean_get(op->ptr, "extend");
@@ -2311,9 +2321,9 @@ static int view3d_select_exec(bContext *C, wmOperator *op)
* or paint-select to allow pose bone select with vert/face select */
bool object = (RNA_boolean_get(op->ptr, "object") &&
(obedit ||
- BKE_paint_select_elem_test(obact) ||
+ BKE_paint_select_elem_test(&eval_ctx, obact) ||
/* so its possible to select bones in weightpaint mode (LMB select) */
- (obact && (obact->mode & OB_MODE_WEIGHT_PAINT) && BKE_object_pose_armature_get(obact))));
+ (obact && (eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT) && BKE_object_pose_armature_get(obact))));
bool retval = false;
int location[2];
@@ -2347,11 +2357,11 @@ static int view3d_select_exec(bContext *C, wmOperator *op)
retval = ED_curve_editfont_select_pick(C, location, extend, deselect, toggle);
}
- else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT)
+ else if (obact && eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT)
return PE_mouse_particles(C, location, extend, deselect, toggle);
- else if (obact && BKE_paint_select_face_test(obact))
+ else if (obact && BKE_paint_select_face_test(&eval_ctx, obact))
retval = paintface_mouse_select(C, obact, location, extend, deselect, toggle);
- else if (BKE_paint_select_vert_test(obact))
+ else if (BKE_paint_select_vert_test(&eval_ctx, obact))
retval = ed_wpaint_vertex_select_pick(C, location, extend, deselect, toggle, obact);
else
retval = ed_object_select_pick(C, location, extend, deselect, toggle, center, enumerate, object);
@@ -2856,6 +2866,8 @@ static bool object_circle_select(ViewContext *vc, const bool select, const int m
/* not a real operator, only for circle test */
static int view3d_circle_select_exec(bContext *C, wmOperator *op)
{
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
Scene *scene = CTX_data_scene(C);
Object *obact = CTX_data_active_object(C);
const int radius = RNA_int_get(op->ptr, "radius");
@@ -2863,35 +2875,33 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op)
const int mval[2] = {RNA_int_get(op->ptr, "x"),
RNA_int_get(op->ptr, "y")};
- if (CTX_data_edit_object(C) || BKE_paint_select_elem_test(obact) ||
- (obact && (obact->mode & (OB_MODE_PARTICLE_EDIT | OB_MODE_POSE))) )
+ if (CTX_data_edit_object(C) || BKE_paint_select_elem_test(&eval_ctx, obact) ||
+ (obact && (eval_ctx.object_mode & (OB_MODE_PARTICLE_EDIT | OB_MODE_POSE))) )
{
- EvaluationContext eval_ctx;
ViewContext vc;
-
+
view3d_operator_needs_opengl(C);
-
- CTX_data_eval_ctx(C, &eval_ctx);
+
view3d_set_viewcontext(C, &vc);
if (CTX_data_edit_object(C)) {
obedit_circle_select(&eval_ctx, &vc, select, mval, (float)radius);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data);
}
- else if (BKE_paint_select_face_test(obact)) {
+ else if (BKE_paint_select_face_test(&eval_ctx, obact)) {
paint_facesel_circle_select(&eval_ctx, &vc, select, mval, (float)radius);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data);
}
- else if (BKE_paint_select_vert_test(obact)) {
+ else if (BKE_paint_select_vert_test(&eval_ctx, obact)) {
paint_vertsel_circle_select(&eval_ctx, &vc, select, mval, (float)radius);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data);
}
- else if (obact->mode & OB_MODE_POSE)
+ else if (eval_ctx.object_mode & OB_MODE_POSE)
pose_circle_select(&vc, select, mval, (float)radius);
else
return PE_circle_select(C, select, mval, (float)radius);
}
- else if (obact && obact->mode & OB_MODE_SCULPT) {
+ else if (obact && eval_ctx.object_mode & OB_MODE_SCULPT) {
return OPERATOR_CANCELLED;
}
else {
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index bd4acbe72cf..d6f2d426d6a 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -1819,7 +1819,7 @@ bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3])
}
}
else if (t->options & CTX_PAINT_CURVE) {
- Paint *p = BKE_paint_get_active(t->scene, t->view_layer);
+ Paint *p = BKE_paint_get_active(t->scene, t->view_layer, t->eval_ctx.object_mode);
Brush *br = p->brush;
PaintCurve *pc = br->paint_curve;
copy_v3_v3(r_center, pc->points[pc->add_index - 1].bez.vec[1]);
diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h
index 8d29632fc71..8ed0c6ec13f 100644
--- a/source/blender/gpu/GPU_draw.h
+++ b/source/blender/gpu/GPU_draw.h
@@ -46,6 +46,7 @@ struct View3D;
struct RegionView3D;
struct SmokeModifierData;
struct DupliObject;
+struct EvaluationContext;
/* OpenGL drawing functions related to shading. These are also
* shared with the game engine, where there were previously
@@ -73,9 +74,10 @@ void GPU_disable_program_point_size(void);
* GPU_object_material_bind returns 0 if drawing should be skipped
* - after drawing, the material must be disabled again */
-void GPU_begin_object_materials(struct View3D *v3d, struct RegionView3D *rv3d,
- struct Scene *scene, struct ViewLayer *view_layer,
- struct Object *ob, bool glsl, bool *do_alpha_after);
+void GPU_begin_object_materials(
+ struct View3D *v3d, struct RegionView3D *rv3d,
+ struct Scene *scene, struct ViewLayer *view_layer,
+ struct Object *ob, bool glsl, const short object_mode, bool *do_alpha_after);
void GPU_end_object_materials(void);
bool GPU_object_materials_check(void);
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index f9cf3235ac1..301527d8fc5 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -1460,6 +1460,7 @@ static struct GPUMaterialState {
Material *gmatbuf_fixed[FIXEDMAT];
Material *gboundmat;
Object *gob;
+ short gob_object_mode;
DupliObject *dob;
Scene *gscene;
int glay;
@@ -1554,7 +1555,7 @@ void GPU_end_dupli_object(void)
void GPU_begin_object_materials(
View3D *v3d, RegionView3D *rv3d, Scene *scene, ViewLayer *view_layer, Object *ob,
- bool glsl, bool *do_alpha_after)
+ bool glsl, const short object_mode, bool *do_alpha_after)
{
Material *ma;
GPUMaterial *gpumat;
@@ -1592,7 +1593,7 @@ void GPU_begin_object_materials(
#ifdef WITH_GAMEENGINE
if (rv3d->rflag & RV3D_IS_GAME_ENGINE) {
- ob = BKE_object_lod_matob_get(ob, view_layer);
+ ob = BKE_object_lod_matob_get(ob, view_layer, object_mode);
}
#else
UNUSED_VARS(view_layer);
@@ -1616,6 +1617,7 @@ void GPU_begin_object_materials(
GMS.two_sided_lighting = (((Mesh *)ob->data)->flag & ME_TWOSIDED) != 0;
GMS.gob = ob;
+ GMS.gob_object_mode = object_mode;
GMS.gscene = scene;
GMS.is_opensubdiv = use_opensubdiv;
GMS.totmat = use_matcap ? 1 : ob->totcol + 1; /* materials start from 1, default material is 0 */
@@ -1834,7 +1836,7 @@ int GPU_object_material_bind(int nr, void *attribs)
}
GPU_material_bind(
- gpumat, GMS.gob->lay, GMS.glay, 1.0, !(GMS.gob->mode & OB_MODE_TEXTURE_PAINT),
+ gpumat, GMS.gob->lay, GMS.glay, 1.0, !(GMS.gob_object_mode & OB_MODE_TEXTURE_PAINT),
GMS.gviewmat, GMS.gviewinv, GMS.gviewcamtexcofac);
auto_bump_scale = GMS.gob->derivedFinal != NULL ? GMS.gob->derivedFinal->auto_bump_scale : 1.0f;
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 51efb5fa6ef..c2bf62da043 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -1703,9 +1703,11 @@ static KeyingSet *rna_Scene_keying_set_new(Scene *sce, ReportList *reports, cons
static void rna_UnifiedPaintSettings_update(bContext *C, PointerRNA *UNUSED(ptr))
{
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- Brush *br = BKE_paint_brush(BKE_paint_get_active(scene, view_layer));
+ Brush *br = BKE_paint_brush(BKE_paint_get_active(scene, view_layer, eval_ctx.object_mode));
WM_main_add_notifier(NC_BRUSH | NA_EDITED, br);
}
diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c
index 7d8bf4949d5..f99803a1d99 100644
--- a/source/blender/makesrna/intern/rna_scene_api.c
+++ b/source/blender/makesrna/intern/rna_scene_api.c
@@ -117,9 +117,9 @@ static void rna_Scene_frame_set(Scene *scene, Main *bmain, int frame, float subf
static void rna_Scene_uvedit_aspect(Scene *scene, Object *ob, float *aspect)
{
- if ((ob->type == OB_MESH) && (ob->mode == OB_MODE_EDIT)) {
- BMEditMesh *em;
- em = BKE_editmesh_from_object(ob);
+ if (ob->type == OB_MESH) {
+ /* Will be NULL when not in editmode */
+ BMEditMesh *em = BKE_editmesh_from_object(ob);
if (EDBM_uv_check(em)) {
ED_uvedit_get_aspect(scene, ob, em->bm, aspect, aspect + 1);
return;
diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c
index a09923d6dfe..8fd510a6662 100644
--- a/source/blender/modifiers/intern/MOD_subsurf.c
+++ b/source/blender/modifiers/intern/MOD_subsurf.c
@@ -117,7 +117,7 @@ static DerivedMesh *applyModifier(ModifierData *md, const EvaluationContext *eva
subsurf_flags |= SUBSURF_USE_RENDER_PARAMS;
if (isFinalCalc)
subsurf_flags |= SUBSURF_IS_FINAL_CALC;
- if (ob->mode & OB_MODE_EDIT)
+ if (eval_ctx->object_mode & OB_MODE_EDIT)
subsurf_flags |= SUBSURF_IN_EDIT_MODE;
#ifdef WITH_OPENSUBDIV
@@ -132,7 +132,7 @@ static DerivedMesh *applyModifier(ModifierData *md, const EvaluationContext *eva
if (U.opensubdiv_compute_type == USER_OPENSUBDIV_COMPUTE_NONE) {
modifier_setError(md, "OpenSubdiv is disabled in User Preferences");
}
- else if ((ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) != 0) {
+ else if ((eval_ctx->object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) != 0) {
modifier_setError(md, "OpenSubdiv is not supported in paint modes");
}
else if ((DEG_get_eval_flags_for_id(eval_ctx->depsgraph, &ob->id) & DAG_EVAL_NEED_CPU) == 0) {
@@ -143,6 +143,8 @@ static DerivedMesh *applyModifier(ModifierData *md, const EvaluationContext *eva
modifier_setError(md, "OpenSubdiv is disabled due to dependencies");
}
}
+#else
+ UNUSED_VARS(ob);
#endif
result = subsurf_make_derived_from_derived(derivedData, smd, NULL, subsurf_flags);