Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / sculpt_paint / paint_image_proj.c
index b43581170d0fc6fd31ddd5dd02d4a8620208d4ce..eeb357d43e725b01fd5521475178e70ea7b13712 100644 (file)
@@ -64,7 +64,6 @@
 #include "BKE_camera.h"
 #include "BKE_context.h"
 #include "BKE_colortools.h"
-#include "BKE_depsgraph.h"
 #include "BKE_DerivedMesh.h"
 #include "BKE_idprop.h"
 #include "BKE_brush.h"
@@ -80,6 +79,8 @@
 #include "BKE_scene.h"
 #include "BKE_texture.h"
 
+#include "DEG_depsgraph.h"
+
 #include "UI_interface.h"
 
 #include "ED_mesh.h"
@@ -3487,7 +3488,7 @@ static void proj_paint_layer_clone_init(
 
        /* use clone mtface? */
        if (ps->do_layer_clone) {
-               const int layer_num = CustomData_get_clone_layer(&((Mesh *)ps->ob->data)->pdata, CD_MTEXPOLY);
+               const int layer_num = CustomData_get_clone_layer(&((Mesh *)ps->ob->data)->ldata, CD_MLOOPUV);
 
                ps->dm_mloopuv_clone = MEM_mallocN(ps->dm_totpoly * sizeof(MLoopUV *), "proj_paint_mtfaces");
 
@@ -3850,7 +3851,7 @@ static void project_paint_begin(
 
        if (ps->do_layer_stencil || ps->do_stencil_brush) {
                //int layer_num = CustomData_get_stencil_layer(&ps->dm->loopData, CD_MLOOPUV);
-               int layer_num = CustomData_get_stencil_layer(&((Mesh *)ps->ob->data)->pdata, CD_MTEXPOLY);
+               int layer_num = CustomData_get_stencil_layer(&((Mesh *)ps->ob->data)->ldata, CD_MLOOPUV);
                if (layer_num != -1)
                        ps->dm_mloopuv_stencil = CustomData_get_layer_n(&ps->dm->loopData, CD_MLOOPUV, layer_num);
 
@@ -3938,7 +3939,7 @@ static void project_paint_end(ProjPaintState *ps)
                ProjPaintImage *projIma;
                for (a = 0, projIma = ps->projImages; a < ps->image_tot; a++, projIma++) {
                        BKE_image_release_ibuf(projIma->ima, projIma->ibuf, NULL);
-                       DAG_id_tag_update(&projIma->ima->id, 0);
+                       DEG_id_tag_update(&projIma->ima->id, 0);
                }
        }
 
@@ -5021,6 +5022,7 @@ void paint_proj_stroke(
        /* clone gets special treatment here to avoid going through image initialization */
        if (ps_handle->is_clone_cursor_pick) {
                Scene *scene = ps_handle->scene;
+               struct Depsgraph *graph = CTX_data_depsgraph(C);
                View3D *v3d = CTX_wm_view3d(C);
                ARegion *ar = CTX_wm_region(C);
                float *cursor = ED_view3d_cursor3d_get(scene, v3d);
@@ -5028,8 +5030,9 @@ void paint_proj_stroke(
 
                view3d_operator_needs_opengl(C);
 
-               if (!ED_view3d_autodist(scene, ar, v3d, mval_i, cursor, false, NULL))
+               if (!ED_view3d_autodist(graph, ar, v3d, mval_i, cursor, false, NULL)) {
                        return;
+               }
 
                ED_region_tag_redraw(ar);
 
@@ -5207,7 +5210,7 @@ void *paint_proj_new_stroke(bContext *C, Object *ob, const float mouse[2], int m
 
                project_state_init(C, ob, ps, mode);
 
-               if (ps->ob == NULL || !(ps->ob->lay & ps->v3d->lay)) {
+               if (ps->ob == NULL) {
                        ps_handle->ps_views_tot = i + 1;
                        goto fail;
                }
@@ -5309,11 +5312,12 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op)
 {
        Image *image = BLI_findlink(&CTX_data_main(C)->image, RNA_enum_get(op->ptr, "image"));
        Scene *scene = CTX_data_scene(C);
+       SceneLayer *sl = CTX_data_scene_layer(C);
        ProjPaintState ps = {NULL};
        int orig_brush_size;
        IDProperty *idgroup;
        IDProperty *view_data = NULL;
-       Object *ob = OBACT;
+       Object *ob = OBACT_NEW;
        bool uvs, mat, tex;
 
        if (ob == NULL || ob->type != OB_MESH) {
@@ -5442,6 +5446,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
        char filename[FILE_MAX];
 
        Scene *scene = CTX_data_scene(C);
+       SceneLayer *sl = CTX_data_scene_layer(C);
        ToolSettings *settings = scene->toolsettings;
        int w = settings->imapaint.screen_grab_size[0];
        int h = settings->imapaint.screen_grab_size[1];
@@ -5456,7 +5461,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
        if (h > maxsize) h = maxsize;
 
        ibuf = ED_view3d_draw_offscreen_imbuf(
-               scene, CTX_wm_view3d(C), CTX_wm_region(C),
+               scene, sl, CTX_wm_view3d(C), CTX_wm_region(C),
                w, h, IB_rect, false, R_ALPHAPREMUL, 0, false, NULL,
                NULL, NULL, err_out);
        if (!ibuf) {
@@ -5590,7 +5595,7 @@ bool BKE_paint_proj_mesh_data_check(Scene *scene, Object *ob, bool *uvs, bool *m
        }
        
        me = BKE_mesh_from_object(ob);
-       layernum = CustomData_number_of_layers(&me->pdata, CD_MTEXPOLY);
+       layernum = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
 
        if (layernum == 0) {
                hasuvs = false;
@@ -5739,7 +5744,7 @@ static bool proj_paint_add_slot(bContext *C, wmOperator *op)
                        BKE_texpaint_slot_refresh_cache(scene, ma);
                        BKE_image_signal(ima, NULL, IMA_SIGNAL_USER_NEW_IMAGE);
                        WM_event_add_notifier(C, NC_IMAGE | NA_ADDED, ima);
-                       DAG_id_tag_update(&ma->id, 0);
+                       DEG_id_tag_update(&ma->id, 0);
                        ED_area_tag_redraw(CTX_wm_area(C));
                        
                        BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
@@ -5855,7 +5860,7 @@ static int texture_paint_delete_texture_paint_slot_exec(bContext *C, wmOperator
        ma->mtex[slot->index] = NULL;
        
        BKE_texpaint_slot_refresh_cache(scene, ma);
-       DAG_id_tag_update(&ma->id, 0);
+       DEG_id_tag_update(&ma->id, 0);
        WM_event_add_notifier(C, NC_MATERIAL, ma);
        /* we need a notifier for data change since we change the displayed modifier uvs */
        WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
@@ -5913,7 +5918,7 @@ static int add_simple_uvs_exec(bContext *C, wmOperator *UNUSED(op))
 
        BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
        
-       DAG_id_tag_update(ob->data, 0);
+       DEG_id_tag_update(ob->data, 0);
        WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
        WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, scene);
        return OPERATOR_FINISHED;