Merge branch 'master' into blender2.8
[blender.git] / source / blender / blenkernel / intern / paint.c
index 5a267f97d03086a2d1249e63f10c9ecf68ad4153..81943d470dc3d1a956da7255608174dd95df342a 100644 (file)
@@ -41,6 +41,7 @@
 #include "DNA_scene_types.h"
 #include "DNA_brush_types.h"
 #include "DNA_space_types.h"
+#include "DNA_workspace_types.h"
 
 #include "BLI_bitmap.h"
 #include "BLI_utildefines.h"
@@ -235,9 +236,7 @@ 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);
-
+               const WorkSpace *workspace = CTX_wm_workspace(C);
                ToolSettings *ts = sce->toolsettings;
                Object *obact = NULL;
 
@@ -245,7 +244,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 && eval_ctx.object_mode == OB_MODE_EDIT) {
+                       if (obact && workspace->object_mode == OB_MODE_EDIT) {
                                if (sima->mode == SI_MODE_PAINT)
                                        return &ts->imapaint.paint;
                                else if (ts->use_uv_sculpt)
@@ -256,7 +255,7 @@ Paint *BKE_paint_get_active_from_context(const bContext *C)
                        }
                }
                else if (obact) {
-                       switch (eval_ctx.object_mode) {
+                       switch (workspace->object_mode) {
                                case OB_MODE_SCULPT:
                                        return &ts->sculpt->paint;
                                case OB_MODE_VERTEX_PAINT:
@@ -289,9 +288,7 @@ 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);
-
+               const WorkSpace *workspace = CTX_wm_workspace(C);
                ToolSettings *ts = sce->toolsettings;
                Object *obact = NULL;
 
@@ -299,7 +296,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 && eval_ctx.object_mode == OB_MODE_EDIT) {
+                       if (obact && workspace->object_mode == OB_MODE_EDIT) {
                                if (sima->mode == SI_MODE_PAINT)
                                        return ePaintTexture2D;
                                else if (ts->use_uv_sculpt)
@@ -310,7 +307,7 @@ ePaintMode BKE_paintmode_get_active_from_context(const bContext *C)
                        }
                }
                else if (obact) {
-                       switch (eval_ctx.object_mode) {
+                       switch (workspace->object_mode) {
                                case OB_MODE_SCULPT:
                                        return ePaintSculpt;
                                case OB_MODE_VERTEX_PAINT:
@@ -501,24 +498,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(const EvaluationContext *eval_ctx, Object *ob)
+bool BKE_paint_select_face_test(Object *ob, eObjectMode object_mode)
 {
        return ( (ob != NULL) &&
                 (ob->type == OB_MESH) &&
                 (ob->data != NULL) &&
                 (((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_FACE_SEL) &&
-                (eval_ctx->object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))
+                (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(const EvaluationContext *eval_ctx, Object *ob)
+bool BKE_paint_select_vert_test(Object *ob, eObjectMode object_mode)
 {
        return ( (ob != NULL) &&
                 (ob->type == OB_MESH) &&
                 (ob->data != NULL) &&
                 (((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_VERT_SEL) &&
-                (eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT || eval_ctx->object_mode & OB_MODE_VERTEX_PAINT)
+                (object_mode & OB_MODE_WEIGHT_PAINT || object_mode & OB_MODE_VERTEX_PAINT)
                 );
 }
 
@@ -526,10 +523,10 @@ bool BKE_paint_select_vert_test(const EvaluationContext *eval_ctx, 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(const EvaluationContext *eval_ctx, Object *ob)
+bool BKE_paint_select_elem_test(Object *ob, eObjectMode object_mode)
 {
-       return (BKE_paint_select_vert_test(eval_ctx, ob) ||
-               BKE_paint_select_face_test(eval_ctx, ob));
+       return (BKE_paint_select_vert_test(ob, object_mode) ||
+               BKE_paint_select_face_test(ob, object_mode));
 }
 
 void BKE_paint_cavity_curve_preset(Paint *p, int preset)