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
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/blender/blenkernel/intern/paint.c
parentef11113399e3273ee647b3710b346356a2b5f8f0 (diff)
Object Mode: Use eval_ctx mode for drawing, paint & modifiers
Diffstat (limited to 'source/blender/blenkernel/intern/paint.c')
-rw-r--r--source/blender/blenkernel/intern/paint.c40
1 files changed, 24 insertions, 16 deletions
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);