Page MenuHome

Copy active view layer, add empty view layer
ClosedPublic

Authored by Chris Clyne (lateasusual) on Feb 15 2020, 5:03 PM.

Details

Summary

Modify the view layer add operator to allow for copying the current view layer, as well as adding a new one but with all LayerCollections disabled by default (this is important for heavy scenes where currently adding view layers can take a long time due to enabling every collection by default)

Not entirely sure if "Empty" is the best name for adding a new blank layer but it's more in line with the Scene add operator.

Diff Detail

Repository
rB Blender

Event Timeline

No strong opinion - I guess this could be useful? Seems somewhat consistent with adding a new scene.

Besides styling notes below, this patch gives memory unfreed errors:

Direct leak of 72 byte(s) in 1 object(s) allocated from:
    #0 0x7f706d334628 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x107628)
    #1 0x557b65c82d66 in MEM_lockfree_mallocN /home/guest/blender/src/intern/guardedalloc/intern/mallocn_lockfree_impl.c:308
    #2 0x557b65985aa0 in ghash_new /home/guest/blender/src/source/blender/blenlib/intern/BLI_ghash.c:440
    #3 0x557b65988899 in BLI_ghash_new_ex /home/guest/blender/src/source/blender/blenlib/intern/BLI_ghash.c:718
    #4 0x557b659888c8 in BLI_ghash_new /home/guest/blender/src/source/blender/blenlib/intern/BLI_ghash.c:726
    #5 0x557b5512ac71 in view_layer_bases_hash_create /home/guest/blender/src/source/blender/blenkernel/intern/layer.c:321
    #6 0x557b5512fe38 in BKE_layer_collection_sync /home/guest/blender/src/source/blender/blenkernel/intern/layer.c:833
    #7 0x557b55129886 in BKE_view_layer_add /home/guest/blender/src/source/blender/blenkernel/intern/layer.c:199
    #8 0x557b5d4249df in view_layer_add_exec /home/guest/blender/src/source/blender/editors/render/render_shading.c:808
    #9 0x557b55d56261 in WM_menu_invoke_ex /home/guest/blender/src/source/blender/windowmanager/intern/wm_operators.c:972
    #10 0x557b55d5665e in WM_menu_invoke /home/guest/blender/src/source/blender/windowmanager/intern/wm_operators.c:992
    #11 0x557b55cd40b9 in wm_operator_invoke /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:1267
    #12 0x557b55cd60c0 in wm_operator_call_internal /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:1480
    #13 0x557b55cd639a in WM_operator_name_call_ptr /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:1528
    #14 0x557b58f8938a in ui_apply_but_funcs_after /home/guest/blender/src/source/blender/editors/interface/interface_handlers.c:880
    #15 0x557b59010a6a in ui_popup_handler /home/guest/blender/src/source/blender/editors/interface/interface_handlers.c:10783
    #16 0x557b55ccd96f in wm_handler_ui_call /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:617
    #17 0x557b55ce18c3 in wm_handlers_do_intern /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:2553
    #18 0x557b55ce4567 in wm_handlers_do /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:2799
    #19 0x557b55ce9584 in wm_event_do_handlers /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:3178
    #20 0x557b55cb868c in WM_main /home/guest/blender/src/source/blender/windowmanager/intern/wm.c:418
    #21 0x557b54f57a12 in main /home/guest/blender/src/source/creator/creator.c:518
    #22 0x7f7068054bba in __libc_start_main ../csu/libc-start.c:308

Direct leak of 72 byte(s) in 1 object(s) allocated from:
    #0 0x7f706d33480e in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10780e)
    #1 0x557b65c82a4b in MEM_lockfree_callocN /home/guest/blender/src/intern/guardedalloc/intern/mallocn_lockfree_impl.c:267
    #2 0x557b551285af in layer_collection_add /home/guest/blender/src/source/blender/blenkernel/intern/layer.c:72
    #3 0x557b5512e268 in layer_collection_sync /home/guest/blender/src/source/blender/blenkernel/intern/layer.c:702
    #4 0x557b55130336 in BKE_layer_collection_sync /home/guest/blender/src/source/blender/blenkernel/intern/layer.c:848
    #5 0x557b55129886 in BKE_view_layer_add /home/guest/blender/src/source/blender/blenkernel/intern/layer.c:199
    #6 0x557b5d4249df in view_layer_add_exec /home/guest/blender/src/source/blender/editors/render/render_shading.c:808
    #7 0x557b55d56261 in WM_menu_invoke_ex /home/guest/blender/src/source/blender/windowmanager/intern/wm_operators.c:972
    #8 0x557b55d5665e in WM_menu_invoke /home/guest/blender/src/source/blender/windowmanager/intern/wm_operators.c:992
    #9 0x557b55cd40b9 in wm_operator_invoke /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:1267
    #10 0x557b55cd60c0 in wm_operator_call_internal /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:1480
    #11 0x557b55cd639a in WM_operator_name_call_ptr /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:1528
    #12 0x557b58f8938a in ui_apply_but_funcs_after /home/guest/blender/src/source/blender/editors/interface/interface_handlers.c:880
    #13 0x557b59010a6a in ui_popup_handler /home/guest/blender/src/source/blender/editors/interface/interface_handlers.c:10783
    #14 0x557b55ccd96f in wm_handler_ui_call /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:617
    #15 0x557b55ce18c3 in wm_handlers_do_intern /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:2553
    #16 0x557b55ce4567 in wm_handlers_do /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:2799
    #17 0x557b55ce9584 in wm_event_do_handlers /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:3178
    #18 0x557b55cb868c in WM_main /home/guest/blender/src/source/blender/windowmanager/intern/wm.c:418
    #19 0x557b54f57a12 in main /home/guest/blender/src/source/creator/creator.c:518
    #20 0x7f7068054bba in __libc_start_main ../csu/libc-start.c:308

Indirect leak of 2032 byte(s) in 1 object(s) allocated from:
    #0 0x7f706d334628 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x107628)
    #1 0x557b65c82d66 in MEM_lockfree_mallocN /home/guest/blender/src/intern/guardedalloc/intern/mallocn_lockfree_impl.c:308
    #2 0x557b659ce140 in mempool_chunk_alloc /home/guest/blender/src/source/blender/blenlib/intern/BLI_mempool.c:184
    #3 0x557b659cf14f in BLI_mempool_create /home/guest/blender/src/source/blender/blenlib/intern/BLI_mempool.c:322
    #4 0x557b6598626e in ghash_new /home/guest/blender/src/source/blender/blenlib/intern/BLI_ghash.c:449
    #5 0x557b65988899 in BLI_ghash_new_ex /home/guest/blender/src/source/blender/blenlib/intern/BLI_ghash.c:718
    #6 0x557b659888c8 in BLI_ghash_new /home/guest/blender/src/source/blender/blenlib/intern/BLI_ghash.c:726
    #7 0x557b5512ac71 in view_layer_bases_hash_create /home/guest/blender/src/source/blender/blenkernel/intern/layer.c:321
    #8 0x557b5512fe38 in BKE_layer_collection_sync /home/guest/blender/src/source/blender/blenkernel/intern/layer.c:833
    #9 0x557b55129886 in BKE_view_layer_add /home/guest/blender/src/source/blender/blenkernel/intern/layer.c:199
    #10 0x557b5d4249df in view_layer_add_exec /home/guest/blender/src/source/blender/editors/render/render_shading.c:808
    #11 0x557b55d56261 in WM_menu_invoke_ex /home/guest/blender/src/source/blender/windowmanager/intern/wm_operators.c:972
    #12 0x557b55d5665e in WM_menu_invoke /home/guest/blender/src/source/blender/windowmanager/intern/wm_operators.c:992
    #13 0x557b55cd40b9 in wm_operator_invoke /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:1267
    #14 0x557b55cd60c0 in wm_operator_call_internal /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:1480
    #15 0x557b55cd639a in WM_operator_name_call_ptr /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:1528
    #16 0x557b58f8938a in ui_apply_but_funcs_after /home/guest/blender/src/source/blender/editors/interface/interface_handlers.c:880
    #17 0x557b59010a6a in ui_popup_handler /home/guest/blender/src/source/blender/editors/interface/interface_handlers.c:10783
    #18 0x557b55ccd96f in wm_handler_ui_call /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:617
    #19 0x557b55ce18c3 in wm_handlers_do_intern /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:2553
    #20 0x557b55ce4567 in wm_handlers_do /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:2799
    #21 0x557b55ce9584 in wm_event_do_handlers /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:3178
    #22 0x557b55cb868c in WM_main /home/guest/blender/src/source/blender/windowmanager/intern/wm.c:418
    #23 0x557b54f57a12 in main /home/guest/blender/src/source/creator/creator.c:518
    #24 0x7f7068054bba in __libc_start_main ../csu/libc-start.c:308

Indirect leak of 240 byte(s) in 3 object(s) allocated from:
    #0 0x7f706d33480e in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10780e)
    #1 0x557b65c82a4b in MEM_lockfree_callocN /home/guest/blender/src/intern/guardedalloc/intern/mallocn_lockfree_impl.c:267
    #2 0x557b55128908 in object_base_new /home/guest/blender/src/source/blender/blenkernel/intern/layer.c:95
    #3 0x557b5512efa6 in layer_collection_sync /home/guest/blender/src/source/blender/blenkernel/intern/layer.c:775
    #4 0x557b5512e6d0 in layer_collection_sync /home/guest/blender/src/source/blender/blenkernel/intern/layer.c:722
    #5 0x557b55130336 in BKE_layer_collection_sync /home/guest/blender/src/source/blender/blenkernel/intern/layer.c:848
    #6 0x557b55129886 in BKE_view_layer_add /home/guest/blender/src/source/blender/blenkernel/intern/layer.c:199
    #7 0x557b5d4249df in view_layer_add_exec /home/guest/blender/src/source/blender/editors/render/render_shading.c:808
    #8 0x557b55d56261 in WM_menu_invoke_ex /home/guest/blender/src/source/blender/windowmanager/intern/wm_operators.c:972
    #9 0x557b55d5665e in WM_menu_invoke /home/guest/blender/src/source/blender/windowmanager/intern/wm_operators.c:992
    #10 0x557b55cd40b9 in wm_operator_invoke /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:1267
    #11 0x557b55cd60c0 in wm_operator_call_internal /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:1480
    #12 0x557b55cd639a in WM_operator_name_call_ptr /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:1528
    #13 0x557b58f8938a in ui_apply_but_funcs_after /home/guest/blender/src/source/blender/editors/interface/interface_handlers.c:880
    #14 0x557b59010a6a in ui_popup_handler /home/guest/blender/src/source/blender/editors/interface/interface_handlers.c:10783
    #15 0x557b55ccd96f in wm_handler_ui_call /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:617
    #16 0x557b55ce18c3 in wm_handlers_do_intern /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:2553
    #17 0x557b55ce4567 in wm_handlers_do /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:2799
    #18 0x557b55ce9584 in wm_event_do_handlers /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:3178
    #19 0x557b55cb868c in WM_main /home/guest/blender/src/source/blender/windowmanager/intern/wm.c:418
    #20 0x557b54f57a12 in main /home/guest/blender/src/source/creator/creator.c:518
    #21 0x7f7068054bba in __libc_start_main ../csu/libc-start.c:308

Indirect leak of 72 byte(s) in 1 object(s) allocated from:
    #0 0x7f706d33480e in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10780e)
    #1 0x557b65c82a4b in MEM_lockfree_callocN /home/guest/blender/src/intern/guardedalloc/intern/mallocn_lockfree_impl.c:267
    #2 0x557b551285af in layer_collection_add /home/guest/blender/src/source/blender/blenkernel/intern/layer.c:72
    #3 0x557b5512e268 in layer_collection_sync /home/guest/blender/src/source/blender/blenkernel/intern/layer.c:702
    #4 0x557b5512e6d0 in layer_collection_sync /home/guest/blender/src/source/blender/blenkernel/intern/layer.c:722
    #5 0x557b55130336 in BKE_layer_collection_sync /home/guest/blender/src/source/blender/blenkernel/intern/layer.c:848
    #6 0x557b55129886 in BKE_view_layer_add /home/guest/blender/src/source/blender/blenkernel/intern/layer.c:199
    #7 0x557b5d4249df in view_layer_add_exec /home/guest/blender/src/source/blender/editors/render/render_shading.c:808
    #8 0x557b55d56261 in WM_menu_invoke_ex /home/guest/blender/src/source/blender/windowmanager/intern/wm_operators.c:972
    #9 0x557b55d5665e in WM_menu_invoke /home/guest/blender/src/source/blender/windowmanager/intern/wm_operators.c:992
    #10 0x557b55cd40b9 in wm_operator_invoke /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:1267
    #11 0x557b55cd60c0 in wm_operator_call_internal /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:1480
    #12 0x557b55cd639a in WM_operator_name_call_ptr /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:1528
    #13 0x557b58f8938a in ui_apply_but_funcs_after /home/guest/blender/src/source/blender/editors/interface/interface_handlers.c:880
    #14 0x557b59010a6a in ui_popup_handler /home/guest/blender/src/source/blender/editors/interface/interface_handlers.c:10783
    #15 0x557b55ccd96f in wm_handler_ui_call /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:617
    #16 0x557b55ce18c3 in wm_handlers_do_intern /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:2553
    #17 0x557b55ce4567 in wm_handlers_do /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:2799
    #18 0x557b55ce9584 in wm_event_do_handlers /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:3178
    #19 0x557b55cb868c in WM_main /home/guest/blender/src/source/blender/windowmanager/intern/wm.c:418
    #20 0x557b54f57a12 in main /home/guest/blender/src/source/creator/creator.c:518
    #21 0x7f7068054bba in __libc_start_main ../csu/libc-start.c:308

Indirect leak of 56 byte(s) in 1 object(s) allocated from:
    #0 0x7f706d334628 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x107628)
    #1 0x557b65c82d66 in MEM_lockfree_mallocN /home/guest/blender/src/intern/guardedalloc/intern/mallocn_lockfree_impl.c:308
    #2 0x557b659cea56 in BLI_mempool_create /home/guest/blender/src/source/blender/blenlib/intern/BLI_mempool.c:275
    #3 0x557b6598626e in ghash_new /home/guest/blender/src/source/blender/blenlib/intern/BLI_ghash.c:449
    #4 0x557b65988899 in BLI_ghash_new_ex /home/guest/blender/src/source/blender/blenlib/intern/BLI_ghash.c:718
    #5 0x557b659888c8 in BLI_ghash_new /home/guest/blender/src/source/blender/blenlib/intern/BLI_ghash.c:726
    #6 0x557b5512ac71 in view_layer_bases_hash_create /home/guest/blender/src/source/blender/blenkernel/intern/layer.c:321
    #7 0x557b5512fe38 in BKE_layer_collection_sync /home/guest/blender/src/source/blender/blenkernel/intern/layer.c:833
    #8 0x557b55129886 in BKE_view_layer_add /home/guest/blender/src/source/blender/blenkernel/intern/layer.c:199
    #9 0x557b5d4249df in view_layer_add_exec /home/guest/blender/src/source/blender/editors/render/render_shading.c:808
    #10 0x557b55d56261 in WM_menu_invoke_ex /home/guest/blender/src/source/blender/windowmanager/intern/wm_operators.c:972
    #11 0x557b55d5665e in WM_menu_invoke /home/guest/blender/src/source/blender/windowmanager/intern/wm_operators.c:992
    #12 0x557b55cd40b9 in wm_operator_invoke /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:1267
    #13 0x557b55cd60c0 in wm_operator_call_internal /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:1480
    #14 0x557b55cd639a in WM_operator_name_call_ptr /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:1528
    #15 0x557b58f8938a in ui_apply_but_funcs_after /home/guest/blender/src/source/blender/editors/interface/interface_handlers.c:880
    #16 0x557b59010a6a in ui_popup_handler /home/guest/blender/src/source/blender/editors/interface/interface_handlers.c:10783
    #17 0x557b55ccd96f in wm_handler_ui_call /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:617
    #18 0x557b55ce18c3 in wm_handlers_do_intern /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:2553
    #19 0x557b55ce4567 in wm_handlers_do /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:2799
    #20 0x557b55ce9584 in wm_event_do_handlers /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:3178
    #21 0x557b55cb868c in WM_main /home/guest/blender/src/source/blender/windowmanager/intern/wm.c:418
    #22 0x557b54f57a12 in main /home/guest/blender/src/source/creator/creator.c:518
    #23 0x7f7068054bba in __libc_start_main ../csu/libc-start.c:308

Indirect leak of 48 byte(s) in 1 object(s) allocated from:
    #0 0x7f706d33480e in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10780e)
    #1 0x557b65c82a4b in MEM_lockfree_callocN /home/guest/blender/src/intern/guardedalloc/intern/mallocn_lockfree_impl.c:267
    #2 0x557b6598408b in ghash_buckets_resize /home/guest/blender/src/source/blender/blenlib/intern/BLI_ghash.c:217
    #3 0x557b659850fd in ghash_buckets_expand /home/guest/blender/src/source/blender/blenlib/intern/BLI_ghash.c:306
    #4 0x557b6598623f in ghash_buckets_reset /home/guest/blender/src/source/blender/blenlib/intern/BLI_ghash.c:378
    #5 0x557b6598623f in ghash_new /home/guest/blender/src/source/blender/blenlib/intern/BLI_ghash.c:448
    #6 0x557b65988899 in BLI_ghash_new_ex /home/guest/blender/src/source/blender/blenlib/intern/BLI_ghash.c:718
    #7 0x557b659888c8 in BLI_ghash_new /home/guest/blender/src/source/blender/blenlib/intern/BLI_ghash.c:726
    #8 0x557b5512ac71 in view_layer_bases_hash_create /home/guest/blender/src/source/blender/blenkernel/intern/layer.c:321
    #9 0x557b5512fe38 in BKE_layer_collection_sync /home/guest/blender/src/source/blender/blenkernel/intern/layer.c:833
    #10 0x557b55129886 in BKE_view_layer_add /home/guest/blender/src/source/blender/blenkernel/intern/layer.c:199
    #11 0x557b5d4249df in view_layer_add_exec /home/guest/blender/src/source/blender/editors/render/render_shading.c:808
    #12 0x557b55d56261 in WM_menu_invoke_ex /home/guest/blender/src/source/blender/windowmanager/intern/wm_operators.c:972
    #13 0x557b55d5665e in WM_menu_invoke /home/guest/blender/src/source/blender/windowmanager/intern/wm_operators.c:992
    #14 0x557b55cd40b9 in wm_operator_invoke /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:1267
    #15 0x557b55cd60c0 in wm_operator_call_internal /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:1480
    #16 0x557b55cd639a in WM_operator_name_call_ptr /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:1528
    #17 0x557b58f8938a in ui_apply_but_funcs_after /home/guest/blender/src/source/blender/editors/interface/interface_handlers.c:880
    #18 0x557b59010a6a in ui_popup_handler /home/guest/blender/src/source/blender/editors/interface/interface_handlers.c:10783
    #19 0x557b55ccd96f in wm_handler_ui_call /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:617
    #20 0x557b55ce18c3 in wm_handlers_do_intern /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:2553
    #21 0x557b55ce4567 in wm_handlers_do /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:2799
    #22 0x557b55ce9584 in wm_event_do_handlers /home/guest/blender/src/source/blender/windowmanager/intern/wm_event_system.c:3178
    #23 0x557b55cb868c in WM_main /home/guest/blender/src/source/blender/windowmanager/intern/wm.c:418
    #24 0x557b54f57a12 in main /home/guest/blender/src/source/creator/creator.c:518
    #25 0x7f7068054bba in __libc_start_main ../csu/libc-start.c:308
source/blender/editors/render/render_shading.c
794–795

No reasons to use a while here, for loop would be better and shorter.

812–818

Would be nicer to use a switch(type) here

Bastien Montagne (mont29) requested changes to this revision.Feb 17 2020, 6:22 PM
This revision now requires changes to proceed.Feb 17 2020, 6:22 PM

Tidied according to suggestions, but... I get the same memory leak errors in master, not really sure what to do :(

Chris Clyne (lateasusual) marked 2 inline comments as done.Feb 17 2020, 10:18 PM

Fixed memory leak in view_layer_add_exec
Not sure about whether what i have is better or if modifying the original view_layer_add in layer.c would be better

  • Formatting, better adherance to coding guideline
Bastien Montagne (mont29) requested changes to this revision.Thu, Mar 26, 12:33 PM

Besides minor comments, and question about general patch organization, this looks almost good to me now.

source/blender/editors/render/render_shading.c
821–824

current_layer -> view_layer_current
view_layer -> view_layer_new

824–854

Am a bit on the fence here, but think this logic should be moved to BKE_layer_add instead. @Brecht Van Lommel (brecht), @Dalai Felinto (dfelinto), what do you think?

840

Think it should also use the name of the current view layer then, instead of default generic one.

source/blender/makesdna/DNA_layer_types.h
117–122 ↗(On Diff #21957)

This has nothing to do here, it should either be in BKE, or in the ED relevant header file (depending on whether we move copy logic to BKE_view_layer_add or not).

This revision now requires changes to proceed.Thu, Mar 26, 12:33 PM
source/blender/editors/render/render_shading.c
824–854

I think this whole switch case should be moved into BKE_view_layer_add.

Things like ensure unique names should be centralized in the blenkernel file, not duplicated and spread across multiple modules.

Refactored BKE_view_layer_add and moved new ViewLayer code to BKE
Rebased to current master and fixed conflicts

Remove commented code left by accident

Chris Clyne (lateasusual) marked 4 inline comments as done.Thu, Mar 26, 6:14 PM

@Brecht Van Lommel (brecht) @Bastien Montagne (mont29) I've moved everything over to BKE_view_layer_add and modified it accordingly. I'm not sure what the best way to maintain calls to it in other places so i tried to keep the new arguments as "optional" as possible.

LGTM, beside small note below.

source/blender/blenkernel/intern/layer.c
242

please use name from view_layer_source in VIEWLAYER_ADD_COPY case. Will do while committing.

This revision is now accepted and ready to land.Thu, Mar 26, 7:01 PM
source/blender/blenkernel/intern/layer.c
242

Woops sorry, not needed here actually, so everything is fine