Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / render / render_shading.c
index 9bdb34f5384564f8c92944b1bed0976e2bbbd1fb..5071c5db4eacbf039f43506b14c0fb50bb10e839 100644 (file)
 #include "BKE_animsys.h"
 #include "BKE_context.h"
 #include "BKE_curve.h"
-#include "BKE_depsgraph.h"
 #include "BKE_font.h"
 #include "BKE_global.h"
 #include "BKE_image.h"
+#include "BKE_layer.h"
 #include "BKE_library.h"
 #include "BKE_linestyle.h"
 #include "BKE_main.h"
@@ -65,7 +65,8 @@
 #include "BKE_world.h"
 #include "BKE_editmesh.h"
 
-
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
 
 #ifdef WITH_FREESTYLE
 #  include "BKE_freestyle.h"
@@ -83,6 +84,7 @@
 #include "ED_mesh.h"
 #include "ED_node.h"
 #include "ED_render.h"
+#include "ED_scene.h"
 #include "ED_screen.h"
 
 #include "RNA_define.h"
@@ -153,7 +155,7 @@ static int material_slot_remove_exec(bContext *C, wmOperator *op)
                WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
        }
        
-       DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
+       DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
        WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
        WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, ob);
        WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_PREVIEW, ob);
@@ -219,7 +221,7 @@ static int material_slot_assign_exec(bContext *C, wmOperator *UNUSED(op))
                }
        }
 
-       DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
+       DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
        WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
        
        return OPERATOR_FINISHED;
@@ -359,7 +361,7 @@ static int material_slot_copy_exec(bContext *C, wmOperator *UNUSED(op))
                        
                        if (ob_iter->totcol == ob->totcol) {
                                ob_iter->actcol = ob->actcol;
-                               DAG_id_tag_update(&ob_iter->id, OB_RECALC_DATA);
+                               DEG_id_tag_update(&ob_iter->id, OB_RECALC_DATA);
                                WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob_iter);
                        }
                }
@@ -424,7 +426,7 @@ static int material_slot_move_exec(bContext *C, wmOperator *op)
 
        MEM_freeN(slot_remap);
 
-       DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
+       DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
        WM_event_add_notifier(C, NC_OBJECT | ND_DRAW | ND_DATA, ob);
 
        return OPERATOR_FINISHED;
@@ -626,11 +628,12 @@ static int render_layer_add_exec(bContext *C, wmOperator *UNUSED(op))
 {
        Scene *scene = CTX_data_scene(C);
 
-       BKE_scene_add_render_layer(scene, NULL);
-       scene->r.actlay = BLI_listbase_count(&scene->r.layers) - 1;
+       BKE_scene_layer_add(scene, NULL);
+       scene->active_layer = BLI_listbase_count(&scene->render_layers) - 1;
 
-       DAG_id_tag_update(&scene->id, 0);
-       WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
+       DEG_id_tag_update(&scene->id, 0);
+       DEG_relations_tag_update(CTX_data_main(C));
+       WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene);
        
        return OPERATOR_FINISHED;
 }
@@ -651,15 +654,16 @@ void SCENE_OT_render_layer_add(wmOperatorType *ot)
 
 static int render_layer_remove_exec(bContext *C, wmOperator *UNUSED(op))
 {
+       Main *bmain = CTX_data_main(C);
        Scene *scene = CTX_data_scene(C);
-       SceneRenderLayer *rl = BLI_findlink(&scene->r.layers, scene->r.actlay);
+       SceneLayer *sl = CTX_data_scene_layer(C);
 
-       if (!BKE_scene_remove_render_layer(CTX_data_main(C), scene, rl))
+       if (!ED_scene_render_layer_delete(bmain, scene, sl, NULL)) {
                return OPERATOR_CANCELLED;
+       }
 
-       DAG_id_tag_update(&scene->id, 0);
        WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
-       
+
        return OPERATOR_FINISHED;
 }
 
@@ -800,7 +804,7 @@ static int freestyle_module_remove_exec(bContext *C, wmOperator *UNUSED(op))
 
        BKE_freestyle_module_delete(&srl->freestyleConfig, module);
 
-       DAG_id_tag_update(&scene->id, 0);
+       DEG_id_tag_update(&scene->id, 0);
        WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
 
        return OPERATOR_FINISHED;
@@ -830,7 +834,7 @@ static int freestyle_module_move_exec(bContext *C, wmOperator *op)
        int dir = RNA_enum_get(op->ptr, "direction");
 
        if (BKE_freestyle_module_move(&srl->freestyleConfig, module, dir)) {
-               DAG_id_tag_update(&scene->id, 0);
+               DEG_id_tag_update(&scene->id, 0);
                WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
        }
 
@@ -870,7 +874,7 @@ static int freestyle_lineset_add_exec(bContext *C, wmOperator *UNUSED(op))
 
        BKE_freestyle_lineset_add(bmain, &srl->freestyleConfig, NULL);
 
-       DAG_id_tag_update(&scene->id, 0);
+       DEG_id_tag_update(&scene->id, 0);
        WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
 
        return OPERATOR_FINISHED;
@@ -934,7 +938,7 @@ static int freestyle_lineset_paste_exec(bContext *C, wmOperator *UNUSED(op))
 
        FRS_paste_active_lineset(&srl->freestyleConfig);
 
-       DAG_id_tag_update(&scene->id, 0);
+       DEG_id_tag_update(&scene->id, 0);
        WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
 
        return OPERATOR_FINISHED;
@@ -962,7 +966,7 @@ static int freestyle_lineset_remove_exec(bContext *C, wmOperator *UNUSED(op))
 
        FRS_delete_active_lineset(&srl->freestyleConfig);
 
-       DAG_id_tag_update(&scene->id, 0);
+       DEG_id_tag_update(&scene->id, 0);
        WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
 
        return OPERATOR_FINISHED;
@@ -990,7 +994,7 @@ static int freestyle_lineset_move_exec(bContext *C, wmOperator *op)
        int dir = RNA_enum_get(op->ptr, "direction");
 
        if (FRS_move_active_lineset(&srl->freestyleConfig, dir)) {
-               DAG_id_tag_update(&scene->id, 0);
+               DEG_id_tag_update(&scene->id, 0);
                WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
        }
 
@@ -1040,7 +1044,7 @@ static int freestyle_linestyle_new_exec(bContext *C, wmOperator *op)
        else {
                lineset->linestyle = BKE_linestyle_new(bmain, "LineStyle");
        }
-       DAG_id_tag_update(&lineset->linestyle->id, 0);
+       DEG_id_tag_update(&lineset->linestyle->id, 0);
        WM_event_add_notifier(C, NC_LINESTYLE, lineset->linestyle);
 
        return OPERATOR_FINISHED;
@@ -1076,7 +1080,7 @@ static int freestyle_color_modifier_add_exec(bContext *C, wmOperator *op)
                BKE_report(op->reports, RPT_ERROR, "Unknown line color modifier type");
                return OPERATOR_CANCELLED;
        }
-       DAG_id_tag_update(&lineset->linestyle->id, 0);
+       DEG_id_tag_update(&lineset->linestyle->id, 0);
        WM_event_add_notifier(C, NC_LINESTYLE, lineset->linestyle);
 
        return OPERATOR_FINISHED;
@@ -1116,7 +1120,7 @@ static int freestyle_alpha_modifier_add_exec(bContext *C, wmOperator *op)
                BKE_report(op->reports, RPT_ERROR, "Unknown alpha transparency modifier type");
                return OPERATOR_CANCELLED;
        }
-       DAG_id_tag_update(&lineset->linestyle->id, 0);
+       DEG_id_tag_update(&lineset->linestyle->id, 0);
        WM_event_add_notifier(C, NC_LINESTYLE, lineset->linestyle);
 
        return OPERATOR_FINISHED;
@@ -1156,7 +1160,7 @@ static int freestyle_thickness_modifier_add_exec(bContext *C, wmOperator *op)
                BKE_report(op->reports, RPT_ERROR, "Unknown line thickness modifier type");
                return OPERATOR_CANCELLED;
        }
-       DAG_id_tag_update(&lineset->linestyle->id, 0);
+       DEG_id_tag_update(&lineset->linestyle->id, 0);
        WM_event_add_notifier(C, NC_LINESTYLE, lineset->linestyle);
 
        return OPERATOR_FINISHED;
@@ -1196,7 +1200,7 @@ static int freestyle_geometry_modifier_add_exec(bContext *C, wmOperator *op)
                BKE_report(op->reports, RPT_ERROR, "Unknown stroke geometry modifier type");
                return OPERATOR_CANCELLED;
        }
-       DAG_id_tag_update(&lineset->linestyle->id, 0);
+       DEG_id_tag_update(&lineset->linestyle->id, 0);
        WM_event_add_notifier(C, NC_LINESTYLE, lineset->linestyle);
 
        return OPERATOR_FINISHED;
@@ -1263,7 +1267,7 @@ static int freestyle_modifier_remove_exec(bContext *C, wmOperator *op)
                        BKE_report(op->reports, RPT_ERROR, "The object the data pointer refers to is not a valid modifier");
                        return OPERATOR_CANCELLED;
        }
-       DAG_id_tag_update(&lineset->linestyle->id, 0);
+       DEG_id_tag_update(&lineset->linestyle->id, 0);
        WM_event_add_notifier(C, NC_LINESTYLE, lineset->linestyle);
 
        return OPERATOR_FINISHED;
@@ -1313,7 +1317,7 @@ static int freestyle_modifier_copy_exec(bContext *C, wmOperator *op)
                        BKE_report(op->reports, RPT_ERROR, "The object the data pointer refers to is not a valid modifier");
                        return OPERATOR_CANCELLED;
        }
-       DAG_id_tag_update(&lineset->linestyle->id, 0);
+       DEG_id_tag_update(&lineset->linestyle->id, 0);
        WM_event_add_notifier(C, NC_LINESTYLE, lineset->linestyle);
 
        return OPERATOR_FINISHED;
@@ -1367,7 +1371,7 @@ static int freestyle_modifier_move_exec(bContext *C, wmOperator *op)
        }
 
        if (changed) {
-               DAG_id_tag_update(&lineset->linestyle->id, 0);
+               DEG_id_tag_update(&lineset->linestyle->id, 0);
                WM_event_add_notifier(C, NC_LINESTYLE, lineset->linestyle);
        }
 
@@ -1488,7 +1492,7 @@ static int texture_slot_move_exec(bContext *C, wmOperator *op)
                        }
                }
 
-               DAG_id_tag_update(id, 0);
+               DEG_id_tag_update(id, 0);
                WM_event_add_notifier(C, NC_TEXTURE, CTX_data_scene(C));
        }