Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / sculpt_paint / paint_utils.c
index 10628d8cccbba51e5224e6db6fa2bd91899a115f..21756fc435d5a9b2e27b3f42e0394ab907d5b83d 100644 (file)
@@ -59,8 +59,7 @@
 #include "RNA_access.h"
 #include "RNA_define.h"
 
-#include "BIF_gl.h"
-#include "BIF_glutil.h"
+#include "GPU_matrix.h"
 
 #include "IMB_colormanagement.h"
 #include "IMB_imbuf_types.h"
@@ -130,17 +129,12 @@ bool paint_convert_bb_to_rect(rcti *rect,
  * 2D screens-space bounding box into four 3D planes) */
 void paint_calc_redraw_planes(float planes[4][4],
                               const ARegion *ar,
-                              RegionView3D *rv3d,
                               Object *ob,
                               const rcti *screen_rect)
 {
        BoundBox bb;
-       bglMats mats;
        rcti rect;
 
-       memset(&bb, 0, sizeof(BoundBox));
-       view3d_get_transformation(ar, rv3d, ob, &mats);
-
        /* use some extra space just in case */
        rect = *screen_rect;
        rect.xmin -= 2;
@@ -148,7 +142,7 @@ void paint_calc_redraw_planes(float planes[4][4],
        rect.ymin -= 2;
        rect.ymax += 2;
 
-       ED_view3d_clipping_calc(&bb, planes, &mats, &rect);
+       ED_view3d_clipping_calc(&bb, planes, ar, ob, &rect);
        negate_m4(planes);
 }
 
@@ -290,8 +284,8 @@ static void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, c
 
        /* get the needed opengl matrices */
        glGetIntegerv(GL_VIEWPORT, view);
-       glGetFloatv(GL_MODELVIEW_MATRIX,  (float *)matrix);
-       glGetFloatv(GL_PROJECTION_MATRIX, (float *)proj);
+       gpuGetModelViewMatrix(matrix);
+       gpuGetProjectionMatrix(proj);
        view[0] = view[1] = 0;
        mul_m4_m4m4(matrix, matrix, ob->obmat);
        mul_m4_m4m4(matrix, proj, matrix);
@@ -447,7 +441,8 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr
 
        if (CTX_wm_view3d(C) && texpaint_proj) {
                /* first try getting a colour directly from the mesh faces if possible */
-               Object *ob = OBACT;
+               SceneLayer *sl = CTX_data_scene_layer(C);
+               Object *ob = OBACT_NEW;
                bool sample_success = false;
                ImagePaintSettings *imapaint = &scene->toolsettings->imapaint;
                bool use_material = (imapaint->mode == IMAGEPAINT_MODE_MATERIAL);
@@ -561,8 +556,9 @@ static int brush_curve_preset_exec(bContext *C, wmOperator *op)
 
        if (br) {
                Scene *scene = CTX_data_scene(C);
+               SceneLayer *sl = CTX_data_scene_layer(C);
                BKE_brush_curve_preset(br, RNA_enum_get(op->ptr, "shape"));
-               BKE_paint_invalidate_cursor_overlay(scene, br->curve);
+               BKE_paint_invalidate_cursor_overlay(scene, sl, br->curve);
        }
 
        return OPERATOR_FINISHED;